This is the docker engine we use at Codacy to have Checkstyle support. You can also create a docker to integrate the tool and language of your choice! See the codacy-engine-scala-seed repository for more information.
You can create the docker by doing:
sbt universal:stage
docker build -t codacy-checkstyle .The docker is ran with the following command:
docker run -it -v $srcDir:/src -v $configFile:/.codacyrc <DOCKER_NAME>:<DOCKER_VERSION>The documentation generator is using the pandoc tool to convert html sections to markdown.
The pandoc version used currently is 2.7.3 which can be downloaded here.
Having pandoc in PATH you can follow these steps:
-
Update the
checkstyleVersionvalue inbuild.sbt -
Run the DocGenerator
sbt "runMain codacy.checkstyle.DocGenerator"We use the codacy-plugins-test to test our external tools integration. You can follow the instructions there to make sure your tool is working as expected.
This section is written for an AI coding agent (or a human) tasked with updating this repo — most commonly bumping the wrapped Checkstyle version, but also base image / orb / dependency bumps. Follow it top to bottom; it tells you what to change, how to regenerate derived files, how to test locally, and how to interpret CI so you can iterate on failures without guessing.
This is a Codacy engine: a thin Scala wrapper (src/main/scala/codacy/Engine.scala, built on codacy-engine-scala-seed) that packages Checkstyle as a Docker image Codacy's platform can run against a customer's source code. The docs/ directory is not just documentation — it is machine-consumed configuration:
docs/patterns.json— the full list of Checkstyle rules ("patterns") Codacy knows about, their parameters/defaults, and which are enabled out of the box. Generated file, do not hand-edit.docs/description/description.json+docs/description/*.md— human-readable titles/descriptions per pattern, used in the Codacy UI. Generated file, do not hand-edit.docs/tests/*anddocs/multiple-tests/*— fixtures used bycodacy-plugins-testto validate the engine actually produces the results it claims to for real code samples.docs/tool-description.md— short blurb about the tool, hand-maintained.
All three generated artifacts above come from DocGenerator (src/main/scala/codacy/checkstyle/DocGenerator.scala), which clones the real checkstyle/checkstyle GitHub repo at the tag checkstyle-<checkstyleVersion> and scrapes its src/site/xdoc/*.xml documentation to build the pattern list. This means the generator needs network access, git, and pandoc installed locally.
| File | What it controls | What to check |
|---|---|---|
build.sbt → checkstyleVersion |
Which Checkstyle release is bundled and which git tag DocGenerator clones |
Bump to the target version. Confirm a matching checkstyle-<version> tag exists in checkstyle/checkstyle. |
build.sbt → codacy-engine-scala-seed dependency |
Codacy's engine SDK/base library | Check Maven Central for newer versions if asked to update it; not tied to Checkstyle bumps. |
.circleci/config.yml → codacy/base orb |
Shared CircleCI steps (checkout, versioning, sbt build, docker publish, tagging) | Check the latest published version (CircleCI orb registry, or ask — WebFetch may not render the JS page; git log -p .circleci/config.yml shows the bump history as a fallback reference). |
.circleci/config.yml → codacy/plugins-test orb |
Runs codacy-plugins-test in CI after the image is built |
Same as above. |
Dockerfile → base image (eclipse-temurin:11-jre-alpine) |
JRE the packaged app runs on | Only bump if the new Checkstyle version raises its minimum JDK requirement (check Checkstyle's release notes) or if asked explicitly — don't bump opportunistically. |
project/build.properties / project/plugins.sbt |
sbt version / sbt plugins | Rarely needs touching; check only if the build itself fails to load. |
Look at recent bump commits for the shape of a typical diff: git log --oneline --all | grep -i bump, then git show <hash>. Recent examples touch build.sbt (checkstyleVersion), .circleci/config.yml (orb versions), and the regenerated docs/* files together.
- Bump the version(s) in
build.sbt(and.circleci/config.ymlorbs, if applicable) as scoped by the task. - Regenerate the docs. Requires
pandoc(tested with 2.7.3, see download link above) onPATH, plus git/network access:This clonessbt "runMain codacy.checkstyle.DocGenerator"checkstyle/checkstyleat the new tag into a temp dir and rewritesdocs/patterns.json,docs/description/description.json, anddocs/description/*.md. Review the diff:- New patterns appear — decide if any should be added to
defaultPatternsinDocGenerator.scala(rules enabled by default; historically only a small curated set is enabled out of the box — don't enable new ones unless asked). - Removed/renamed patterns — check whether they're referenced in
docs/tests/,docs/multiple-tests/*/patterns.xml, ordocs/multiple-tests/*/results.xml; stale references will failcodacy-plugins-test. Header.md/RegexpHeader.md-style deletions have happened before when Checkstyle merges/renames checks — this is expected, not a bug, as long as it matches upstream's changelog.
- New patterns appear — decide if any should be added to
- Compile and format:
This mirrors the CI
sbt "set ThisBuild / scalafmtUseIvy := false; scalafmt::test; test:scalafmt::test; sbt:scalafmt::test; universal:stage"publish_docker_localjob exactly. If formatting fails, run the same commands without::test(i.e.sbt scalafmt) to auto-fix, then re-run the check. - Build the Docker image (same as CI):
docker build -t codacy-checkstyle . - Run
codacy-plugins-testlocally before pushing — this is the real correctness check (there is nosrc/testunit test suite in this repo; verification is entirely through this external tool against fixtures indocs/). Clone https://github.com/codacy/codacy-plugins-test and run, from that repo, against your local image tag:Useful flags:sbt "runMain codacy.plugins.DockerTest pattern codacy-checkstyle:latest" sbt "runMain codacy.plugins.DockerTest json codacy-checkstyle:latest" sbt "runMain codacy.plugins.DockerTest multiple codacy-checkstyle:latest"
-Dcodacy.tests.languages=javato scope languages,--only <folderName>to target a singledocs/multiple-tests/<folderName>case while iterating,-Dcodacy.tests.ignore.descriptionsto skip description-completeness checks while debugging something unrelated. - Iterate on failures (see table below), re-running only the relevant
DockerTestcommand after each fix — no need to rebuild the whole loop from step 1 unlessbuild.sbt/source changed. - Commit the version bump(s) together with the regenerated
docs/files in one change (this matches historical commits likedc394fc,d104910). - Push and open a PR. CI (
.circleci/config.yml) runs, in order:codacy/checkout_and_version→publish_docker_local(scalafmt +universal:stage+docker build+docker save) →plugins_test(codacy_plugins_test/run,run_multiple_tests: true) →codacy/publish_docker(master only) →codacy/tag_version. A failure inpublish_docker_localis almost always scalafmt or a compile error; a failure inplugins_testmeans the generated patterns/docs don't match what the engine actually outputs for the fixtures. - Poll the PR's real CI checks until they all pass — local validation is NOT the finish line. After every push, run
gh pr checks <pr-url>and keep re-polling (short sleep while any check ispending) until all checks finish. If a check fails, fetch its actual log (CircleCI API/UI for the failing job — don't guess), find the true root cause, fix it, push again (never--no-verify, never force-push), and re-poll. Repeat until every check is green. The CI environment's toolchain can differ from your local one, so a clean local run does not guarantee CI passes. Concrete example this playbook has already hit: the 13.x bump compiled fine locally under a manually-installed JDK 21, butpublish_docker_localwent red withClass java.lang.Record not foundbecause the CircleCIcodacy/sbtjob's build JDK defaulted to Java 8 — a different concern from the Dockerfile's runtime JDK. It was only caught by polling the real CI check, and fixed by passingopenjdk_version: "21"to the job (and bumping thecodacy/baseorb to a version that supports it). Only stop iterating when every check passes, or you hit a genuine product/infra decision that needs a human — in which case explain it in the PR rather than guessing.
| Symptom | Likely cause | Fix |
|---|---|---|
scalafmt::test fails in CI/locally |
Generated or hand-edited Scala file not formatted | Run sbt scalafmt (drop the ::test suffix) then re-run the check command |
DocGenerator run fails to clone |
Wrong/nonexistent checkstyle-<version> tag |
Verify the tag exists upstream; Checkstyle tags are exactly checkstyle-X.Y.Z |
DocGenerator run fails needing pandoc |
pandoc missing from PATH |
Install pandoc 2.7.3 (link at top of README) |
pattern/json DockerTest fails: pattern present in docs/patterns.json but tool doesn't emit it (or vice versa) |
Checkstyle rule renamed/removed/added upstream between versions | Re-run DocGenerator; if a pattern legitimately vanished upstream, its removal from docs/patterns.json/description.json is correct — just confirm no fixture still references it |
multiple DockerTest fails on a specific folder under docs/multiple-tests/ |
results.xml or patterns.xml expectations are stale for the new Checkstyle behavior |
Regenerate/update the expected results.xml for that folder to match the new (correct) tool output — verify the new output is actually correct, don't just rubber-stamp a diff |
| Docker image runs but engine crashes on startup | JDK in Dockerfile too old for new Checkstyle version, or codacy-engine-scala-seed incompatibility |
Check Checkstyle's release notes for its minimum JDK; bump the eclipse-temurin tag in Dockerfile only if actually required |
CI publish_docker / tag_version steps don't run on your branch |
Expected — those are gated to master only (filters: branches: only: master) via requires: codacy/publish_docker |
Nothing to fix; this is only exercised after merge |
build.sbt(and orbs, if in scope) reflect the target versions.docs/patterns.json,docs/description/description.json, anddocs/description/*.mdare regenerated and committed, with any fixture/test-data inconsistencies resolved.sbt scalafmt::testandsbt universal:stagepass locally.docker build -t codacy-checkstyle .succeeds.codacy-plugins-test'spattern,json, andmultiplecommands all pass locally against the freshly built image.- The diff looks like previous version-bump commits in shape (
git log --oneline --all | grep -i bumpfor reference). - After pushing and opening/updating the PR, every CI check on it is green. Poll
gh pr checks <pr-url>and iterate on any failure (fetch the real CI log, fix, push, re-poll) until all pass — a passing local build is not sufficient, because the CI toolchain (e.g. the CircleCI build JDK) can differ from your local one (see step 9).
Codacy is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.
- Identify new Static Analysis issues
- Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
- Auto-comments on Commits and Pull Requests
- Integrations with Slack, HipChat, Jira, YouTrack
- Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories
Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.
Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others.
Codacy is free for Open Source projects.