{"id":24300798,"url":"https://github.com/fabasoad/pre-commit-checkstyle","last_synced_at":"2026-01-26T13:08:04.008Z","repository":{"id":272311885,"uuid":"916128113","full_name":"fabasoad/pre-commit-checkstyle","owner":"fabasoad","description":"pre-commit hooks to run checkstyle","archived":false,"fork":false,"pushed_at":"2026-01-15T22:07:58.000Z","size":69,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-16T01:44:19.524Z","etag":null,"topics":["checkstyle","java","java-lint","lint","linter","linting","pre-commit","pre-commit-hook"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabasoad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"custom":["https://www.bitcoinqrcodemaker.com/?style=bitcoin\u0026address=145HwyQAcv4vrzUumJhu7nWGAVBysX9jJH\u0026prefix=on","https://paypal.me/fabasoad"],"github":["fabasoad"],"ko_fi":"fabasoad","liberapay":"fabasoad"}},"created_at":"2025-01-13T14:07:08.000Z","updated_at":"2026-01-15T22:08:02.000Z","dependencies_parsed_at":"2025-02-20T23:19:12.856Z","dependency_job_id":"e07f9a0f-d8e6-44c4-9a1b-50aa958e1571","html_url":"https://github.com/fabasoad/pre-commit-checkstyle","commit_stats":null,"previous_names":["fabasoad/pre-commit-checkstyle"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/fabasoad/pre-commit-checkstyle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabasoad%2Fpre-commit-checkstyle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabasoad%2Fpre-commit-checkstyle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabasoad%2Fpre-commit-checkstyle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabasoad%2Fpre-commit-checkstyle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabasoad","download_url":"https://codeload.github.com/fabasoad/pre-commit-checkstyle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabasoad%2Fpre-commit-checkstyle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28778829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T11:46:04.308Z","status":"ssl_error","status_checked_at":"2026-01-26T11:46:02.664Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checkstyle","java","java-lint","lint","linter","linting","pre-commit","pre-commit-hook"],"created_at":"2025-01-16T23:17:17.389Z","updated_at":"2026-01-26T13:08:03.974Z","avatar_url":"https://github.com/fabasoad.png","language":"Shell","funding_links":["https://www.bitcoinqrcodemaker.com/?style=bitcoin\u0026address=145HwyQAcv4vrzUumJhu7nWGAVBysX9jJH\u0026prefix=on","https://paypal.me/fabasoad","https://github.com/sponsors/fabasoad","https://ko-fi.com/fabasoad","https://liberapay.com/fabasoad"],"categories":[],"sub_categories":[],"readme":"# Checkstyle pre-commit hooks\n\n[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua)\n![GitHub release](https://img.shields.io/github/v/release/fabasoad/pre-commit-checkstyle?include_prereleases)\n![security](https://github.com/fabasoad/pre-commit-checkstyle/actions/workflows/security.yml/badge.svg)\n![linting](https://github.com/fabasoad/pre-commit-checkstyle/actions/workflows/linting.yml/badge.svg)\n![functional-tests](https://github.com/fabasoad/pre-commit-checkstyle/actions/workflows/functional-tests.yml/badge.svg)\n\n## Table of Contents\n\n- [Checkstyle pre-commit hooks](#checkstyle-pre-commit-hooks)\n  - [Table of Contents](#table-of-contents)\n  - [How it works?](#how-it-works)\n  - [Prerequisites](#prerequisites)\n  - [Hooks](#hooks)\n    - [checkstyle](#checkstyle)\n    - [checkstyle-google](#checkstyle-google)\n    - [checkstyle-sun](#checkstyle-sun)\n  - [Customization](#customization)\n    - [Description](#description)\n    - [Parameters](#parameters)\n      - [Checkstyle](#checkstyle-parameters)\n      - [pre-commit-checkstyle](#pre-commit-checkstyle)\n        - [Log level](#log-level)\n        - [Log color](#log-color)\n        - [Checkstyle version](#checkstyle-version)\n        - [Clean cache](#clean-cache)\n    - [Examples](#examples)\n  - [Contributions](#contributions)\n\n## How it works?\n\nAt first hook tries to use globally installed [checkstyle](https://github.com/checkstyle/checkstyle)\njar file. And if it doesn't exist then hook installs `checkstyle.jar` into a\n`.fabasoad/pre-commit-checkstyle` temporary directory that will be removed after\nscanning is completed.\n\n## Prerequisites\n\nThe following tools have to be available on a machine prior using this pre-commit\nhook:\n\n- [bash \u003e=4.0](https://www.gnu.org/software/bash/)\n- [curl](https://curl.se/)\n- [jq](https://jqlang.github.io/jq/)\n\n## Hooks\n\n\u003c!-- markdownlint-disable-next-line MD013 --\u003e\n\n\u003e `\u003crev\u003e` in the examples below, is the latest revision tag from [fabasoad/pre-commit-checkstyle](https://github.com/fabasoad/pre-commit-checkstyle/releases)\n\u003e repository.\n\n### checkstyle\n\nThis hook runs `checkstyle` without specifying config file. Config file parameter\nis required and must be specified by the user:\n\n```yaml\nrepos:\n  - repo: https://github.com/fabasoad/pre-commit-checkstyle\n    rev: \u003crev\u003e\n    hooks:\n      - id: checkstyle\n        args:\n          - --checkstyle-args=-c config.xml\n```\n\n### checkstyle-google\n\nThis hook runs `checkstyle` with [google_checks.xml](https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml)\nconfig file. User does not have to define anything using this hook:\n\n```yaml\nrepos:\n  - repo: https://github.com/fabasoad/pre-commit-checkstyle\n    rev: \u003crev\u003e\n    hooks:\n      - id: checkstyle-google\n```\n\n### checkstyle-sun\n\nThis hook runs `checkstyle` with [sun_checks.xml](https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/sun_checks.xml)\nconfig file. User does not have to define anything using this hook:\n\n```yaml\nrepos:\n  - repo: https://github.com/fabasoad/pre-commit-checkstyle\n    rev: \u003crev\u003e\n    hooks:\n      - id: checkstyle-sun\n```\n\n## Customization\n\n### Description\n\nThere are 2 ways to customize scanning for both `checkstyle` and `pre-commit-checkstyle`:\nenvironment variables and arguments passed to [args](https://pre-commit.com/#config-args).\n\nYou can pass arguments to the hook as well as to the `checkstyle` itself. To distinguish\nparameters you need to use `--checkstyle-args` for `checkstyle` arguments and `--hook-args`\nfor `pre-commit-checkstyle` arguments. Supported delimiter is `=`. So, use `--hook-args=\u003carg\u003e`\nbut not `--hook-args \u003carg\u003e`. Please find [Examples](#examples) for more details.\n\n### Parameters\n\n#### Checkstyle Parameters\n\nYou can [install](https://github.com/checkstyle/checkstyle?tab=readme-ov-file#quick-start)\n`checkstyle.jar` locally and run `java -jar checkstyle.jar --help` to see all the\navailable arguments:\n\n\u003c!-- markdownlint-disable MD013 --\u003e\n\n```shell\n$ java -jar checkstyle.jar --version\nCheckstyle version: 10.21.2\n\n$ java -jar checkstyle.jar --help\nUsage: checkstyle [-dEghjJtTV] [-b=\u003cxpath\u003e] [-c=\u003cconfigurationFile\u003e] [-f=\u003cformat\u003e]\n                  [-o=\u003coutputPath\u003e] [-p=\u003cpropertiesFile\u003e] [-s=\u003csuppressionLineColumnNumber\u003e]\n                  [-w=\u003ctabWidth\u003e] [-e=\u003cexclude\u003e]... [-x=\u003cexcludeRegex\u003e]... \u003cfiles\u003e...\nCheckstyle verifies that the specified source code files adhere to the specified rules. By default,\nviolations are reported to standard out in plain format. Checkstyle requires a configuration XML\nfile that configures the checks to apply.\n      \u003cfiles\u003e...            One or more source files to verify\n  -b, --branch-matching-xpath=\u003cxpath\u003e\n                            Shows Abstract Syntax Tree(AST) branches that match given XPath query.\n  -c=\u003cconfigurationFile\u003e    Specifies the location of the file that defines the configuration\n                              modules. The location can either be a filesystem location, or a name\n                              passed to the ClassLoader.getResource() method.\n  -d, --debug               Prints all debug logging of CheckStyle utility.\n  -e, --exclude=\u003cexclude\u003e   Directory/file to exclude from CheckStyle. The path can be the full,\n                              absolute path, or relative to the current path. Multiple excludes are\n                              allowed.\n  -E, --executeIgnoredModules\n                            Allows ignored modules to be run.\n  -f=\u003cformat\u003e               Specifies the output format. Valid values: xml, sarif, plain for\n                              XMLLogger, SarifLogger, and DefaultLogger respectively. Defaults to\n                              plain.\n  -g, --generate-xpath-suppression\n                            Generates to output a suppression xml to use to suppress all violations\n                              from user's config. Instead of printing every violation, all\n                              violations will be catched and single suppressions xml file will be\n                              printed out. Used only with -c option. Output location can be\n                              specified with -o option.\n  -h, --help                Show this help message and exit.\n  -j, --javadocTree         This option is used to print the Parse Tree of the Javadoc comment. The\n                              file has to contain only Javadoc comment content excluding '/**' and\n                              '*/' at the beginning and at the end respectively. It can only be\n                              used on a single file and cannot be combined with other options.\n  -J, --treeWithJavadoc     This option is used to display the Abstract Syntax Tree (AST) with\n                              Javadoc nodes of the specified file. It can only be used on a single\n                              file and cannot be combined with other options.\n  -o=\u003coutputPath\u003e           Sets the output file. Defaults to stdout.\n  -p=\u003cpropertiesFile\u003e       Sets the property files to load.\n  -s=\u003csuppressionLineColumnNumber\u003e\n                            Prints xpath suppressions at the file's line and column position.\n                              Argument is the line and column number (separated by a : ) in the\n                              file that the suppression should be generated for. The option cannot\n                              be used with other options and requires exactly one file to run on to\n                              be specified. Note that the generated result will have few queries,\n                              joined by pipe(|). Together they will match all AST nodes on\n                              specified line and column. You need to choose only one and recheck\n                              that it works. Usage of all of them is also ok, but might result in\n                              undesirable matching and suppress other issues.\n  -t, --tree                This option is used to display the Abstract Syntax Tree (AST) without\n                              any comments of the specified file. It can only be used on a single\n                              file and cannot be combined with other options.\n  -T, --treeWithComments    This option is used to display the Abstract Syntax Tree (AST) with\n                              comment nodes excluding Javadoc of the specified file. It can only be\n                              used on a single file and cannot be combined with other options.\n  -V, --version             Print version information and exit.\n  -w, --tabWidth=\u003ctabWidth\u003e Sets the length of the tab character. Used only with -s option. Default\n                              value is 8.\n  -x, --exclude-regexp=\u003cexcludeRegex\u003e\n                            Directory/file pattern to exclude from CheckStyle. Multiple excludes\n                              are allowed.\n```\n\n\u003c!-- markdownlint-enable MD013 --\u003e\n\n#### pre-commit-checkstyle\n\nHere is the precedence order of `pre-commit-checkstyle` tool:\n\n- Parameter passed to the hook as argument via `--hook-args`.\n- Environment variable.\n- Default value.\n\nFor example, if you set `PRE_COMMIT_CHECKSTYLE_LOG_LEVEL=warning` and `--hook-args=--log-level\nerror` then `error` value will be used.\n\n##### Log level\n\nWith this parameter you can control the log level of `pre-commit-checkstyle` hook\noutput. It doesn't impact `checkstyle` log level output. To control `checkstyle`\nlog level output please look at the [Checkstyle parameters](#checkstyle).\n\n- Parameter name: `--log-level`\n- Environment variable: `PRE_COMMIT_CHECKSTYLE_LOG_LEVEL`\n- Possible values: `debug`, `info`, `warning`, `error`\n- Default: `info`\n\n##### Log color\n\nWith this parameter you can enable/disable the coloring of `pre-commit-checkstyle`\nhook logs. It doesn't impact `checkstyle` logs coloring.\n\n- Parameter name: `--log-color`\n- Environment variable: `PRE_COMMIT_CHECKSTYLE_LOG_COLOR`\n- Possible values: `true`, `false`\n- Default: `true`\n\n##### Checkstyle version\n\nSpecifies specific `checkstyle` version to use. This will work only if `checkstyle`\nis not globally installed, otherwise globally installed `checkstyle` takes precedence.\n\n- Parameter name: `--checkstyle-version`\n- Environment variable: `PRE_COMMIT_CHECKSTYLE_CHECKSTYLE_VERSION`\n- Possible values: [Checkstyle version](https://github.com/checkstyle/checkstyle/releases)\n- Default: `latest`\n\n##### Clean cache\n\nWith this parameter you can choose either to keep cache directory (`.fabasoad/pre-commit-checkstyle`),\nor to remove it. By default, it removes cache directory. With `false` parameter\ncache directory will not be removed which means that if `checkstyle` is not installed\nglobally every subsequent run won't download `checkstyle` again. Don't forget to\nadd cache directory into the `.gitignore` file.\n\n- Parameter name: `--clean-cache`\n- Environment variable: `PRE_COMMIT_CHECKSTYLE_CLEAN_CACHE`\n- Possible values: `true`, `false`\n- Default: `true`\n\n### Examples\n\nPass arguments separately from each other:\n\n```yaml\nrepos:\n  - repo: https://github.com/fabasoad/pre-commit-checkstyle\n    rev: \u003crev\u003e\n    hooks:\n      - id: checkstyle\n        args:\n          - --hook-args=--log-level debug\n          - --checkstyle-args=-c config.xml\n          - --checkstyle-args=--debug\n```\n\nPass arguments altogether grouped by category:\n\n```yaml\nrepos:\n  - repo: https://github.com/fabasoad/pre-commit-checkstyle\n    rev: \u003crev\u003e\n    hooks:\n      - id: checkstyle\n        args:\n          - --hook-args=--log-level debug\n          - --checkstyle-args=-c config.xml --debug\n```\n\nSet these parameters to have the minimal possible logs output:\n\n```yaml\nrepos:\n  - repo: https://github.com/fabasoad/pre-commit-checkstyle\n    rev: \u003crev\u003e\n    hooks:\n      - id: checkstyle-google\n        args:\n          - --hook-args=--log-level=error\n```\n\n## Contributions\n\n![Alt](https://repobeats.axiom.co/api/embed/3679a9d55b33e5a729c6ae0dad36f4f5fd57d2ca.svg \"Repobeats analytics image\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabasoad%2Fpre-commit-checkstyle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabasoad%2Fpre-commit-checkstyle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabasoad%2Fpre-commit-checkstyle/lists"}