repometry 0.1.0 → 0.2.1

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 (119) hide show
  1. package/README.md +3 -2
  2. package/package.json +5 -4
  3. package/target/main/resources/report/json/config-v1.schema.json +0 -1
  4. package/target/main/resources/report/json/report-v2.schema.json +14 -0
  5. package/target/main/resources/viewer/index.html +10 -20
  6. package/target/main/resources/viewer/styles.css +3 -29
  7. package/target/main/ts/api/gh/github.js +1 -0
  8. package/target/main/ts/api/git/blob-batch.js +1 -0
  9. package/target/main/ts/api/git/changes.js +1 -0
  10. package/target/main/ts/api/git/commit-metadata.js +5 -6
  11. package/target/main/ts/api/git/git-churn.js +1 -0
  12. package/target/main/ts/api/git/git-reader.js +1 -0
  13. package/target/main/ts/api/git/git.js +1 -0
  14. package/target/main/ts/api/git/inspection-source.js +1 -0
  15. package/target/main/ts/api/git/local-sources.js +1 -0
  16. package/target/main/ts/api/git/local.js +1 -0
  17. package/target/main/ts/api/git/metabranch-worktree.js +1 -0
  18. package/target/main/ts/api/git/source-cache.js +1 -0
  19. package/target/main/ts/api/import/finding-import.js +1 -0
  20. package/target/main/ts/api/import/lcov-files.js +1 -0
  21. package/target/main/ts/api/import/profile-file.js +1 -0
  22. package/target/main/ts/api/worker/remote-executor.js +1 -0
  23. package/target/main/ts/api/worker/worker-protocol.js +1 -0
  24. package/target/main/ts/api/worker/worker.js +1 -0
  25. package/target/main/ts/cli/arguments.js +1 -0
  26. package/target/main/ts/cli/config.d.ts +0 -1
  27. package/target/main/ts/cli/config.js +3 -5
  28. package/target/main/ts/cli/imports.js +1 -0
  29. package/target/main/ts/cli/main.js +3 -2
  30. package/target/main/ts/cli/reporting.js +9 -13
  31. package/target/main/ts/cli/revisions.js +1 -0
  32. package/target/main/ts/cli/store.js +1 -0
  33. package/target/main/ts/compose/analyze-snapshot.js +1 -0
  34. package/target/main/ts/compose/attach-churn.js +13 -0
  35. package/target/main/ts/compose/diff-coverage.js +1 -0
  36. package/target/main/ts/compose/inspect.js +1 -0
  37. package/target/main/ts/compose/plugin-list.js +1 -0
  38. package/target/main/ts/compose/prepare-metabranch.js +1 -0
  39. package/target/main/ts/compose/review.js +1 -0
  40. package/target/main/ts/compose/sources.js +1 -0
  41. package/target/main/ts/core/engine/execute.js +1 -0
  42. package/target/main/ts/core/engine/manifest.js +1 -0
  43. package/target/main/ts/core/engine/plan.js +1 -0
  44. package/target/main/ts/core/engine/report-products.js +1 -0
  45. package/target/main/ts/core/model/changes.js +1 -0
  46. package/target/main/ts/core/model/clone-source.js +1 -0
  47. package/target/main/ts/core/model/code-structure.js +1 -0
  48. package/target/main/ts/core/model/finding-ignore.js +1 -0
  49. package/target/main/ts/core/model/measurement.d.ts +6 -0
  50. package/target/main/ts/core/model/measurement.js +6 -0
  51. package/target/main/ts/core/model/report.d.ts +8 -0
  52. package/target/main/ts/core/model/scanner-import.js +1 -0
  53. package/target/main/ts/core/model/snapshot.js +1 -0
  54. package/target/main/ts/core/ports/report.js +1 -0
  55. package/target/main/ts/core/ports/source-provider.js +1 -0
  56. package/target/main/ts/core/profile/exclusions.js +1 -0
  57. package/target/main/ts/core/profile/maintainability.js +1 -0
  58. package/target/main/ts/core/profile/profile.js +1 -0
  59. package/target/main/ts/core/usecases/compare.js +1 -0
  60. package/target/main/ts/core/usecases/diff-coverage-policy.js +1 -0
  61. package/target/main/ts/core/usecases/diff-coverage.js +1 -0
  62. package/target/main/ts/core/usecases/inspect.js +1 -0
  63. package/target/main/ts/core/usecases/review.js +1 -0
  64. package/target/main/ts/index.js +1 -0
  65. package/target/main/ts/plugin.js +1 -0
  66. package/target/main/ts/plugins/coverage/coverage.d.ts +2 -0
  67. package/target/main/ts/plugins/coverage/coverage.js +83 -4
  68. package/target/main/ts/plugins/coverage/diff-coverage.js +1 -0
  69. package/target/main/ts/plugins/duplication/duplication.js +1 -0
  70. package/target/main/ts/plugins/language-js/babel-provider.js +1 -0
  71. package/target/main/ts/plugins/language-js/clone-candidates.js +1 -0
  72. package/target/main/ts/plugins/language-js/code-lines.js +1 -0
  73. package/target/main/ts/plugins/language-js/function-facts.js +1 -0
  74. package/target/main/ts/plugins/language-js/structural-observations.js +1 -0
  75. package/target/main/ts/plugins/maintainability/maintainability.js +1 -0
  76. package/target/main/ts/plugins/maintainability/structural-smells.js +1 -0
  77. package/target/main/ts/plugins/source/forges.js +1 -0
  78. package/target/main/ts/plugins/structure/structure.js +1 -0
  79. package/target/main/ts/report/html/app/viewer-chart.js +5 -5
  80. package/target/main/ts/report/html/app/viewer-commits.d.ts +1 -1
  81. package/target/main/ts/report/html/app/viewer-commits.js +1 -1
  82. package/target/main/ts/report/html/app/viewer-data.d.ts +1 -1
  83. package/target/main/ts/report/html/app/viewer-data.js +4 -4
  84. package/target/main/ts/report/html/app/viewer-files.js +25 -8
  85. package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +3 -1
  86. package/target/main/ts/report/html/app/viewer-metric-registry.js +24 -6
  87. package/target/main/ts/report/html/app/viewer-profile.js +3 -3
  88. package/target/main/ts/report/html/app/viewer-trends.d.ts +0 -1
  89. package/target/main/ts/report/html/app/viewer-trends.js +16 -6
  90. package/target/main/ts/report/html/app/viewer.js +48 -107
  91. package/target/main/ts/report/html/site/badges.js +1 -0
  92. package/target/main/ts/report/html/site/export-site.d.ts +2 -1
  93. package/target/main/ts/report/html/site/export-site.js +17 -24
  94. package/target/main/ts/report/html/site/exported-server.js +1 -0
  95. package/target/main/ts/report/html/site/local-server.js +1 -0
  96. package/target/main/ts/report/html/site/projects.js +1 -0
  97. package/target/main/ts/report/html/site/server.js +1 -0
  98. package/target/main/ts/report/html/site/source-route.js +1 -0
  99. package/target/main/ts/report/json/projections/commit-summary.d.ts +1 -0
  100. package/target/main/ts/report/json/projections/commit-summary.js +7 -1
  101. package/target/main/ts/report/json/projections/components.js +1 -0
  102. package/target/main/ts/report/json/projections/file-metrics.js +1 -0
  103. package/target/main/ts/report/json/projections/inspection-context.js +1 -0
  104. package/target/main/ts/report/json/projections/inspection-details.js +1 -0
  105. package/target/main/ts/report/json/projections/metric-values.js +1 -0
  106. package/target/main/ts/report/json/projections/public-history.js +1 -0
  107. package/target/main/ts/report/json/store/components.js +1 -0
  108. package/target/main/ts/report/json/store/local-store.js +1 -0
  109. package/target/main/ts/report/json/store/pull-review-store.js +1 -0
  110. package/target/main/ts/report/json/validation/metabranch.js +1 -0
  111. package/target/main/ts/report/json/validation/report.js +1 -0
  112. package/target/main/ts/report/json/validation/summary-validation.js +1 -0
  113. package/target/main/ts/report.js +1 -0
  114. package/target/main/ts/api/gh/github-pr-comment.d.ts +0 -4
  115. package/target/main/ts/api/gh/github-pr-comment.js +0 -107
  116. package/target/main/ts/cli/github-pr-comment.d.ts +0 -1
  117. package/target/main/ts/cli/github-pr-comment.js +0 -12
  118. package/target/main/ts/report/html/app/viewer-access.d.ts +0 -19
  119. package/target/main/ts/report/html/app/viewer-access.js +0 -25
