setup-java/.github/checkstyle.json
Kian Cross 42dba1991e Add problem matcher for Checkstyle
This commit adds a problem matcher for Checkstyle to allow
automatic GitHub annotations.

When run through Gradle, an example line is:
```
[ant:checkstyle] [ERROR] /root/Bound.java:7:2: 'import' has incorrect indentation level 1, expected level should be 0. [Indentation]
```

Alternatively, when run standalone, an example output is:
```
[WARN] /root/test.java:2:1: The name of the outer type and the file do not match. [OuterTypeFilename]
```

The regular expression matches both cases.

In the latter example, `WARN`, rather than `WARNING` is output.
This is resolved by using a default severity of `warning`, which
will be overridden in the case that the severity is `ERROR`.
2021-07-20 12:08:03 +01:00

20 lines
494 B
JSON

{
"problemMatcher": [
{
"owner": "checkstyle",
"severity": "warning",
"pattern": [
{
"regexp": "^.*\\[(ERROR|WARN)\\]\\s+(.*):(\\d+):(\\d+):\\s+(.*)\\s+\\[(.*)\\]$",
"severity": 1,
"file": 2,
"line": 3,
"column": 4,
"message": 5,
"code": 6
}
]
}
]
}