@codacy/tools-detekt-1 0.1.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,70 @@
1
+ # @codacy/tools-detekt-1
2
+
3
+ ## Table of Contents
4
+ - [Overview](#overview)
5
+ - [Updating patterns](#updating-patterns)
6
+ - [Updating the detekt version](#updating-the-detekt-version)
7
+ - [Development](#development)
8
+ - [Notes for maintainers](#notes-for-maintainers)
9
+
10
+ ---
11
+
12
+ ## Overview
13
+
14
+ Kotlin static analyzer using the [detekt](https://detekt.dev/) CLI JAR. Uses the CLI execution strategy -- spawns `java -jar detekt-cli-all.jar` via `spawnTool()` and parses its Checkstyle XML output.
15
+
16
+ | Property | Value |
17
+ |----------|-------|
18
+ | Tool ID | `detekt` |
19
+ | Codacy UUID | `cb36c32d-fc0d-4b4c-8f21-66e536ef4513` |
20
+ | Strategy | CLI |
21
+ | Languages | Kotlin |
22
+ | Binary | `detekt-cli-1.23.8-all.jar` (downloaded from GitHub) |
23
+ | File patterns | `**/*.kt`, `**/*.kts` |
24
+
25
+ ## Updating patterns
26
+
27
+ ```bash
28
+ # Re-fetch pattern metadata from the Codacy API
29
+ pnpm prefetch
30
+
31
+ # Commit the result
32
+ git add src/patterns.json
33
+ ```
34
+
35
+ Pattern IDs are bare rule names (no prefix): `LongMethod`, `MagicNumber`, `ComplexCondition`, etc.
36
+
37
+ ## Updating the detekt version
38
+
39
+ 1. Update `DETEKT_VERSION` and `JAR_NAME` in `src/adapter.ts`
40
+ 2. Update `JAR_URL` to point to the new release
41
+ 3. Run `pnpm prefetch` to check for new/removed rules
42
+ 4. Run `pnpm test` to verify compatibility
43
+ 5. If the major version changes, create a new adapter package (`detekt-2/`)
44
+
45
+ ## Development
46
+
47
+ ```bash
48
+ pnpm build # Build with tsup
49
+ pnpm test # Run tests (requires java in PATH + detekt JAR)
50
+ ```
51
+
52
+ To install detekt locally for testing:
53
+ ```bash
54
+ # Download the all-in-one JAR
55
+ curl -L -o /tmp/codacy-detekt-test-tools/detekt-cli-1.23.8-all.jar \
56
+ https://github.com/detekt/detekt/releases/download/v1.23.8/detekt-cli-1.23.8-all.jar
57
+ ```
58
+
59
+ ## Notes for maintainers
60
+
61
+ - detekt requires Java 8+ as a runtime. The adapter uses `ensureJre()` to download Adoptium Temurin JDK 17 if no system Java is found.
62
+ - The detekt CLI JAR is an all-in-one fat JAR downloaded from GitHub releases to `ctx.toolInstallDir`.
63
+ - Output format is Checkstyle 4.3 XML written to a temp file via `--report xml:<path>`.
64
+ - `--base-path <repoRoot>` ensures file paths in the XML are relative to the repository root.
65
+ - `--parallel` enables multi-threaded analysis for performance.
66
+ - The `source` attribute in XML has format `detekt.RuleName` or `detekt.ruleset.RuleName`. The adapter strips the `detekt.` prefix and any ruleset prefix to get just the rule name.
67
+ - Pattern IDs in `patterns.json` have no prefix -- they are bare rule names (e.g. `LongMethod`, not `detekt_LongMethod`).
68
+ - Exit codes: 0 = no findings, 1 = findings found (build failure threshold), 2 = findings found, 3 = invalid config.
69
+ - Config file detection supports `detekt.yml` and `default-detekt-config.yml`. When a local config is found, it is passed via `--config <path>`.
70
+ - Pattern filtering is post-hoc: detekt runs with all default rules, then output is filtered by the enabled patterns set.
@@ -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 };