@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.
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
- const require_src = require('./src-C7XK6Kp-.cjs');
3
+ const require_src = require('./src-DiT93yVt.cjs');
4
4
 
5
5
  //#region ../core/src/config/define-config.ts
6
6
  const defineConfig = (config) => config;
package/dist/index.d.cts CHANGED
@@ -74,7 +74,7 @@ export declare const defineConfig: (config: DockerDoctorConfig) => DockerDoctorC
74
74
  export declare const loadConfig: (rootDir: string, customPath?: string, onWarning?: (message: string) => void) => Promise<DockerDoctorConfig>;
75
75
  //#endregion
76
76
  //#region ../core/src/scoring.d.ts
77
- export declare const calculateScore: (diagnostics: Diagnostic[]) => {
77
+ export declare const calculateScore: (diagnostics: Diagnostic[], analyzedFileCount?: number) => {
78
78
  score: number;
79
79
  label: string;
80
80
  };
package/dist/index.d.mts CHANGED
@@ -74,7 +74,7 @@ export declare const defineConfig: (config: DockerDoctorConfig) => DockerDoctorC
74
74
  export declare const loadConfig: (rootDir: string, customPath?: string, onWarning?: (message: string) => void) => Promise<DockerDoctorConfig>;
75
75
  //#endregion
76
76
  //#region ../core/src/scoring.d.ts
77
- export declare const calculateScore: (diagnostics: Diagnostic[]) => {
77
+ export declare const calculateScore: (diagnostics: Diagnostic[], analyzedFileCount?: number) => {
78
78
  score: number;
79
79
  label: string;
80
80
  };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as runDockerfileRules, d as discoverProject, f as version$1, i as runComposeRules, l as parseCompose, n as calculateScore, o as allRules, r as loadConfig, s as findRule, t as toJsonReport, u as parseDockerfile } from "./src-DiEWLJ6g.mjs";
2
+ import { a as runDockerfileRules, d as discoverProject, f as version$1, i as runComposeRules, l as parseCompose, n as calculateScore, o as allRules, r as loadConfig, s as findRule, t as toJsonReport, u as parseDockerfile } from "./src-D2DWrv5B.mjs";
3
3
 
4
4
  //#region ../core/src/config/define-config.ts
5
5
  const defineConfig = (config) => config;
@@ -5,7 +5,7 @@ import { LineCounter, isAlias, isMap, isScalar, isSeq, parse, parseDocument } fr
5
5
  import { pathToFileURL } from "node:url";
6
6
 
7
7
  //#region package.json
8
- var version = "0.6.1";
8
+ var version = "0.7.0";
9
9
 
10
10
  //#endregion
11
11
  //#region ../core/src/project-info/ignore.ts
@@ -1872,11 +1872,15 @@ const getScoreBucket = (score) => {
1872
1872
  for (const bucket of SCORE_BUCKETS) if (score >= bucket.min) return bucket;
1873
1873
  return SCORE_BUCKETS.at(-1);
1874
1874
  };
1875
- const calculateScore = (diagnostics) => {
1876
- let penalty = 0;
1877
- for (const diag of diagnostics) if (diag.severity === "error") penalty += 10;
1878
- else if (diag.severity === "warning") penalty += 4;
1879
- else if (diag.severity === "info") penalty += 1;
1875
+ const SEVERITY_PENALTY = {
1876
+ error: 10,
1877
+ info: 1,
1878
+ warning: 4
1879
+ };
1880
+ const calculateScore = (diagnostics, analyzedFileCount = 1) => {
1881
+ let totalPenalty = 0;
1882
+ for (const diag of diagnostics) totalPenalty += SEVERITY_PENALTY[diag.severity];
1883
+ const penalty = totalPenalty / Math.max(1, analyzedFileCount);
1880
1884
  const score = Math.round(100 * Math.exp(-penalty / 70));
1881
1885
  const bucket = getScoreBucket(score);
1882
1886
  return {
@@ -1887,7 +1891,7 @@ const calculateScore = (diagnostics) => {
1887
1891
 
1888
1892
  //#endregion
1889
1893
  //#region ../core/src/report.ts
1890
- const REPORT_SCHEMA_VERSION = 4;
1894
+ const REPORT_SCHEMA_VERSION = 5;
1891
1895
  const resolveCategory = (diagnostic) => {
1892
1896
  const category = diagnostic.category ?? findRule(diagnostic.rule)?.category;
1893
1897
  if (!category) throw new Error(`Diagnostic for unknown rule "${diagnostic.rule}" has no category`);
@@ -1910,11 +1914,11 @@ const toJsonReport = (diagnostics, score, label, project, failures = []) => ({
1910
1914
  })),
1911
1915
  label,
1912
1916
  project,
1913
- schemaVersion: 4,
1917
+ schemaVersion: 5,
1914
1918
  score,
1915
1919
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
1916
1920
  });
1917
1921
 
1918
1922
  //#endregion
1919
1923
  export { runDockerfileRules as a, createComposeLocator as c, discoverProject as d, version as f, runComposeRules as i, parseCompose as l, calculateScore as n, allRules as o, loadConfig as r, findRule as s, toJsonReport as t, parseDockerfile as u };
1920
- //# sourceMappingURL=src-DiEWLJ6g.mjs.map
1924
+ //# sourceMappingURL=src-D2DWrv5B.mjs.map