@@ -3,7 +3,8 @@ Plugin that runs the provided executable and compares emitted warnings with expe
33Please note, that it is important for test resources to have specific keywords. For test file it should be ` Test ` .
44
55### Examples
6- If you don't like to read long readme file, you can simply check [ examples] ( /examples/kotlin-diktat/warn ) .
6+ If you don't like to read long readme file, you can simply check [ examples] ( /examples/kotlin-diktat/warn ) .
7+ There are all available configurations that you need.
78
89### Source files
910Test source files (input for SAVE) should have a comment line (use single-line commenting syntax of the target programming language for it)
@@ -27,7 +28,13 @@ Warning messages are very flexible and can be described in very different ways:
2728```
2829// ;warn:3:1: Warning with an explicit set of a line number and column number
2930```
30-
31+ ```
32+ /* ;warn:1: Multiline warning. This line should match `expectedWariningsPattern`
33+ * To match other lines, you need to specify a value of `expectedWarningsEndPattern` (and `expectedWarningsMiddlePattern` if there is any).
34+ * This line should match `expectedWarningsMiddlePattern`
35+ * And the next line should match `expectedWarningsEndPattern`
36+ */
37+ ```
3138### Regular expressions in warnings
3239Regular expressions can be used in warning messages.
3340To configure delimiters, use ` patternForRegexInWarning ` option (default: ` "{{", "}}" ` ):
@@ -74,13 +81,27 @@ you will need the following SAVE configuration:
7481execCmd = " ./detekt"
7582description = " My suite description"
7683suiteName = " DocsCheck"
77- # warning is set inside the comment in code, `//` marks comment start in Java
84+ language = " Kotlin"
85+ # if you are using IN_PLACE mode, this flag will be used to extract EXPECTED warnings from the file
7886expectedWarningsPattern = " // ;warn:(\\ d+):(\\ d+): (.*)" # (default value)
79-
87+ # for multiline warnings ONLY (if you are using IN_PLACE mode and multiline warnings)
88+ expectedWarningsMiddlePattern = " \\ * (.*)"
89+ expectedWarningsEndPattern = " (.*)?\\ */"
8090
8191[warn ]
92+ # extra execution flags that are added to the exec cmd
8293execFlags = " --build-upon-default-config -i"
8394
95+ # the format and place, where EXPECTED warnings should be put, for example:
96+ # SARIF: means that you put ALL your expected warnings into the special file with the name 'save-warnings.sarif'
97+ # (default) IN_PLACE: means that you need to put your expected warnings into the test resource (and they will be matched by expectedWarningsPattern)
98+ expectedWarningsFormat = " SARIF"
99+
100+ # the format of actual warnings
101+ # (default) PLAIN: means that your tool reports warnings in plain text that. Warnings will be extracted with actualWarningsPattern
102+ # SARIF: means that the output of the tool will be extracted with a SARIF format
103+ actualWarningsFormat = " SARIF"
104+
84105# e.g. `WARN - 10/14 - Class name is in incorrect case`
85106# expected regex may allow an empty group for line number
86107# regex group with lineCaptureGroupIdx may include a number or linePlaceholder and addition/subtraction of a number
@@ -95,6 +116,10 @@ columnCaptureGroup = 3 # (default value)
95116# index of regex capture group for message text
96117messageCaptureGroup = 4 # (default value)
97118
119+ # options that control the capture group for patterns of warnings to extract multiline warning
120+ messageCaptureGroupMiddle = 1 # (default value)
121+ messageCaptureGroupEnd = 1 # (default value)
122+
98123warningTextHasColumn = true # (default value)
99124warningTextHasLine = true # (default value)
100125testNameRegex = " .*Test.*" # (default value)
@@ -115,7 +140,7 @@ parsed from the same `$testFile` using `warningsInputPattern`. `batchSeparator`
115140If line number is not present in the comment, it's assumed to be ` current line + 1 ` in regex group with lineCaptureGroupIdx.
116141` linePlaceholder ` is an optional placeholder for the line number that is recognized as the current line and supports addition and subtraction.
117142
118- ` warningsInputPattern ` and ` warningsOutputPattern ` must include some mandatory capture groups: for line number (if ` warningTextHasLine ` is true),
143+ ` expectedWarningsPattern ` and ` actualWarningsPattern ` must include some mandatory capture groups: for line number (if ` warningTextHasLine ` is true),
119144for column number (if ` warningTextHasColumn ` is true) and for warning text. Their indices can be customized
120145with ` lineCaptureGroup ` , ` columnCaptureGroup ` and ` messageCaptureGroup ` parameters. These parameters are shared between input and output pattern;
121146usually you'll want them to be consistent to make testing easier, i.e. if input has line number, then so should output.
0 commit comments