@codacy/tools-revive-1 0.3.0 → 0.3.2

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
@@ -890,24 +890,25 @@ var patterns_default = [
890
890
  }
891
891
  ];
892
892
 
893
+ // src/metadata.ts
894
+ var descriptor = {
895
+ id: "Revive",
896
+ displayName: "Revive",
897
+ preferredVersion: "1.12.0",
898
+ languages: ["Go"],
899
+ filePatterns: ["**/*.go"],
900
+ supportedOS: ["linux", "darwin"],
901
+ supportedArch: ["x64", "arm64"],
902
+ supportedRunners: ["local", "container"]
903
+ };
904
+
893
905
  // src/adapter.ts
894
906
  var TOOL_ID = "Revive";
895
- var VALID_CATEGORIES = /* @__PURE__ */ new Set([
896
- "Security",
897
- "ErrorProne",
898
- "CodeStyle",
899
- "Compatibility",
900
- "Performance",
901
- "UnusedCode",
902
- "Complexity",
903
- "BestPractice",
904
- "Documentation"
905
- ]);
906
907
  var PATTERN_META = new Map(
907
908
  patterns_default.map((p) => [
908
909
  p.id,
909
910
  {
910
- category: VALID_CATEGORIES.has(p.category) ? p.category : "BestPractice",
911
+ category: import_tooling.ISSUE_CATEGORIES.has(p.category) ? p.category : "BestPractice",
911
912
  severity: p.severityLevel ?? "Info"
912
913
  }
913
914
  ])
@@ -916,37 +917,6 @@ function ruleMetadata(ruleName) {
916
917
  const patternId = `${TOOL_ID}_${ruleName}`;
917
918
  return PATTERN_META.get(patternId) ?? { category: "BestPractice", severity: "Info" };
918
919
  }
919
- function getLineContent(lines, lineNumber) {
920
- return lines[lineNumber - 1] ?? "";
921
- }
922
- async function readFileLines(filePath) {
923
- try {
924
- const content = await import_promises.default.readFile(filePath, "utf-8");
925
- return content.split("\n");
926
- } catch {
927
- return [];
928
- }
929
- }
930
- function buildResult(startedAt, completedAt, issues, errors, filesAnalyzed) {
931
- const durationMs = completedAt.getTime() - startedAt.getTime();
932
- return {
933
- metadata: {
934
- startedAt: startedAt.toISOString(),
935
- completedAt: completedAt.toISOString(),
936
- durationMs
937
- },
938
- issues,
939
- errors,
940
- summary: {
941
- toolId: TOOL_ID,
942
- status: errors.some((e) => e.level === "error") ? "partial" : "success",
943
- issueCount: issues.length,
944
- errorCount: errors.length,
945
- durationMs,
946
- filesAnalyzed
947
- }
948
- };
949
- }
950
920
  var BINARY = "revive";
951
921
  var PLATFORM_MAP = {
952
922
  "darwin-arm64": "darwin_arm64",
@@ -994,16 +964,9 @@ function generateReviveToml(patterns) {
994
964
  return lines.join("\n");
995
965
  }
996
966
  var adapter = {
997
- id: TOOL_ID,
998
- displayName: "Revive",
999
- preferredVersion: "1.12.0",
967
+ ...descriptor,
1000
968
  compatibleVersions: ">=1.0.0",
1001
969
  website: "https://github.com/mgechev/revive",
1002
- languages: ["Go"],
1003
- filePatterns: ["**/*.go"],
1004
- supportedOS: ["linux", "darwin"],
1005
- supportedArch: ["x64", "arm64"],
1006
- supportedRunners: ["local", "container"],
1007
970
  prerequisites: [],
1008
971
  /**
1009
972
  * Checks whether the `revive` binary is present and runnable.
@@ -1162,7 +1125,7 @@ var adapter = {
1162
1125
  const issues = [];
1163
1126
  const errors = [];
1164
1127
  if (ctx.targetFiles.length === 0) {
1165
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
1128
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
1166
1129
  }
1167
1130
  let configPath;
1168
1131
  if (codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile) {
@@ -1177,7 +1140,7 @@ var adapter = {
1177
1140
  ctx.logger.info("Skipping analysis: no local config and no patterns enabled", {
1178
1141
  toolId: TOOL_ID
1179
1142
  });
1180
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
1143
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
1181
1144
  }
1182
1145
  const binary = await resolveBinaryPath(ctx);
1183
1146
  const goInfo = await (0, import_tooling.findGo)(">=1.21", ctx.logger);
@@ -1211,10 +1174,10 @@ var adapter = {
1211
1174
  message: `revive exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
1212
1175
  level: "error"
1213
1176
  });
1214
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
1177
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
1215
1178
  }
1216
1179
  if (!stdout.trim()) {
1217
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
1180
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
1218
1181
  }
1219
1182
  let findings;
1220
1183
  try {
@@ -1227,7 +1190,7 @@ var adapter = {
1227
1190
  message: `Failed to parse revive JSON output: ${err instanceof Error ? err.message : String(err)}`,
1228
1191
  level: "error"
1229
1192
  });
1230
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
1193
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
1231
1194
  }
1232
1195
  const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
1233
1196
  const findingsByFile = /* @__PURE__ */ new Map();
@@ -1239,7 +1202,7 @@ var adapter = {
1239
1202
  }
1240
1203
  for (const [filePath, fileFindings] of findingsByFile) {
1241
1204
  const absoluteFilePath = import_path.default.isAbsolute(filePath) ? filePath : import_path.default.resolve(ctx.repositoryRoot, filePath);
1242
- const lines = await readFileLines(absoluteFilePath);
1205
+ const lines = await (0, import_tooling.readFileLines)(absoluteFilePath);
1243
1206
  const relPath = import_path.default.isAbsolute(filePath) ? import_path.default.relative(ctx.repositoryRoot, filePath) : filePath;
1244
1207
  for (const finding of fileFindings) {
1245
1208
  const patternId = `${TOOL_ID}_${finding.RuleName}`;
@@ -1260,7 +1223,7 @@ var adapter = {
1260
1223
  endLine,
1261
1224
  endColumn,
1262
1225
  message: finding.Failure,
1263
- lineContent: getLineContent(lines, line),
1226
+ lineContent: (0, import_tooling.getLineContent)(lines, line),
1264
1227
  multilineContent: (0, import_tooling.getMultilineContent)(lines, line, endLine),
1265
1228
  category: meta.category,
1266
1229
  severity: meta.severity
@@ -1292,7 +1255,7 @@ var adapter = {
1292
1255
  errorCount: errors.length,
1293
1256
  durationMs
1294
1257
  });
1295
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
1258
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
1296
1259
  }
1297
1260
  };
1298
1261
 
@@ -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: "Revive",
28
+ displayName: "Revive",
29
+ preferredVersion: "1.12.0",
30
+ languages: ["Go"],
31
+ filePatterns: ["**/*.go"],
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-revive-1",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Revive adapter — CLI-mode Go linter",
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",