@@ -6,6 +6,12 @@ export declare const definitions: {
6
6
  readonly coverage: 'repometry.lcov-line-coverage/v1';
7
7
  readonly coveredLines: 'repometry.lcov-covered-lines/v1';
8
8
  readonly coverableLines: 'repometry.lcov-coverable-lines/v1';
9
+ readonly branchCoverage: 'repometry.lcov-branch-coverage/v1';
10
+ readonly coveredBranches: 'repometry.lcov-covered-branches/v1';
11
+ readonly coverableBranches: 'repometry.lcov-coverable-branches/v1';
12
+ readonly functionCoverage: 'repometry.lcov-function-coverage/v1';
13
+ readonly coveredFunctions: 'repometry.lcov-covered-functions/v1';
14
+ readonly coverableFunctions: 'repometry.lcov-coverable-functions/v1';
9
15
  readonly codeLines: 'repometry.code-lines-babel/v1';
10
16
  readonly comments: 'repometry.comment-lines-babel/v1';
11
17
  readonly classes: 'repometry.classes-babel/v1';
@@ -6,6 +6,12 @@ export const definitions = {
6
6
  coverage: 'repometry.lcov-line-coverage/v1',
7
7
  coveredLines: 'repometry.lcov-covered-lines/v1',
8
8
  coverableLines: 'repometry.lcov-coverable-lines/v1',
9
+ branchCoverage: 'repometry.lcov-branch-coverage/v1',
10
+ coveredBranches: 'repometry.lcov-covered-branches/v1',
11
+ coverableBranches: 'repometry.lcov-coverable-branches/v1',
12
+ functionCoverage: 'repometry.lcov-function-coverage/v1',
13
+ coveredFunctions: 'repometry.lcov-covered-functions/v1',
14
+ coverableFunctions: 'repometry.lcov-coverable-functions/v1',
9
15
  codeLines: 'repometry.code-lines-babel/v1',
10
16
  comments: 'repometry.comment-lines-babel/v1',
11
17
  classes: 'repometry.classes-babel/v1',
@@ -16,6 +16,14 @@ export interface Report {
16
16
  readonly subject: Subject;
17
17
  readonly generatedAt: string;
18
18
  readonly committedAt?: string;
19
+ /** The inspected commit's message title and author, recorded at analysis so the store alone can describe it. */
20
+ readonly commit?: {
21
+ readonly subject: string;
22
+ readonly author: {
23
+ readonly name: string;
24
+ readonly email: string;
25
+ };
26
+ };
19
27
  readonly appliedConfig: Readonly<Record<string, unknown>>;
20
28
  readonly definitions: Readonly<Record<string, string>>;
21
29
  readonly scope: {
@@ -26,3 +26,4 @@ export function uniqueScanners(tools) {
26
26
  export function scannerText(value) {
27
27
  return typeof value === 'string' && value.trim() !== '' ? value : undefined;
28
28
  }
29
+ //# sourceMappingURL=scanner-import.js.map
@@ -48,3 +48,4 @@ export function workingSnapshot(files) {
48
48
  const id = digest(JSON.stringify(files.map(file => [file.path, digest(file.bytes)])));
49
49
  return { subject: { kind: 'working-tree', id }, files };
50
50
  }
51
+ //# sourceMappingURL=snapshot.js.map
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=report.js.map
@@ -2,3 +2,4 @@ export function isSourcePathname(path) {
2
2
  return !/^[A-Za-z]:/.test(path) && !/[\\\0\r\n]/.test(path)
3
3
  && path.split('/').every(segment => segment !== '' && segment !== '.' && segment !== '..');
4
4
  }
5
+ //# sourceMappingURL=source-provider.js.map
@@ -55,3 +55,4 @@ export function exclusionMatcher(patterns) {
55
55
  function isRelativePath(path) {
56
56
  return !/^[A-Za-z]:/.test(path) && path.split('/').every(part => part !== '' && part !== '.' && part !== '..');
57
57
  }
58
+ //# sourceMappingURL=exclusions.js.map
@@ -7,3 +7,4 @@ export const structuralRules = {
7
7
  'file-complexity': { limit: 50, minutesPerExcess: 5 },
8
8
  };
9
9
  export const duplicationSettings = { minCodeLines: 12, minNodes: 50, minutesPerRepeatedLine: 2 };
10
+ //# sourceMappingURL=maintainability.js.map
@@ -8,3 +8,4 @@ export function normalizeProfile(profile) {
8
8
  return { exclude: normalizeExclusions(profile.exclude === undefined ? [] : profile.exclude),
9
9
  ignore: normalizeFindingIgnore(profile.ignore === undefined ? [] : profile.ignore) };
10
10
  }
11
+ //# sourceMappingURL=profile.js.map
@@ -143,3 +143,4 @@ function recordedEntries(value, key, names) {
143
143
  function subject({ subject, generatedAt, status, scope }) {
144
144
  return { subject, generatedAt, status, scope };
145
145
  }
146
+ //# sourceMappingURL=compare.js.map
@@ -8,3 +8,4 @@ export function assessDiffCoverage(result, minimumPercent) {
8
8
  return { status: 'not-applicable', minimumPercent };
9
9
  return { status: result.percent >= minimumPercent ? 'passed' : 'failed', minimumPercent };
10
10
  }
11
+ //# sourceMappingURL=diff-coverage-policy.js.map
@@ -13,3 +13,4 @@ export async function executeDiffCoverage(options, ports) {
13
13
  };
14
14
  return { report, uncovered };
15
15
  }
16
+ //# sourceMappingURL=diff-coverage.js.map
@@ -39,3 +39,4 @@ function withLcovDigests(report, { text, inputDigests }) {
39
39
  }
40
40
  return { ...report, appliedConfig: { ...report.appliedConfig, coverage: { ...coverage, inputDigests } } };
41
41
  }
42
+ //# sourceMappingURL=inspect.js.map
@@ -126,3 +126,4 @@ function findingMethod(report, qualityOnly) {
126
126
  const imported = findingImportMethods(findingImports).filter(({ category }) => !qualityOnly || !isSensitiveFinding(category));
127
127
  return { ...settings, imported, plugins: exclude(plugins, 'id', 'lcov'), operations: exclude(operations, 'key', 'lcov/import') };
128
128
  }
129
+ //# sourceMappingURL=review.js.map
@@ -15,3 +15,4 @@ export { readReport, reportSchema } from './report/json/validation/report.js';
15
15
  export { coverageGrade, qualitySummary } from './core/model/quality-summary.js';
16
16
  export { pullReviewSchema } from './core/model/pull-review.js';
17
17
  export { pullReviewsSchema } from './report/json/wire/pull-review-model.js';
18
+ //# sourceMappingURL=index.js.map
@@ -3,3 +3,4 @@ export { codeStructure } from './core/model/code-structure.js';
3
3
  export { sourceFile } from './core/model/snapshot.js';
4
4
  export { measurements } from './core/model/measurement.js';
5
5
  export { findingResult } from './core/model/finding.js';
6
+ //# sourceMappingURL=plugin.js.map
@@ -18,6 +18,8 @@ export declare const coverageResult: DataContract<CoverageResult>;
18
18
  export declare const coverage: Plugin;
19
19
  export declare function mapCoverage({ text, root, sourceLines, excludes }: CoverageInput): {
20
20
  files: Map<string, Map<number, boolean>>;
21
+ branches: Map<string, Map<string, boolean>>;
22
+ functions: Map<string, Map<string, boolean>>;
21
23
  gaps: Map<string, string>;
22
24
  };
23
25
  export {};
@@ -15,7 +15,7 @@ export const coverageResult = {
15
15
  };
16
16
  export const coverage = {
17
17
  id: 'lcov',
18
- version: '1.1.0',
18
+ version: '1.2.0',
19
19
  api: pluginApi,
20
20
  kinds: ['coverage', 'import'],
21
21
  produces: [{ contract: coverageResult.id, persistence: 'report', metrics: [
@@ -23,6 +23,14 @@ export const coverage = {
23
23
  ratio: { of: definitions.coveredLines, over: definitions.coverableLines }, bands: [0.6, 0.7, 0.8, 0.9], group: 'Coverage' },
24
24
  { id: definitions.coveredLines, label: 'Covered lines', unit: 'count', scope: 'file', aggregate: 'sum', better: 'higher', group: 'Coverage' },
25
25
  { id: definitions.coverableLines, label: 'Measured lines', unit: 'count', scope: 'file', aggregate: 'sum', better: 'none', group: 'Coverage' },
26
+ { id: definitions.branchCoverage, label: 'Branch coverage', unit: 'ratio', scope: 'file', aggregate: 'sum', better: 'higher',
27
+ ratio: { of: definitions.coveredBranches, over: definitions.coverableBranches }, bands: [0.6, 0.7, 0.8, 0.9], group: 'Coverage' },
28
+ { id: definitions.coveredBranches, label: 'Covered branches', unit: 'count', scope: 'file', aggregate: 'sum', better: 'higher', group: 'Coverage' },
29
+ { id: definitions.coverableBranches, label: 'Measured branches', unit: 'count', scope: 'file', aggregate: 'sum', better: 'none', group: 'Coverage' },
30
+ { id: definitions.functionCoverage, label: 'Function coverage', unit: 'ratio', scope: 'file', aggregate: 'sum', better: 'higher',
31
+ ratio: { of: definitions.coveredFunctions, over: definitions.coverableFunctions }, bands: [0.6, 0.7, 0.8, 0.9], group: 'Coverage' },
32
+ { id: definitions.coveredFunctions, label: 'Covered functions', unit: 'count', scope: 'file', aggregate: 'sum', better: 'higher', group: 'Coverage' },
33
+ { id: definitions.coverableFunctions, label: 'Measured functions', unit: 'count', scope: 'file', aggregate: 'sum', better: 'none', group: 'Coverage' },
26
34
  ] }],
27
35
  operations: [{
28
36
  id: 'import',
@@ -34,6 +42,17 @@ export const coverage = {
34
42
  };
35
43
  export function mapCoverage({ text, root, sourceLines, excludes }) {
36
44
  const files = new Map();
45
+ // Branches by line, block and branch. Functions by name and its occurrence in the record: tools such as c8 repeat a
46
+ // name for different functions and list FNDA in FN order. Several reports merge by any hit.
47
+ const branches = new Map();
48
+ const declared = new Map();
49
+ const called = new Map();
50
+ const occurrences = { declared: new Map(), called: new Map() };
51
+ const occurrence = (seen, name) => {
52
+ const count = (seen.get(name) ?? 0) + 1;
53
+ seen.set(name, count);
54
+ return `${name}#${count}`;
55
+ };
37
56
  const gaps = new Map();
38
57
  let active;
39
58
  let ignored = false;
@@ -44,6 +63,8 @@ export function mapCoverage({ text, root, sourceLines, excludes }) {
44
63
  if (active !== undefined || line.length === 3)
45
64
  throw new Error(`Unexpected LCOV source at line ${index + 1}`);
46
65
  active = normalizeLcovPath(root, line.slice(3));
66
+ occurrences.declared.clear();
67
+ occurrences.called.clear();
47
68
  sawSource = true;
48
69
  ignored = excludes?.(active) ?? false;
49
70
  if (ignored)
@@ -70,6 +91,34 @@ export function mapCoverage({ text, root, sourceLines, excludes }) {
70
91
  else if (file)
71
92
  file.set(number, (file.get(number) ?? false) || hits > 0);
72
93
  }
94
+ else if (line.startsWith('BRDA:') || line.startsWith('FN:') || line.startsWith('FNDA:')) {
95
+ if (active === undefined)
96
+ throw new Error(`LCOV data outside a source record at line ${index + 1}`);
97
+ if (ignored || !files.has(active))
98
+ continue;
99
+ const branch = /^BRDA:([1-9]\d*),([^,]+),([^,]+),(\d+|-)$/.exec(line);
100
+ const declaration = /^FN:[1-9]\d*(?:,[1-9]\d*)?,(.+)$/.exec(line);
101
+ const call = /^FNDA:(\d+),(.+)$/.exec(line);
102
+ if (branch) {
103
+ const taken = branch[4] !== '-' && Number(branch[4]) > 0;
104
+ const key = `${branch[1]},${branch[2]},${branch[3]}`;
105
+ const file = branches.get(active) ?? new Map();
106
+ file.set(key, (file.get(key) ?? false) || taken);
107
+ branches.set(active, file);
108
+ }
109
+ else if (declaration) {
110
+ declared.set(active, (declared.get(active) ?? new Set()).add(occurrence(occurrences.declared, declaration[1])));
111
+ }
112
+ else if (call) {
113
+ const key = occurrence(occurrences.called, call[2]);
114
+ const file = called.get(active) ?? new Map();
115
+ file.set(key, (file.get(key) ?? false) || Number(call[1]) > 0);
116
+ called.set(active, file);
117
+ }
118
+ else {
119
+ throw new Error(`Invalid LCOV data at line ${index + 1}`);
120
+ }
121
+ }
73
122
  else if (line === 'end_of_record') {
74
123
  if (active === undefined)
75
124
  throw new Error(`Unexpected LCOV record end at line ${index + 1}`);
@@ -80,10 +129,11 @@ export function mapCoverage({ text, root, sourceLines, excludes }) {
80
129
  throw new Error('Unterminated LCOV source record');
81
130
  if (!sawSource && text.trim() !== '')
82
131
  throw new Error('LCOV contains no source records');
83
- return { files, gaps };
132
+ const functions = new Map([...declared].map(([path, names]) => [path, new Map([...names].map(name => [name, called.get(path)?.get(name) ?? false]))]));
133
+ return { files, branches, functions, gaps };
84
134
  }
85
135
  function importCoverage(input) {
86
- const { files, gaps } = mapCoverage(input);
136
+ const { files, branches, functions, gaps } = mapCoverage(input);
87
137
  const rows = [];
88
138
  let totalCovered = 0;
89
139
  let totalLines = 0;
@@ -103,9 +153,37 @@ function importCoverage(input) {
103
153
  { definition: definitions.coveredLines, target, path, value: covered ?? null },
104
154
  { definition: definitions.coverableLines, target, path, value: total ?? null },
105
155
  ]);
106
- return { measurements: [...rows, ...counts],
156
+ const extra = [
157
+ ...hitRows(branches, gaps, definitions.branchCoverage, definitions.coveredBranches, definitions.coverableBranches),
158
+ ...hitRows(functions, gaps, definitions.functionCoverage, definitions.coveredFunctions, definitions.coverableFunctions),
159
+ ];
160
+ return { measurements: [...rows, ...counts, ...extra],
107
161
  gaps: [...gaps].sort(([left], [right]) => comparePaths(left, right)).map(([path, reason]) => ({ path, reason })) };
108
162
  }
163
+ /** Per-file and repository ratios with their counts, for a kind the LCOV reports; nothing when it reports none. */
164
+ function hitRows(files, gaps, ratioId, coveredId, totalId) {
165
+ const rows = [];
166
+ let totalCovered = 0;
167
+ let totalCount = 0;
168
+ for (const [path, hits] of [...files].sort(([left], [right]) => comparePaths(left, right))) {
169
+ if (gaps.has(path) || hits.size === 0)
170
+ continue;
171
+ let covered = 0;
172
+ for (const hit of hits.values())
173
+ if (hit)
174
+ covered++;
175
+ totalCovered += covered;
176
+ totalCount += hits.size;
177
+ rows.push({ definition: ratioId, target: 'file', path, covered, total: hits.size, value: ratio(covered, hits.size) });
178
+ }
179
+ if (totalCount === 0)
180
+ return [];
181
+ rows.push({ definition: ratioId, target: 'repository', covered: totalCovered, total: totalCount, value: ratio(totalCovered, totalCount) });
182
+ return [...rows, ...rows.flatMap(({ target, path, covered, total }) => [
183
+ { definition: coveredId, target, path, value: covered ?? null },
184
+ { definition: totalId, target, path, value: total ?? null },
185
+ ])];
186
+ }
109
187
  function ratio(covered, total) {
110
188
  return total === 0 ? null : covered / total;
111
189
  }
@@ -118,3 +196,4 @@ function normalizeLcovPath(root, path) {
118
196
  return posix.normalize(candidate.replaceAll('\\', '/'));
119
197
  return posix.normalize(candidate);
120
198
  }
199
+ //# sourceMappingURL=coverage.js.map
@@ -87,3 +87,4 @@ function containsLine(ranges, line) {
87
87
  }
88
88
  return false;
89
89
  }
90
+ //# sourceMappingURL=diff-coverage.js.map
@@ -91,3 +91,4 @@ function matchedLineCount(codeLines, matches) {
91
91
  }
92
92
  return count;
93
93
  }
94
+ //# sourceMappingURL=duplication.js.map
@@ -44,3 +44,4 @@ export const babelProvider = {
44
44
  },
45
45
  }],
46
46
  };
47
+ //# sourceMappingURL=babel-provider.js.map
@@ -62,3 +62,4 @@ function firstAtLeast(numbers, number) {
62
62
  }
63
63
  return left;
64
64
  }
65
+ //# sourceMappingURL=clone-candidates.js.map
@@ -33,3 +33,4 @@ export function classifyLines(source, ast, physical) {
33
33
  }
34
34
  return { code, comments };
35
35
  }
36
+ //# sourceMappingURL=code-lines.js.map
@@ -58,3 +58,4 @@ export function functionName(node) {
58
58
  }
59
59
  return '(anonymous)';
60
60
  }
61
+ //# sourceMappingURL=function-facts.js.map
@@ -77,3 +77,4 @@ function countLogicalOperators(node) {
77
77
  return 0;
78
78
  return 1 + countLogicalOperators(node.left) + countLogicalOperators(node.right);
79
79
  }
80
+ //# sourceMappingURL=structural-observations.js.map
@@ -40,3 +40,4 @@ export const maintainability = {
40
40
  },
41
41
  }],
42
42
  };
