repometry 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +27 -2
- package/package.json +63 -4
- package/target/main/resources/report/json/compact-json-v1.schema.json +24 -0
- package/target/main/resources/report/json/comparison-v1.schema.json +65 -0
- package/target/main/resources/report/json/config-v1.schema.json +34 -0
- package/target/main/resources/report/json/diff-coverage-v1.schema.json +55 -0
- package/target/main/resources/report/json/file-metrics-v1.schema.json +134 -0
- package/target/main/resources/report/json/inspection-context-v1.schema.json +172 -0
- package/target/main/resources/report/json/metabranch-v1.schema.json +9 -0
- package/target/main/resources/report/json/metric-catalog-v1.schema.json +31 -0
- package/target/main/resources/report/json/public-history-v1.schema.json +50 -0
- package/target/main/resources/report/json/pull-review-v1.schema.json +97 -0
- package/target/main/resources/report/json/quality-history-v1.schema.json +51 -0
- package/target/main/resources/report/json/report-v1.schema.json +65 -0
- package/target/main/resources/report/json/report-v2.schema.json +238 -0
- package/target/main/resources/report/json/repository-summary-v1.schema.json +181 -0
- package/target/main/resources/report/json/viewer-details-v1.schema.json +343 -0
- package/target/main/resources/report/json/viewer-inspection-v1.schema.json +13 -0
- package/target/main/resources/viewer/files.css +578 -0
- package/target/main/resources/viewer/index.html +130 -0
- package/target/main/resources/viewer/projects.html +52 -0
- package/target/main/resources/viewer/styles.css +586 -0
- package/target/main/resources/viewer/viewer-pulls.css +64 -0
- package/target/main/ts/api/gh/github-pr-comment.d.ts +4 -0
- package/target/main/ts/api/gh/github-pr-comment.js +107 -0
- package/target/main/ts/api/gh/github.d.ts +6 -0
- package/target/main/ts/api/gh/github.js +91 -0
- package/target/main/ts/api/git/blob-batch.d.ts +10 -0
- package/target/main/ts/api/git/blob-batch.js +105 -0
- package/target/main/ts/api/git/changes.d.ts +22 -0
- package/target/main/ts/api/git/changes.js +107 -0
- package/target/main/ts/api/git/commit-metadata.d.ts +3 -0
- package/target/main/ts/api/git/commit-metadata.js +54 -0
- package/target/main/ts/api/git/git-churn.d.ts +9 -0
- package/target/main/ts/api/git/git-churn.js +70 -0
- package/target/main/ts/api/git/git-reader.d.ts +16 -0
- package/target/main/ts/api/git/git-reader.js +73 -0
- package/target/main/ts/api/git/git.d.ts +21 -0
- package/target/main/ts/api/git/git.js +152 -0
- package/target/main/ts/api/git/inspection-source.d.ts +15 -0
- package/target/main/ts/api/git/inspection-source.js +30 -0
- package/target/main/ts/api/git/local-sources.d.ts +5 -0
- package/target/main/ts/api/git/local-sources.js +46 -0
- package/target/main/ts/api/git/local.d.ts +3 -0
- package/target/main/ts/api/git/local.js +35 -0
- package/target/main/ts/api/git/metabranch-worktree.d.ts +1 -0
- package/target/main/ts/api/git/metabranch-worktree.js +34 -0
- package/target/main/ts/api/git/source-cache.d.ts +3 -0
- package/target/main/ts/api/git/source-cache.js +56 -0
- package/target/main/ts/api/import/finding-import.d.ts +9 -0
- package/target/main/ts/api/import/finding-import.js +226 -0
- package/target/main/ts/api/import/lcov-files.d.ts +5 -0
- package/target/main/ts/api/import/lcov-files.js +13 -0
- package/target/main/ts/api/import/profile-file.d.ts +4 -0
- package/target/main/ts/api/import/profile-file.js +16 -0
- package/target/main/ts/api/worker/remote-executor.d.ts +2 -0
- package/target/main/ts/api/worker/remote-executor.js +45 -0
- package/target/main/ts/api/worker/worker-protocol.d.ts +7 -0
- package/target/main/ts/api/worker/worker-protocol.js +101 -0
- package/target/main/ts/api/worker/worker.d.ts +5 -0
- package/target/main/ts/api/worker/worker.js +85 -0
- package/target/main/ts/cli/arguments.d.ts +28 -0
- package/target/main/ts/cli/arguments.js +110 -0
- package/target/main/ts/cli/config.d.ts +14 -0
- package/target/main/ts/cli/config.js +60 -0
- package/target/main/ts/cli/github-pr-comment.d.ts +1 -0
- package/target/main/ts/cli/github-pr-comment.js +12 -0
- package/target/main/ts/cli/imports.d.ts +7 -0
- package/target/main/ts/cli/imports.js +29 -0
- package/target/main/ts/cli/main.d.ts +2 -0
- package/target/main/ts/cli/main.js +378 -0
- package/target/main/ts/cli/reporting.d.ts +18 -0
- package/target/main/ts/cli/reporting.js +108 -0
- package/target/main/ts/cli/revisions.d.ts +6 -0
- package/target/main/ts/cli/revisions.js +15 -0
- package/target/main/ts/cli/store.d.ts +13 -0
- package/target/main/ts/cli/store.js +38 -0
- package/target/main/ts/compose/analyze-snapshot.d.ts +4 -0
- package/target/main/ts/compose/analyze-snapshot.js +163 -0
- package/target/main/ts/compose/attach-churn.d.ts +2 -0
- package/target/main/ts/compose/attach-churn.js +37 -0
- package/target/main/ts/compose/diff-coverage.d.ts +20 -0
- package/target/main/ts/compose/diff-coverage.js +56 -0
- package/target/main/ts/compose/inspect.d.ts +23 -0
- package/target/main/ts/compose/inspect.js +44 -0
- package/target/main/ts/compose/plugin-list.d.ts +6 -0
- package/target/main/ts/compose/plugin-list.js +9 -0
- package/target/main/ts/compose/prepare-metabranch.d.ts +9 -0
- package/target/main/ts/compose/prepare-metabranch.js +16 -0
- package/target/main/ts/compose/review.d.ts +16 -0
- package/target/main/ts/compose/review.js +38 -0
- package/target/main/ts/compose/sources.d.ts +3 -0
- package/target/main/ts/compose/sources.js +29 -0
- package/target/main/ts/core/engine/execute.d.ts +10 -0
- package/target/main/ts/core/engine/execute.js +49 -0
- package/target/main/ts/core/engine/manifest.d.ts +4 -0
- package/target/main/ts/core/engine/manifest.js +104 -0
- package/target/main/ts/core/engine/plan.d.ts +22 -0
- package/target/main/ts/core/engine/plan.js +106 -0
- package/target/main/ts/core/engine/plugin.d.ts +59 -0
- package/target/main/ts/core/engine/plugin.js +4 -0
- package/target/main/ts/core/engine/report-products.d.ts +16 -0
- package/target/main/ts/core/engine/report-products.js +85 -0
- package/target/main/ts/core/model/changes.d.ts +8 -0
- package/target/main/ts/core/model/changes.js +1 -0
- package/target/main/ts/core/model/churn.d.ts +11 -0
- package/target/main/ts/core/model/churn.js +5 -0
- package/target/main/ts/core/model/clone-source.d.ts +16 -0
- package/target/main/ts/core/model/clone-source.js +14 -0
- package/target/main/ts/core/model/code-structure.d.ts +30 -0
- package/target/main/ts/core/model/code-structure.js +31 -0
- package/target/main/ts/core/model/comparison.d.ts +24 -0
- package/target/main/ts/core/model/comparison.js +1 -0
- package/target/main/ts/core/model/diff-coverage.d.ts +23 -0
- package/target/main/ts/core/model/diff-coverage.js +1 -0
- package/target/main/ts/core/model/finding-ignore.d.ts +8 -0
- package/target/main/ts/core/model/finding-ignore.js +35 -0
- package/target/main/ts/core/model/finding.d.ts +28 -0
- package/target/main/ts/core/model/finding.js +29 -0
- package/target/main/ts/core/model/ignore-rule.d.ts +11 -0
- package/target/main/ts/core/model/ignore-rule.js +1 -0
- package/target/main/ts/core/model/measurement.d.ts +27 -0
- package/target/main/ts/core/model/measurement.js +24 -0
- package/target/main/ts/core/model/metric-descriptor.d.ts +17 -0
- package/target/main/ts/core/model/metric-descriptor.js +1 -0
- package/target/main/ts/core/model/plugin-data.d.ts +25 -0
- package/target/main/ts/core/model/plugin-data.js +1 -0
- package/target/main/ts/core/model/pull-review.d.ts +48 -0
- package/target/main/ts/core/model/pull-review.js +1 -0
- package/target/main/ts/core/model/quality-summary.d.ts +42 -0
- package/target/main/ts/core/model/quality-summary.js +64 -0
- package/target/main/ts/core/model/report.d.ts +32 -0
- package/target/main/ts/core/model/report.js +5 -0
- package/target/main/ts/core/model/scanner-import.d.ts +39 -0
- package/target/main/ts/core/model/scanner-import.js +28 -0
- package/target/main/ts/core/model/snapshot.d.ts +15 -0
- package/target/main/ts/core/model/snapshot.js +50 -0
- package/target/main/ts/core/model/source-locator.d.ts +7 -0
- package/target/main/ts/core/model/source-locator.js +1 -0
- package/target/main/ts/core/model/source.d.ts +23 -0
- package/target/main/ts/core/model/source.js +1 -0
- package/target/main/ts/core/ports/report.d.ts +9 -0
- package/target/main/ts/core/ports/report.js +1 -0
- package/target/main/ts/core/ports/source-provider.d.ts +14 -0
- package/target/main/ts/core/ports/source-provider.js +4 -0
- package/target/main/ts/core/profile/exclusions.d.ts +11 -0
- package/target/main/ts/core/profile/exclusions.js +57 -0
- package/target/main/ts/core/profile/maintainability.d.ts +31 -0
- package/target/main/ts/core/profile/maintainability.js +9 -0
- package/target/main/ts/core/profile/profile.d.ts +4 -0
- package/target/main/ts/core/profile/profile.js +10 -0
- package/target/main/ts/core/usecases/compare.d.ts +6 -0
- package/target/main/ts/core/usecases/compare.js +145 -0
- package/target/main/ts/core/usecases/diff-coverage-policy.d.ts +6 -0
- package/target/main/ts/core/usecases/diff-coverage-policy.js +10 -0
- package/target/main/ts/core/usecases/diff-coverage.d.ts +40 -0
- package/target/main/ts/core/usecases/diff-coverage.js +15 -0
- package/target/main/ts/core/usecases/inspect.d.ts +38 -0
- package/target/main/ts/core/usecases/inspect.js +41 -0
- package/target/main/ts/core/usecases/review.d.ts +31 -0
- package/target/main/ts/core/usecases/review.js +128 -0
- package/target/main/ts/index.d.ts +35 -0
- package/target/main/ts/index.js +17 -0
- package/target/main/ts/plugin.d.ts +14 -0
- package/target/main/ts/plugin.js +5 -0
- package/target/main/ts/plugins/coverage/coverage.d.ts +23 -0
- package/target/main/ts/plugins/coverage/coverage.js +120 -0
- package/target/main/ts/plugins/coverage/diff-coverage.d.ts +7 -0
- package/target/main/ts/plugins/coverage/diff-coverage.js +89 -0
- package/target/main/ts/plugins/duplication/duplication.d.ts +4 -0
- package/target/main/ts/plugins/duplication/duplication.js +93 -0
- package/target/main/ts/plugins/language-js/babel-provider.d.ts +10 -0
- package/target/main/ts/plugins/language-js/babel-provider.js +46 -0
- package/target/main/ts/plugins/language-js/clone-candidates.d.ts +3 -0
- package/target/main/ts/plugins/language-js/clone-candidates.js +64 -0
- package/target/main/ts/plugins/language-js/code-lines.d.ts +6 -0
- package/target/main/ts/plugins/language-js/code-lines.js +35 -0
- package/target/main/ts/plugins/language-js/function-facts.d.ts +8 -0
- package/target/main/ts/plugins/language-js/function-facts.js +60 -0
- package/target/main/ts/plugins/language-js/structural-observations.d.ts +8 -0
- package/target/main/ts/plugins/language-js/structural-observations.js +79 -0
- package/target/main/ts/plugins/maintainability/maintainability.d.ts +9 -0
- package/target/main/ts/plugins/maintainability/maintainability.js +42 -0
- package/target/main/ts/plugins/maintainability/structural-smells.d.ts +3 -0
- package/target/main/ts/plugins/maintainability/structural-smells.js +15 -0
- package/target/main/ts/plugins/source/forges.d.ts +4 -0
- package/target/main/ts/plugins/source/forges.js +79 -0
- package/target/main/ts/plugins/structure/structure.d.ts +2 -0
- package/target/main/ts/plugins/structure/structure.js +37 -0
- package/target/main/ts/report/html/app/viewer-access.d.ts +19 -0
- package/target/main/ts/report/html/app/viewer-access.js +25 -0
- package/target/main/ts/report/html/app/viewer-chart.d.ts +101 -0
- package/target/main/ts/report/html/app/viewer-chart.js +711 -0
- package/target/main/ts/report/html/app/viewer-commits.d.ts +36 -0
- package/target/main/ts/report/html/app/viewer-commits.js +280 -0
- package/target/main/ts/report/html/app/viewer-data.d.ts +23 -0
- package/target/main/ts/report/html/app/viewer-data.js +105 -0
- package/target/main/ts/report/html/app/viewer-files.d.ts +117 -0
- package/target/main/ts/report/html/app/viewer-files.js +2087 -0
- package/target/main/ts/report/html/app/viewer-filter.d.ts +113 -0
- package/target/main/ts/report/html/app/viewer-filter.js +492 -0
- package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +68 -0
- package/target/main/ts/report/html/app/viewer-metric-registry.js +206 -0
- package/target/main/ts/report/html/app/viewer-metrics.d.ts +44 -0
- package/target/main/ts/report/html/app/viewer-metrics.js +172 -0
- package/target/main/ts/report/html/app/viewer-profile.d.ts +17 -0
- package/target/main/ts/report/html/app/viewer-profile.js +401 -0
- package/target/main/ts/report/html/app/viewer-projects.d.ts +1 -0
- package/target/main/ts/report/html/app/viewer-projects.js +90 -0
- package/target/main/ts/report/html/app/viewer-pulls.d.ts +3 -0
- package/target/main/ts/report/html/app/viewer-pulls.js +242 -0
- package/target/main/ts/report/html/app/viewer-source.d.ts +75 -0
- package/target/main/ts/report/html/app/viewer-source.js +313 -0
- package/target/main/ts/report/html/app/viewer-trends.d.ts +74 -0
- package/target/main/ts/report/html/app/viewer-trends.js +413 -0
- package/target/main/ts/report/html/app/viewer.d.ts +1 -0
- package/target/main/ts/report/html/app/viewer.js +794 -0
- package/target/main/ts/report/html/site/badges.d.ts +14 -0
- package/target/main/ts/report/html/site/badges.js +39 -0
- package/target/main/ts/report/html/site/export-site.d.ts +21 -0
- package/target/main/ts/report/html/site/export-site.js +157 -0
- package/target/main/ts/report/html/site/exported-server.d.ts +6 -0
- package/target/main/ts/report/html/site/exported-server.js +70 -0
- package/target/main/ts/report/html/site/local-server.d.ts +7 -0
- package/target/main/ts/report/html/site/local-server.js +64 -0
- package/target/main/ts/report/html/site/projects.d.ts +3 -0
- package/target/main/ts/report/html/site/projects.js +79 -0
- package/target/main/ts/report/html/site/server.d.ts +4 -0
- package/target/main/ts/report/html/site/server.js +64 -0
- package/target/main/ts/report/html/site/source-route.d.ts +6 -0
- package/target/main/ts/report/html/site/source-route.js +22 -0
- package/target/main/ts/report/json/projections/commit-summary.d.ts +11 -0
- package/target/main/ts/report/json/projections/commit-summary.js +118 -0
- package/target/main/ts/report/json/projections/components.d.ts +4 -0
- package/target/main/ts/report/json/projections/components.js +29 -0
- package/target/main/ts/report/json/projections/file-metrics.d.ts +5 -0
- package/target/main/ts/report/json/projections/file-metrics.js +243 -0
- package/target/main/ts/report/json/projections/inspection-context.d.ts +6 -0
- package/target/main/ts/report/json/projections/inspection-context.js +92 -0
- package/target/main/ts/report/json/projections/inspection-details.d.ts +11 -0
- package/target/main/ts/report/json/projections/inspection-details.js +69 -0
- package/target/main/ts/report/json/projections/metric-values.d.ts +7 -0
- package/target/main/ts/report/json/projections/metric-values.js +57 -0
- package/target/main/ts/report/json/projections/public-history.d.ts +4 -0
- package/target/main/ts/report/json/projections/public-history.js +16 -0
- package/target/main/ts/report/json/store/components.d.ts +2 -0
- package/target/main/ts/report/json/store/components.js +31 -0
- package/target/main/ts/report/json/store/local-store.d.ts +13 -0
- package/target/main/ts/report/json/store/local-store.js +179 -0
- package/target/main/ts/report/json/store/pull-review-store.d.ts +3 -0
- package/target/main/ts/report/json/store/pull-review-store.js +51 -0
- package/target/main/ts/report/json/validation/metabranch.d.ts +4 -0
- package/target/main/ts/report/json/validation/metabranch.js +7 -0
- package/target/main/ts/report/json/validation/report.d.ts +15 -0
- package/target/main/ts/report/json/validation/report.js +64 -0
- package/target/main/ts/report/json/validation/summary-validation.d.ts +4 -0
- package/target/main/ts/report/json/validation/summary-validation.js +27 -0
- package/target/main/ts/report/json/wire/compact-json.d.ts +11 -0
- package/target/main/ts/report/json/wire/compact-json.js +76 -0
- package/target/main/ts/report/json/wire/component-model.d.ts +9 -0
- package/target/main/ts/report/json/wire/component-model.js +1 -0
- package/target/main/ts/report/json/wire/domain-types.d.ts +2 -0
- package/target/main/ts/report/json/wire/domain-types.js +1 -0
- package/target/main/ts/report/json/wire/file-metrics-model.d.ts +77 -0
- package/target/main/ts/report/json/wire/file-metrics-model.js +1 -0
- package/target/main/ts/report/json/wire/inspection-context-model.d.ts +26 -0
- package/target/main/ts/report/json/wire/inspection-context-model.js +1 -0
- package/target/main/ts/report/json/wire/inspection-details-model.d.ts +82 -0
- package/target/main/ts/report/json/wire/inspection-details-model.js +1 -0
- package/target/main/ts/report/json/wire/project-model.d.ts +7 -0
- package/target/main/ts/report/json/wire/project-model.js +1 -0
- package/target/main/ts/report/json/wire/public-history-model.d.ts +42 -0
- package/target/main/ts/report/json/wire/public-history-model.js +6 -0
- package/target/main/ts/report/json/wire/pull-review-model.d.ts +7 -0
- package/target/main/ts/report/json/wire/pull-review-model.js +1 -0
- package/target/main/ts/report/json/wire/summary-model.d.ts +45 -0
- package/target/main/ts/report/json/wire/summary-model.js +1 -0
- package/target/main/ts/report.d.ts +11 -0
- package/target/main/ts/report.js +5 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { copyIcon, multiChoice, navigationButtons, searchField, splitter } from './viewer-files.js';
|
|
2
|
+
import { count, duration, securityGrades, securityRisks } from './viewer-metrics.js';
|
|
3
|
+
/** What each structural rule measures, and in what unit its limit and its cost are counted. */
|
|
4
|
+
const ruleNames = {
|
|
5
|
+
'function-complexity': ['Cognitive complexity of a function', 'point'],
|
|
6
|
+
'file-complexity': ['Cognitive complexity of a file', 'point'],
|
|
7
|
+
'function-parameters': ['Parameters of a function', 'parameter'],
|
|
8
|
+
'return-statements': ['Return statements in a function', 'return'],
|
|
9
|
+
'boolean-logic': ['Operators in one condition', 'operator'],
|
|
10
|
+
'nested-control-flow': ['Depth of nested control flow', 'level'],
|
|
11
|
+
};
|
|
12
|
+
const ruleOrder = Object.keys(ruleNames);
|
|
13
|
+
export function renderProfile(container, data) {
|
|
14
|
+
const view = element('div', 'fx-view');
|
|
15
|
+
const split = element('div', 'fx-split profile');
|
|
16
|
+
const main = element('div', 'fx-main profile-main');
|
|
17
|
+
const profile = data.details?.profile;
|
|
18
|
+
if (profile)
|
|
19
|
+
main.append(identity(profile), files(profile), rules(profile), exclusions(profile, data.context));
|
|
20
|
+
else
|
|
21
|
+
main.append(fallback(data));
|
|
22
|
+
const scanners = data.context?.scanners;
|
|
23
|
+
if (scanners?.length) {
|
|
24
|
+
const section = block('Imported scanners');
|
|
25
|
+
section.append(chips(scanners.map(({ name, version }) => version ? `${name} ${version}` : name)));
|
|
26
|
+
main.append(section);
|
|
27
|
+
}
|
|
28
|
+
split.append(main, splitter(split), badges(data));
|
|
29
|
+
view.append(split);
|
|
30
|
+
container.replaceChildren(view);
|
|
31
|
+
}
|
|
32
|
+
/** The profile's name and the analyzers it ran, with their versions. */
|
|
33
|
+
function identity(profile) {
|
|
34
|
+
const section = block('Analyzers');
|
|
35
|
+
const facts = element('dl', 'profile-facts');
|
|
36
|
+
if (profile.id)
|
|
37
|
+
facts.append(row('Profile', code(profile.id)));
|
|
38
|
+
if (profile.analyzers.length) {
|
|
39
|
+
facts.append(row('Plugins', chips(profile.analyzers.map(analyzer => {
|
|
40
|
+
const tools = Object.entries(analyzer.tools).map(([tool, version]) => `${tool} ${version}`);
|
|
41
|
+
return `${analyzer.id} ${analyzer.version}${tools.length ? ` (${tools.join(', ')})` : ''}`;
|
|
42
|
+
}))));
|
|
43
|
+
}
|
|
44
|
+
if (profile.churn) {
|
|
45
|
+
facts.append(row('Change window', element('span', '', `${count(profile.churn.lookbackDays)} days, at most ${count(profile.churn.maxCommits)} commits`)));
|
|
46
|
+
}
|
|
47
|
+
section.append(facts);
|
|
48
|
+
return section;
|
|
49
|
+
}
|
|
50
|
+
/** What the inspection reads and what it leaves out, as the patterns the profile states. */
|
|
51
|
+
function files(profile) {
|
|
52
|
+
const section = block('Files');
|
|
53
|
+
const facts = element('dl', 'profile-facts');
|
|
54
|
+
facts.append(row('Included', profile.extensions.length ? chips(profile.extensions.map(extension => `**/*${extension}`)) : none('Every file')));
|
|
55
|
+
facts.append(row('Excluded paths', profile.excludedPaths.length ? chips(profile.excludedPaths) : none()));
|
|
56
|
+
facts.append(row('Excluded directories', profile.excludedDirectories.length
|
|
57
|
+
? chips(profile.excludedDirectories.map(directory => `**/${directory}/`)) : none()));
|
|
58
|
+
section.append(facts);
|
|
59
|
+
return section;
|
|
60
|
+
}
|
|
61
|
+
/** Every check the profile applies, from every plugin: what it measures, where its limit lies, what each unit past it costs. */
|
|
62
|
+
function rules(profile) {
|
|
63
|
+
const section = block('Rules');
|
|
64
|
+
const rows = profile.rules.map(rule => {
|
|
65
|
+
const [measure, unit] = ruleNames[rule.rule] ?? [null, 'unit'];
|
|
66
|
+
return { plugin: rule.plugin, rule: rule.rule, measure, limit: rule.limit, limitText: count(rule.limit),
|
|
67
|
+
minutes: rule.minutesPerExcess, cost: `${duration(rule.minutesPerExcess)} per ${unit} over` };
|
|
68
|
+
});
|
|
69
|
+
const duplication = profile.duplication;
|
|
70
|
+
if (duplication) {
|
|
71
|
+
rows.push({ plugin: 'duplication', rule: 'identical-code', measure: 'Repeated code', limit: duplication.minCodeLines,
|
|
72
|
+
limitText: `${count(duplication.minCodeLines)} lines, ${count(duplication.minNodes)} nodes`,
|
|
73
|
+
minutes: duplication.minutesPerRepeatedLine, cost: `${duration(duplication.minutesPerRepeatedLine)} per repeated line` });
|
|
74
|
+
}
|
|
75
|
+
rows.sort((a, b) => a.plugin.localeCompare(b.plugin) || order(a.rule) - order(b.rule) || a.rule.localeCompare(b.rule));
|
|
76
|
+
section.append(pagedTable({
|
|
77
|
+
label: 'Rules', noun: ['rule', 'rules'], rows, empty: 'The profile records no rules.', controls: true,
|
|
78
|
+
search: row => `${row.rule} ${row.plugin} ${row.measure ?? ''}`,
|
|
79
|
+
facet: { text: 'Plugin', all: 'All plugins', plural: 'plugins', key: row => row.plugin },
|
|
80
|
+
columns: [
|
|
81
|
+
{ label: 'Rule', cell: row => ruleCell(row.rule, row.measure), sort: row => row.rule },
|
|
82
|
+
{ label: 'Plugin', cell: row => element('span', 'profile-plugin', row.plugin), sort: row => row.plugin },
|
|
83
|
+
{ label: 'Limit', numeric: true, cell: row => row.limitText, sort: row => row.limit },
|
|
84
|
+
{ label: 'Cost', numeric: true, cell: row => row.cost, sort: row => row.minutes },
|
|
85
|
+
],
|
|
86
|
+
}));
|
|
87
|
+
return section;
|
|
88
|
+
}
|
|
89
|
+
function ruleCell(name, measure) {
|
|
90
|
+
const cell = element('span');
|
|
91
|
+
cell.append(element('code', 'profile-rule', name));
|
|
92
|
+
if (measure)
|
|
93
|
+
cell.append(element('span', 'profile-rule-meta', measure));
|
|
94
|
+
return cell;
|
|
95
|
+
}
|
|
96
|
+
/** The findings the profile tells the inspection to skip, by tool, rule and path. */
|
|
97
|
+
function exclusions(profile, context) {
|
|
98
|
+
const section = block('Rule exclusions');
|
|
99
|
+
const skipped = context?.ignores?.count;
|
|
100
|
+
if (profile.ignore.length && skipped !== undefined) {
|
|
101
|
+
section.append(element('p', 'detail', `${count(skipped)} ${skipped === 1 ? 'finding' : 'findings'} skipped at this commit.`));
|
|
102
|
+
}
|
|
103
|
+
section.append(pagedTable({
|
|
104
|
+
label: 'Rule exclusions', noun: ['exclusion', 'exclusions'], rows: profile.ignore,
|
|
105
|
+
empty: 'None. “Ignore rule” on an issue gives the entry to add to the profile’s ignore list.',
|
|
106
|
+
search: row => [row.tool, row.rule, row.path, row.reason].filter(Boolean).join(' '),
|
|
107
|
+
facet: { text: 'Tool', all: 'All tools', plural: 'tools', key: row => row.tool ?? 'Any tool' },
|
|
108
|
+
columns: [
|
|
109
|
+
{ label: 'Rule', cell: row => code([row.tool, row.rule].filter(Boolean).join(' / ') || 'Any rule'), sort: row => `${row.tool ?? ''} ${row.rule ?? ''}` },
|
|
110
|
+
{ label: 'Path', cell: row => row.path ? element('span', 'profile-ignore-path', row.path) : none('Everywhere'), sort: row => row.path ?? '' },
|
|
111
|
+
{ label: 'Reason', cell: row => row.reason ?? '', sort: row => row.reason ?? '' },
|
|
112
|
+
],
|
|
113
|
+
}));
|
|
114
|
+
return section;
|
|
115
|
+
}
|
|
116
|
+
const tableSize = 50;
|
|
117
|
+
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
|
|
118
|
+
/**
|
|
119
|
+
* A list that may run to tens of thousands of rows, as a profile's rules and patterns do in a monorepo: searched,
|
|
120
|
+
* narrowed by one facet, sorted by any column, and paged, with the count beside the page buttons as in Metrics.
|
|
121
|
+
* Only the page in view is built.
|
|
122
|
+
*/
|
|
123
|
+
function pagedTable(spec) {
|
|
124
|
+
const box = element('div', 'profile-table');
|
|
125
|
+
if (!spec.rows.length) {
|
|
126
|
+
box.append(element('p', 'detail', spec.empty));
|
|
127
|
+
return box;
|
|
128
|
+
}
|
|
129
|
+
const haystacks = spec.rows.map(row => spec.search(row).toLowerCase());
|
|
130
|
+
let page = 0;
|
|
131
|
+
let sortBy = -1;
|
|
132
|
+
let ascending = true;
|
|
133
|
+
const reset = () => { page = 0; render(); };
|
|
134
|
+
const tools = element('div', 'fx-tools profile-table-tools');
|
|
135
|
+
const search = searchField(`Search ${spec.noun[1]}`, `Search ${spec.noun[1]}`);
|
|
136
|
+
search.label.classList.add('fx-field-bare');
|
|
137
|
+
search.input.addEventListener('input', reset);
|
|
138
|
+
const facet = spec.facet && multiChoice(spec.facet.text, spec.facet.all, spec.facet.plural, [...spec.rows.reduce((counts, row) => {
|
|
139
|
+
const key = spec.facet.key(row);
|
|
140
|
+
return counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
141
|
+
}, new Map())].sort((a, b) => collator.compare(a[0], b[0])).map(([key, total]) => [key, key, total]), reset);
|
|
142
|
+
// A short list needs no controls: it is read at a glance.
|
|
143
|
+
if (spec.controls || spec.rows.length > 10)
|
|
144
|
+
tools.append(search.label);
|
|
145
|
+
if (facet && !facet.element.hidden)
|
|
146
|
+
tools.append(facet.element);
|
|
147
|
+
const table = element('table', 'fx-table profile-list');
|
|
148
|
+
table.setAttribute('aria-label', spec.label);
|
|
149
|
+
const head = element('tr');
|
|
150
|
+
const headers = spec.columns.map((column, index) => {
|
|
151
|
+
const cell = element('th', column.numeric ? 'numeric' : '');
|
|
152
|
+
cell.scope = 'col';
|
|
153
|
+
const button = element('button', 'fx-sort', column.label);
|
|
154
|
+
button.type = 'button';
|
|
155
|
+
button.addEventListener('click', () => {
|
|
156
|
+
ascending = sortBy === index ? !ascending : !column.numeric;
|
|
157
|
+
sortBy = index;
|
|
158
|
+
reset();
|
|
159
|
+
});
|
|
160
|
+
cell.append(button);
|
|
161
|
+
head.append(cell);
|
|
162
|
+
return cell;
|
|
163
|
+
});
|
|
164
|
+
const thead = element('thead');
|
|
165
|
+
thead.append(head);
|
|
166
|
+
const body = element('tbody');
|
|
167
|
+
table.append(thead, body);
|
|
168
|
+
const frame = element('div', 'table-scroll fx-table-scroll');
|
|
169
|
+
frame.append(table);
|
|
170
|
+
const pager = element('div', 'fx-pager');
|
|
171
|
+
const result = element('p', 'fx-note fx-results');
|
|
172
|
+
result.setAttribute('aria-live', 'polite');
|
|
173
|
+
const buttons = navigationButtons(`${spec.label} pages`, () => { page -= 1; render(); }, () => { page += 1; render(); });
|
|
174
|
+
pager.append(result, buttons.section);
|
|
175
|
+
if (tools.childElementCount)
|
|
176
|
+
box.append(tools);
|
|
177
|
+
box.append(frame, pager);
|
|
178
|
+
function render() {
|
|
179
|
+
const words = search.input.value.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
180
|
+
const chosen = facet?.values;
|
|
181
|
+
let shown = spec.rows.flatMap((row, index) => (!chosen?.size || chosen.has(spec.facet.key(row)))
|
|
182
|
+
&& words.every(word => haystacks[index].includes(word)) ? [row] : []);
|
|
183
|
+
if (sortBy >= 0) {
|
|
184
|
+
const key = spec.columns[sortBy].sort;
|
|
185
|
+
const direction = ascending ? 1 : -1;
|
|
186
|
+
shown = shown.sort((a, b) => {
|
|
187
|
+
const left = key(a);
|
|
188
|
+
const right = key(b);
|
|
189
|
+
return direction * (typeof left === 'number' && typeof right === 'number' ? left - right : collator.compare(String(left), String(right)));
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
for (const [index, cell] of headers.entries()) {
|
|
193
|
+
if (index === sortBy)
|
|
194
|
+
cell.setAttribute('aria-sort', ascending ? 'ascending' : 'descending');
|
|
195
|
+
else
|
|
196
|
+
cell.removeAttribute('aria-sort');
|
|
197
|
+
}
|
|
198
|
+
const pages = Math.max(1, Math.ceil(shown.length / tableSize));
|
|
199
|
+
page = Math.min(page, pages - 1);
|
|
200
|
+
const visible = shown.slice(page * tableSize, (page + 1) * tableSize);
|
|
201
|
+
body.replaceChildren(...visible.map(row => {
|
|
202
|
+
const line = element('tr');
|
|
203
|
+
for (const column of spec.columns) {
|
|
204
|
+
const cell = element('td', column.numeric ? 'numeric' : '');
|
|
205
|
+
cell.append(column.cell(row));
|
|
206
|
+
line.append(cell);
|
|
207
|
+
}
|
|
208
|
+
return line;
|
|
209
|
+
}));
|
|
210
|
+
frame.hidden = shown.length === 0;
|
|
211
|
+
const [one, many] = spec.noun;
|
|
212
|
+
const filtered = shown.length !== spec.rows.length;
|
|
213
|
+
result.textContent = shown.length === 0 ? `No ${many} match.`
|
|
214
|
+
: shown.length > tableSize ? `${count(page * tableSize + 1)}–${count(page * tableSize + visible.length)} of ${count(shown.length)} ${many}`
|
|
215
|
+
: filtered ? `${count(shown.length)} of ${count(spec.rows.length)} ${many}`
|
|
216
|
+
: `${count(shown.length)} ${shown.length === 1 ? one : many}`;
|
|
217
|
+
buttons.section.hidden = shown.length <= tableSize;
|
|
218
|
+
buttons.update(page, pages);
|
|
219
|
+
}
|
|
220
|
+
render();
|
|
221
|
+
return box;
|
|
222
|
+
}
|
|
223
|
+
/** Without the details (the public view) only the exclusions are known; the profile itself is not published. */
|
|
224
|
+
function fallback(data) {
|
|
225
|
+
const section = block('Files');
|
|
226
|
+
const exclusions = data.context?.exclusions;
|
|
227
|
+
if (exclusions) {
|
|
228
|
+
const facts = element('dl', 'profile-facts');
|
|
229
|
+
facts.append(row('Excluded paths', exclusions.paths.length ? chips(exclusions.paths) : none()));
|
|
230
|
+
facts.append(row('Excluded directories', exclusions.directories.length ? chips(exclusions.directories.map(directory => `**/${directory}/`)) : none()));
|
|
231
|
+
section.append(facts);
|
|
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.'));
|
|
235
|
+
return section;
|
|
236
|
+
}
|
|
237
|
+
const formatKey = 'repometry.badge-format';
|
|
238
|
+
/** The badges as a README shows them: each with the scale it grades by, and the snippet that embeds it. */
|
|
239
|
+
function badges(data) {
|
|
240
|
+
const panel = element('aside', 'fx-aside profile-aside');
|
|
241
|
+
panel.setAttribute('aria-label', 'Badges');
|
|
242
|
+
const heading = element('div', 'fx-aside-heading');
|
|
243
|
+
heading.append(element('h2', '', 'Badges'));
|
|
244
|
+
let format = 'markdown';
|
|
245
|
+
try {
|
|
246
|
+
if (localStorage.getItem(formatKey) === 'html')
|
|
247
|
+
format = 'html';
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
// Blocked storage only forgets the choice.
|
|
251
|
+
}
|
|
252
|
+
const snippets = [];
|
|
253
|
+
const toggle = element('div', 'fx-segmented profile-format');
|
|
254
|
+
toggle.setAttribute('role', 'group');
|
|
255
|
+
toggle.setAttribute('aria-label', 'Snippet format');
|
|
256
|
+
for (const [value, label] of [['markdown', 'Markdown'], ['html', 'HTML']]) {
|
|
257
|
+
const button = element('button', '', label);
|
|
258
|
+
button.type = 'button';
|
|
259
|
+
button.setAttribute('aria-pressed', String(value === format));
|
|
260
|
+
button.addEventListener('click', () => {
|
|
261
|
+
format = value;
|
|
262
|
+
for (const other of toggle.querySelectorAll('button'))
|
|
263
|
+
other.setAttribute('aria-pressed', String(other === button));
|
|
264
|
+
try {
|
|
265
|
+
localStorage.setItem(formatKey, value);
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
// As above.
|
|
269
|
+
}
|
|
270
|
+
for (const update of snippets)
|
|
271
|
+
update();
|
|
272
|
+
});
|
|
273
|
+
toggle.append(button);
|
|
274
|
+
}
|
|
275
|
+
heading.append(toggle);
|
|
276
|
+
panel.append(heading);
|
|
277
|
+
const { report, quality, context } = data.latest;
|
|
278
|
+
const lines = report.lineCoverage;
|
|
279
|
+
const coverage = lines && lines.total > 0 ? lines.covered / lines.total : null;
|
|
280
|
+
const ratio = quality?.maintainability?.debtRatio ?? null;
|
|
281
|
+
const security = context?.security;
|
|
282
|
+
const worst = !security ? null : security.critical ? 4 : security.high ? 3 : security.medium ? 2 : security.low || security.unknown ? 1 : 0;
|
|
283
|
+
const areas = [
|
|
284
|
+
['maintainability', 'Maintainability', [['A', '<5%'], ['B', '<10%'], ['C', '<20%'], ['D', '<50%'], ['F', '50%+']],
|
|
285
|
+
ratio === null ? null : [.05, .1, .2, .5, Infinity].findIndex(limit => ratio < limit), true],
|
|
286
|
+
['coverage', 'Coverage', [['A', '90%+'], ['B', '80%+'], ['C', '70%+'], ['D', '60%+'], ['F', '<60%']],
|
|
287
|
+
coverage === null ? null : [.9, .8, .7, .6, -Infinity].findIndex(limit => coverage >= limit), true],
|
|
288
|
+
['security', 'Security', securityGrades.map((grade, index) => [grade, securityRisks[index]]), worst, security !== undefined],
|
|
289
|
+
];
|
|
290
|
+
for (const [name, label, steps, current, published] of areas) {
|
|
291
|
+
const section = element('section', 'fx-aside-section profile-badge-area');
|
|
292
|
+
section.append(element('h3', '', label));
|
|
293
|
+
if (published) {
|
|
294
|
+
const image = element('img', 'profile-badge');
|
|
295
|
+
image.src = `./${name}.svg`;
|
|
296
|
+
image.alt = `${label} badge`;
|
|
297
|
+
image.height = 22;
|
|
298
|
+
section.append(image);
|
|
299
|
+
}
|
|
300
|
+
section.append(scale(steps, current));
|
|
301
|
+
if (published) {
|
|
302
|
+
const url = new URL(`./${name}.svg`, location.href).href;
|
|
303
|
+
const home = new URL('./', location.href).href;
|
|
304
|
+
const box = element('div', 'profile-snippet');
|
|
305
|
+
const text = element('code');
|
|
306
|
+
box.append(text, copyButton(`Copy the ${label.toLowerCase()} badge snippet`, () => text.textContent ?? ''));
|
|
307
|
+
const update = () => {
|
|
308
|
+
text.textContent = format === 'markdown' ? `[](${home})`
|
|
309
|
+
: `<a href="${home}"><img src="${url}" alt="${label}"></a>`;
|
|
310
|
+
};
|
|
311
|
+
update();
|
|
312
|
+
snippets.push(update);
|
|
313
|
+
section.append(box);
|
|
314
|
+
}
|
|
315
|
+
else
|
|
316
|
+
section.append(element('p', 'fx-note', 'No scanner report, so no badge.'));
|
|
317
|
+
panel.append(section);
|
|
318
|
+
}
|
|
319
|
+
// Footnotes close the sidebar, under the last badge: how the maintainability grade's ratio is made, and what badges show.
|
|
320
|
+
const model = data.details?.profile?.debtModel;
|
|
321
|
+
panel.append(element('p', 'fx-note profile-badge-note', model
|
|
322
|
+
? `Debt ratio: remediation time over the time to write the code, by ${model.name === 'basic-cocomo-organic' ? 'basic COCOMO (organic)' : model.name}: ${model.scale} × KLOC^${model.exponent} person-months of ${count(Math.round(model.minutesPerPersonMonth / 60))} hours.`
|
|
323
|
+
: 'Debt ratio: remediation time over the estimated time to write the code.'));
|
|
324
|
+
panel.append(element('p', 'fx-note profile-footnote', 'Badges show the latest inspection; their links work once the report is hosted.'));
|
|
325
|
+
return panel;
|
|
326
|
+
}
|
|
327
|
+
/** The scale as one strip in the grade colours, the latest inspection's step at full strength. */
|
|
328
|
+
function scale(steps, current) {
|
|
329
|
+
const box = element('div', 'profile-scale');
|
|
330
|
+
const strip = element('div', 'profile-scale-strip');
|
|
331
|
+
const words = element('div', 'profile-scale-words');
|
|
332
|
+
for (const [index, [grade, range, word]] of steps.entries()) {
|
|
333
|
+
const segment = element('span', 'profile-scale-grade', word ?? grade);
|
|
334
|
+
segment.dataset.grade = grade;
|
|
335
|
+
if (index === current)
|
|
336
|
+
segment.setAttribute('aria-current', 'true');
|
|
337
|
+
strip.append(segment);
|
|
338
|
+
words.append(element('span', '', range));
|
|
339
|
+
}
|
|
340
|
+
box.append(strip, words);
|
|
341
|
+
return box;
|
|
342
|
+
}
|
|
343
|
+
function copyButton(label, text) {
|
|
344
|
+
const button = element('button', 'fx-copy profile-copy');
|
|
345
|
+
button.type = 'button';
|
|
346
|
+
button.title = label;
|
|
347
|
+
button.setAttribute('aria-label', label);
|
|
348
|
+
button.append(copyIcon());
|
|
349
|
+
let reset;
|
|
350
|
+
button.addEventListener('click', async () => {
|
|
351
|
+
clearTimeout(reset);
|
|
352
|
+
try {
|
|
353
|
+
await navigator.clipboard.writeText(text());
|
|
354
|
+
button.classList.add('fx-copied');
|
|
355
|
+
reset = setTimeout(() => button.classList.remove('fx-copied'), 1500);
|
|
356
|
+
}
|
|
357
|
+
catch {
|
|
358
|
+
// Without clipboard access the snippet is selected, ready for the copy shortcut.
|
|
359
|
+
const range = document.createRange();
|
|
360
|
+
range.selectNodeContents(button.previousElementSibling);
|
|
361
|
+
getSelection()?.removeAllRanges();
|
|
362
|
+
getSelection()?.addRange(range);
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
return button;
|
|
366
|
+
}
|
|
367
|
+
function order(rule) {
|
|
368
|
+
const index = ruleOrder.indexOf(rule);
|
|
369
|
+
return index < 0 ? ruleOrder.length : index;
|
|
370
|
+
}
|
|
371
|
+
function block(title) {
|
|
372
|
+
const section = element('section', 'profile-block');
|
|
373
|
+
section.append(element('h3', '', title));
|
|
374
|
+
return section;
|
|
375
|
+
}
|
|
376
|
+
function row(label, value) {
|
|
377
|
+
const item = element('div');
|
|
378
|
+
const detail = element('dd');
|
|
379
|
+
detail.append(value);
|
|
380
|
+
item.append(element('dt', '', label), detail);
|
|
381
|
+
return item;
|
|
382
|
+
}
|
|
383
|
+
function chips(values) {
|
|
384
|
+
const list = element('ul', 'profile-chips');
|
|
385
|
+
list.append(...values.map(value => element('li', '', value)));
|
|
386
|
+
return list;
|
|
387
|
+
}
|
|
388
|
+
function none(text = 'None') {
|
|
389
|
+
return element('span', 'detail', text);
|
|
390
|
+
}
|
|
391
|
+
function code(text) {
|
|
392
|
+
return element('code', '', text);
|
|
393
|
+
}
|
|
394
|
+
function element(tag, className, text) {
|
|
395
|
+
const node = document.createElement(tag);
|
|
396
|
+
if (className)
|
|
397
|
+
node.className = className;
|
|
398
|
+
if (text !== undefined)
|
|
399
|
+
node.textContent = text;
|
|
400
|
+
return node;
|
|
401
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const totals = new Intl.NumberFormat();
|
|
2
|
+
const percentage = new Intl.NumberFormat(undefined, { style: 'percent', maximumFractionDigits: 1 });
|
|
3
|
+
const date = new Intl.DateTimeFormat(undefined, { dateStyle: 'medium' });
|
|
4
|
+
const search = document.querySelector('#search');
|
|
5
|
+
const sort = document.querySelector('#sort');
|
|
6
|
+
const rows = document.querySelector('#projects');
|
|
7
|
+
const summary = document.querySelector('#project-count');
|
|
8
|
+
const statusLabels = { complete: 'Complete', partial: 'Partial', 'not-applicable': 'Not applicable' };
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch('./projects.json');
|
|
11
|
+
if (!response.ok)
|
|
12
|
+
throw new Error('No index');
|
|
13
|
+
const data = await response.json();
|
|
14
|
+
if (data.schema !== 'urn:repometry:schema:projects:1' || !Array.isArray(data.projects))
|
|
15
|
+
throw new Error('Invalid index');
|
|
16
|
+
const render = () => {
|
|
17
|
+
const query = search.value.trim().toLowerCase();
|
|
18
|
+
const matches = data.projects.filter(project => project.name.toLowerCase().includes(query));
|
|
19
|
+
matches.sort(compare);
|
|
20
|
+
rows.replaceChildren(...matches.map(projectRow));
|
|
21
|
+
summary.textContent = matches.length === 0 ? 'No matching projects.' : `${matches.length} of ${data.projects.length} projects`;
|
|
22
|
+
};
|
|
23
|
+
search.addEventListener('input', render);
|
|
24
|
+
sort.addEventListener('change', render);
|
|
25
|
+
render();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
summary.textContent = 'Could not load project reports.';
|
|
29
|
+
}
|
|
30
|
+
function compare(a, b) {
|
|
31
|
+
switch (sort.value) {
|
|
32
|
+
case 'date': return when(b).localeCompare(when(a));
|
|
33
|
+
case 'coverage': return (coverage(a) ?? Infinity) - (coverage(b) ?? Infinity);
|
|
34
|
+
case 'debt': return (b.quality?.maintainability?.debtRatio ?? -1) - (a.quality?.maintainability?.debtRatio ?? -1);
|
|
35
|
+
case 'size': return (b.quality?.codeLines ?? -1) - (a.quality?.codeLines ?? -1);
|
|
36
|
+
default: return a.name.localeCompare(b.name);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** The latest commit's time, falling back to the inspection time for exports without commit times. */
|
|
40
|
+
function when(project) {
|
|
41
|
+
return project.inspection?.committedAt ?? project.inspection?.generatedAt ?? '';
|
|
42
|
+
}
|
|
43
|
+
function projectRow(project) {
|
|
44
|
+
const { name, inspection, quality } = project;
|
|
45
|
+
const maintainability = quality?.maintainability ?? null;
|
|
46
|
+
const row = document.createElement('tr');
|
|
47
|
+
const key = document.createElement('th');
|
|
48
|
+
key.scope = 'row';
|
|
49
|
+
const link = document.createElement('a');
|
|
50
|
+
link.href = `./${encodeURIComponent(name)}/`;
|
|
51
|
+
link.textContent = name;
|
|
52
|
+
key.append(link);
|
|
53
|
+
row.append(key);
|
|
54
|
+
const debt = row.insertCell();
|
|
55
|
+
debt.className = 'numeric';
|
|
56
|
+
debt.textContent = formatPercent(maintainability?.debtRatio ?? null);
|
|
57
|
+
if (maintainability?.grade) {
|
|
58
|
+
const grade = document.createElement('abbr');
|
|
59
|
+
grade.className = 'grade grade-inline';
|
|
60
|
+
grade.title = 'Maintainability grade';
|
|
61
|
+
grade.dataset.grade = maintainability.grade;
|
|
62
|
+
grade.textContent = maintainability.grade;
|
|
63
|
+
debt.append(grade);
|
|
64
|
+
}
|
|
65
|
+
for (const value of [formatPercent(coverage(project)), formatPercent(quality?.duplication?.ratio ?? null),
|
|
66
|
+
quality?.codeLines == null ? '—' : totals.format(quality.codeLines)]) {
|
|
67
|
+
const cell = row.insertCell();
|
|
68
|
+
cell.className = 'numeric';
|
|
69
|
+
cell.textContent = value;
|
|
70
|
+
}
|
|
71
|
+
const last = row.insertCell();
|
|
72
|
+
if (inspection) {
|
|
73
|
+
const sha = document.createElement('code');
|
|
74
|
+
sha.textContent = inspection.sha.slice(0, 7);
|
|
75
|
+
last.append(sha, ` · ${date.format(new Date(when(project)))}`);
|
|
76
|
+
if (inspection.status !== 'complete')
|
|
77
|
+
last.append(` · ${statusLabels[inspection.status]}`);
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
last.textContent = 'Not inspected';
|
|
81
|
+
return row;
|
|
82
|
+
}
|
|
83
|
+
function coverage(project) {
|
|
84
|
+
const data = project.inspection?.lineCoverage;
|
|
85
|
+
return data && data.total > 0 ? data.covered / data.total : null;
|
|
86
|
+
}
|
|
87
|
+
function formatPercent(value) {
|
|
88
|
+
return value === null ? '—' : percentage.format(value);
|
|
89
|
+
}
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PullReview } from '../../json/wire/pull-review-model.js';
|
|
2
|
+
export declare function renderPulls(container: HTMLElement, records: readonly PullReview[]): void;
|
|
3
|
+
export declare function renderDiffCoverageTrend(container: HTMLElement, records: readonly PullReview[]): void;
|