@docker-doctor/cli 0.6.1 → 0.7.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.
@@ -34,7 +34,7 @@ let yaml = require("yaml");
34
34
  let node_url = require("node:url");
35
35
 
36
36
  //#region package.json
37
- var version = "0.6.1";
37
+ var version = "0.7.0";
38
38
 
39
39
  //#endregion
40
40
  //#region ../core/src/project-info/ignore.ts
@@ -1901,11 +1901,15 @@ const getScoreBucket = (score) => {
1901
1901
  for (const bucket of SCORE_BUCKETS) if (score >= bucket.min) return bucket;
1902
1902
  return SCORE_BUCKETS.at(-1);
1903
1903
  };
1904
- const calculateScore = (diagnostics) => {
1905
- let penalty = 0;
1906
- for (const diag of diagnostics) if (diag.severity === "error") penalty += 10;
1907
- else if (diag.severity === "warning") penalty += 4;
1908
- else if (diag.severity === "info") penalty += 1;
1904
+ const SEVERITY_PENALTY = {
1905
+ error: 10,
1906
+ info: 1,
1907
+ warning: 4
1908
+ };
1909
+ const calculateScore = (diagnostics, analyzedFileCount = 1) => {
1910
+ let totalPenalty = 0;
1911
+ for (const diag of diagnostics) totalPenalty += SEVERITY_PENALTY[diag.severity];
1912
+ const penalty = totalPenalty / Math.max(1, analyzedFileCount);
1909
1913
  const score = Math.round(100 * Math.exp(-penalty / 70));
1910
1914
  const bucket = getScoreBucket(score);
1911
1915
  return {
@@ -1916,7 +1920,7 @@ const calculateScore = (diagnostics) => {
1916
1920
 
1917
1921
  //#endregion
1918
1922
  //#region ../core/src/report.ts
1919
- const REPORT_SCHEMA_VERSION = 4;
1923
+ const REPORT_SCHEMA_VERSION = 5;
1920
1924
  const resolveCategory = (diagnostic) => {
1921
1925
  const category = diagnostic.category ?? findRule(diagnostic.rule)?.category;
1922
1926
  if (!category) throw new Error(`Diagnostic for unknown rule "${diagnostic.rule}" has no category`);
@@ -1939,7 +1943,7 @@ const toJsonReport = (diagnostics, score, label, project, failures = []) => ({
1939
1943
  })),
1940
1944
  label,
1941
1945
  project,
1942
- schemaVersion: 4,
1946
+ schemaVersion: 5,
1943
1947
  score,
1944
1948
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
1945
1949
  });
@@ -2023,4 +2027,4 @@ Object.defineProperty(exports, 'version', {
2023
2027
  return version;
2024
2028
  }
2025
2029
  });
2026
- //# sourceMappingURL=src-C7XK6Kp-.cjs.map
2030
+ //# sourceMappingURL=src-DiT93yVt.cjs.map