@codacy/tools-scalastyle-1 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Codacy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # @codacy/tools-scalastyle-1
2
+
3
+ ## Table of Contents
4
+
5
+ - [Overview](#overview)
6
+ - [Updating patterns](#updating-patterns)
7
+ - [Updating the Scalastyle version](#updating-the-scalastyle-version)
8
+ - [Development](#development)
9
+ - [Notes for maintainers](#notes-for-maintainers)
10
+
11
+ ---
12
+
13
+ ## Overview
14
+
15
+ Scala style checker and static analysis tool using the [Scalastyle](http://www.scalastyle.org/) assembly JAR. Uses the CLI execution strategy -- spawns `java -cp scalastyle.jar org.scalastyle.Main` via `spawnTool()` and parses its Checkstyle-format XML output.
16
+
17
+ | Property | Value |
18
+ | ------------- | --------------------------------------------- |
19
+ | Tool ID | `ScalaStyle` |
20
+ | Codacy UUID | `21586cd3-3eaa-4454-878e-ac0211a833c2` |
21
+ | Strategy | CLI |
22
+ | Languages | Scala |
23
+ | Binary | `java -cp scalastyle.jar org.scalastyle.Main` |
24
+ | File patterns | `**/*.scala` |
25
+ | Pattern count | 74 |
26
+
27
+ 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.
28
+
29
+ ## Updating patterns
30
+
31
+ ```bash
32
+ # Re-fetch pattern metadata from the Codacy API
33
+ pnpm prefetch
34
+
35
+ # Commit the result
36
+ git add src/patterns.json
37
+ ```
38
+
39
+ 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`).
40
+
41
+ ## Updating the Scalastyle version
42
+
43
+ 1. Update `SCALASTYLE_VERSION` in `src/adapter.ts`
44
+ 2. Update `JAR_URL` to point to the new assembly JAR on Maven Central
45
+ 3. Run `pnpm prefetch` to check for new/removed rules
46
+ 4. Run `pnpm test` to verify compatibility
47
+ 5. If the major version changes, create a new adapter package (`scalastyle-2/`)
48
+
49
+ The Maven Central artifact coordinates are:
50
+
51
+ ```
52
+ com.beautiful-scala:scalastyle_2.13:{version}:assembly
53
+ ```
54
+
55
+ ## Development
56
+
57
+ ```bash
58
+ pnpm build # Build with tsup
59
+ pnpm test # Run tests (unit tests always run; integration tests require java + JAR)
60
+ ```
61
+
62
+ To install the Scalastyle JAR locally for integration testing:
63
+
64
+ ```bash
65
+ mkdir -p /tmp/codacy-scalastyle-test-tools
66
+ curl -L -o /tmp/codacy-scalastyle-test-tools/scalastyle.jar \
67
+ https://repo1.maven.org/maven2/com/beautiful-scala/scalastyle_2.13/1.5.1/scalastyle_2.13-1.5.1-assembly.jar
68
+ ```
69
+
70
+ ## Notes for maintainers
71
+
72
+ - Scalastyle requires Java 8+ as a runtime. The adapter uses `ensureJre()` to download Adoptium Temurin JDK 17 if no system Java is found.
73
+ - The assembly JAR (~9 MB) is downloaded from Maven Central via `downloadJar()` to `~/.codacy/tools/scalastyle-1/`.
74
+ - Scalastyle takes **directories** as input, not individual file lists. The adapter passes the repository root and then filters the XML output by `ctx.targetFiles`.
75
+ - XML output is written to a temp file via `--xmlOutput`, not to stdout. The adapter reads and parses the temp file after execution.
76
+ - 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.
77
+ - Checker namespace mapping: checkers in the static `FILE_LEVEL_CHECKERS` set map to `org.scalastyle.file.*`; all others map to `org.scalastyle.scalariform.*`.
78
+ - Exit code 0 = clean, 1 = findings found or error. The adapter reads the XML output regardless of exit code (0 or 1).
79
+ - Config file detection looks for `scalastyle_config.xml` or `scalastyle-config.xml` in the repository root (underscore variant preferred).
80
+ - When generating config from patterns, each check is emitted with `level="warning"` and includes default parameters from `patterns.json`.
81
+ - The `column` attribute may be absent in Scalastyle output; it is omitted from the issue when not present.
82
+ - `fast-xml-parser` is configured with `ignoreAttributes: false` and `isArray` for `file`/`error` elements to handle single-element cases.
@@ -0,0 +1,5 @@
1
+ import * as _codacy_tooling from '@codacy/tooling';
2
+
3
+ declare const _default: Readonly<_codacy_tooling.ToolAdapter>;
4
+
5
+ export { _default as default };