@codacy/tools-detekt-1 0.4.0 → 0.5.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/dist/index.js CHANGED
@@ -2414,6 +2414,18 @@ var patterns_default = [
2414
2414
  }
2415
2415
  ];
2416
2416
 
2417
+ // src/metadata.ts
2418
+ var descriptor = {
2419
+ id: "detekt",
2420
+ displayName: "detekt",
2421
+ preferredVersion: "1.23.8",
2422
+ languages: ["Kotlin"],
2423
+ filePatterns: ["**/*.kt", "**/*.kts"],
2424
+ supportedOS: ["linux", "darwin"],
2425
+ supportedArch: ["x64", "arm64"],
2426
+ supportedRunners: ["local", "container"]
2427
+ };
2428
+
2417
2429
  // src/adapter.ts
2418
2430
  var TOOL_ID = "detekt";
2419
2431
  var DETEKT_VERSION = "1.23.8";
@@ -2441,37 +2453,6 @@ var xmlParser = new import_fast_xml_parser.XMLParser({
2441
2453
  maxTotalExpansions: 1e5
2442
2454
  }
2443
2455
  });
2444
- function getLineContent(lines, lineNumber) {
2445
- return lines[lineNumber - 1] ?? "";
2446
- }
2447
- async function readFileLines(filePath) {
2448
- try {
2449
- const content = await import_promises.default.readFile(filePath, "utf-8");
2450
- return content.split("\n");
2451
- } catch {
2452
- return [];
2453
- }
2454
- }
2455
- function buildResult(startedAt, completedAt, issues, errors, filesAnalyzed) {
2456
- const durationMs = completedAt.getTime() - startedAt.getTime();
2457
- return {
2458
- metadata: {
2459
- startedAt: startedAt.toISOString(),
2460
- completedAt: completedAt.toISOString(),
2461
- durationMs
2462
- },
2463
- issues,
2464
- errors,
2465
- summary: {
2466
- toolId: TOOL_ID,
2467
- status: errors.some((e) => e.level === "error") ? "partial" : "success",
2468
- issueCount: issues.length,
2469
- errorCount: errors.length,
2470
- durationMs,
2471
- filesAnalyzed
2472
- }
2473
- };
2474
- }
2475
2456
  function extractRuleId(source) {
2476
2457
  let ruleId = source.startsWith("detekt.") ? source.slice(7) : source;
2477
2458
  const lastDot = ruleId.lastIndexOf(".");
@@ -2509,16 +2490,9 @@ async function resolveJarPath(ctx) {
2509
2490
  }
2510
2491
  var CONFIG_FILE_CANDIDATES = ["detekt.yml", "default-detekt-config.yml"];
2511
2492
  var adapter = {
2512
- id: TOOL_ID,
2513
- displayName: "detekt",
2514
- preferredVersion: DETEKT_VERSION,
2493
+ ...descriptor,
2515
2494
  compatibleVersions: ">=1.20.0",
2516
2495
  website: "https://detekt.dev/",
2517
- languages: ["Kotlin"],
2518
- filePatterns: ["**/*.kt", "**/*.kts"],
2519
- supportedOS: ["linux", "darwin"],
2520
- supportedArch: ["x64", "arm64"],
2521
- supportedRunners: ["local", "container"],
2522
2496
  prerequisites: [
2523
2497
  {
2524
2498
  name: "Java",
@@ -2667,13 +2641,7 @@ var adapter = {
2667
2641
  const issues = [];
2668
2642
  const errors = [];
2669
2643
  if (ctx.targetFiles.length === 0) {
2670
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
2671
- }
2672
- if (!(codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile) && codacyConfig.patterns.length === 0) {
2673
- ctx.logger.info("Skipping analysis: no local config and no patterns enabled", {
2674
- toolId: TOOL_ID
2675
- });
2676
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2644
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
2677
2645
  }
2678
2646
  const javaBin = await resolveJavaPath(ctx);
2679
2647
  const jarPath = await resolveJarPath(ctx);
@@ -2685,7 +2653,7 @@ var adapter = {
2685
2653
  message: `detekt JAR not found at ${import_path.default.join(ctx.toolInstallDir, JAR_NAME)}. Run install first.`,
2686
2654
  level: "error"
2687
2655
  });
2688
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2656
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2689
2657
  }
2690
2658
  const tmpDir = await import_promises.default.mkdtemp(import_path.default.join(import_os.default.tmpdir(), "detekt-"));
2691
2659
  const reportFile = import_path.default.join(tmpDir, "detekt-report.xml");
@@ -2720,7 +2688,7 @@ var adapter = {
2720
2688
  level: "error"
2721
2689
  });
2722
2690
  await cleanupTmpDir(tmpDir);
2723
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2691
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2724
2692
  }
2725
2693
  let xmlContent;
2726
2694
  try {
@@ -2736,11 +2704,11 @@ var adapter = {
2736
2704
  });
2737
2705
  }
