| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is the docker engine we use at Codacy to have Rubocop 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-rubocop .
The docker is ran with the following command:
docker run -it -v $srcDir:/src <DOCKER_NAME>:<DOCKER_VERSION>
Rubocop is moving some checks to separate repositories, as an example you can check rubocop/rubocop#6890
There are some important details to take into consideration:
- private val plugins: List[String] = List("rubocop-performance")
+ private val plugins: List[String] = List("rubocop-performance", "rubocop-style")- $plugins = ["rubocop-performance"]
+ $plugins = ["rubocop-performance", "rubocop-style"]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.
bundle update
bundle config set --local path 'vendor/bundle'
bundle install
./scripts/doc_generate.sh <docs_location>Notes on the documentation generation:
This section is written for an AI coding agent (or a human) tasked with updating this repo — most commonly bumping the wrapped RuboCop version (and its cop plugins), 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/rubocop/Rubocop.scala, built on codacy-engine-scala-seed) that packages RuboCop — plus a large set of RuboCop cop plugins (rubocop-rails, rubocop-performance, rubocop-rspec, etc., listed in the Gemfile) — as a Docker image Codacy's platform runs against a customer's Ruby source code. The Scala side only orchestrates: it shells out to the rubocop gem at runtime and translates its output/config into Codacy's API shapes.
The docs/ directory is machine-consumed configuration, not just documentation:
Both generated artifacts above come from two Ruby scripts run via scripts/doc_generate.sh: doc_generation/rubocop_doc/generator.rb (scrapes RuboCop/plugin cop YAML+YARD docs into markdown) and doc_generation/codacy/rubocop/generator.rb (turns that into docs/patterns.json and docs/description/description.json). These need the gems actually installed locally (bundle install) since they introspect the installed cop classes — they are not simple web scrapers.
| File | What it controls | What to check |
|---|---|---|
| Gemfile → gem "rubocop" (unpinned) and the gem "rubocop-*" plugin lines | Which RuboCop core/plugin versions bundle update will resolve to | RuboCop itself is not version-pinned here — the actual resolved version only shows up in Gemfile.lock after bundle update. If a plugin needs pinning to a specific version, add a version constraint on its line. |
| Gemfile.lock | The exact resolved RuboCop + plugin + transitive dependency versions actually shipped | Regenerated by bundle update / bundle install — do not hand-edit; commit the regenerated file. |
| docs/patterns.json → top-level "version" field | The RuboCop version recorded in the generated pattern catalog | Set automatically by the doc generator when re-run after the gem bump — verify it matches the new Gemfile.lock version after regeneration. |
| src/main/scala/codacy/rubocop/Rubocop.scala → plugins list (and the "legacy requires" block) | Which cop plugins are required/enabled when the engine invokes RuboCop | Add new plugin gems here (mirrors the doc_generation/codacy/rubocop/generator.rb $plugins list — keep both in sync, see the "Add plugin" section above). |
| doc_generation/codacy/rubocop/generator.rb → $plugins | Which plugins the doc generator requires so their cops are picked up when building docs/patterns.json | Keep in sync with the plugins list in Rubocop.scala above. |
| build.sbt → codacy-engine-scala-seed, scala-xml, jackson-dataformat-yaml, play-json versions, scalaVersion | Codacy's engine SDK and Scala-side dependencies — unrelated to the RuboCop version | Only touch when explicitly asked to bump these, or when a build failure forces it (e.g. codacy-engine-scala-seed API changes). |
| Dockerfile → ARG BASE_IMAGE=ruby:<version>-alpine<version> | The Ruby runtime the gems and the engine binary run on | Only bump if the new RuboCop/gem versions raise the minimum Ruby requirement, or if asked explicitly. |
| project/build.properties / project/plugins.sbt | sbt version / the codacy-sbt-plugin version | Rarely needs touching; check only if the build itself fails to load. |
| .circleci/config.yml → codacy/base and codacy/plugins-test orb versions | Shared CircleCI steps (checkout/versioning/sbt build/docker publish/tagging) and the codacy-plugins-test runner | Check the latest published orb versions if asked to bump them; not tied to RuboCop bumps. |
bundle config set --local path 'vendor/bundle'
bundle install
./scripts/doc_generate.sh .| Symptom | Likely cause | Fix |
|---|---|---|
| scalafmtCheckAll fails in CI/locally | Generated or hand-edited Scala file not formatted | Run sbt scalafmt then re-run the check command |
| Doc generator run fails or produces empty/garbled descriptions | Plugin not required, or gems not installed under vendor/bundle before running scripts/doc_generate.sh | Ensure the plugin is listed in both $plugins (generator) and plugins (Rubocop.scala), then re-run bundle install with the vendored path before regenerating |
| plugins_test (multiple-tests) fails on a specific fixture | A cop was renamed/removed/added upstream, or default enablement/parameters changed between RuboCop versions | Regenerate docs, diff docs/patterns.json, and update the relevant fixture under docs/multiple-tests/ to match the new (verified correct) output |
| CI publish_docker/tag_version don't run on your branch | Expected — gated to master only in .circleci/config.yml | Nothing to fix |
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.
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.
| Back | FazBrowse Home | New Git URL |