├── .gitignore ├── testdata ├── properties_file │ ├── additional.properties │ └── test_checks.xml └── java │ └── Application.java ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── code-maintenance.md │ └── feature-request.md ├── labeler.yml ├── renovate.json └── workflows │ ├── dockerimage.yml │ ├── dependency-review.yml │ ├── test-other.yml │ ├── pr-labeler.yml │ ├── test-reviewers.yml │ ├── test-versions.yml │ ├── release.yml │ ├── scorecards.yml │ ├── depup.yml │ └── reviewdog.yml ├── .editorconfig ├── .pre-commit-config.yaml ├── SECURITY.md ├── Dockerfile ├── LICENSE ├── entrypoint.sh ├── action.yml ├── CONTRIBUTING.md ├── CODE_OF_CONDUCT.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Folders to ignore 2 | .vscode/ 3 | *.jar 4 | *.DS_Store 5 | -------------------------------------------------------------------------------- /testdata/properties_file/additional.properties: -------------------------------------------------------------------------------- 1 | max-line-length=50 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report something that is broken or not working as intended 4 | title: '' 5 | labels: 'type: :bug: bug' 6 | assignees: '' 7 | --- 8 | 9 | #### Expected Behavior 10 | 11 | #### Actual Behavior 12 | 13 | #### Steps to Reproduce 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = crlf 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | max_line_length = 120 10 | trim_trailing_whitespace = true 11 | 12 | [*.java] 13 | indent_size = 4 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/code-maintenance.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Code Maintenance 3 | about: Project cleanup, improve documentation, refactor code 4 | title: '' 5 | labels: 'type: :wrench: maintenance' 6 | assignees: '' 7 | 8 | --- 9 | 10 | #### Describe Problem 11 | 12 | #### Suggest Changes 13 | 14 | #### Provide Examples 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for a new feature or enhancement to existing features 4 | title: '' 5 | labels: 'type: :bulb: feature request' 6 | assignees: '' 7 | --- 8 | 9 | #### Describe Problem 10 | 11 | #### Suggest Solution 12 | 13 | #### Additional Details 14 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/gitleaks/gitleaks 3 | rev: v8.16.3 4 | hooks: 5 | - id: gitleaks 6 | - repo: https://github.com/jumanjihouse/pre-commit-hooks 7 | rev: 3.0.0 8 | hooks: 9 | - id: shellcheck 10 | - repo: https://github.com/pre-commit/pre-commit-hooks 11 | rev: v4.4.0 12 | hooks: 13 | - id: end-of-file-fixer 14 | - id: trailing-whitespace 15 | -------------------------------------------------------------------------------- /.github/labeler.yml: -------------------------------------------------------------------------------- 1 | action: 2 | - any: 3 | - changed-files: 4 | - any-glob-to-any-file: ['action.yml', 'Dockerfile', 'entrypoint.sh'] 5 | 6 | tests: 7 | - any: 8 | - changed-files: 9 | - any-glob-to-any-file: testdata/** 10 | 11 | automation: 12 | - any: 13 | - changed-files: 14 | - any-glob-to-any-file: .github/** 15 | 16 | docs: 17 | - any: 18 | - changed-files: 19 | - any-glob-to-any-file: '**/*.md' 20 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security 2 | 3 | If you discover a security vulnerability in this project, please follow the steps below to report it. 4 | 5 | ## Reporting Security Issues 6 | 7 | - **Alternative A:** 8 | Create a GitHub issue for the vulnerability and ask the maintainer to reach out to you. 9 | Avoid putting sensitive information in the issue. 10 | - **Alternative B:** 11 | Send an email to the projects maintainer at describing the issue. 12 | 13 | ## Preffered languages 14 | 15 | We prefer all communications to be in English. 16 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:best-practices" 4 | ], 5 | "labels": [ 6 | "dependencies" 7 | ], 8 | "packageRules": [ 9 | { 10 | "description": "Automerge non-major updates", 11 | "matchUpdateTypes": [ 12 | "minor", 13 | "patch" 14 | ], 15 | "automerge": true 16 | }, 17 | { 18 | "matchManagers": [ 19 | "github-actions" 20 | ], 21 | "pinDigests": false, 22 | "matchPackageNames": [ 23 | "/^actions//", 24 | "/^github//" 25 | ] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /testdata/properties_file/test_checks.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.github/workflows/dockerimage.yml: -------------------------------------------------------------------------------- 1 | name: Docker Image CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | # set empty default permissions and define them explicitly in each job for security 10 | permissions: {} 11 | 12 | jobs: 13 | 14 | docker-build: 15 | runs-on: ubuntu-latest 16 | 17 | permissions: 18 | contents: read 19 | 20 | steps: 21 | - name: Harden Runner 22 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 23 | with: 24 | egress-policy: audit 25 | 26 | - uses: actions/checkout@v6 27 | - name: Build the Docker image 28 | run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s) 29 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:25.0.1_8-jre-alpine@sha256:b51543f89580c1ba70e441cfbc0cfc1635c3c16d2e2d77fec9d890342a3a8687 2 | 3 | ENV REVIEWDOG_VERSION=v0.21.0 4 | ENV CHECKSTYLE_VERSION=12.3.0 5 | 6 | SHELL ["/bin/ash", "-eo", "pipefail", "-c"] 7 | 8 | # hadolint ignore=DL3018 9 | RUN apk --no-cache add curl git wget 10 | 11 | # pre-install reviewdog and checkstyle 12 | RUN wget -4 -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} && \ 13 | mkdir -p /opt/lib && \ 14 | wget -4 -q -O /opt/lib/checkstyle.jar https://github.com/checkstyle/checkstyle/releases/download/checkstyle-${CHECKSTYLE_VERSION}/checkstyle-${CHECKSTYLE_VERSION}-all.jar 15 | 16 | COPY entrypoint.sh /entrypoint.sh 17 | 18 | ENTRYPOINT ["/entrypoint.sh"] 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 reviewdog developers 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/dependency-review.yml: -------------------------------------------------------------------------------- 1 | # Dependency Review Action 2 | # 3 | # This Action will scan dependency manifest files that change as part of a Pull Request, 4 | # surfacing known-vulnerable versions of the packages declared or updated in the PR. 5 | # Once installed, if the workflow run is marked as required, 6 | # PRs introducing known-vulnerable packages will be blocked from merging. 7 | # 8 | # Source repository: https://github.com/actions/dependency-review-action 9 | name: 'Dependency Review' 10 | 11 | on: [ pull_request ] 12 | 13 | # set empty default permissions and define them explicitly in each job for security 14 | permissions: {} 15 | 16 | jobs: 17 | 18 | dependency-review: 19 | runs-on: ubuntu-latest 20 | 21 | permissions: 22 | contents: read 23 | 24 | steps: 25 | - name: Harden Runner 26 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 27 | with: 28 | egress-policy: audit 29 | 30 | - name: 'Checkout Repository' 31 | uses: actions/checkout@v6 32 | - name: 'Dependency Review' 33 | uses: actions/dependency-review-action@v4 34 | -------------------------------------------------------------------------------- /testdata/java/Application.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | import org.springframework.boot.CommandLineRunner; 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.context.annotation.Bean; 7 | 8 | @SpringBootApplication 9 | public class Application { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(Application.class, args); 13 | } 14 | 15 | /** 16 | * some java doc. 17 | * 18 | * @param ctx application contexxt 19 | * @return some return 20 | */ 21 | @Bean 22 | public CommandLineRunner CommandLineRunner(ApplicationContext ctx) { 23 | return args -> { 24 | System.out.println("Let's inspect the beans provided by Spring Boot:"); 25 | 26 | var LongString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Porta lorem"; 27 | 28 | String[] beanNames = ctx.getBeanDefinitionNames(); 29 | Arrays.sort(beanNames); 30 | for (String beanName : beanNames) 31 | { 32 | System.out.println(beanName); 33 | } 34 | }; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /.github/workflows/test-other.yml: -------------------------------------------------------------------------------- 1 | name: Test - Other 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | # set empty default permissions and define them explicitly in each job for security 10 | permissions: {} 11 | 12 | jobs: 13 | 14 | test-reviewdog-flags: 15 | if: github.event_name == 'pull_request' 16 | name: runner / checkstyle (reviewdog-flags) 17 | runs-on: ubuntu-latest 18 | 19 | steps: 20 | - name: Harden Runner 21 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 22 | with: 23 | egress-policy: audit 24 | 25 | - uses: actions/checkout@v6 26 | - uses: ./ 27 | with: 28 | github_token: ${{ secrets.github_token }} 29 | reviewdog_flags: -filter-mode=added -fail-level=none 30 | 31 | test-properties-file: 32 | if: github.event_name == 'pull_request' 33 | name: runner / checkstyle (properties_file) 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - name: Harden Runner 38 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 39 | with: 40 | egress-policy: audit 41 | 42 | - uses: actions/checkout@v6 43 | - uses: ./ 44 | with: 45 | github_token: ${{ secrets.github_token }} 46 | workdir: ./testdata/java/ 47 | checkstyle_config: ./testdata/properties_file/test_checks.xml 48 | properties_file: ./testdata/properties_file/additional.properties 49 | -------------------------------------------------------------------------------- /.github/workflows/pr-labeler.yml: -------------------------------------------------------------------------------- 1 | name: PR Labeler 2 | 3 | on: 4 | pull_request_target: 5 | types: [ opened, synchronize ] 6 | 7 | # set empty default permissions and define them explicitly in each job for security 8 | permissions: {} 9 | 10 | jobs: 11 | 12 | label-pr-size: 13 | name: Label PR size 14 | runs-on: ubuntu-latest 15 | 16 | permissions: 17 | contents: read 18 | pull-requests: write # for codelytv/pr-size-labeler to add labels & comment on PRs 19 | 20 | steps: 21 | - name: Harden Runner 22 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 23 | with: 24 | egress-policy: audit 25 | 26 | - uses: codelytv/pr-size-labeler@4ec67706cd878fbc1c8db0a5dcd28b6bb412e85a # v1.10.3 27 | with: 28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 29 | xs_max_size: '10' 30 | s_max_size: '50' 31 | m_max_size: '100' 32 | l_max_size: '1000' 33 | fail_if_xl: 'false' 34 | message_if_xl: > 35 | This PR exceeds the recommended size of 1000 lines. 36 | Please make sure you are NOT addressing multiple issues with one PR. 37 | Note this PR might be rejected due to its size. 38 | 39 | label-pr-changes: 40 | name: Label PR changes 41 | runs-on: ubuntu-latest 42 | 43 | permissions: 44 | contents: read 45 | pull-requests: write 46 | 47 | steps: 48 | - name: Harden Runner 49 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 50 | with: 51 | egress-policy: audit 52 | 53 | - uses: actions/labeler@v6 54 | with: 55 | sync-labels: true 56 | -------------------------------------------------------------------------------- /.github/workflows/test-reviewers.yml: -------------------------------------------------------------------------------- 1 | name: Test - Reviewers 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | # set empty default permissions and define them explicitly in each job for security 10 | permissions: {} 11 | 12 | jobs: 13 | 14 | test-check: 15 | name: runner / checkstyle (github-check) 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - name: Harden Runner 20 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 21 | with: 22 | egress-policy: audit 23 | 24 | - uses: actions/checkout@v6 25 | - uses: ./ 26 | with: 27 | github_token: ${{ secrets.github_token }} 28 | reporter: github-check 29 | level: info 30 | 31 | test-pr-check: 32 | if: github.event_name == 'pull_request' 33 | name: runner / checkstyle (github-pr-check) 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - name: Harden Runner 38 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 39 | with: 40 | egress-policy: audit 41 | 42 | - uses: actions/checkout@v6 43 | - uses: ./ 44 | with: 45 | github_token: ${{ secrets.github_token }} 46 | reporter: github-pr-check 47 | level: warning 48 | workdir: ./testdata/java/ 49 | 50 | test-pr-review: 51 | if: github.event_name == 'pull_request' 52 | name: runner / checkstyle (github-pr-review) 53 | runs-on: ubuntu-latest 54 | 55 | steps: 56 | - name: Harden Runner 57 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 58 | with: 59 | egress-policy: audit 60 | 61 | - uses: actions/checkout@v6 62 | - uses: ./ 63 | with: 64 | github_token: ${{ secrets.github_token }} 65 | reporter: github-pr-review 66 | level: error 67 | -------------------------------------------------------------------------------- /.github/workflows/test-versions.yml: -------------------------------------------------------------------------------- 1 | name: Test - Versions 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | # set empty default permissions and define them explicitly in each job for security 10 | permissions: {} 11 | 12 | jobs: 13 | 14 | test-custom-checkstyle-version-9: 15 | if: github.event_name == 'pull_request' 16 | name: runner / checkstyle (v9.0) 17 | runs-on: ubuntu-latest 18 | 19 | steps: 20 | - name: Harden Runner 21 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 22 | with: 23 | egress-policy: audit 24 | 25 | - uses: actions/checkout@v6 26 | - uses: ./ 27 | with: 28 | github_token: ${{ secrets.github_token }} 29 | workdir: ./testdata/java/ 30 | checkstyle_version: "9.0" 31 | 32 | test-custom-checkstyle-version-10: 33 | if: github.event_name == 'pull_request' 34 | name: runner / checkstyle (v10.0) 35 | runs-on: ubuntu-latest 36 | 37 | steps: 38 | - name: Harden Runner 39 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 40 | with: 41 | egress-policy: audit 42 | 43 | - uses: actions/checkout@v6 44 | - uses: ./ 45 | with: 46 | github_token: ${{ secrets.github_token }} 47 | workdir: ./testdata/java/ 48 | checkstyle_version: "10.0" 49 | 50 | test-custom-checkstyle-version-11: 51 | if: github.event_name == 'pull_request' 52 | name: runner / checkstyle (v11.0.0) 53 | runs-on: ubuntu-latest 54 | 55 | steps: 56 | - name: Harden Runner 57 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 58 | with: 59 | egress-policy: audit 60 | 61 | - uses: actions/checkout@v6 62 | - uses: ./ 63 | with: 64 | github_token: ${{ secrets.github_token }} 65 | workdir: ./testdata/java/ 66 | checkstyle_version: "11.0.0" 67 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | command -v reviewdog >/dev/null 2>&1 || { echo >&2 "reviewdog: not found"; exit 1; } 3 | 4 | set -e 5 | 6 | # output some information 7 | { echo "Pre-installed"; java -jar /opt/lib/checkstyle.jar --version; } | sed ':a;N;s/\n/ /;ba' 8 | 9 | if [ -n "${GITHUB_WORKSPACE}" ]; then 10 | cd "${GITHUB_WORKSPACE}" || exit 11 | git config --global --add safe.directory "${GITHUB_WORKSPACE}" || exit 1 12 | fi 13 | 14 | # user supplied custom properties file parameter, define it 15 | OPTIONAL_PROPERTIES_FILE="" 16 | if [ -n "${INPUT_PROPERTIES_FILE}" ]; then 17 | OPTIONAL_PROPERTIES_FILE="-p ${INPUT_PROPERTIES_FILE}" 18 | fi 19 | 20 | # user wants to use custom Checkstyle version, try to install it 21 | if [ -n "${INPUT_CHECKSTYLE_VERSION}" ]; then 22 | echo '::group::📥 Installing user-defined Checkstyle version ... https://github.com/checkstyle/checkstyle' 23 | url="https://github.com/checkstyle/checkstyle/releases/download/checkstyle-${INPUT_CHECKSTYLE_VERSION}/checkstyle-${INPUT_CHECKSTYLE_VERSION}-all.jar" 24 | 25 | echo "Custom Checkstyle version has been configured: 'v${INPUT_CHECKSTYLE_VERSION}', try to download from ${url}" 26 | if ! wget -q -O /opt/lib/checkstyle.jar "$url"; then 27 | echo "Failed to download Checkstyle version ${INPUT_CHECKSTYLE_VERSION}" >&2 28 | exit 1 29 | fi 30 | 31 | echo '::endgroup::' 32 | fi 33 | 34 | export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" 35 | 36 | # run check 37 | echo '::group:: Running Checkstyle with reviewdog 🐶 ...' 38 | { echo "Run check with"; java -jar /opt/lib/checkstyle.jar --version; } | sed ':a;N;s/\n/ /;ba' 39 | 40 | # shellcheck disable=SC2086 41 | exec java -jar /opt/lib/checkstyle.jar "${INPUT_WORKDIR}" -c "${INPUT_CHECKSTYLE_CONFIG}" ${OPTIONAL_PROPERTIES_FILE} -f xml \ 42 | | reviewdog -f=checkstyle \ 43 | -name="checkstyle" \ 44 | -reporter="${INPUT_REPORTER:-github-pr-check}" \ 45 | -filter-mode="${INPUT_FILTER_MODE:-added}" \ 46 | -fail-level="${INPUT_FAIL_LEVEL:-none}" \ 47 | -level="${INPUT_LEVEL}" \ 48 | ${INPUT_REVIEWDOG_FLAGS} 49 | 50 | echo '::endgroup::' 51 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Checkstyle for Java" 2 | # description should be no more than 125 characters! 3 | description: "🐶 Run checkstyle analysis on Java code and report results directly to pull request with the help of reviewdog." 4 | author: "Dmitriy Belyaev" 5 | inputs: 6 | github_token: 7 | description: "GITHUB_TOKEN" 8 | default: "${{ github.token }}" 9 | workdir: 10 | description: "Working directory relative to the root directory." 11 | default: "." 12 | ### Flags for reviewdog ### 13 | level: 14 | description: "Report level for reviewdog [info, warning, error]" 15 | default: "info" 16 | reporter: 17 | description: "Reporter of reviewdog command [github-pr-check, github-pr-review]." 18 | default: "github-pr-check" 19 | filter_mode: 20 | description: | 21 | Filtering mode for the reviewdog command [added, diff_context, file, nofilter]. 22 | Default is added. 23 | default: "added" 24 | fail_level: 25 | description: | 26 | Exits code 1 when errors are found at that level or above. Options are [none, any, error, warning, info] 27 | Default is `none`. 28 | default: "none" 29 | reviewdog_flags: 30 | description: "Additional reviewdog flags" 31 | default: "" 32 | ### Flags for checkstyle ### 33 | checkstyle_config: 34 | description: | 35 | Checkstyle configuration specifies which ruleset to apply during scan. 36 | There are two built-in configurations in checkstyle: [google_checks.xml, sun_checks.xml]. 37 | google_checks.xml configures Checkstyle for the Google coding conventions (https://google.github.io/styleguide/javaguide.html) 38 | sun_checks.xml configures Checkstyle for the Sun coding conventions (https://www.oracle.com/java/technologies/javase/codeconventions-contents.html) 39 | default: "google_checks.xml" 40 | checkstyle_version: 41 | description: | 42 | Checkstyle version to be used during analysis. 43 | For a list of available version numbers go to [Checkstyle release page](https://github.com/checkstyle/checkstyle/releases/). 44 | **IMPORTANT NOTE** 45 | This field will always try to follow Checkstyle releases as close as possible and will use the latest available by default. 46 | If it is not a default preference for your project, please, pin the needed version using this property. 47 | default: "" 48 | properties_file: 49 | description: | 50 | 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. 51 | default: "" 52 | runs: 53 | using: "docker" 54 | image: "Dockerfile" 55 | 56 | # Ref: https://haya14busa.github.io/github-action-brandings/ 57 | branding: 58 | icon: "check" 59 | color: "green" 60 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | tags: 8 | - "v*.*.*" 9 | pull_request: 10 | types: 11 | - labeled 12 | 13 | # set empty default permissions and define them explicitly in each job for security 14 | permissions: {} 15 | 16 | jobs: 17 | 18 | release: 19 | if: github.event.action != 'labeled' 20 | runs-on: ubuntu-latest 21 | 22 | permissions: 23 | contents: write # hay14busa/action-* to create releases, push tags 24 | pull-requests: read # hay14busa/action-* to list pull requests 25 | 26 | steps: 27 | - name: Harden Runner 28 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 29 | with: 30 | egress-policy: audit 31 | 32 | - uses: actions/checkout@v6 33 | 34 | # Bump version on merging Pull Requests with specific labels. 35 | # (bump:major,bump:minor,bump:patch) 36 | - id: bumpr 37 | if: "!startsWith(github.ref, 'refs/tags/')" 38 | uses: haya14busa/action-bumpr@faf6f474bcb6174125cfc569f0b2e24cbf03d496 # v1.11.4 39 | 40 | # Update corresponding major and minor tag. 41 | # e.g. Update v1 and v1.2 when releasing v1.2.3 42 | - uses: haya14busa/action-update-semver@7d2c558640ea49e798d46539536190aff8c18715 # v1.5.1 43 | if: "!steps.bumpr.outputs.skip" 44 | with: 45 | tag: ${{ steps.bumpr.outputs.next_version }} 46 | 47 | # Get tag name. 48 | - id: tag 49 | uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1 50 | with: 51 | cond: "${{ startsWith(github.ref, 'refs/tags/') }}" 52 | if_true: ${{ github.ref }} 53 | if_false: ${{ steps.bumpr.outputs.next_version }} 54 | 55 | # Create release 56 | - if: "steps.tag.outputs.value != ''" 57 | env: 58 | TAG_NAME: ${{ steps.tag.outputs.value }} 59 | BODY: ${{ steps.bumpr.outputs.message }} 60 | # This token is provided by Actions, you do not need to create your own token 61 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 62 | run: | 63 | gh release create "${TAG_NAME}" -t "Release ${TAG_NAME/refs\/tags\//}" --notes "${BODY}" 64 | 65 | release-check: 66 | if: github.event.action == 'labeled' 67 | runs-on: ubuntu-latest 68 | 69 | permissions: 70 | contents: read 71 | pull-requests: write # hay14busa/action-* to add changelog comment to PR 72 | 73 | steps: 74 | - name: Harden Runner 75 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 76 | with: 77 | egress-policy: audit 78 | 79 | - uses: actions/checkout@v6 80 | - name: Post bumpr status comment 81 | uses: haya14busa/action-bumpr@faf6f474bcb6174125cfc569f0b2e24cbf03d496 # v1.11.4 82 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guide 2 | 3 | ## How to Start contributing 4 | 5 | Welcome! We are delighted that you want to contribute to our project! 💖 6 | 7 | This project accepts contributions via GitHub pull requests. 8 | 9 | This document outlines the process to help ensure your contribution is accepted. 10 | 11 | There are several ways to contribute: 12 | 13 | * Suggest [features](https://github.com/dbelyaev/action-checkstyle/issues/new?assignees=&labels=type%3A+%3Abulb%3A+feature+request&template=feature-request.md&title=) 14 | * Suggest [changes](https://github.com/dbelyaev/action-checkstyle/issues/new?assignees=&labels=type%3A+%3Awrench%3A+maintenance&template=code-maintenance.md&title=) 15 | * Report [bugs](https://github.com/dbelyaev/action-checkstyle/issues/new?assignees=&labels=type%3A+%3Abug+bug&template=bug-report.md&title=) 16 | 17 | ## How to contribute your changes via PR 18 | 19 | In general, we follow [Work and Pull Request Workflow](https://github.com/susam/gitpr). 20 | 21 | Here's a quick guide: 22 | 23 | 1. Create your fork of the repository. 24 | 1. Clone the project to your machine. 25 | 1. To keep track of the original repository add another remote named "upstream". 26 | 27 | ```shell 28 | git remote add upstream git@github.com:dbelyaev/action-checkstyle.git 29 | ``` 30 | 31 | 1. Create a branch locally with a succinct but descriptive name, prefixed with change type. 32 | 33 | ```shell 34 | git checkout -b feature/my-new-feature 35 | ``` 36 | 37 | 1. Make the changes in the created branch. 38 | 1. Add the changed files. 39 | 40 | ```shell 41 | git add path/to/filename 42 | ``` 43 | 44 | 1. Commit your changes using the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) formatting for the commit messages. 45 | 46 | ```shell 47 | git commit -m "conventional commit formatted message" 48 | ``` 49 | 50 | 1. Before sending the pull request, make sure to rebase onto the upstream source. This ensures your code is based on the latest available code. 51 | 52 | ```shell 53 | git fetch upstream 54 | git rebase upstream/main 55 | ``` 56 | 57 | 1. Push to your fork. 58 | 59 | ```shell 60 | git push origin feature/my-new-feature 61 | ``` 62 | 63 | 1. Submit a pull request to the original repository via GitHub interface. 64 | * Please provide us with some explanation of why you made the changes you made. 65 | * For new features make sure to explain a standard use case to us. 66 | 67 | That's it... thank you for your contribution! 68 | 69 | After your pull request is merged, you can safely delete your branch. 70 | 71 | ## Code review process 72 | 73 | The core team regularly reviews pull requests. 74 | 75 | After feedback has been provided, we expect responses within three weeks. 76 | 77 | If there is no activity on the pull request after three weeks, we may consider closing it. 78 | -------------------------------------------------------------------------------- /.github/workflows/scorecards.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. They are provided 2 | # by a third-party and are governed by separate terms of service, privacy 3 | # policy, and support documentation. 4 | 5 | name: Scorecard supply-chain security 6 | 7 | on: 8 | # For Branch-Protection check. Only the default branch is supported. See 9 | # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection 10 | branch_protection_rule: 11 | # To guarantee Maintained check is occasionally updated. See 12 | # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained 13 | schedule: 14 | - cron: '20 7 * * 2' 15 | push: 16 | branches: [ "master" ] 17 | 18 | # set empty default permissions and define them explicitly in each job for security 19 | permissions: {} 20 | 21 | jobs: 22 | 23 | analysis: 24 | name: Scorecard analysis 25 | runs-on: ubuntu-latest 26 | permissions: 27 | # Needed to upload the results to code-scanning dashboard. 28 | security-events: write 29 | # Needed to publish results and get a badge (see publish_results below). 30 | id-token: write 31 | contents: read 32 | actions: read 33 | 34 | steps: 35 | - name: Harden Runner 36 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 37 | with: 38 | egress-policy: audit 39 | 40 | - name: Checkout 41 | uses: actions/checkout@v6 42 | with: 43 | persist-credentials: false 44 | 45 | - name: Run analysis 46 | uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3 47 | with: 48 | results_file: results.sarif 49 | results_format: sarif 50 | # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: 51 | # - you want to enable the Branch-Protection check on a *public* repository, or 52 | # - you are installing Scorecards on a *private* repository 53 | # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. 54 | # repo_token: ${{ secrets.SCORECARD_TOKEN }} 55 | 56 | # Public repositories: 57 | # - Publish results to OpenSSF REST API for easy access by consumers 58 | # - Allows the repository to include the Scorecard badge. 59 | # - See https://github.com/ossf/scorecard-action#publishing-results. 60 | # For private repositories: 61 | # - `publish_results` will always be set to `false`, regardless 62 | # of the value entered here. 63 | publish_results: true 64 | 65 | # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF 66 | # format to the repository Actions tab. 67 | - name: Upload artifact 68 | uses: actions/upload-artifact@v6 69 | with: 70 | name: SARIF file 71 | path: results.sarif 72 | retention-days: 5 73 | 74 | # Upload the results to GitHub's code scanning dashboard. 75 | - name: Upload to code-scanning 76 | uses: github/codeql-action/upload-sarif@v4 77 | with: 78 | sarif_file: results.sarif 79 | -------------------------------------------------------------------------------- /.github/workflows/depup.yml: -------------------------------------------------------------------------------- 1 | name: depup 2 | 3 | on: 4 | schedule: 5 | - cron: "14 14 * * *" # Runs at 14:14 UTC every day 6 | repository_dispatch: 7 | types: [ depup ] 8 | workflow_dispatch: 9 | 10 | # set empty default permissions and define them explicitly in each job for security 11 | permissions: {} 12 | 13 | jobs: 14 | 15 | reviewdog: 16 | runs-on: ubuntu-latest 17 | 18 | permissions: 19 | pull-requests: write # for peter-evans/create-pull-request to add upgrade PRs 20 | contents: write # to access git (used in auto commits) 21 | 22 | steps: 23 | - name: Harden Runner 24 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 25 | with: 26 | egress-policy: audit 27 | 28 | - uses: actions/checkout@v6 29 | - uses: reviewdog/action-depup@94a1aaf4e4923064019214b48a43276218af7ad5 # v1.6.4 30 | id: depup 31 | with: 32 | file: Dockerfile 33 | version_name: REVIEWDOG_VERSION 34 | repo: reviewdog/reviewdog 35 | 36 | - name: Create Pull Request 37 | uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v8.0.0 38 | with: 39 | token: ${{ secrets.GITHUB_TOKEN }} 40 | title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 41 | commit-message: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 42 | body: | 43 | Update reviewdog to [v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/releases/tag/v${{ steps.depup.outputs.latest }}) 44 | Compare [v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/compare/v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}) 45 | 46 | This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). 47 | branch: depup/reviewdog 48 | base: master 49 | labels: "bump:minor" 50 | 51 | checkstyle: 52 | runs-on: ubuntu-latest 53 | 54 | permissions: 55 | pull-requests: write # for peter-evans/create-pull-request to add upgrade PRs 56 | contents: write # to access git (used in auto commits) 57 | 58 | steps: 59 | - name: Harden Runner 60 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 61 | with: 62 | egress-policy: audit 63 | 64 | - uses: actions/checkout@v6 65 | - uses: reviewdog/action-depup@94a1aaf4e4923064019214b48a43276218af7ad5 # v1.6.4 66 | id: depup-checkstyle 67 | with: 68 | file: Dockerfile 69 | version_name: CHECKSTYLE_VERSION 70 | repo: checkstyle/checkstyle 71 | 72 | - name: Create Pull Request 73 | uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v8.0.0 74 | with: 75 | token: ${{ secrets.GITHUB_TOKEN }} 76 | title: "chore(deps): update default checkstyle to ${{ steps.depup-checkstyle.outputs.latest }}" 77 | commit-message: "chore(deps): update default checkstyle to ${{ steps.depup-checkstyle.outputs.latest }}" 78 | body: | 79 | Update checkstyle to [v${{ steps.depup-checkstyle.outputs.latest }}](https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-${{ steps.depup-checkstyle.outputs.latest }}) 80 | Compare [v${{ steps.depup-checkstyle.outputs.current }}...v${{ steps.depup-checkstyle.outputs.latest }}](https://github.com/checkstyle/checkstyle/compare/checkstyle-${{ steps.depup-checkstyle.outputs.current }}...checkstyle-${{ steps.depup-checkstyle.outputs.latest }}) 81 | 82 | This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). 83 | branch: depup/checkstyle 84 | base: master 85 | labels: "bump:minor" 86 | -------------------------------------------------------------------------------- /.github/workflows/reviewdog.yml: -------------------------------------------------------------------------------- 1 | name: reviewdog 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | types: [ opened, synchronize ] 9 | 10 | # set empty default permissions and define them explicitly in each job for security 11 | permissions: {} 12 | 13 | jobs: 14 | 15 | shellcheck: 16 | name: runner / shellcheck 17 | runs-on: ubuntu-latest 18 | 19 | permissions: 20 | contents: read 21 | pull-requests: write # add check status to PR 22 | 23 | steps: 24 | - name: Harden Runner 25 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 26 | with: 27 | egress-policy: audit 28 | 29 | - uses: actions/checkout@v6 30 | - uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1 31 | id: reporter 32 | with: 33 | cond: ${{ github.event_name == 'pull_request' }} 34 | if_true: "github-pr-review" 35 | if_false: "github-check" 36 | - uses: reviewdog/action-shellcheck@4c07458293ac342d477251099501a718ae5ef86e # v1.32.0 37 | with: 38 | github_token: ${{ secrets.github_token }} 39 | reporter: ${{ steps.reporter.outputs.value }} 40 | level: warning 41 | 42 | hadolint: 43 | name: runner / hadolint 44 | runs-on: ubuntu-latest 45 | 46 | permissions: 47 | contents: read 48 | pull-requests: write # add check status to PR 49 | 50 | steps: 51 | - name: Harden Runner 52 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 53 | with: 54 | egress-policy: audit 55 | 56 | - uses: actions/checkout@v6 57 | - uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1 58 | id: reporter 59 | with: 60 | cond: ${{ github.event_name == 'pull_request' }} 61 | if_true: "github-pr-review" 62 | if_false: "github-check" 63 | - uses: reviewdog/action-hadolint@fc7ee4a9f71e521bc43e370819247b70e5327540 # v1.50.2 64 | with: 65 | github_token: ${{ secrets.github_token }} 66 | reporter: ${{ steps.reporter.outputs.value }} 67 | level: warning 68 | 69 | markdown-lint: 70 | name: runner / markdownlint 71 | runs-on: ubuntu-latest 72 | 73 | permissions: 74 | contents: read 75 | pull-requests: write # add check status to PR 76 | 77 | steps: 78 | - name: Harden Runner 79 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 80 | with: 81 | egress-policy: audit 82 | 83 | - uses: actions/checkout@v6 84 | - name: markdown-lint 85 | uses: reviewdog/action-markdownlint@3667398db9118d7e78f7a63d10e26ce454ba5f58 # v0.26.2 86 | with: 87 | github_token: ${{ secrets.GITHUB_TOKEN }} 88 | reporter: github-pr-review 89 | markdownlint_flags: '**/*.md --ignore LICENSE.md --disable MD013 --' # disable line length rule and ignore LICENSE file 90 | 91 | misspell: 92 | name: runner / misspell 93 | runs-on: ubuntu-latest 94 | 95 | permissions: 96 | contents: read 97 | pull-requests: write # add check status to PR 98 | 99 | steps: 100 | - name: Harden Runner 101 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 102 | with: 103 | egress-policy: audit 104 | 105 | - uses: actions/checkout@v6 106 | - uses: reviewdog/action-misspell@d6429416b12b09b4e2768307d53bef58d172e962 # v1.27.0 107 | with: 108 | github_token: ${{ secrets.github_token }} 109 | reporter: github-check 110 | level: warning 111 | locale: "US" 112 | 113 | alex: 114 | name: runner / alex 115 | runs-on: ubuntu-latest 116 | 117 | permissions: 118 | contents: read 119 | pull-requests: write # add check status to PR 120 | 121 | steps: 122 | - name: Harden Runner 123 | uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 124 | with: 125 | egress-policy: audit 126 | 127 | - uses: actions/checkout@v6 128 | - uses: reviewdog/action-alex@6083b8ca333981fa617c6828c5d8fb21b13d916b # v1.16.0 129 | with: 130 | github_token: ${{ secrets.github_token }} 131 | reporter: github-check 132 | level: warning 133 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributor Covenant Code of Conduct 3 | 4 | ## Our Pledge 5 | 6 | We as members, contributors, and leaders pledge to make participation in our 7 | community a harassment-free experience for everyone, regardless of age, body 8 | size, visible or invisible disability, ethnicity, sex characteristics, gender 9 | identity and expression, level of experience, education, socio-economic status, 10 | nationality, personal appearance, race, caste, color, religion, or sexual 11 | identity and orientation. 12 | 13 | We pledge to act and interact in ways that contribute to an open, welcoming, 14 | diverse, inclusive, and healthy community. 15 | 16 | ## Our Standards 17 | 18 | Examples of behavior that contributes to a positive environment for our 19 | community include: 20 | 21 | * Demonstrating empathy and kindness toward other people 22 | * Being respectful of differing opinions, viewpoints, and experiences 23 | * Giving and gracefully accepting constructive feedback 24 | * Accepting responsibility and apologizing to those affected by our mistakes, 25 | and learning from the experience 26 | * Focusing on what is best not just for us as individuals, but for the overall 27 | community 28 | 29 | Examples of unacceptable behavior include: 30 | 31 | * The use of sexualized language or imagery, and sexual attention or advances of 32 | any kind 33 | * Trolling, insulting or derogatory comments, and personal or political attacks 34 | * Public or private harassment 35 | * Publishing others' private information, such as a physical or email address, 36 | without their explicit permission 37 | * Other conduct which could reasonably be considered inappropriate in a 38 | professional setting 39 | 40 | ## Enforcement Responsibilities 41 | 42 | Community leaders are responsible for clarifying and enforcing our standards of 43 | acceptable behavior and will take appropriate and fair corrective action in 44 | response to any behavior that they deem inappropriate, threatening, offensive, 45 | or harmful. 46 | 47 | Community leaders have the right and responsibility to remove, edit, or reject 48 | comments, commits, code, wiki edits, issues, and other contributions that are 49 | not aligned to this Code of Conduct, and will communicate reasons for moderation 50 | decisions when appropriate. 51 | 52 | ## Scope 53 | 54 | This Code of Conduct applies within all community spaces, and also applies when 55 | an individual is officially representing the community in public spaces. 56 | Examples of representing our community include using an official e-mail address, 57 | posting via an official social media account, or acting as an appointed 58 | representative at an online or offline event. 59 | 60 | ## Enforcement 61 | 62 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 63 | reported to the community leaders responsible for enforcement at 64 | . 65 | All complaints will be reviewed and investigated promptly and fairly. 66 | 67 | All community leaders are obligated to respect the privacy and security of the 68 | reporter of any incident. 69 | 70 | ## Enforcement Guidelines 71 | 72 | Community leaders will follow these Community Impact Guidelines in determining 73 | the consequences for any action they deem in violation of this Code of Conduct: 74 | 75 | ### 1. Correction 76 | 77 | **Community Impact**: Use of inappropriate language or other behavior deemed 78 | unprofessional or unwelcome in the community. 79 | 80 | **Consequence**: A private, written warning from community leaders, providing 81 | clarity around the nature of the violation and an explanation of why the 82 | behavior was inappropriate. A public apology may be requested. 83 | 84 | ### 2. Warning 85 | 86 | **Community Impact**: A violation through a single incident or series of 87 | actions. 88 | 89 | **Consequence**: A warning with consequences for continued behavior. No 90 | interaction with the people involved, including unsolicited interaction with 91 | those enforcing the Code of Conduct, for a specified period of time. This 92 | includes avoiding interactions in community spaces as well as external channels 93 | like social media. Violating these terms may lead to a temporary or permanent 94 | ban. 95 | 96 | ### 3. Temporary Ban 97 | 98 | **Community Impact**: A serious violation of community standards, including 99 | sustained inappropriate behavior. 100 | 101 | **Consequence**: A temporary ban from any sort of interaction or public 102 | communication with the community for a specified period of time. No public or 103 | private interaction with the people involved, including unsolicited interaction 104 | with those enforcing the Code of Conduct, is allowed during this period. 105 | Violating these terms may lead to a permanent ban. 106 | 107 | ### 4. Permanent Ban 108 | 109 | **Community Impact**: Demonstrating a pattern of violation of community 110 | standards, including sustained inappropriate behavior, harassment of an 111 | individual, or aggression toward or disparagement of classes of individuals. 112 | 113 | **Consequence**: A permanent ban from any sort of public interaction within the 114 | community. 115 | 116 | ## Attribution 117 | 118 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 119 | version 2.1, available at 120 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 121 | 122 | Community Impact Guidelines were inspired by 123 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 124 | 125 | For answers to common questions about this code of conduct, see the FAQ at 126 | [https://www.contributor-covenant.org/faq][FAQ]. 127 | 128 | Translations are available at 129 | [https://www.contributor-covenant.org/translations][translations]. 130 | 131 | [homepage]: https://www.contributor-covenant.org 132 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 133 | [Mozilla CoC]: https://github.com/mozilla/diversity 134 | [FAQ]: https://www.contributor-covenant.org/faq 135 | [translations]: https://www.contributor-covenant.org/translations 136 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Checkstyle for Java GitHub Action 2 | 3 | 4 | [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/dbelyaev/action-checkstyle?logo=github&sort=semver)](https://github.com/dbelyaev/action-checkstyle/releases) 5 | [![reviewdog](https://github.com/dbelyaev/action-checkstyle/workflows/reviewdog/badge.svg)](https://github.com/dbelyaev/action-checkstyle/actions?query=workflow%3Areviewdog) 6 | [![release](https://github.com/dbelyaev/action-checkstyle/workflows/release/badge.svg)](https://github.com/dbelyaev/action-checkstyle/actions?query=workflow%3Arelease) 7 | [![depup](https://github.com/dbelyaev/action-checkstyle/workflows/depup/badge.svg)](https://github.com/dbelyaev/action-checkstyle/actions?query=workflow%3Adepup) 8 | 9 | [![Test - Reviewers](https://github.com/dbelyaev/action-checkstyle/actions/workflows/test-reviewers.yml/badge.svg)](https://github.com/dbelyaev/action-checkstyle/actions/workflows/test-reviewers.yml) 10 | [![Test - Versions](https://github.com/dbelyaev/action-checkstyle/actions/workflows/test-versions.yml/badge.svg)](https://github.com/dbelyaev/action-checkstyle/actions/workflows/test-versions.yml) 11 | [![Test - Other](https://github.com/dbelyaev/action-checkstyle/actions/workflows/test-other.yml/badge.svg)](https://github.com/dbelyaev/action-checkstyle/actions/workflows/test-other.yml) 12 | 13 | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/dbelyaev/action-checkstyle/badge)](https://securityscorecards.dev/viewer/?uri=github.com/dbelyaev/action-checkstyle) 14 | [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md) 15 | [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdbelyaev%2Faction-checkstyle.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fdbelyaev%2Faction-checkstyle?ref=badge_shield) 16 | [![action-bumpr supported](https://img.shields.io/badge/bumpr-supported-ff69b4?logo=github&link=https://github.com/haya14busa/action-bumpr)](https://github.com/haya14busa/action-bumpr) 17 | 18 | A GitHub action that integrates [Checkstyle](https://github.com/checkstyle/checkstyle) with your pull request workflow to enforce Java code quality standards. Violations are automatically reported via [reviewdog](https://github.com/reviewdog/reviewdog), making code reviews more efficient and consistent. 19 | 20 | ## Table of Contents 21 | 22 | - [Checkstyle for Java GitHub Action](#checkstyle-for-java-github-action) 23 | - [Table of Contents](#table-of-contents) 24 | - [Example](#example) 25 | - [Usage](#usage) 26 | - [Security Note: Pin by Tag or by Hash?](#security-note-pin-by-tag-or-by-hash) 27 | - [Pinning by Tag](#pinning-by-tag) 28 | - [Pinning by Commit SHA](#pinning-by-commit-sha) 29 | - [Best Practice](#best-practice) 30 | - [Input Parameters](#input-parameters) 31 | - [Checkstyle Parameters](#checkstyle-parameters) 32 | - [Reviewdog Parameters](#reviewdog-parameters) 33 | 34 | ## Example 35 | 36 | An example of how the reported Checkstyle violations will look on a pull request is shown below ([link to example PR](https://github.com/dbelyaev/action-checkstyle-tester/pull/9)): 37 | 38 | ![PR comment with violation](https://user-images.githubusercontent.com/6915328/149333188-4600a75d-5670-4013-9395-d5852e3c7839.png) 39 | 40 | ## Usage 41 | 42 | ```yaml 43 | name: reviewdog 44 | on: [pull_request] 45 | jobs: 46 | checkstyle: 47 | name: runner / checkstyle 48 | runs-on: ubuntu-latest 49 | steps: 50 | - uses: actions/checkout@v5 51 | - uses: dbelyaev/action-checkstyle@v3 52 | with: 53 | github_token: ${{ secrets.github_token }} 54 | reporter: github-pr-review 55 | level: warning 56 | ``` 57 | 58 | ### Security Note: Pin by Tag or by Hash? 59 | 60 | When using GitHub Actions, you can pin to a specific version in two ways: 61 | 62 | #### Pinning by Tag 63 | 64 | ```yaml 65 | - uses: dbelyaev/action-checkstyle@v3 # pin to the latest major tag 66 | ``` 67 | 68 | ```yaml 69 | - uses: dbelyaev/action-checkstyle@v3.0.0 # pin to specific version tag 70 | ``` 71 | 72 | - **Pros**: Convenient, automatically receives updates 73 | - **Cons**: Less secure, as tags can be modified to point to different commits 74 | 75 | #### Pinning by Commit SHA 76 | 77 | ```yaml 78 | - uses: dbelyaev/action-checkstyle@0babcc5b0e55e5a8ab6f8a17134f2d613e2bcdda # v3.0.0 79 | ``` 80 | 81 | - **Pros**: Maximum security, guarantees the exact same code runs every time 82 | - **Cons**: Requires manual updates when new versions are released 83 | 84 | #### Best Practice 85 | 86 | GitHub [officially recommends](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-third-party-actions) pinning actions to a full length commit SHA for production workflows and 3rd party actions to ensure security. For non-critical workflows, major version tags provide a reasonable balance between convenience and safety. 87 | 88 | For automated SHA updates, consider using tools like [Dependabot (owned by GitHub)](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot) or [Renovate (owned by mend.io)](https://github.com/apps/renovate) to keep your actions current while maintaining security. 89 | 90 | ## Input Parameters 91 | 92 | ### Checkstyle Parameters 93 | 94 | - ### `checkstyle_config` 95 | 96 | Checkstyle configuration specifies which ruleset to apply during the scan. 97 | 98 | There are two built-in configurations: 99 | - `google_checks.xml` - Configuration for the [Google coding conventions](https://google.github.io/styleguide/javaguide.html) 100 | - `sun_checks.xml` - Configuration for the [Sun coding conventions](https://www.oracle.com/java/technologies/javase/codeconventions-contents.html) 101 | 102 | It is also possible to supply your custom Checkstyle configuration file located in the same directory. 103 | 104 | **Default:** `google_checks.xml` 105 | 106 | **Example:** 107 | 108 | ```yaml 109 | name: reviewdog 110 | on: [pull_request] 111 | jobs: 112 | checkstyle: 113 | name: runner / checkstyle 114 | runs-on: ubuntu-latest 115 | steps: 116 | - uses: actions/checkout@v5 117 | - uses: dbelyaev/action-checkstyle@v3 118 | with: 119 | github_token: ${{ secrets.github_token }} 120 | reporter: github-pr-review 121 | checkstyle_config: sun_checks.xml 122 | ``` 123 | 124 | Link to [example PR](https://github.com/dbelyaev/action-checkstyle-tester/pull/10). 125 | 126 | - ### `checkstyle_version` 127 | 128 | Checkstyle version to be used during analysis. 129 | 130 | For a list of available version numbers, go to the [Checkstyle release page](https://github.com/checkstyle/checkstyle/releases/). 131 | 132 | **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. 133 | 134 | **Default:** Latest available version 135 | 136 | **Example:** 137 | 138 | ```yaml 139 | name: reviewdog 140 | on: [pull_request] 141 | jobs: 142 | checkstyle: 143 | name: runner / checkstyle 144 | runs-on: ubuntu-latest 145 | steps: 146 | - uses: actions/checkout@v5 147 | - uses: dbelyaev/action-checkstyle@v3 148 | with: 149 | github_token: ${{ secrets.github_token }} 150 | reporter: github-pr-review 151 | checkstyle_version: "9.0" # double quotes important here 152 | ``` 153 | 154 | - ### `workdir` 155 | 156 | The working directory relative to the root directory. 157 | 158 | **Default:** `'.'` (root) 159 | 160 | - ### `properties_file` 161 | 162 | Location of the properties file relative to the root directory. 163 | 164 | This file serves as a means to resolve repetitive or predefined values within the checkstyle configuration file. 165 | 166 | **Default:** `''` (empty) 167 | 168 | **Example:** 169 | 170 | ```yaml 171 | name: reviewdog 172 | on: [pull_request] 173 | jobs: 174 | checkstyle: 175 | name: runner / checkstyle 176 | runs-on: ubuntu-latest 177 | steps: 178 | - uses: actions/checkout@v5 179 | - uses: dbelyaev/action-checkstyle@v3 180 | with: 181 | github_token: ${{ secrets.github_token }} 182 | reporter: github-pr-review 183 | checkstyle_config: ./properties_file/test_checks.xml 184 | properties_file: ./properties_file/additional.properties 185 | ``` 186 | 187 | Link to [example PR](https://github.com/dbelyaev/action-checkstyle-tester/pull/11). 188 | 189 | ### Reviewdog Parameters 190 | 191 | - ### `reporter` 192 | 193 | Specific reporter to be used for the GitHub results reporting by reviewdog. 194 | 195 | **Values:** `github-pr-check`, `github-check`, `github-pr-review` 196 | 197 | For more information, check [reviewdog / reporters](https://github.com/reviewdog/reviewdog#reporters) documentation, which includes examples of GitHub reports and descriptions of possible limitations. 198 | 199 | **Default:** `github-pr-check` 200 | 201 | - ### `level` 202 | 203 | This flag is used to change report level for the chosen `reporter`. 204 | 205 | **Values:** `info`, `warning`, `error` 206 | 207 | You can control GitHub status check result with this feature: 208 | 209 | | Level | GitHub Status | 210 | | --------- | ------------- | 211 | | `info` | neutral | 212 | | `warning` | neutral | 213 | | `error` | failure | 214 | 215 | **Default:** `info` 216 | 217 | - ### `filter_mode` 218 | 219 | Filtering mode for the reviewdog command. 220 | 221 | **Values:** `added`, `diff_context`, `file`, `nofilter` 222 | 223 | For more information, check [reviewdog / filter-mode](https://github.com/reviewdog/reviewdog#filter-mode) documentation. 224 | 225 | **Default:** `added` 226 | 227 | - ### `fail_level` 228 | 229 | Controls when reviewdog should return a non-zero exit code to fail your workflow. 230 | 231 | **Values:** `none`, `any`, `info`, `warning`, `error` 232 | 233 | By default (`none`), reviewdog will exit with code `0` even if it finds errors. Setting this to another value will cause reviewdog to exit with code `1` when it finds issues at or above the specified severity level, which can be used to fail the GitHub workflow. 234 | 235 | **Default:** `none` 236 | 237 | - ### `reviewdog_flags` 238 | 239 | Additional reviewdog flags. 240 | 241 | **Default:** `""` 242 | --------------------------------------------------------------------------------