43
+ //# sourceMappingURL=maintainability.js.map
@@ -13,3 +13,4 @@ export function structuralSmells(path, observations) {
13
13
  }
14
14
  return findings;
15
15
  }
16
+ //# sourceMappingURL=structural-smells.js.map
@@ -77,3 +77,4 @@ function remoteProject(remote) {
77
77
  return undefined;
78
78
  }
79
79
  }
80
+ //# sourceMappingURL=forges.js.map
@@ -35,3 +35,4 @@ export const structure = {
35
35
  },
36
36
  }],
37
37
  };
38
+ //# sourceMappingURL=structure.js.map
@@ -280,7 +280,7 @@ function lineChart(svg, layout, points, { format, ratio, compact, tickUnit = 1,
280
280
  markBoundaries(svg, layout, points);
281
281
  if (secondary && secondHigh > 0) {
282
282
  const y2 = (value) => layout.top + layout.plotHeight - value / secondHigh * layout.plotHeight;
283
- for (const segment of segments(secondary.values, points)) {
283
+ for (const segment of segments(secondary.values)) {
284
284
  const path = svgElement('path', 'tc-line tc-line-secondary');
285
285
  path.setAttribute('d', segment.map((index, order) => {
286
286
  const value = secondary.values[index];
@@ -292,7 +292,7 @@ function lineChart(svg, layout, points, { format, ratio, compact, tickUnit = 1,
292
292
  svg.append(path);
293
293
  }
294
294
  }
295
- for (const segment of segments(points.map(point => point.value), points)) {
295
+ for (const segment of segments(points.map(point => point.value))) {
296
296
  const path = svgElement('path', 'tc-line');
297
297
  // Code keeps its state until the next commit, so the line holds each value and steps at the commit that changed it;
298
298
  // a slope would invent values for the days between commits.
@@ -622,12 +622,12 @@ function interact(svg, tip, layout, points) {
622
622
  }
623
623
  });
624
624
  }
625
- /** Runs of consecutive measured points, broken where a measurement is missing. */
626
- function segments(values, points) {
625
+ /** Runs of consecutive measured points, broken only where a measurement is missing; a profile change is marked, not cut. */
626
+ function segments(values) {
627
627
  const result = [];
628
628
  let run = [];
629
629
  for (const [index, value] of values.entries()) {
630
- if (value === null || points[index]?.boundary === 'changed') {
630
+ if (value === null) {
631
631
  if (run.length)
632
632
  result.push(run);
633
633
  run = [];
@@ -30,7 +30,7 @@ export interface CommitPicker {
30
30
  export declare function createCommitPicker(slot: HTMLElement, entries: readonly PublicHistoryEntry[], pick: (sha: string) => void, branch?: string): CommitPicker;
31
31
  /**
32
32
  * How a commit's author reads in the list: the name, with the email only when the search found the email and not the
33
- * name. A public export carries the name alone, and then it is the name alone; nothing reads as missing.
33
+ * name. A history without emails carries the name alone, and then it is the name alone; nothing reads as missing.
34
34
  */
35
35
  export declare function authorLabel(author: PublicHistoryEntry['author'], words: readonly string[]): string | null;
36
36
  export {};
@@ -226,7 +226,7 @@ export function createCommitPicker(slot, entries, pick, branch) {
226
226
  }
227
227
  /**
228
228
  * How a commit's author reads in the list: the name, with the email only when the search found the email and not the
229
- * name. A public export carries the name alone, and then it is the name alone; nothing reads as missing.
229
+ * name. A history without emails carries the name alone, and then it is the name alone; nothing reads as missing.
230
230
  */
231
231
  export function authorLabel(author, words) {
232
232
  if (!author?.name)
@@ -13,7 +13,7 @@ export interface ViewerData {
13
13
  readonly branch?: string;
14
14
  /** The metrics the history's plugins declare; each commit's values are indexed by it. */
15
15
  readonly metrics?: readonly MetricDescriptor[];
16
- /** Where file sources come from, in a detailed export that names a place. */
16
+ /** Where file sources come from, when the export names a place. */
17
17
  readonly sources?: SourceLocator;
18
18
  loadDetails(sha: string): Promise<InspectionAsset | null>;
19
19
  }
@@ -21,17 +21,17 @@ export async function loadViewerData(mode) {
21
21
  context: Object.fromEntries(summary.commits.map(commit => [commit.sha, {
22
22
  exclusions: null, boundary: commit.profileBoundary ?? null, security: commit.counts?.security,
23
23
  }])),
24
- counts: mode === 'public' ? undefined : counts,
24
+ counts,
25
25
  pullReviewCount: summary.pullReviewCount,
26
26
  ...(Array.isArray(summary.metrics) ? { metrics: summary.metrics } : {}),
27
27
  ...(() => {
28
- const sources = mode === 'public' ? undefined : sourceLocator(summary.sources);
28
+ const sources = sourceLocator(summary.sources);
29
29
  return sources ? { sources } : {};
30
30
  })(),
31
31
  ...(typeof summary.source?.branch === 'string' && summary.source.branch.trim() ? { branch: summary.source.branch.trim() } : {}),
32
32
  async loadDetails(sha) {
33
33
  const path = details.get(sha);
34
- if (path === undefined || (mode !== 'local' && mode !== 'private'))
34
+ if (path === undefined)
35
35
  return null;
36
36
  const asset = await readInspection(path, sha, mode);
37
37
  if (asset)
@@ -74,7 +74,7 @@ async function legacyViewerData(mode) {
74
74
  const [history, quality, saved, localContext] = await Promise.all([
75
75
  readOptional('./history.json'),
76
76
  readOptional('./quality-history.json'),
77
- mode === 'private' ? readOptional('./details.json') : null,
77
+ mode === 'local' ? null : readOptional('./details.json'),
78
78
  mode === 'local' ? readOptional('./inspection-context.json') : null,
79
79
  ]);
80
80
  if (history?.schema !== historySchema || !Array.isArray(history.reports))
@@ -36,9 +36,14 @@ function useDetails(details) {
36
36
  function measured(descriptor) {
37
37
  return local.index.has(descriptor.ratio?.over ?? descriptor.id);
38
38
  }
39
- /** Other plugins' metrics as Metrics columns, after Repometry's own, in the order the history lists them. */
40
- function pluginColumns() {
41
- return pluginMetrics().filter(spec => spec.descriptor.scope === 'file').map(spec => ({
39
+ /** Coverage kinds beside line coverage (branches, functions), where the coverage report has them. */
40
+ function coverageKinds() {
41
+ return pluginMetrics().filter(spec => spec.plugin === 'repometry' && spec.group === 'Coverage' && spec.descriptor.unit === 'ratio'
42
+ && spec.descriptor.scope === 'file');
43
+ }
44
+ /** Registry metrics as Metrics columns, in the order the history lists them. */
45
+ function pluginColumns(specs) {
46
+ return specs.map(spec => ({
42
47
  label: spec.short,
43
48
  value: entry => entryValue(local.index, entry, spec),
44
49
  display: entry => format(spec, entryValue(local.index, entry, spec)),
@@ -87,7 +92,7 @@ const builtinColumns = [
87
92
  { label: labelOf('complexity'), value: entry => entry.complexity?.maximum ?? null, display: entry => count(entry.complexity?.maximum) },
88
93
  { label: labelOf('cognitive'), value: entry => entry.quality?.cognitiveComplexity ?? null, display: entry => count(entry.quality?.cognitiveComplexity),
89
94
  available: directory => directory?.quality?.cognitiveComplexity !== undefined },
90
- { label: 'Line coverage', value: coverageRatio, display: coverageText, available: directory => directory ? coverageRatio(directory) !== null : true },
95
+ { label: labelOf('coverage'), value: coverageRatio, display: coverageText, available: directory => directory ? coverageRatio(directory) !== null : true },
91
96
  { label: 'Duplication', value: duplicationRatio, display: duplicationText,
92
97
  available: directory => directory?.quality?.duplication !== undefined },
93
98
  { label: labelOf('effort'), value: entry => entry.quality?.maintainability?.effortMinutes ?? null,
@@ -104,7 +109,13 @@ function isGroup(value) {
104
109
  function metricsView(details, navigation, settings, directory, selectedFile) {
105
110
  const view = element('div', 'fx-view');
106
111
  const { metrics } = details;
107
- const columns = [...builtinColumns, ...pluginColumns()];
112
+ // The other coverage kinds sit beside line coverage; every other registry metric follows Repometry's own columns,
113
+ // except the counts a ratio is made of, which read through the ratio as line coverage's do.
114
+ const kinds = coverageKinds();
115
+ const afterCoverage = builtinColumns.findIndex(column => column.label === labelOf('coverage')) + 1;
116
+ const columns = [...builtinColumns.slice(0, afterCoverage),
117
+ ...pluginColumns(kinds), ...builtinColumns.slice(afterCoverage),
118
+ ...pluginColumns(pluginMetrics().filter(spec => spec.descriptor.scope === 'file' && !spec.ratioPart && !kinds.includes(spec)))];
108
119
  const scopeFiles = metrics.files.filter(entry => inside(entry.path, directory));
109
120
  const scopeTotals = aggregate(directory, scopeFiles);
110
121
  const scopeIgnored = scopeFiles.some(entry => entry.analysed === false);
@@ -555,9 +566,10 @@ function directorySummary(entry, analysed, lockfiles, selection) {
555
566
  quality?.duplication === undefined ? null : fact(labelOf('duplication'), duplicationText(entry)),
556
567
  quality?.maintainability === undefined ? null : fact(labelOf('effort'), duration(quality.maintainability.effortMinutes)),
557
568
  coverageRatio(entry) === null ? null : fact(labelOf('coverage'), coverageText(entry)),
558
- // Other plugins' totals follow Repometry's own, where this inspection ran them and they roll up.
559
- ...pluginMetrics().filter(spec => spec.descriptor.scope === 'file' && spec.descriptor.aggregate !== 'none' && measured(spec.descriptor))
560
- .map(spec => fact(spec.short, format(spec, entryValue(local.index, entry, spec)))),
569
+ // Other plugins' totals follow Repometry's own, where this inspection ran them and they roll up; the counts behind
570
+ // a ratio read through it.
571
+ ...pluginMetrics().filter(spec => spec.descriptor.scope === 'file' && spec.descriptor.aggregate !== 'none' && !spec.ratioPart
572
+ && measured(spec.descriptor)).map(spec => fact(spec.short, format(spec, entryValue(local.index, entry, spec)))),
561
573
  ].filter(item => item !== null));
562
574
  panel.append(heading, facts);
563
575
  return panel;
@@ -589,6 +601,11 @@ function fileDetails(details, entry, navigation, hooks = {}) {
589
601
  if (quality?.cognitiveComplexity !== undefined)
590
602
  facts.append(fact(labelOf('cognitive'), count(quality.cognitiveComplexity)));
591
603
  facts.append(fact(labelOf('coverage'), coverageText(entry), coverageContext(entry)));
604
+ for (const spec of coverageKinds()) {
605
+ const value = measured(spec.descriptor) ? entryValue(local.index, entry, spec) : null;
606
+ if (value !== null)
607
+ facts.append(fact(spec.short, format(spec, value)));
608
+ }
592
609
  if (quality?.duplication)
593
610
  facts.append(fact(labelOf('duplication'), duplicationText(entry), duplicationContext(entry)));
594
611
  if (quality?.maintainability)
@@ -16,6 +16,8 @@ export interface MetricSpec {
16
16
  readonly hotspot: boolean;
17
17
  /** Has one value per commit, so a trend chart. */
18
18
  readonly trend: boolean;
19
+ /** A count another metric's ratio is made of, as covered branches are of branch coverage. */
20
+ readonly ratioPart: boolean;
19
21
  }
20
22
  /** A row that may carry values: a commit, a file or a folder. */
21
23
  export interface Valued {
@@ -24,7 +26,7 @@ export interface Valued {
24
26
  }
25
27
  /** Curated groups first, in this order; groups named by plugins follow in catalog order. */
26
28
  export declare const curatedGroups: readonly ['Maintainability', 'Coverage', 'Security', 'Size'];
27
- /** Repometry's own metrics, which the viewer draws from their typed fields. */
29
+ /** The metrics the viewer draws from their typed fields; a Repometry metric it has no code for goes by its descriptor. */
28
30
  export declare function isBuiltin(descriptor: MetricDescriptor): boolean;
29
31
  /** One spec per descriptor, in catalog order; descriptors listed twice by id count once. */
30
32
  export declare function metricSpecs(catalog: readonly MetricDescriptor[]): MetricSpec[];
@@ -1,4 +1,4 @@
1
- /** Built-in metrics keep the query words people already use; every other key comes from the descriptor's id. */
1
+ /** Repometry's metrics keep short query words; every other key comes from the descriptor's id. */
2
2
  const builtinKeys = {
3
3
  'repometry.cyclomatic-babel/v1': 'complexity',
4
4
  'repometry.cognitive-babel/v1': 'cognitive',
@@ -7,7 +7,20 @@ const builtinKeys = {
7
7
  'repometry.lcov-line-coverage/v1': 'coverage',
8
8
  'repometry.duplicated-lines-babel/v1': 'duplication',
9
9
  'repometry.git-change-frequency/v1': 'changes',
10
+ 'repometry.lcov-branch-coverage/v1': 'branch-coverage',
11
+ 'repometry.lcov-covered-branches/v1': 'covered-branches',
12
+ 'repometry.lcov-coverable-branches/v1': 'coverable-branches',
13
+ 'repometry.lcov-function-coverage/v1': 'function-coverage',
14
+ 'repometry.lcov-covered-functions/v1': 'covered-functions',
15
+ 'repometry.lcov-coverable-functions/v1': 'coverable-functions',
10
16
  };
17
+ /** The Repometry metrics the viewer draws from typed fields, with their own labels, columns and charts. */
18
+ const handDrawn = new Set([
19
+ 'repometry.physical-lines/v1', 'repometry.functions/v1', 'repometry.cyclomatic-babel/v1', 'repometry.cognitive-babel/v1',
20
+ 'repometry.classes-babel/v1', 'repometry.code-lines-babel/v1', 'repometry.comment-lines-babel/v1',
21
+ 'repometry.duplicated-lines-babel/v1', 'repometry.lcov-line-coverage/v1', 'repometry.lcov-covered-lines/v1',
22
+ 'repometry.lcov-coverable-lines/v1', 'repometry.git-change-frequency/v1',
23
+ ]);
11
24
  /** Words that already mean something: query keys, Trends views and the series the viewer draws by hand. */
12
25
  const reserved = new Set(['lang', 'language', 'component', 'path', 'in', 'has', 'analysed', 'ignored', 'lockfile', 'lockfiles', 'remediation', 'missedlines', 'churn',
13
26
  'debt', 'debt-changes', 'diff-coverage', 'effort', 'smells', 'files', 'classes', 'comments', 'code-lines', 'security',
@@ -15,9 +28,9 @@ const reserved = new Set(['lang', 'language', 'component', 'path', 'in', 'has',
15
28
  ...Object.values(builtinKeys)]);
16
29
  /** Curated groups first, in this order; groups named by plugins follow in catalog order. */
17
30
  export const curatedGroups = ['Maintainability', 'Coverage', 'Security', 'Size'];
18
- /** Repometry's own metrics, which the viewer draws from their typed fields. */
31
+ /** The metrics the viewer draws from their typed fields; a Repometry metric it has no code for goes by its descriptor. */
19
32
  export function isBuiltin(descriptor) {
20
- return descriptor.id.startsWith('repometry.');
33
+ return handDrawn.has(descriptor.id);
21
34
  }
22
35
  function parts(id) {
23
36
  const bare = id.replace(/\/v\d+$/, '');
@@ -33,19 +46,24 @@ export function metricSpecs(catalog) {
33
46
  const { plugin, name } = parts(id);
34
47
  owners.set(name, (owners.get(name) ?? new Set()).add(plugin));
35
48
  }
49
+ // The counts a ratio is made of (covered and measured branches) read through the ratio: no chart, column or rank of their own.
50
+ const ratioParts = new Set(unique.flatMap(({ ratio }) => ratio ? [ratio.of, ratio.over] : []));
36
51
  return unique.map(descriptor => {
37
52
  const { plugin, name } = parts(descriptor.id);
38
53
  const builtin = builtinKeys[descriptor.id];
39
54
  const key = builtin ?? (owners.get(name).size > 1 || reserved.has(name.toLowerCase()) ? `${plugin}.${name}` : name);
40
55
  const rolls = descriptor.aggregate !== 'none' || descriptor.ratio !== undefined;
56
+ const ranked = descriptor.scope === 'file' && descriptor.better !== 'none' && !ratioParts.has(descriptor.id);
41
57
  return {
42
58
  descriptor, key, plugin,
43
59
  label: descriptor.label,
44
60
  short: descriptor.short ?? descriptor.label,
45
61
  group: descriptor.group ?? plugin,
46
- column: descriptor.scope === 'file' && descriptor.better !== 'none',
47
- hotspot: descriptor.scope === 'file' && descriptor.better !== 'none' && rolls,
48
- trend: descriptor.scope === 'repository' || rolls,
62
+ // Repometry's own columns are curated; its metrics without a hand-made column are there to pick, not shown first.
63
+ column: ranked && plugin !== 'repometry',
64
+ hotspot: ranked && rolls,
65
+ trend: !ratioParts.has(descriptor.id) && (descriptor.scope === 'repository' || rolls),
66
+ ratioPart: ratioParts.has(descriptor.id),
49
67
  };
50
68
  });
51
69
  }
@@ -220,7 +220,7 @@ function pagedTable(spec) {
220
220
  render();
221
221
  return box;
222
222
  }
223
- /** Without the details (the public view) only the exclusions are known; the profile itself is not published. */
223
+ /** Until the details arrive only the exclusions are known; the summary does not carry the profile itself. */
224
224
  function fallback(data) {
225
225
  const section = block('Files');
226
226
  const exclusions = data.context?.exclusions;
@@ -230,8 +230,8 @@ function fallback(data) {
230
230
  facts.append(row('Excluded directories', exclusions.directories.length ? chips(exclusions.directories.map(directory => `**/${directory}/`)) : none()));
231
231
  section.append(facts);
232
232
  }
233
- section.append(element('p', 'detail', data.details ? 'This inspection did not record its profile.'
234
- : 'The applied profile is shown in the local and private views.'));
233
+ if (data.details)
234
+ section.append(element('p', 'detail', 'This inspection did not record its profile.'));
235
235
  return section;
236
236
  }
237
237
  const formatKey = 'repometry.badge-format';