repometry 0.6.2 → 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/package.json +1 -1
- package/target/main/resources/config/process-plugins-v1.schema.json +75 -0
- package/target/main/resources/report/json/report-v2.schema.json +21 -1
- package/target/main/resources/report/json/repository-summary-v1.schema.json +9 -0
- package/target/main/resources/report/json/viewer-inspection-v1.schema.json +11 -3
- package/target/main/resources/viewer/files.css +6 -0
- package/target/main/resources/viewer/index.html +1 -1
- package/target/main/resources/viewer/styles.css +1 -0
- package/target/main/ts/cli/config.d.ts +1 -0
- package/target/main/ts/cli/config.js +3 -2
- package/target/main/ts/cli/main.js +37 -19
- package/target/main/ts/cli/reporting.js +3 -3
- package/target/main/ts/compose/analysis-files.d.ts +1 -0
- package/target/main/ts/compose/analysis-files.js +27 -7
- package/target/main/ts/compose/analysis-imports.js +2 -1
- package/target/main/ts/compose/analysis-report.js +7 -3
- package/target/main/ts/compose/analysis-results.d.ts +4 -1
- package/target/main/ts/compose/analysis-results.js +3 -0
- package/target/main/ts/compose/analysis-sources.js +2 -1
- package/target/main/ts/compose/languages.js +4 -1
- package/target/main/ts/compose/plugin-list.d.ts +11 -2
- package/target/main/ts/compose/plugin-list.js +4 -1
- package/target/main/ts/compose/process-plugins.d.ts +2 -0
- package/target/main/ts/compose/process-plugins.js +63 -0
- package/target/main/ts/compose/structure-measures.d.ts +5 -0
- package/target/main/ts/compose/structure-measures.js +57 -0
- package/target/main/ts/core/engine/manifest.js +5 -1
- package/target/main/ts/core/model/clone-source.js +0 -1
- package/target/main/ts/core/model/code-structure.d.ts +14 -9
- package/target/main/ts/core/model/code-structure.js +23 -10
- package/target/main/ts/core/model/language.d.ts +2 -0
- package/target/main/ts/core/model/plugin-data.d.ts +2 -0
- package/target/main/ts/core/model/quality-summary.d.ts +4 -0
- package/target/main/ts/core/model/quality-summary.js +53 -29
- package/target/main/ts/core/model/report.d.ts +6 -0
- package/target/main/ts/plugin.d.ts +1 -1
- package/target/main/ts/plugins/coverage/coverage.d.ts +2 -1
- package/target/main/ts/plugins/coverage/coverage.js +40 -30
- package/target/main/ts/plugins/language-js/function-facts.d.ts +1 -1
- package/target/main/ts/plugins/language-js/function-facts.js +0 -1
- package/target/main/ts/plugins/language-js/js-security.js +25 -37
- package/target/main/ts/plugins/language-js/structural-observations.js +5 -4
- package/target/main/ts/plugins/maintainability/maintainability.d.ts +1 -1
- package/target/main/ts/plugins/maintainability/maintainability.js +9 -8
- package/target/main/ts/plugins/security/dockerfile.js +45 -37
- package/target/main/ts/plugins/structure/structure.js +2 -2
- package/target/main/ts/report/html/app/viewer-code-map.js +6 -5
- package/target/main/ts/report/html/app/viewer-columns.d.ts +2 -0
- package/target/main/ts/report/html/app/viewer-columns.js +9 -4
- package/target/main/ts/report/html/app/viewer-data.d.ts +2 -1
- package/target/main/ts/report/html/app/viewer-data.js +1 -1
- package/target/main/ts/report/html/app/viewer-file-aside.d.ts +5 -9
- package/target/main/ts/report/html/app/viewer-file-aside.js +18 -8
- package/target/main/ts/report/html/app/viewer-file-figures.d.ts +2 -0
- package/target/main/ts/report/html/app/viewer-file-figures.js +6 -1
- package/target/main/ts/report/html/app/viewer-hotspots.js +7 -5
- package/target/main/ts/report/html/app/viewer-inspection.js +1 -1
- package/target/main/ts/report/html/app/viewer-issue-group.js +2 -2
- package/target/main/ts/report/html/app/viewer-languages.d.ts +3 -2
- package/target/main/ts/report/html/app/viewer-languages.js +14 -7
- package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +4 -4
- package/target/main/ts/report/html/app/viewer-line-coverage.js +11 -24
- package/target/main/ts/report/html/app/viewer-map-scale.d.ts +1 -1
- package/target/main/ts/report/html/app/viewer-map-scale.js +1 -1
- package/target/main/ts/report/html/app/viewer-map-shape.d.ts +2 -2
- package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +0 -3
- package/target/main/ts/report/html/app/viewer-metric-registry.js +0 -9
- package/target/main/ts/report/html/app/viewer-metrics-view.js +1 -4
- package/target/main/ts/report/html/app/viewer-metrics.d.ts +2 -0
- package/target/main/ts/report/html/app/viewer-metrics.js +5 -0
- package/target/main/ts/report/html/app/viewer-overview-cards.js +4 -1
- package/target/main/ts/report/html/app/viewer-overview-hotspots.js +2 -2
- package/target/main/ts/report/html/app/viewer-profile.js +15 -1
- package/target/main/ts/report/html/app/viewer-source-view.js +7 -6
- package/target/main/ts/report/html/app/viewer-table-cells.js +8 -2
- package/target/main/ts/report/html/app/viewer-table-rows.d.ts +2 -0
- package/target/main/ts/report/html/app/viewer-table-rows.js +7 -5
- package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +2 -5
- package/target/main/ts/report/html/app/viewer-tokenizer.js +9 -12
- package/target/main/ts/report/html/app/viewer-totals.d.ts +6 -0
- package/target/main/ts/report/html/app/viewer-totals.js +11 -0
- package/target/main/ts/report/html/app/viewer-trend-data.d.ts +1 -1
- package/target/main/ts/report/html/app/viewer-trend-data.js +1 -1
- package/target/main/ts/report/html/app/viewer-trend-nav.js +3 -2
- package/target/main/ts/report/html/app/viewer.js +1 -7
- package/target/main/ts/report/json/projections/commit-summary.js +5 -0
- package/target/main/ts/report/json/projections/file-metrics.js +20 -4
- package/target/main/ts/report/json/projections/inspection-details.js +32 -14
- package/target/main/ts/report/json/projections/metric-values.d.ts +1 -0
- package/target/main/ts/report/json/projections/metric-values.js +36 -3
- package/target/main/ts/report/json/wire/inspection-details-model.d.ts +8 -1
|
@@ -45,7 +45,8 @@ export function fileMetrics(report, registry = { id: fileTypeId, catalog: [] })
|
|
|
45
45
|
entry.provider = provider;
|
|
46
46
|
}
|
|
47
47
|
const duplicatedLines = collectMeasurements(report.measurements, file, pluginMetrics !== undefined);
|
|
48
|
-
|
|
48
|
+
const skipped = new Set(report.ruleSkips?.map(({ path }) => path));
|
|
49
|
+
addFileQuality(byPath, duplicatedLines, report.findings, skipped);
|
|
49
50
|
let unassignedDiagnostics = 0;
|
|
50
51
|
for (const diagnostic of report.diagnostics) {
|
|
51
52
|
const { path, operation } = diagnostic;
|
|
@@ -67,7 +68,7 @@ export function fileMetrics(report, registry = { id: fileTypeId, catalog: [] })
|
|
|
67
68
|
if (Object.keys(values).length)
|
|
68
69
|
entry.values = values;
|
|
69
70
|
}
|
|
70
|
-
if (entry.functions === 0 && !entry.complexity) {
|
|
71
|
+
if (entry.functions === 0 && !entry.complexity && pluginMetrics?.isAvailable(definitions.complexity, entry.path) !== false) {
|
|
71
72
|
entry.complexity = { sum: 0, maximum: null, measuredFunctions: 0 };
|
|
72
73
|
}
|
|
73
74
|
let path = entry.path;
|
|
@@ -86,6 +87,7 @@ export function fileMetrics(report, registry = { id: fileTypeId, catalog: [] })
|
|
|
86
87
|
const values = pluginMetrics.values(entry.path, true);
|
|
87
88
|
if (Object.keys(values).length)
|
|
88
89
|
entry.values = values;
|
|
90
|
+
applyDirectoryAvailability(entry, pluginMetrics.isAvailable);
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
const complexity = files.filter(entry => entry.complexity?.maximum != null)
|
|
@@ -141,7 +143,21 @@ function collectMeasurements(rows, file, includeMeasuredFiles) {
|
|
|
141
143
|
}
|
|
142
144
|
return duplicated;
|
|
143
145
|
}
|
|
144
|
-
function
|
|
146
|
+
function applyDirectoryAvailability(entry, available) {
|
|
147
|
+
const known = (id) => available(id, entry.path, true);
|
|
148
|
+
if (!known(definitions.functions))
|
|
149
|
+
entry.functions = null;
|
|
150
|
+
if (!known(definitions.complexity))
|
|
151
|
+
entry.complexity = null;
|
|
152
|
+
if (!entry.quality)
|
|
153
|
+
return;
|
|
154
|
+
for (const [id, field] of qualityFields)
|
|
155
|
+
if (!known(id))
|
|
156
|
+
delete entry.quality[field];
|
|
157
|
+
if (!known(definitions.duplicatedLines) || !known(definitions.codeLines))
|
|
158
|
+
delete entry.quality.duplication;
|
|
159
|
+
}
|
|
160
|
+
function addFileQuality(byPath, duplicated, findings, skipped) {
|
|
145
161
|
for (const [path, duplicatedLines] of duplicated) {
|
|
146
162
|
const entry = byPath.get(path);
|
|
147
163
|
const codeLines = entry?.quality?.codeLines;
|
|
@@ -149,7 +165,7 @@ function addFileQuality(byPath, duplicated, findings) {
|
|
|
149
165
|
continue;
|
|
150
166
|
const result = quality(entry);
|
|
151
167
|
result.duplication = { duplicatedLines, codeLines };
|
|
152
|
-
if (findings !== undefined)
|
|
168
|
+
if (findings !== undefined && !skipped.has(path))
|
|
153
169
|
result.maintainability = { smells: 0, effortMinutes: 0 };
|
|
154
170
|
}
|
|
155
171
|
for (const finding of findings ?? []) {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { javascriptType, typescriptType } from '../../../core/model/file-types.js';
|
|
2
|
+
import { isRecord } from '../../../core/model/plugin-data.js';
|
|
3
|
+
import { legacySyntaxPlugin } from '../../../core/model/report.js';
|
|
1
4
|
import { canonicalMetricId, definitions } from '../../../core/model/measurement.js';
|
|
2
5
|
import { lcovLines } from '../../../core/model/line-coverage.js';
|
|
3
6
|
import { comparePaths } from '../../../core/model/snapshot.js';
|
|
4
7
|
import { fileMetrics } from './file-metrics.js';
|
|
5
8
|
import { inspectionContext } from './inspection-context.js';
|
|
9
|
+
import { isLanguageDisplay } from '../../../core/model/language.js';
|
|
6
10
|
import { componentFiles } from './components.js';
|
|
7
11
|
export function inspectionAsset(report, options) {
|
|
8
12
|
return { schema: 'urn:repometry:schema:viewer-inspection:1', sha: report.subject.id,
|
|
@@ -25,34 +29,48 @@ export function inspectionDetails(report, { components = [], languages } = {}) {
|
|
|
25
29
|
}
|
|
26
30
|
/** The applied configuration, field by field; whatever is missing or malformed is left out rather than guessed. */
|
|
27
31
|
export function profileSettings(applied) {
|
|
28
|
-
if (!
|
|
32
|
+
if (!isRecord(applied))
|
|
29
33
|
return undefined;
|
|
30
|
-
const source =
|
|
31
|
-
const maintainability =
|
|
32
|
-
const rules =
|
|
34
|
+
const source = isRecord(applied.source) ? applied.source : {};
|
|
35
|
+
const maintainability = isRecord(applied.maintainability) ? applied.maintainability : {};
|
|
36
|
+
const rules = isRecord(maintainability.structuralRules) ? Object.entries(maintainability.structuralRules).flatMap(([rule, value]) => isRecord(value) && finite(value.limit) && finite(value.minutesPerExcess)
|
|
33
37
|
? [{ plugin: 'maintainability', rule, limit: value.limit, minutesPerExcess: value.minutesPerExcess }] : []) : [];
|
|
34
38
|
const duplication = maintainability.duplication;
|
|
35
39
|
const model = maintainability.debtModel;
|
|
36
40
|
const churn = applied.churn;
|
|
41
|
+
const plugins = Array.isArray(applied.plugins) ? applied.plugins.filter(isRecord) : [];
|
|
42
|
+
const languages = profileLanguages(plugins, new Set(strings(source.extensions)));
|
|
37
43
|
return {
|
|
38
44
|
id: typeof applied.profile === 'string' ? applied.profile : null,
|
|
39
|
-
|
|
45
|
+
...(languages.length ? { languages } : {}),
|
|
40
46
|
excludedPaths: [...new Set([...strings(source.defaultExclusions), ...strings(source.excludedPaths), ...strings(source.generatedExcluded)])],
|
|
41
47
|
excludedDirectories: strings(source.excludedDirectories),
|
|
42
48
|
rules,
|
|
43
|
-
duplication:
|
|
49
|
+
duplication: isRecord(duplication) && finite(duplication.minCodeLines) && finite(duplication.minNodes) && finite(duplication.minutesPerRepeatedLine)
|
|
44
50
|
? { minCodeLines: duplication.minCodeLines, minNodes: duplication.minNodes, minutesPerRepeatedLine: duplication.minutesPerRepeatedLine } : null,
|
|
45
|
-
debtModel:
|
|
51
|
+
debtModel: isRecord(model) && typeof model.name === 'string' && finite(model.scale) && finite(model.exponent) && finite(model.minutesPerPersonMonth)
|
|
46
52
|
? { name: model.name, scale: model.scale, exponent: model.exponent, minutesPerPersonMonth: model.minutesPerPersonMonth } : null,
|
|
47
|
-
churn:
|
|
48
|
-
ignore: Array.isArray(applied.findingIgnore) ? applied.findingIgnore.flatMap(entry =>
|
|
49
|
-
analyzers:
|
|
50
|
-
? [{ id
|
|
51
|
-
? Object.fromEntries(Object.entries(
|
|
53
|
+
churn: isRecord(churn) && finite(churn.lookbackDays) && finite(churn.maxCommits) ? { lookbackDays: churn.lookbackDays, maxCommits: churn.maxCommits } : null,
|
|
54
|
+
ignore: Array.isArray(applied.findingIgnore) ? applied.findingIgnore.flatMap(entry => isRecord(entry) ? [Object.fromEntries(['tool', 'rule', 'path', 'reason'].flatMap(key => typeof entry[key] === 'string' ? [[key, entry[key]]] : []))] : []) : [],
|
|
55
|
+
analyzers: plugins.flatMap(({ id, version, tools }) => typeof id === 'string' && typeof version === 'string'
|
|
56
|
+
? [{ id, version, tools: isRecord(tools)
|
|
57
|
+
? Object.fromEntries(Object.entries(tools).filter((entry) => typeof entry[1] === 'string')) : {} }] : []),
|
|
52
58
|
};
|
|
53
59
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
60
|
+
function profileLanguages(plugins, recordedExtensions) {
|
|
61
|
+
const recorded = plugins.flatMap(({ id: plugin, providesLanguages }) => {
|
|
62
|
+
if (typeof plugin !== 'string' || !Array.isArray(providesLanguages))
|
|
63
|
+
return [];
|
|
64
|
+
return providesLanguages.flatMap(language => isRecord(language) && isLanguageDisplay(language)
|
|
65
|
+
? [{ plugin, id: language.id, label: language.label, extensions: strings(language.extensions), globs: strings(language.globs) }]
|
|
66
|
+
: []);
|
|
67
|
+
});
|
|
68
|
+
if (recorded.length)
|
|
69
|
+
return recorded;
|
|
70
|
+
return [javascriptType, typescriptType].flatMap(({ id, label, extensions }) => {
|
|
71
|
+
const selected = extensions.filter(ext => recordedExtensions.has(ext));
|
|
72
|
+
return selected.length ? [{ plugin: legacySyntaxPlugin, id, label, extensions: selected, globs: [] }] : [];
|
|
73
|
+
});
|
|
56
74
|
}
|
|
57
75
|
function finite(value) {
|
|
58
76
|
return typeof value === 'number' && Number.isFinite(value);
|
|
@@ -4,5 +4,6 @@ export declare function metricProjection(report: Report): {
|
|
|
4
4
|
catalog: MetricDescriptor[];
|
|
5
5
|
privateMetrics: string[] | undefined;
|
|
6
6
|
values: (path?: string, directory?: boolean) => MetricValues;
|
|
7
|
+
isAvailable: (id: string, path?: string, directory?: boolean) => boolean;
|
|
7
8
|
} | undefined;
|
|
8
9
|
export declare function canonicalMetricDescriptor(metric: MetricDescriptor): MetricDescriptor;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { canonicalMetricId } from '../../../core/model/measurement.js';
|
|
1
|
+
import { canonicalMetricId, definitions } from '../../../core/model/measurement.js';
|
|
2
|
+
const structureMetricIds = {
|
|
3
|
+
functions: definitions.functions, cyclomaticComplexity: definitions.complexity,
|
|
4
|
+
cognitiveComplexity: definitions.cognitiveComplexity, classes: definitions.classes,
|
|
5
|
+
commentLines: definitions.comments, codeLines: definitions.codeLines, duplication: definitions.duplicatedLines,
|
|
6
|
+
};
|
|
2
7
|
export function metricProjection(report) {
|
|
3
8
|
const metadata = report.pluginData;
|
|
4
9
|
if (!metadata?.metrics.length)
|
|
@@ -16,6 +21,31 @@ export function metricProjection(report) {
|
|
|
16
21
|
else
|
|
17
22
|
rows.set(id, [row]);
|
|
18
23
|
}
|
|
24
|
+
const unavailable = new Map();
|
|
25
|
+
for (const { path, unmeasured } of metadata.inventory ?? []) {
|
|
26
|
+
for (const measure of unmeasured ?? []) {
|
|
27
|
+
const id = structureMetricIds[measure];
|
|
28
|
+
if (id === undefined)
|
|
29
|
+
continue;
|
|
30
|
+
let files = unavailable.get(id);
|
|
31
|
+
if (!files)
|
|
32
|
+
unavailable.set(id, files = new Set());
|
|
33
|
+
files.add(path);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function isAvailable(id, path, directory = false) {
|
|
37
|
+
const files = unavailable.get(id);
|
|
38
|
+
if (!files)
|
|
39
|
+
return true;
|
|
40
|
+
if (path === undefined || (directory && path === ''))
|
|
41
|
+
return false;
|
|
42
|
+
if (!directory)
|
|
43
|
+
return !files.has(path);
|
|
44
|
+
for (const file of files)
|
|
45
|
+
if (file.startsWith(path + '/'))
|
|
46
|
+
return false;
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
19
49
|
function values(path, directory = false) {
|
|
20
50
|
const result = {};
|
|
21
51
|
for (const [index, metric] of metrics.entries()) {
|
|
@@ -23,7 +53,10 @@ export function metricProjection(report) {
|
|
|
23
53
|
continue;
|
|
24
54
|
const rowValues = (id) => rows.get(id) ?? [];
|
|
25
55
|
let value;
|
|
26
|
-
if (metric.
|
|
56
|
+
if (!isAvailable(metric.id, path, directory)) {
|
|
57
|
+
value = null;
|
|
58
|
+
}
|
|
59
|
+
else if (metric.ratio) {
|
|
27
60
|
const numerator = rollup(rowValues(metric.ratio.of), 'sum', path, directory);
|
|
28
61
|
const denominator = rollup(rowValues(metric.ratio.over), 'sum', path, directory);
|
|
29
62
|
value = denominator && numerator !== null ? numerator / denominator : null;
|
|
@@ -37,7 +70,7 @@ export function metricProjection(report) {
|
|
|
37
70
|
return result;
|
|
38
71
|
}
|
|
39
72
|
const privateMetrics = metadata.privateMetrics?.map(canonicalMetricId).filter(id => measured.has(id));
|
|
40
|
-
return { catalog: metrics, privateMetrics: privateMetrics?.length ? privateMetrics : undefined, values };
|
|
73
|
+
return { catalog: metrics, privateMetrics: privateMetrics?.length ? privateMetrics : undefined, values, isAvailable };
|
|
41
74
|
}
|
|
42
75
|
export function canonicalMetricDescriptor(metric) {
|
|
43
76
|
const id = canonicalMetricId(metric.id);
|
|
@@ -22,7 +22,7 @@ export interface InspectionDetails {
|
|
|
22
22
|
/** What the inspection read and how it scored it: a projection of the report's applied configuration. */
|
|
23
23
|
export interface ProfileSettings {
|
|
24
24
|
readonly id: string | null;
|
|
25
|
-
readonly
|
|
25
|
+
readonly languages?: readonly ProfileLanguage[];
|
|
26
26
|
readonly excludedPaths: readonly string[];
|
|
27
27
|
readonly excludedDirectories: readonly string[];
|
|
28
28
|
/** Every check the profile applies, each named with the plugin that runs it. */
|
|
@@ -60,6 +60,13 @@ export interface ProfileSettings {
|
|
|
60
60
|
readonly tools: Readonly<Record<string, string>>;
|
|
61
61
|
}[];
|
|
62
62
|
}
|
|
63
|
+
export interface ProfileLanguage {
|
|
64
|
+
readonly plugin: string;
|
|
65
|
+
readonly id: string;
|
|
66
|
+
readonly label: string;
|
|
67
|
+
readonly extensions: readonly string[];
|
|
68
|
+
readonly globs: readonly string[];
|
|
69
|
+
}
|
|
63
70
|
export interface ProfileRule {
|
|
64
71
|
readonly source: string;
|
|
65
72
|
readonly kind: 'check' | 'scanner';
|