@codacy/analysis-runner 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/dist/index.js +26 -2
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -95,11 +95,25 @@ async function readCodacyConfig(repositoryRoot) {
95
95
  const configPath = import_path.default.join(repositoryRoot, CODACY_DIR, CONFIG_FILE);
96
96
  try {
97
97
  const raw = await import_promises.default.readFile(configPath, "utf-8");
98
- return JSON.parse(raw);
98
+ const config = JSON.parse(raw);
99
+ coerceParameterValues(config);
100
+ return config;
99
101
  } catch {
100
102
  return null;
101
103
  }
102
104
  }
105
+ function coerceParameterValues(config) {
106
+ for (const tool of config.tools) {
107
+ for (const pattern of tool.patterns) {
108
+ if (!pattern.parameters) continue;
109
+ for (const [key, value] of Object.entries(pattern.parameters)) {
110
+ if (typeof value !== "string") {
111
+ pattern.parameters[key] = String(value);
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
103
117
  async function writeCodacyConfig(repositoryRoot, config) {
104
118
  const codacyDir = import_path.default.join(repositoryRoot, CODACY_DIR);
105
119
  await import_promises.default.mkdir(codacyDir, { recursive: true });
@@ -4961,9 +4975,19 @@ async function initContainerConfig(repositoryRoot, adapters2) {
4961
4975
  for (const p of entry["patterns"]) {
4962
4976
  if (typeof p === "object" && p !== null && typeof p["patternId"] === "string") {
4963
4977
  const pe = p;
4978
+ const rawParams = pe["parameters"];
4979
+ let params;
4980
+ if (rawParams && typeof rawParams === "object" && !Array.isArray(rawParams)) {
4981
+ params = Object.fromEntries(
4982
+ Object.entries(rawParams).map(([k, v]) => [
4983
+ k,
4984
+ String(v)
4985
+ ])
4986
+ );
4987
+ }
4964
4988
  patterns.push({
4965
4989
  patternId: pe["patternId"],
4966
- ...pe["parameters"] && typeof pe["parameters"] === "object" ? { parameters: pe["parameters"] } : {}
4990
+ ...params ? { parameters: params } : {}
4967
4991
  });
4968
4992
  }
4969
4993
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/analysis-runner",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Core orchestration engine for Codacy analysis",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,11 +12,11 @@
12
12
  "cli-table3": "^0.6",
13
13
  "minimatch": "10.2.4",
14
14
  "yaml": "^2.6.0",
15
- "@codacy/tooling": "0.2.0"
15
+ "@codacy/tooling": "0.2.2"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@codacy/openapi-typescript-codegen": "0.0.9",
19
- "@codacy/tools-dummy-1": "0.2.0"
19
+ "@codacy/tools-dummy-1": "0.2.2"
20
20
  },
21
21
  "license": "MIT",
22
22
  "author": "Codacy <support@codacy.com> (https://www.codacy.com)",