@codacy/tools-reek-6 0.2.3 → 0.2.5

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
@@ -521,6 +521,18 @@ var patterns_default = [
521
521
  }
522
522
  ];
523
523
 
524
+ // src/metadata.ts
525
+ var descriptor = {
526
+ id: "Reek",
527
+ displayName: "Reek",
528
+ preferredVersion: "6.5.0",
529
+ languages: ["Ruby"],
530
+ filePatterns: ["**/*.rb"],
531
+ supportedOS: ["linux", "darwin", "win32"],
532
+ supportedArch: ["x64", "arm64"],
533
+ supportedRunners: ["local", "container"]
534
+ };
535
+
524
536
  // src/adapter.ts
525
537
  var TOOL_ID = "Reek";
526
538
  var ADAPTER_ID = "reek-6";
@@ -539,37 +551,6 @@ var PATTERN_META = new Map(
539
551
  function ruleMetadata(smellType) {
540
552
  return PATTERN_META.get(smellType) ?? { category: "CodeStyle", severity: "Info" };
541
553
  }
542
- function getLineContent(lines, lineNumber) {
543
- return lines[lineNumber - 1] ?? "";
544
- }
545
- async function readFileLines(filePath) {
546
- try {
547
- const content = await import_promises.default.readFile(filePath, "utf-8");
548
- return content.split("\n");
549
- } catch {
550
- return [];
551
- }
552
- }
553
- function buildResult(startedAt, completedAt, issues, errors, filesAnalyzed) {
554
- const durationMs = completedAt.getTime() - startedAt.getTime();
555
- return {
556
- metadata: {
557
- startedAt: startedAt.toISOString(),
558
- completedAt: completedAt.toISOString(),
559
- durationMs
560
- },
561
- issues,
562
- errors,
563
- summary: {
564
- toolId: TOOL_ID,
565
- status: errors.some((e) => e.level === "error") ? "partial" : "success",
566
- issueCount: issues.length,
567
- errorCount: errors.length,
568
- durationMs,
569
- filesAnalyzed
570
- }
571
- };
572
- }
573
554
  async function resolveToolInvocation(ctx) {
574
555
  const gemPaths = (0, import_tooling.getGemPaths)(ctx.globalDir, ADAPTER_ID);
575
556
  const scriptPath = (0, import_tooling.resolveGemBinary)(gemPaths, "reek");
@@ -593,16 +574,9 @@ async function resolveToolInvocation(ctx) {
593
574
  return { binary: "reek", prefixArgs: [], rubyPath: rubyInfo?.path };
594
575
  }
595
576
  var adapter = {
596
- id: TOOL_ID,
597
- displayName: "Reek",
598
- preferredVersion: REEK_VERSION,
577
+ ...descriptor,
599
578
  compatibleVersions: ">=6.0.0",
600
579
  website: "https://github.com/troessner/reek",
601
- languages: ["Ruby"],
602
- filePatterns: ["**/*.rb"],
603
- supportedOS: ["linux", "darwin", "win32"],
604
- supportedArch: ["x64", "arm64"],
605
- supportedRunners: ["local", "container"],
606
580
  prerequisites: [
607
581
  {
608
582
  name: "Ruby",
@@ -767,7 +741,7 @@ var adapter = {
767
741
  const issues = [];
768
742
  const errors = [];
769
743
  if (ctx.targetFiles.length === 0) {
770
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
744
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
771
745
  }
772
746
  const invocation = await resolveToolInvocation(ctx);
773
747
  const absoluteFiles = ctx.targetFiles.map((f) => import_path.default.resolve(ctx.repositoryRoot, f));
@@ -779,7 +753,7 @@ var adapter = {
779
753
  ctx.logger.info("Skipping analysis: no local config and no patterns enabled", {
780
754
  toolId: TOOL_ID
781
755
  });
782
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
756
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
783
757
  }
784
758
  args.push(...absoluteFiles);
785
759
  try {
@@ -798,10 +772,10 @@ var adapter = {
798
772
  message: `Reek exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
799
773
  level: "error"
800
774
  });
801
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
775
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
802
776
  }
803
777
  if (!stdout.trim()) {
804
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
778
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
805
779
  }
806
780
  let smells;
807
781
  try {
@@ -814,7 +788,7 @@ var adapter = {
814
788
  message: `Failed to parse Reek JSON output: ${err instanceof Error ? err.message : String(err)}`,
815
789
  level: "error"
816
790
  });
817
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
791
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
818
792
  }
819
793
  if (!Array.isArray(smells)) {
820
794
  errors.push({
@@ -824,7 +798,7 @@ var adapter = {
824
798
  message: "Reek output is not a JSON array",
825
799
  level: "error"
826
800
  });
827
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
801
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
828
802
  }
829
803
  const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
830
804
  const fileLineCache = /* @__PURE__ */ new Map();
@@ -840,7 +814,7 @@ var adapter = {
840
814
  const meta = ruleMetadata(patternId);
841
815
  const absPath = import_path.default.resolve(ctx.repositoryRoot, filePath);
842
816
  if (!fileLineCache.has(absPath)) {
843
- fileLineCache.set(absPath, await readFileLines(absPath));
817
+ fileLineCache.set(absPath, await (0, import_tooling.readFileLines)(absPath));
844
818
  }
845
819
  const fileLines = fileLineCache.get(absPath);
846
820
  issues.push({
@@ -849,7 +823,7 @@ var adapter = {
849
823
  toolId: TOOL_ID,
850
824
  line,
851
825
  message: smell.message,
852
- lineContent: getLineContent(fileLines, line),
826
+ lineContent: (0, import_tooling.getLineContent)(fileLines, line),
853
827
  category: meta.category,
854
828
  severity: meta.severity
855
829
  });
@@ -880,7 +854,7 @@ var adapter = {
880
854
  errorCount: errors.length,
881
855
  durationMs
882
856
  });
883
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
857
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
884
858
  }
885
859
  };
886
860
 
@@ -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: "Reek",
28
+ displayName: "Reek",
29
+ preferredVersion: "6.5.0",
30
+ languages: ["Ruby"],
31
+ filePatterns: ["**/*.rb"],
32
+ supportedOS: ["linux", "darwin", "win32"],
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-reek-6",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Reek adapter — CLI-mode Ruby code smell detector",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "dist"
9
9
  ],
10
10
  "dependencies": {
11
- "@codacy/tooling": "0.3.0"
11
+ "@codacy/tooling": "0.5.0"
12
12
  },
13
13
  "license": "MIT",
14
14
  "author": "Codacy <support@codacy.com> (https://www.codacy.com)",
@@ -21,8 +21,18 @@
21
21
  "engines": {
22
22
  "node": ">=20.0.0"
23
23
  },
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/index.js"
28
+ },
29
+ "./metadata": {
30
+ "types": "./dist/metadata.d.ts",
31
+ "default": "./dist/metadata.js"
32
+ }
33
+ },
24
34
  "scripts": {
25
- "build": "tsup src/index.ts --format cjs --dts --clean",
35
+ "build": "tsup src/index.ts src/metadata.ts --format cjs --dts --clean",
26
36
  "test": "vitest run",
27
37
  "lint": "eslint src/",
28
38
  "clean": "rm -rf dist",