2738
2706
  await cleanupTmpDir(tmpDir);
2739
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2707
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2740
2708
  }
2741
2709
  if (!xmlContent.trim()) {
2742
2710
  await cleanupTmpDir(tmpDir);
2743
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2711
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2744
2712
  }
2745
2713
  let files;
2746
2714
  try {
@@ -2755,7 +2723,7 @@ var adapter = {
2755
2723
  level: "error"
2756
2724
  });
2757
2725
  await cleanupTmpDir(tmpDir);
2758
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2726
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2759
2727
  }
2760
2728
  const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
2761
2729
  for (const file of files) {
@@ -2765,7 +2733,7 @@ var adapter = {
2765
2733
  if (fileErrors.length === 0) continue;
2766
2734
  const relPath = import_path.default.isAbsolute(filePath) ? import_path.default.relative(ctx.repositoryRoot, filePath) : filePath;
2767
2735
  const absolutePath = import_path.default.resolve(ctx.repositoryRoot, relPath);
2768
- const lines = await readFileLines(absolutePath);
2736
+ const lines = await (0, import_tooling.readFileLines)(absolutePath);
2769
2737
  for (const error of fileErrors) {
2770
2738
  const source = error["@_source"] ?? "";
2771
2739
  const ruleId = extractRuleId(source);
@@ -2784,7 +2752,7 @@ var adapter = {
2784
2752
  line,
2785
2753
  column,
2786
2754
  message: error["@_message"],
2787
- lineContent: getLineContent(lines, line),
2755
+ lineContent: (0, import_tooling.getLineContent)(lines, line),
2788
2756
  category: meta.category,
2789
2757
  severity: meta.severity
2790
2758
  });
@@ -2825,7 +2793,7 @@ var adapter = {
2825
2793
  errorCount: errors.length,
2826
2794
  durationMs
2827
2795
  });
2828
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2796
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
2829
2797
  }
2830
2798
  };
2831
2799
  async function cleanupTmpDir(tmpDir) {
@@ -0,0 +1,13 @@
1
+ import { AdapterDescriptor } from '@codacy/tooling';
2
+
3
+ /**
4
+ * Lightweight adapter descriptor for lazy loading.
5
+ *
6
+ * This module contains only plain-data metadata fields and has zero heavy
7
+ * imports (no patterns.json, no runtime utilities). The CLI imports this
8
+ * at startup for adapter registration without loading the full adapter module.
9
+ */
10
+
11
+ declare const descriptor: AdapterDescriptor;
12
+
13
+ export { descriptor };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/metadata.ts
21
+ var metadata_exports = {};
22
+ __export(metadata_exports, {
23
+ descriptor: () => descriptor
24
+ });
25
+ module.exports = __toCommonJS(metadata_exports);
26
+ var descriptor = {
27
+ id: "detekt",
28
+ displayName: "detekt",
29
+ preferredVersion: "1.23.8",
30
+ languages: ["Kotlin"],
31
+ filePatterns: ["**/*.kt", "**/*.kts"],
32
+ supportedOS: ["linux", "darwin"],
33
+ supportedArch: ["x64", "arm64"],
34
+ supportedRunners: ["local", "container"]
35
+ };
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ descriptor
39
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/tools-detekt-1",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "detekt adapter — CLI-mode Kotlin static analyzer",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  ],
10
10
  "dependencies": {
11
11
  "fast-xml-parser": "^5.5.6",
12
- "@codacy/tooling": "0.4.0"
12
+ "@codacy/tooling": "0.5.0"
13
13
  },
14
14
  "license": "MIT",
15
15
  "author": "Codacy <support@codacy.com> (https://www.codacy.com)",
@@ -22,8 +22,18 @@
22
22
  "engines": {
23
23
  "node": ">=20.0.0"
24
24
  },
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
29
+ },
30
+ "./metadata": {
31
+ "types": "./dist/metadata.d.ts",
32
+ "default": "./dist/metadata.js"
33
+ }
34
+ },
25
35
  "scripts": {
26
- "build": "tsup src/index.ts --format cjs --dts --clean",
36
+ "build": "tsup src/index.ts src/metadata.ts --format cjs --dts --clean",
27
37
  "test": "vitest run",
28
38
  "lint": "eslint src/",
29
39
  "clean": "rm -rf dist",