@codacy/tools-scalastyle-1

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

Scalastyle adapter — CLI-mode Scala style checker

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

@codacy/tools-scalastyle-1

Table of Contents


Overview

Scala style checker and static analysis tool using the Scalastyle assembly JAR. Uses the CLI execution strategy -- spawns java -cp scalastyle.jar org.scalastyle.Main via spawnTool() and parses its Checkstyle-format XML output.

PropertyValue
Tool IDScalaStyle
Codacy UUID21586cd3-3eaa-4454-878e-ac0211a833c2
StrategyCLI
LanguagesScala
Binaryjava -cp scalastyle.jar org.scalastyle.Main
File patterns**/*.scala
Pattern count74

Scalastyle is primarily a Scala 2 tool. It parses Scala source files and checks for style violations, complexity issues, and potential bugs. The assembly JAR is hosted on Maven Central.

Updating patterns

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

# Commit the result
git add src/patterns.json

Pattern IDs follow the format ScalaStyle_MagicNumberChecker, ScalaStyle_FileLengthChecker, etc. Note the capital S in ScalaStyle and that the Checker suffix is retained (unlike Checkstyle which strips Check).

Updating the Scalastyle version

  1. Update SCALASTYLE_VERSION in src/adapter.ts
  2. Update JAR_URL to point to the new assembly JAR on Maven Central
  3. Run pnpm prefetch to check for new/removed rules
  4. Run pnpm test to verify compatibility
  5. If the major version changes, create a new adapter package (scalastyle-2/)

The Maven Central artifact coordinates are:

com.beautiful-scala:scalastyle_2.13:{version}:assembly

Development

pnpm build    # Build with tsup
pnpm test     # Run tests (unit tests always run; integration tests require java + JAR)

To install the Scalastyle JAR locally for integration testing:

mkdir -p /tmp/codacy-scalastyle-test-tools
curl -L -O --output-dir /tmp/codacy-scalastyle-test-tools \
  https://repo1.maven.org/maven2/com/beautiful-scala/scalastyle_2.13/1.5.1/scalastyle_2.13-1.5.1-assembly.jar

The filename must be kept as published (scalastyle_2.13-<version>-assembly.jar) — the adapter's presence check is version-stamped, so a renamed JAR will not be found.

Notes for maintainers

  • Scalastyle requires Java 8+ as a runtime. The adapter uses ensureJre() to download Adoptium Temurin JDK 21 if no system Java is found.
  • The assembly JAR (~9 MB) is downloaded from Maven Central via downloadJar() to ~/.codacy/tools/scalastyle-1/.
  • Scalastyle takes directories as input, not individual file lists. The adapter passes the repository root and then filters the XML output by ctx.targetFiles.
  • XML output is written to a temp file via --xmlOutput, not to stdout. The adapter reads and parses the temp file after execution.
  • The source attribute in XML output is an FQCN like org.scalastyle.scalariform.MagicNumberChecker. The adapter extracts the last segment to derive the pattern ID.
  • Checker namespace mapping: checkers in the static FILE_LEVEL_CHECKERS set map to org.scalastyle.file.*; all others map to org.scalastyle.scalariform.*.
  • Exit code 0 = clean, 1 = findings found or error. The adapter reads the XML output regardless of exit code (0 or 1).
  • Config file detection looks for scalastyle_config.xml or scalastyle-config.xml in the repository root (underscore variant preferred).
  • When generating config from patterns, each check is emitted with level="warning" and includes default parameters from patterns.json.
  • The column attribute may be absent in Scalastyle output; it is omitted from the issue when not present.
  • fast-xml-parser is configured with ignoreAttributes: false and isArray for file/error elements to handle single-element cases.

版本与发布记录

@codacy/tools-scalastyle-1 共发布 31 个版本,首次发布于 2026/04/10;过去 12 个月发布了 31 个版本。

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

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

Scalastyle adapter — CLI-mode Scala style checker

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

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

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

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

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

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

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

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

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

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

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

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

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

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