@codacy/tools-pmd-6

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

Pmd tool adapter for Codacy analysis

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

@codacy/tools-pmd-6

Table of Contents


Overview

PMD 6 adapter for Codacy analysis. PMD is a multi-language static analysis tool that finds common programming flaws such as unused variables, empty catch blocks, and unnecessary object creation. This adapter wraps PMD 6.55.0 (the final 6.x release) as a CLI child process.

PropertyValue
Tool IDPMD
Codacy UUID9ed24812-b6ee-4a58-9004-0ed183c45b8f
StrategyCLI (child process, JVM-based)
LanguagesJava, Javascript, PLSQL, XML, Apex, Velocity, VisualForce, JSP
File patterns**/*.java, **/*.js, **/*.sql, **/*.xml, **/*.cls, **/*.jsp, etc.
RuntimeJava 8+

Updating patterns

# Re-fetch pattern metadata from the Codacy API
pnpm prefetch

# Commit the result
git add src/patterns.json

Updating the PMD version

PMD 6.55.0 is the final PMD 6.x release. No further updates will be made to PMD 6. For PMD 7.x, see the pmd-7 adapter package.

Development

pnpm build    # Build with tsup
pnpm test     # Run tests

To run integration tests, ensure Java 8+ and the PMD 6 distribution are available on your PATH. Tests requiring the real binary are automatically skipped when PMD is not present.

Notes for maintainers

  • Preset mappings (src/pattern-mappings.json): the JUnit and EJB rules are gated. The JUnit4* rules go to junit (the Maven junit:junit artifact, i.e. JUnit 3/4) and JUnit5TestShouldBePackagePrivate to junit-5 (junit-jupiter), so a JUnit-5-only project no longer gets JUnit-4 annotation advice. The version-agnostic ones (JUnitAssertions*, JUnitTest*, DetachedTestCase, TestClassWithoutTestCases) are claimed by both keys, which filterAutoPatterns treats as an OR. Three were default-on (JUnitSpelling, JUnitStaticSuite, JUnitTestsShouldIncludeAssert) and now stay out of a Java repo with no test framework. The five session-bean naming rules plus StaticEJBFieldShouldBeFinal gate on jakarta-ee, matched from the EJB/Jakarta EE API jars under every name they have shipped as.

    Detection had to learn spring-boot-starter-test (which pulls JUnit 5 transitively and is the only test declaration most Spring projects have), the junit-jupiter-/junit-platform- per-role artifacts, and Gradle's testRuntimeOnly verb — without those, gating these default-on rules would have lost them for every Spring Boot repo.

  • CLI entry point differs from PMD 7: PMD 6 uses bin/run.sh pmd ... (with pmd as the first argument to run.sh), while PMD 7 uses bin/pmd check ....

  • Fail flag syntax: PMD 6 uses --fail-on-violation false (flag + value), while PMD 7 uses --no-fail-on-violation (single flag).

  • No progress bar flag: PMD 6 does not support --no-progress.

  • Filtered extensions: .jsx, .jsm, and .vue files are filtered out before analysis because PMD 6's JavaScript engine (Mozilla Rhino) cannot parse them.

  • Language terse names: PMD 6 uses vm for Velocity and vf for VisualForce (PMD 7 uses velocity and visualforce). This affects pattern ID matching.

  • No Kotlin/Swift/TypeScript: These languages were added in PMD 7 only.

  • JSON output: The processingErrors and configurationErrors fields may be absent in PMD 6's JSON output (they are optional in the adapter's type definition).

版本与发布记录

@codacy/tools-pmd-6 共发布 29 个版本,首次发布于 2026/04/17;过去 12 个月发布了 29 个版本。

版本发布日期距今
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-pmd-6 的常见问题

@codacy/tools-pmd-6 是什么?

Pmd tool adapter for Codacy analysis

如何安装 @codacy/tools-pmd-6?

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

@codacy/tools-pmd-6 支持 TypeScript 吗?

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

@codacy/tools-pmd-6 支持 ESM 还是 CommonJS?

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

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

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

@codacy/tools-pmd-6 可以商用吗?

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

@codacy/tools-pmd-6 的下载量有多少?

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

@codacy/tools-pmd-6 还在维护吗?

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