@codacy/tools-revive-1 0.3.1 → 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,6 +890,18 @@ 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
907
  var PATTERN_META = new Map(
@@ -905,37 +917,6 @@ function ruleMetadata(ruleName) {
905
917
  const patternId = `${TOOL_ID}_${ruleName}`;
906
918
  return PATTERN_META.get(patternId) ?? { category: "BestPractice", severity: "Info" };
907
919
  }
908
- function getLineContent(lines, lineNumber) {
909
- return lines[lineNumber - 1] ?? "";
910
- }
911
- async function readFileLines(filePath) {
912
- try {
913
- const content = await import_promises.default.readFile(filePath, "utf-8");
914
- return content.split("\n");
915
- } catch {
916
- return [];
917
- }
918
- }
919
- function buildResult(startedAt, completedAt, issues, errors, filesAnalyzed) {
920
- const durationMs = completedAt.getTime() - startedAt.getTime();
921
- return {
922
- metadata: {
923
- startedAt: startedAt.toISOString(),
924
- completedAt: completedAt.toISOString(),
925
- durationMs
926
- },
927
- issues,
928
- errors,
929
- summary: {
930
- toolId: TOOL_ID,
931
- status: errors.some((e) => e.level === "error") ? "partial" : "success",
932
- issueCount: issues.length,
933
- errorCount: errors.length,
934
- durationMs,
935
- filesAnalyzed
936
- }
937
- };
938
- }
939
920
  var BINARY = "revive";
940
921
  var PLATFORM_MAP = {
941
922
  "darwin-arm64": "darwin_arm64",
@@ -983,16 +964,9 @@ function generateReviveToml(patterns) {
983
964
  return lines.join("\n");
984
965
  }
985
966
  var adapter = {
986
- id: TOOL_ID,
987
- displayName: "Revive",
988
- preferredVersion: "1.12.0",
967
+ ...descriptor,
989
968
  compatibleVersions: ">=1.0.0",
990
969
  website: "https://github.com/mgechev/revive",
991
- languages: ["Go"],
992
- filePatterns: ["**/*.go"],
993
- supportedOS: ["linux", "darwin"],
994
- supportedArch: ["x64", "arm64"],
995
- supportedRunners: ["local", "container"],
996
970
  prerequisites: [],
997
971
  /**
998
972
  * Checks whether the `revive` binary is present and runnable.
@@ -1151,7 +1125,7 @@ var adapter = {
1151
1125
  const issues = [];
1152
1126
  const errors = [];
1153
1127
  if (ctx.targetFiles.length === 0) {
1154
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
1128
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
1155
1129
  }
1156
1130
  let configPath;
1157
1131
  if (codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile) {
@@ -1166,7 +1140,7 @@ var adapter = {
1166
1140
  ctx.logger.info("Skipping analysis: no local config and no patterns enabled", {
1167
1141
  toolId: TOOL_ID
1168
1142
  });
1169
- 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);
1170
1144
  }
1171
1145
  const binary = await resolveBinaryPath(ctx);
1172
1146
  const goInfo = await (0, import_tooling.findGo)(">=1.21", ctx.logger);
@@ -1200,10 +1174,10 @@ var adapter = {
1200
1174
  message: `revive exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
1201
1175
  level: "error"
1202
1176
  });
1203
- 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);
1204
1178
  }
1205
1179
  if (!stdout.trim()) {
1206
- 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);
1207
1181
  }
1208
1182
  let findings;
1209
1183
  try {
@@ -1216,7 +1190,7 @@ var adapter = {
1216
1190
  message: `Failed to parse revive JSON output: ${err instanceof Error ? err.message : String(err)}`,
1217
1191
  level: "error"
1218
1192
  });
1219
- 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);
1220
1194
  }
1221
1195
  const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
1222
1196
  const findingsByFile = /* @__PURE__ */ new Map();
@@ -1228,7 +1202,7 @@ var adapter = {
1228
1202
  }
1229
1203
  for (const [filePath, fileFindings] of findingsByFile) {
1230
1204
  const absoluteFilePath = import_path.default.isAbsolute(filePath) ? filePath : import_path.default.resolve(ctx.repositoryRoot, filePath);
1231
- const lines = await readFileLines(absoluteFilePath);
1205
+ const lines = await (0, import_tooling.readFileLines)(absoluteFilePath);
1232
1206
  const relPath = import_path.default.isAbsolute(filePath) ? import_path.default.relative(ctx.repositoryRoot, filePath) : filePath;
1233
1207
  for (const finding of fileFindings) {
1234
1208
  const patternId = `${TOOL_ID}_${finding.RuleName}`;
@@ -1249,7 +1223,7 @@ var adapter = {
1249
1223
  endLine,
1250
1224
  endColumn,
1251
1225
  message: finding.Failure,
1252
- lineContent: getLineContent(lines, line),
1226
+ lineContent: (0, import_tooling.getLineContent)(lines, line),
1253
1227
  multilineContent: (0, import_tooling.getMultilineContent)(lines, line, endLine),
1254
1228
  category: meta.category,
1255
1229
  severity: meta.severity
@@ -1281,7 +1255,7 @@ var adapter = {
1281
1255
  errorCount: errors.length,
1282
1256
  durationMs
1283
1257
  });
1284
- 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);
1285
1259
  }
1286
1260
  };
1287
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.1",
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.4.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",