@codacy/tools-rubocop-1

中文文档
0.28.0发布于 2026/11/09MITTypeScriptCommonJS近 30 天下载 1.2万

RuboCop adapter — CLI-mode Ruby linter and formatter

原始使用文档
文档目录6 节
  1. Table of Contents
  2. Overview
  3. Updating patterns
  4. Updating the RuboCop version
  5. Development
  6. Notes for maintainers

@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.

PropertyValue
Tool IDRuboCop
Codacy UUID724f98da-f616-4e37-9606-f16919137a1e
StrategyCLI
LanguagesRuby
Binaryrubocop (installed via gem install)
File patterns**/*.rb, **/*.rake, **/*.gemspec, **/Gemfile, **/Rakefile

Updating patterns

pnpm prefetch
git add src/patterns.json

Pattern IDs use underscore-separated cop names (no prefix): Style_StringLiterals, Lint_Debugger, Metrics_MethodLength, etc.

Updating the RuboCop version

  1. Update RUBOCOP_VERSION in src/adapter.ts
  2. Review plugin gem compatibility -- some plugins pin specific RuboCop versions
  3. Run pnpm prefetch to check for new/removed cops
  4. Run pnpm test to verify compatibility
  5. 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.91.0
gem install rubocop-performance rubocop-rails rubocop-rspec

Notes for maintainers

  • Preset mappings (src/pattern-mappings.json): I18n_GetText_* gates on a new gettext entity (the gettext, gettext_i18n_rails or rubocop-i18n gem) and I18n_RailsI18n_* joins the existing ruby-on-rails key, since Rails I18n ships with Rails and needs no separate entity. All six were default-off and ungated before, which meant init --auto could never enable them — the two cop families are mutually exclusive in practice, so leaving both universal was the worst of both options.

  • RuboCop requires Ruby >= 2.7. The adapter uses ensureRuby() for portable Ruby download.

  • 22+ plugin gems are installed alongside rubocop, matching the Codacy codacy-rubocop wrapper. The full list is in GEM_PACKAGES in adapter.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/ via GEM_HOME/GEM_PATH.

  • Output format is JSON with files[].offenses[] structure.

  • Pattern IDs: cop_name with / 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_line map to Issue.line/Issue.endLine.

  • Exit codes: 0 = clean, 1 = offenses found (normal success), 2 = error.

  • --force-exclusion ensures config exclusions apply even for explicitly listed files.

  • --cache false ensures 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.

版本与发布记录

@codacy/tools-rubocop-1 共发布 34 个版本,首次发布于 2026/03/27;过去 12 个月发布了 34 个版本。

版本发布日期距今
0.28.0latest2026/11/09今天
0.27.12026/11/054 天前
0.27.02026/11/036 天前
0.26.02026/10/3010 天前
0.25.02026/10/1921 天前
0.24.02026/09/251 个月前

关于 @codacy/tools-rubocop-1 的常见问题

@codacy/tools-rubocop-1 是什么?

RuboCop adapter — CLI-mode Ruby linter and formatter

如何安装 @codacy/tools-rubocop-1?

在项目目录运行 npm install @codacy/tools-rubocop-1,或使用 pnpm add / yarn add / bun add。

@codacy/tools-rubocop-1 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@codacy/tools-rubocop-1 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@codacy/tools-rubocop-1 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@codacy/tools-rubocop-1 可以商用吗?

@codacy/tools-rubocop-1 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codacy/tools-rubocop-1 的下载量有多少?

根据 npm 官方下载统计,@codacy/tools-rubocop-1 在 2026/10/10 – 2026/11/08 这 30 天内被下载 11,950 次,日均约 398 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codacy/tools-rubocop-1 还在维护吗?

最新版本 0.28.0 发布于 2026/11/09(今天);至今共发布 34 个版本,其中过去 12 个月发布了 34 个;首次发布于 2026/03/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。