@codacy/tools-shellcheck-0 0.3.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 +20 -51
- package/dist/metadata.d.ts +13 -0
- package/dist/metadata.js +39 -0
- package/package.json +13 -3
package/dist/index.js
CHANGED
|
@@ -3972,6 +3972,18 @@ var patterns_default = [
|
|
|
3972
3972
|
}
|
|
3973
3973
|
];
|
|
3974
3974
|
|
|
3975
|
+
// src/metadata.ts
|
|
3976
|
+
var descriptor = {
|
|
3977
|
+
id: "shellcheck",
|
|
3978
|
+
displayName: "ShellCheck",
|
|
3979
|
+
preferredVersion: "0.9.0",
|
|
3980
|
+
languages: ["Shell"],
|
|
3981
|
+
filePatterns: ["**/*.sh", "**/*.bash", "**/*.ksh", "**/*.dash"],
|
|
3982
|
+
supportedOS: ["linux", "darwin", "win32"],
|
|
3983
|
+
supportedArch: ["x64", "arm64"],
|
|
3984
|
+
supportedRunners: ["local", "container"]
|
|
3985
|
+
};
|
|
3986
|
+
|
|
3975
3987
|
// src/adapter.ts
|
|
3976
3988
|
var TOOL_ID = "shellcheck";
|
|
3977
3989
|
var PATTERN_META = new Map(
|
|
@@ -3987,37 +3999,6 @@ function ruleMetadata(code) {
|
|
|
3987
3999
|
const patternId = `${TOOL_ID}_SC${code}`;
|
|
3988
4000
|
return PATTERN_META.get(patternId) ?? { category: "ErrorProne", severity: "Info" };
|
|
3989
4001
|
}
|
|
3990
|
-
function getLineContent(lines, lineNumber) {
|
|
3991
|
-
return lines[lineNumber - 1] ?? "";
|
|
3992
|
-
}
|
|
3993
|
-
async function readFileLines(filePath) {
|
|
3994
|
-
try {
|
|
3995
|
-
const content = await import_promises.default.readFile(filePath, "utf-8");
|
|
3996
|
-
return content.split("\n");
|
|
3997
|
-
} catch {
|
|
3998
|
-
return [];
|
|
3999
|
-
}
|
|
4000
|
-
}
|
|
4001
|
-
function buildResult(startedAt, completedAt, issues, errors, filesAnalyzed) {
|
|
4002
|
-
const durationMs = completedAt.getTime() - startedAt.getTime();
|
|
4003
|
-
return {
|
|
4004
|
-
metadata: {
|
|
4005
|
-
startedAt: startedAt.toISOString(),
|
|
4006
|
-
completedAt: completedAt.toISOString(),
|
|
4007
|
-
durationMs
|
|
4008
|
-
},
|
|
4009
|
-
issues,
|
|
4010
|
-
errors,
|
|
4011
|
-
summary: {
|
|
4012
|
-
toolId: TOOL_ID,
|
|
4013
|
-
status: errors.some((e) => e.level === "error") ? "partial" : "success",
|
|
4014
|
-
issueCount: issues.length,
|
|
4015
|
-
errorCount: errors.length,
|
|
4016
|
-
durationMs,
|
|
4017
|
-
filesAnalyzed
|
|
4018
|
-
}
|
|
4019
|
-
};
|
|
4020
|
-
}
|
|
4021
4002
|
var BINARY = "shellcheck";
|
|
4022
4003
|
var PLATFORM_MAP = {
|
|
4023
4004
|
"darwin-arm64": { suffix: "darwin.x86_64", format: "tar.xz" },
|
|
@@ -4044,16 +4025,9 @@ async function resolveBinaryPath(ctx) {
|
|
|
4044
4025
|
return BINARY;
|
|
4045
4026
|
}
|
|
4046
4027
|
var adapter = {
|
|
4047
|
-
|
|
4048
|
-
displayName: "ShellCheck",
|
|
4049
|
-
preferredVersion: "0.9.0",
|
|
4028
|
+
...descriptor,
|
|
4050
4029
|
compatibleVersions: ">=0.7.0",
|
|
4051
4030
|
website: "https://www.shellcheck.net",
|
|
4052
|
-
languages: ["Shell"],
|
|
4053
|
-
filePatterns: ["**/*.sh", "**/*.bash", "**/*.ksh", "**/*.dash"],
|
|
4054
|
-
supportedOS: ["linux", "darwin", "win32"],
|
|
4055
|
-
supportedArch: ["x64", "arm64"],
|
|
4056
|
-
supportedRunners: ["local", "container"],
|
|
4057
4031
|
prerequisites: [],
|
|
4058
4032
|
/**
|
|
4059
4033
|
* Checks whether the `shellcheck` binary is present and runnable.
|
|
@@ -4197,18 +4171,13 @@ var adapter = {
|
|
|
4197
4171
|
const issues = [];
|
|
4198
4172
|
const errors = [];
|
|
4199
4173
|
if (ctx.targetFiles.length === 0) {
|
|
4200
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
|
|
4174
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
|
|
4201
4175
|
}
|
|
4202
4176
|
const binary = await resolveBinaryPath(ctx);
|
|
4203
4177
|
const absoluteFiles = ctx.targetFiles.map((f) => import_path.default.resolve(ctx.repositoryRoot, f));
|
|
4204
4178
|
const args = ["--format", "json"];
|
|
4205
4179
|
if (codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile) {
|
|
4206
4180
|
args.push("--rcfile", codacyConfig.localConfigurationFile);
|
|
4207
|
-
} else if (codacyConfig.patterns.length === 0) {
|
|
4208
|
-
ctx.logger.info("Skipping analysis: no local config and no patterns enabled", {
|
|
4209
|
-
toolId: TOOL_ID
|
|
4210
|
-
});
|
|
4211
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
4212
4181
|
}
|
|
4213
4182
|
args.push(...absoluteFiles);
|
|
4214
4183
|
try {
|
|
@@ -4224,10 +4193,10 @@ var adapter = {
|
|
|
4224
4193
|
message: `shellcheck exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
|
|
4225
4194
|
level: "error"
|
|
4226
4195
|
});
|
|
4227
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
4196
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
4228
4197
|
}
|
|
4229
4198
|
if (!stdout.trim()) {
|
|
4230
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
4199
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
4231
4200
|
}
|
|
4232
4201
|
let findings;
|
|
4233
4202
|
try {
|
|
@@ -4240,7 +4209,7 @@ var adapter = {
|
|
|
4240
4209
|
message: `Failed to parse shellcheck JSON output: ${err instanceof Error ? err.message : String(err)}`,
|
|
4241
4210
|
level: "error"
|
|
4242
4211
|
});
|
|
4243
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
4212
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
4244
4213
|
}
|
|
4245
4214
|
const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
|
|
4246
4215
|
const findingsByFile = /* @__PURE__ */ new Map();
|
|
@@ -4250,7 +4219,7 @@ var adapter = {
|
|
|
4250
4219
|
findingsByFile.set(finding.file, list);
|
|
4251
4220
|
}
|
|
4252
4221
|
for (const [absoluteFilePath, fileFindings] of findingsByFile) {
|
|
4253
|
-
const lines = await readFileLines(absoluteFilePath);
|
|
4222
|
+
const lines = await (0, import_tooling.readFileLines)(absoluteFilePath);
|
|
4254
4223
|
const relPath = import_path.default.relative(ctx.repositoryRoot, absoluteFilePath);
|
|
4255
4224
|
for (const finding of fileFindings) {
|
|
4256
4225
|
const patternId = `${TOOL_ID}_SC${finding.code}`;
|
|
@@ -4267,7 +4236,7 @@ var adapter = {
|
|
|
4267
4236
|
endLine: finding.endLine,
|
|
4268
4237
|
endColumn: finding.endColumn,
|
|
4269
4238
|
message: finding.message,
|
|
4270
|
-
lineContent: getLineContent(lines, finding.line),
|
|
4239
|
+
lineContent: (0, import_tooling.getLineContent)(lines, finding.line),
|
|
4271
4240
|
multilineContent: (0, import_tooling.getMultilineContent)(lines, finding.line, finding.endLine),
|
|
4272
4241
|
category: meta.category,
|
|
4273
4242
|
severity: meta.severity
|
|
@@ -4299,7 +4268,7 @@ var adapter = {
|
|
|
4299
4268
|
errorCount: errors.length,
|
|
4300
4269
|
durationMs
|
|
4301
4270
|
});
|
|
4302
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
4271
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
4303
4272
|
}
|
|
4304
4273
|
};
|
|
4305
4274
|
|
|
@@ -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 };
|
package/dist/metadata.js
ADDED
|
@@ -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: "shellcheck",
|
|
28
|
+
displayName: "ShellCheck",
|
|
29
|
+
preferredVersion: "0.9.0",
|
|
30
|
+
languages: ["Shell"],
|
|
31
|
+
filePatterns: ["**/*.sh", "**/*.bash", "**/*.ksh", "**/*.dash"],
|
|
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-shellcheck-0",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "ShellCheck adapter — CLI-mode shell script 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.
|
|
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",
|