@codacy/tools-rubocop-1
v0.2.0
Published
RuboCop adapter — CLI-mode Ruby linter and formatter
Downloads
48
Readme
@codacy/tools-rubocop-1
Table of Contents
Overview
Ruby linter and formatter using RuboCop with 22+ plugin gems. Uses the CLI execution strategy -- spawns rubocop --format json via spawnTool() and parses its JSON output.
| Property | Value |
| ------------- | ------------------------------------------------------------------- |
| Tool ID | RuboCop |
| Codacy UUID | 724f98da-f616-4e37-9606-f16919137a1e |
| Strategy | CLI |
| Languages | Ruby |
| Binary | rubocop (installed via gem install) |
| File patterns | **/*.rb, **/*.rake, **/*.gemspec, **/Gemfile, **/Rakefile |
Updating patterns
pnpm prefetch
git add src/patterns.jsonPattern IDs use underscore-separated cop names (no prefix): Style_StringLiterals, Lint_Debugger, Metrics_MethodLength, etc.
Updating the RuboCop version
- Update
RUBOCOP_VERSIONinsrc/adapter.ts - Review plugin gem compatibility -- some plugins pin specific RuboCop versions
- Run
pnpm prefetchto check for new/removed cops - Run
pnpm testto verify compatibility - If the major version changes, create a new adapter package (
rubocop-2/)
Development
pnpm build # Build with tsup
pnpm test # Run tests (requires ruby + rubocop in PATH for integration tests)To install rubocop locally for testing:
gem install rubocop -v 1.80.2
gem install rubocop-performance rubocop-rails rubocop-rspecNotes for maintainers
- RuboCop requires Ruby >= 2.7. The adapter uses
ensureRuby()for portable Ruby download. - 22+ plugin gems are installed alongside rubocop, matching the Codacy
codacy-rubocopwrapper. The full list is inGEM_PACKAGESinadapter.ts. Plugin gems are installed without version pins (except rubocop itself) to let gem resolve compatible versions. - Gems are installed in
~/.codacy/runtimes/rubocop-1/gems/viaGEM_HOME/GEM_PATH. - Output format is JSON with
files[].offenses[]structure. - Pattern IDs:
cop_namewith/replaced by_(e.g.Style/StringLiterals→Style_StringLiterals). - Line/column are 1-based — direct mapping, no conversion needed.
- Multi-line offenses:
location.start_line/location.last_linemap toIssue.line/Issue.endLine. - Exit codes: 0 = clean, 1 = offenses found (normal success), 2 = error.
--force-exclusionensures config exclusions apply even for explicitly listed files.--cache falseensures fresh analysis on every run.- Pattern filtering is post-hoc: RuboCop runs against all provided files with all cops, then output is filtered by the enabled patterns set.
- Config file detection supports
.rubocop.yml,.config/.rubocop.yml,.config/rubocop/config.yml.
