This is a GitHub action to run Checkstyle checks on your Java code and report the status via reviewdog on pull requests.
An example of how the reported Checkstyle violations will look on a pull request is shown below (link to example PR):
name: reviewdog
on: [pull_request]
jobs:
checkstyle:
name: runner / checkstyle
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dbelyaev/action-checkstyle@master
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: warning
-
Checkstyle configuration specifies which ruleset to apply during the scan.
There are two built-in configurations:google_checks.xml
config for the Google coding conventionssun_checks.xml
config for the Sun coding conventions
It is also possible to supply your custom Checkstyle configuration file located in the same directory.
Default:
google_checks.xml
Example:
name: reviewdog on: [pull_request] jobs: checkstyle: name: runner / checkstyle runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dbelyaev/action-checkstyle@master with: github_token: ${{ secrets.github_token }} reporter: github-pr-review checkstyle_config: sun_checks.xml
Link to example PR.
-
Checkstyle version to be used during analysis.
For a list of available version numbers, go to the Checkstyle release page.
[!IMPORTANT] This field will always try to follow Checkstyle releases as closely as possible and will use the latest available version by default.
If the default preference is not suitable for your project, please pin the needed version using this property.
Default:
latest availableExample:
name: reviewdog on: [pull_request] jobs: checkstyle: name: runner / checkstyle runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dbelyaev/action-checkstyle@master with: github_token: ${{ secrets.github_token }} reporter: github-pr-review checkstyle_version: "9.0" # double quotes important here
-
The working directory relative to the root directory.
Default:
'.'
(root) -
Location of the properties file relative to the root directory.
This file serves as a means to resolve repetitive or predefined values within the checkstyle configuration file.
Default:
''
(empty)Example:
name: reviewdog on: [pull_request] jobs: checkstyle: name: runner / checkstyle runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dbelyaev/action-checkstyle@master with: github_token: ${{ secrets.github_token }} reporter: github-pr-review checkstyle_config: ./properties_file/test_checks.xml properties_file: ./properties_file/additional.properties
Link to example PR.
-
Report level for the reviewdog command.
Values:
[info, warning, error]
You can control GitHub status check result with this feature.
Level GitHub Status info
neutral warning
neutral error
failure Default:
info
-
Reporter for the reviewdog command.
For more information, check reviewdog / reporters documentation.
Values:
[github-pr-check, github-check, github-pr-review]
Default:
github-pr-check
-
Filtering mode for the reviewdog command.
For more information, check reviewdog / filter-mode documentation.
Values:
[added, diff_context, file, nofilter]
Default:
added
-
The reviewdog tool gives you a way to tell your automated system (like a CI pipeline) if it has found any errors in your code. This is done using something known as an exit code.
By default (
-fail-level=none
), reviewdog will finish its run and give an exit code of0
, which means everything is fine, even if it actually found some errors.But you can change this. If you use the
-fail-level
flag withany
,info
,warning
, orerror
, reviewdog will finish with an exit code of1
if it finds at least one problem with severity greater than or equal to the given level. This tells your automated system that there's something that needs attention (and you can trigger some actions, rules or events based on it).Values:
[none, any, info, warning, error]
Default:
none
-
Additional reviewdog flags.
Default:
``