repometry 0.10.1 → 0.11.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.
Files changed (147) hide show
  1. package/README.md +4 -2
  2. package/package.json +1 -1
  3. package/target/main/resources/config/process-plugins-v1.schema.json +22 -0
  4. package/target/main/resources/report/json/config-v1.schema.json +41 -0
  5. package/target/main/resources/report/json/file-metrics-v1.schema.json +23 -1
  6. package/target/main/resources/report/json/pull-review-v2.schema.json +100 -0
  7. package/target/main/ts/api/cache/root.d.ts +1 -1
  8. package/target/main/ts/api/cache/root.js +2 -2
  9. package/target/main/ts/api/gh/github.d.ts +0 -4
  10. package/target/main/ts/api/gh/github.js +3 -33
  11. package/target/main/ts/api/git/commit-metadata.d.ts +0 -1
  12. package/target/main/ts/api/git/commit-metadata.js +1 -10
  13. package/target/main/ts/api/import/cobertura.d.ts +2 -0
  14. package/target/main/ts/api/import/cobertura.js +160 -0
  15. package/target/main/ts/api/import/coverage-xml.d.ts +7 -0
  16. package/target/main/ts/api/import/coverage-xml.js +135 -0
  17. package/target/main/ts/api/import/lcov-files.d.ts +3 -1
  18. package/target/main/ts/api/import/lcov-files.js +23 -4
  19. package/target/main/ts/cli/arguments.js +2 -4
  20. package/target/main/ts/cli/config.d.ts +10 -6
  21. package/target/main/ts/cli/config.js +36 -6
  22. package/target/main/ts/cli/imports.d.ts +1 -0
  23. package/target/main/ts/cli/imports.js +6 -2
  24. package/target/main/ts/cli/main.js +47 -139
  25. package/target/main/ts/cli/range-inspection.d.ts +0 -3
  26. package/target/main/ts/cli/range-inspection.js +5 -17
  27. package/target/main/ts/cli/range-jobs.js +1 -3
  28. package/target/main/ts/cli/reporting.d.ts +2 -7
  29. package/target/main/ts/cli/reporting.js +23 -37
  30. package/target/main/ts/compose/analysis-report.d.ts +1 -1
  31. package/target/main/ts/compose/analysis-report.js +4 -5
  32. package/target/main/ts/compose/analysis-results.d.ts +1 -1
  33. package/target/main/ts/compose/analysis-results.js +4 -6
  34. package/target/main/ts/compose/analysis-steps.d.ts +23 -0
  35. package/target/main/ts/compose/analysis-steps.js +215 -0
  36. package/target/main/ts/compose/analyze-snapshot.d.ts +1 -1
  37. package/target/main/ts/compose/analyze-snapshot.js +8 -12
  38. package/target/main/ts/compose/built-ins.d.ts +3 -0
  39. package/target/main/ts/compose/built-ins.js +5 -0
  40. package/target/main/ts/compose/diff-coverage.d.ts +2 -4
  41. package/target/main/ts/compose/diff-coverage.js +15 -12
  42. package/target/main/ts/compose/history-cache.d.ts +1 -1
  43. package/target/main/ts/compose/inspect.d.ts +6 -9
  44. package/target/main/ts/compose/inspect.js +8 -9
  45. package/target/main/ts/compose/languages.d.ts +4 -1
  46. package/target/main/ts/compose/languages.js +9 -6
  47. package/target/main/ts/compose/native-language-plugins.d.ts +0 -1
  48. package/target/main/ts/compose/native-language-plugins.js +4 -11
  49. package/target/main/ts/compose/phases.d.ts +126 -0
  50. package/target/main/ts/compose/phases.js +154 -0
  51. package/target/main/ts/compose/plugin-list.d.ts +8 -2
  52. package/target/main/ts/compose/plugin-list.js +4 -13
  53. package/target/main/ts/compose/process-plugins.js +1 -1
  54. package/target/main/ts/compose/review.d.ts +2 -4
  55. package/target/main/ts/compose/review.js +10 -9
  56. package/target/main/ts/compose/sources.d.ts +1 -2
  57. package/target/main/ts/compose/sources.js +7 -7
  58. package/target/main/ts/core/engine/execute.d.ts +4 -1
  59. package/target/main/ts/core/engine/execute.js +1 -1
  60. package/target/main/ts/core/engine/manifest.d.ts +0 -1
  61. package/target/main/ts/core/engine/manifest.js +9 -13
  62. package/target/main/ts/core/engine/plugin.d.ts +1 -1
  63. package/target/main/ts/core/engine/report-products.js +3 -2
  64. package/target/main/ts/core/model/changes.d.ts +2 -0
  65. package/target/main/ts/core/model/changes.js +5 -1
  66. package/target/main/ts/core/model/clone-source.d.ts +2 -0
  67. package/target/main/ts/core/model/clone-source.js +4 -0
  68. package/target/main/ts/core/model/code-structure.d.ts +4 -1
  69. package/target/main/ts/core/model/code-structure.js +3 -1
  70. package/target/main/ts/core/model/coverage-input.d.ts +12 -0
  71. package/target/main/ts/core/model/coverage-input.js +11 -0
  72. package/target/main/ts/core/model/diff-coverage.d.ts +2 -0
  73. package/target/main/ts/core/model/diff-coverage.js +9 -1
  74. package/target/main/ts/core/model/language.d.ts +28 -0
  75. package/target/main/ts/core/model/language.js +25 -1
  76. package/target/main/ts/core/model/quality-summary.js +1 -1
  77. package/target/main/ts/core/model/report.d.ts +0 -2
  78. package/target/main/ts/core/model/report.js +0 -20
  79. package/target/main/ts/core/ports/tool-runner.d.ts +13 -0
  80. package/target/main/ts/core/usecases/inspect.d.ts +1 -2
  81. package/target/main/ts/core/usecases/review.js +11 -3
  82. package/target/main/ts/index.d.ts +6 -33
  83. package/target/main/ts/index.js +3 -18
  84. package/target/main/ts/plugin.d.ts +7 -3
  85. package/target/main/ts/plugin.js +3 -0
  86. package/target/main/ts/plugins/built-in.d.ts +6 -0
  87. package/target/main/ts/plugins/built-in.js +39 -0
  88. package/target/main/ts/plugins/coverage/coverage.d.ts +3 -24
  89. package/target/main/ts/plugins/coverage/coverage.js +8 -11
  90. package/target/main/ts/plugins/coverage/diff-coverage.d.ts +1 -5
  91. package/target/main/ts/plugins/coverage/diff-coverage.js +5 -14
  92. package/target/main/ts/plugins/duplication/duplication.d.ts +1 -3
  93. package/target/main/ts/plugins/duplication/duplication.js +2 -6
  94. package/target/main/ts/plugins/language-js/babel-provider.js +3 -2
  95. package/target/main/ts/plugins/language-js/structural-observations.js +1 -1
  96. package/target/main/ts/plugins/language-js/syntax.d.ts +2 -0
  97. package/target/main/ts/plugins/language-js/syntax.js +11 -0
  98. package/target/main/ts/plugins/maintainability/maintainability.d.ts +1 -8
  99. package/target/main/ts/plugins/maintainability/maintainability.js +4 -10
  100. package/target/main/ts/plugins/source/forges.js +1 -1
  101. package/target/main/ts/report/html/app/viewer-languages.d.ts +3 -1
  102. package/target/main/ts/report/html/app/viewer-languages.js +11 -1
  103. package/target/main/ts/report/html/app/viewer-metrics-view.js +1 -1
  104. package/target/main/ts/report/html/app/viewer-source-view.js +2 -2
  105. package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +7 -6
  106. package/target/main/ts/report/html/app/viewer-tokenizer.js +72 -71
  107. package/target/main/ts/report/html/site/export-site.d.ts +1 -5
  108. package/target/main/ts/report/html/site/export-site.js +2 -6
  109. package/target/main/ts/report/html/site/projects.d.ts +1 -3
  110. package/target/main/ts/report/html/site/projects.js +2 -4
  111. package/target/main/ts/report/json/projections/file-metrics.js +1 -1
  112. package/target/main/ts/report/json/projections/inspection-context.d.ts +1 -0
  113. package/target/main/ts/report/json/projections/inspection-context.js +19 -1
  114. package/target/main/ts/report/json/projections/inspection-details.js +7 -2
  115. package/target/main/ts/report/json/store/local-store.js +2 -0
  116. package/target/main/ts/report/json/store/replace-file.d.ts +1 -1
  117. package/target/main/ts/report/json/store/replace-file.js +24 -3
  118. package/target/main/ts/report/json/store/store-check.js +10 -1
  119. package/target/main/ts/report/json/validation/metabranch.d.ts +1 -1
  120. package/target/main/ts/report/json/validation/metabranch.js +6 -3
  121. package/target/main/ts/report/json/wire/file-metrics-model.d.ts +3 -1
  122. package/target/main/ts/report.d.ts +13 -1
  123. package/target/main/ts/report.js +7 -1
  124. package/target/main/ts/api/git/metabranch-worktree.d.ts +0 -1
  125. package/target/main/ts/api/git/metabranch-worktree.js +0 -35
  126. package/target/main/ts/api/worker/remote-executor.d.ts +0 -2
  127. package/target/main/ts/api/worker/remote-executor.js +0 -46
  128. package/target/main/ts/api/worker/worker-protocol.d.ts +0 -7
  129. package/target/main/ts/api/worker/worker-protocol.js +0 -127
  130. package/target/main/ts/api/worker/worker.d.ts +0 -5
  131. package/target/main/ts/api/worker/worker.js +0 -86
  132. package/target/main/ts/compose/analysis-files.d.ts +0 -15
  133. package/target/main/ts/compose/analysis-files.js +0 -129
  134. package/target/main/ts/compose/analysis-imports.d.ts +0 -7
  135. package/target/main/ts/compose/analysis-imports.js +0 -36
  136. package/target/main/ts/compose/analysis-repository.d.ts +0 -7
  137. package/target/main/ts/compose/analysis-repository.js +0 -99
  138. package/target/main/ts/compose/analysis-sources.d.ts +0 -48
  139. package/target/main/ts/compose/analysis-sources.js +0 -54
  140. package/target/main/ts/compose/prepare-metabranch.d.ts +0 -9
  141. package/target/main/ts/compose/prepare-metabranch.js +0 -17
  142. package/target/main/ts/compose/security-plugins.d.ts +0 -1
  143. package/target/main/ts/compose/security-plugins.js +0 -7
  144. package/target/main/ts/core/usecases/compare.d.ts +0 -6
  145. package/target/main/ts/core/usecases/compare.js +0 -189
  146. package/target/main/ts/report/json/store/components.d.ts +0 -2
  147. package/target/main/ts/report/json/store/components.js +0 -32
@@ -0,0 +1,12 @@
1
+ import type { DataContract } from '../engine/plugin.js';
2
+ import type { SourceLineRange } from './source.js';
3
+ export interface CoverageInput {
4
+ readonly text: string;
5
+ readonly root: string;
6
+ readonly sourceLines: ReadonlyMap<string, number>;
7
+ readonly codeLines?: ReadonlyMap<string, ReadonlySet<number>>;
8
+ readonly unclassified?: ReadonlySet<string>;
9
+ readonly functionBodies?: ReadonlyMap<string, readonly SourceLineRange[]>;
10
+ readonly excludes?: (path: string) => boolean;
11
+ }
12
+ export declare const lcovInput: DataContract<CoverageInput>;
@@ -0,0 +1,11 @@
1
+ import { isRecord } from './plugin-data.js';
2
+ export const lcovInput = {
3
+ id: 'repometry.lcov-input/v1',
4
+ accepts: (value) => isRecord(value) && typeof value.text === 'string'
5
+ && typeof value.root === 'string' && value.sourceLines instanceof Map
6
+ && (value.codeLines === undefined || value.codeLines instanceof Map)
7
+ && (value.unclassified === undefined || value.unclassified instanceof Set)
8
+ && (value.functionBodies === undefined || value.functionBodies instanceof Map)
9
+ && (value.excludes === undefined || typeof value.excludes === 'function'),
10
+ };
11
+ //# sourceMappingURL=coverage-input.js.map
@@ -1,3 +1,4 @@
1
+ import type { DataContract } from '../engine/plugin.js';
1
2
  export interface FileCoverage {
2
3
  readonly path: string;
3
4
  readonly addedLines: number;
@@ -21,3 +22,4 @@ export interface DiffCoverageResult extends DiffCoverage {
21
22
  readonly lines: readonly number[];
22
23
  }[];
23
24
  }
25
+ export declare const diffCoverageResult: DataContract<DiffCoverageResult>;
@@ -1 +1,9 @@
1
- export {};
1
+ import { isRecord } from './plugin-data.js';
2
+ export const diffCoverageResult = {
3
+ id: 'repometry.diff-coverage-result/v1',
4
+ accepts: (value) => isRecord(value) && Array.isArray(value.files) && Array.isArray(value.gaps)
5
+ && Array.isArray(value.uncovered)
6
+ && (value.status === 'complete' || value.status === 'partial' || value.status === 'not-applicable')
7
+ && typeof value.covered === 'number' && typeof value.total === 'number'
8
+ && (value.percent === null || typeof value.percent === 'number'),
9
+ };
@@ -7,10 +7,38 @@ export interface LanguageDisplay {
7
7
  export interface LanguageLookup {
8
8
  readonly catalog: readonly LanguageDisplay[];
9
9
  id(path: string): string;
10
+ syntax?(id: string): LanguageSyntax | undefined;
11
+ }
12
+ /**
13
+ * How the viewer colours a language's source: data for a scanner, not a grammar. Every field is optional; a language
14
+ * with no syntax shows as plain text.
15
+ */
16
+ export interface LanguageSyntax {
17
+ /** Markers that start a comment running to the end of the line, such as `//` or `#`. */
18
+ readonly lineComments?: readonly string[];
19
+ /** Start and end markers of comments that may span lines, such as slash-star and star-slash. They do not nest. */
20
+ readonly blockComments?: readonly (readonly [start: string, end: string])[];
21
+ /**
22
+ * String forms. A string ends at the same quote that opened it. A backslash escapes the next character unless the form
23
+ * is raw. A form that is not multi-line ends at the end of the line.
24
+ */
25
+ readonly strings?: readonly {
26
+ readonly quote: string;
27
+ readonly multiline?: boolean;
28
+ readonly raw?: boolean;
29
+ }[];
30
+ /** Letters that may stand right before a quote and belong to the string, compared without case: `r`, `b`, `f`, `rb`. */
31
+ readonly stringPrefixes?: readonly string[];
32
+ /** Words coloured as keywords, literals such as `true` and `nil` among them. Compared with case. */
33
+ readonly keywords?: readonly string[];
34
+ /** Words after which a slash opens a regular-expression literal, as in JavaScript. Without this field a slash is plain. */
35
+ readonly regexAfter?: readonly string[];
10
36
  }
11
37
  export interface ProvidedLanguage extends LanguageDisplay {
12
38
  readonly extensions?: readonly string[];
13
39
  readonly globs?: readonly string[];
14
40
  readonly measures?: readonly StructureMeasure[];
41
+ readonly syntax?: LanguageSyntax;
15
42
  }
16
43
  export declare function isLanguageDisplay(value: unknown): value is LanguageDisplay;
44
+ export declare function isLanguageSyntax(value: unknown): value is LanguageSyntax;
@@ -1,6 +1,30 @@
1
- import { isRecord } from './plugin-data.js';
1
+ import { isJsonValue, isRecord } from './plugin-data.js';
2
2
  export function isLanguageDisplay(value) {
3
3
  return isRecord(value) && typeof value.id === 'string' && /^[a-z][a-z0-9-]*$/.test(value.id)
4
4
  && typeof value.label === 'string' && value.label.trim().length > 0
5
5
  && (value.color === undefined || typeof value.color === 'string' && /^#[a-f\d]{6}$/i.test(value.color));
6
6
  }
7
+ const syntaxChecks = {
8
+ lineComments: value => entries(value, marker),
9
+ blockComments: value => entries(value, pair => Array.isArray(pair) && pair.length === 2 && marker(pair[0]) && marker(pair[1])),
10
+ strings: value => entries(value, stringForm),
11
+ stringPrefixes: value => entries(value, word),
12
+ keywords: value => entries(value, word, 512),
13
+ regexAfter: value => entries(value, word),
14
+ };
15
+ export function isLanguageSyntax(value) {
16
+ return isRecord(value) && isJsonValue(value)
17
+ && Object.entries(value).every(([key, item]) => Object.hasOwn(syntaxChecks, key) && syntaxChecks[key](item));
18
+ }
19
+ function entries(value, valid, maximum = Infinity) {
20
+ return Array.isArray(value) && value.length <= maximum && Array.from(value).every(valid);
21
+ }
22
+ function marker(value) {
23
+ return typeof value === 'string' && /^\S{1,8}$/u.test(value);
24
+ }
25
+ function word(value) {
26
+ return typeof value === 'string' && /^[A-Za-z_$][\w$]*$/.test(value);
27
+ }
28
+ function stringForm(value) {
29
+ return isRecord(value) && marker(value.quote) && Object.entries(value).every(([key, item]) => key === 'quote' || ((key === 'multiline' || key === 'raw') && typeof item === 'boolean'));
30
+ }
@@ -41,7 +41,7 @@ function totalMeasured(values, expected) {
41
41
  function gradeMeasuredFiles(report, code, duplication) {
42
42
  if (report.findings === undefined || code === undefined)
43
43
  return null;
44
- const skipped = new Set(report.ruleSkips?.filter(({ plugin }) => plugin === 'maintainability' || plugin === 'duplication')
44
+ const skipped = new Set(report.ruleSkips?.filter(({ reason }) => reason === 'unmeasured')
45
45
  .map(({ path }) => path));
46
46
  const measured = new Map([...code].filter(([path]) => duplication?.has(path) && !skipped.has(path)));
47
47
  if (measured.size === 0)
@@ -43,5 +43,3 @@ export interface Report {
43
43
  readonly pluginData?: PluginData;
44
44
  }
45
45
  export declare function validSubjectId(kind: Subject['kind'], id: string): boolean;
46
- export declare const legacySyntaxPlugin = "babel-syntax";
47
- export declare function historicalPluginTools(plugins: unknown): unknown;
@@ -1,24 +1,4 @@
1
- import { isRecord } from './plugin-data.js';
2
1
  export const reportSchema = 'urn:repometry:schema:report:2';
3
2
  export function validSubjectId(kind, id) {
4
3
  return /^[a-f0-9]{64}$/.test(id) || (kind === 'commit' && /^[a-f0-9]{40}$/.test(id));
5
4
  }
6
- export const legacySyntaxPlugin = 'babel-syntax';
7
- // Keep history comparable when the parser starts recording its own tool versions.
8
- export function historicalPluginTools(plugins) {
9
- if (!Array.isArray(plugins))
10
- return plugins;
11
- const syntax = plugins.find(entry => isRecord(entry) && entry.id === legacySyntaxPlugin);
12
- if (!isRecord(syntax?.tools))
13
- return plugins;
14
- const { '@babel/types': types, ...native } = syntax.tools;
15
- if (typeof types !== 'string')
16
- return plugins;
17
- return plugins.map(entry => {
18
- if (entry === syntax)
19
- return { ...syntax, tools: native };
20
- if (!isRecord(entry) || (entry.id !== 'structure' && entry.id !== 'maintainability') || !isRecord(entry.tools))
21
- return entry;
22
- return { ...entry, tools: { '@babel/types': types, ...entry.tools } };
23
- });
24
- }
@@ -1,3 +1,5 @@
1
+ import type { StructureMeasure } from '../model/code-structure.js';
2
+ import type { LanguageSyntax } from '../model/language.js';
1
3
  import type { SourceFile } from '../model/source.js';
2
4
  export interface ToolInvocation {
3
5
  readonly argv: readonly string[];
@@ -16,3 +18,14 @@ export interface ToolRunner {
16
18
  readonly implementation?: string;
17
19
  run(invocation: ToolInvocation): Promise<ToolResult>;
18
20
  }
21
+ /** A language parser that runs as a host process: the binary, how to start it and what it measures. */
22
+ export type HostLanguageDescriptor = Readonly<{
23
+ id: string;
24
+ language: string;
25
+ binary: string;
26
+ args: readonly string[];
27
+ versionArgs: readonly string[];
28
+ script: string;
29
+ measures: readonly StructureMeasure[];
30
+ syntax: LanguageSyntax;
31
+ }>;
@@ -11,7 +11,6 @@ export interface AnalysisInput {
11
11
  readonly sourceRoot: string;
12
12
  };
13
13
  }
14
- export type AnalysisExecutor = (input: AnalysisInput) => Promise<Report>;
15
14
  type Excludes = (path: string) => boolean;
16
15
  interface InspectionSource {
17
16
  readonly snapshot: SourceSnapshot;
@@ -25,7 +24,7 @@ interface InspectionCoverage {
25
24
  }
26
25
  export interface InspectionPorts {
27
26
  readSource(excludes: Excludes): Promise<InspectionSource>;
28
- readonly analyze: AnalysisExecutor;
27
+ analyze(input: AnalysisInput): Promise<Report>;
29
28
  readCoverage?(source: Pick<InspectionSource, 'root' | 'snapshot'>): Promise<InspectionCoverage>;
30
29
  importFindings?(report: Report, root: string, excludes: Excludes): Promise<Report>;
31
30
  recordChurn?(report: Report, root: string, paths: readonly string[]): Promise<Report>;
@@ -1,7 +1,8 @@
1
1
  import { pullReviewSchema } from '../model/pull-review.js';
2
+ import { isRecord } from '../model/plugin-data.js';
2
3
  import { classifyIssues, debtEffect } from './review-effect.js';
3
4
  export const coverageDefaults = { minimumPercent: 80, minimumLines: 20 };
4
- const ignoredOperations = new Set(['lcov/import', 'git/churn', 'source/claims']);
5
+ const hostOperations = new Set(['git/churn', 'source/claims']);
5
6
  const settingsNote = 'This change edits Repometry settings, which can hide issues from this check.';
6
7
  export function projectReview(options, inputs) {
7
8
  checkOptions(options, inputs.coverage !== null);
@@ -25,7 +26,7 @@ export function checkOptions({ number, maxNewIssues = 0, minimumPercent }, cover
25
26
  if (!Number.isSafeInteger(maxNewIssues) || maxNewIssues < 0)
26
27
  throw new Error('Maximum new issues must be a non-negative integer');
27
28
  if (minimumPercent !== undefined && !coverage)
28
- throw new Error('Minimum changed-line coverage requires --import lcov=PATH or go-cover=PATH');
29
+ throw new Error('Minimum changed-line coverage requires --import lcov=PATH, go-cover=PATH or cobertura=PATH');
29
30
  }
30
31
  /** The verdict and its reason, in one line. */
31
32
  export function reviewReason({ verdict, unmeasured, issueGate, coverage }) {
@@ -72,11 +73,18 @@ function ranges(path, lines) {
72
73
  }
73
74
  return merged;
74
75
  }
76
+ /** The operations that read the host's coverage input, which their stored records name as the external port `lcov`. */
77
+ function coverageImporters({ appliedConfig }) {
78
+ const records = Array.isArray(appliedConfig.operations) ? appliedConfig.operations : [];
79
+ return new Set(records.flatMap(record => isRecord(record) && isRecord(record.inputs)
80
+ && Object.values(record.inputs).some(input => isRecord(input) && input.external === 'lcov') ? [record.key] : []));
81
+ }
75
82
  /** Failures on the head only leave the check unmeasured. Failures on both sides, and skipped large files, are notes. */
76
83
  function diagnose({ base, head, changes }) {
77
84
  const changed = new Set(changes.files.flatMap(file => file.path === null ? [] : [file.path]));
78
85
  const failing = (diagnostic) => diagnostic.state === 'failed' || diagnostic.state === 'blocked';
79
86
  const failedOnBase = new Set(base.diagnostics.filter(failing).map(({ operation }) => operation));
87
+ const coverageImports = coverageImporters(head);
80
88
  const unmeasured = [];
81
89
  const notes = [];
82
90
  const brokenPaths = new Set(head.diagnostics.filter(item => item.state === 'failed' && item.path !== undefined).map(item => item.path));
@@ -89,7 +97,7 @@ function diagnose({ base, head, changes }) {
89
97
  if (diagnostic.path !== undefined && changed.has(diagnostic.path))
90
98
  notes.push(reason);
91
99
  }
92
- else if (ignoredOperations.has(diagnostic.operation) || !failing(diagnostic)) {
100
+ else if (hostOperations.has(diagnostic.operation) || coverageImports.has(diagnostic.operation) || !failing(diagnostic)) {
93
101
  continue;
94
102
  }
95
103
  else if (failedOnBase.has(diagnostic.operation) && (diagnostic.path === undefined || !changed.has(diagnostic.path))) {
@@ -1,37 +1,10 @@
1
- export { pluginApi } from './core/engine/plugin.js';
2
- export type { DataContract, InspectionInputs, Operation, Plugin, Product } from './core/engine/plugin.js';
3
- export { plan } from './core/engine/plan.js';
4
- export type { InputBinding, PlanRequest, PlannedOperation } from './core/engine/plan.js';
5
- export { execute } from './core/engine/execute.js';
6
- export type { Outcome } from './core/engine/execute.js';
7
- export { analyzeSnapshot, inspect } from './compose/inspect.js';
8
- export type { AnalysisExecutor, AnalysisInput, InspectionPorts, InspectRequest } from './compose/inspect.js';
9
- export { diffCoverageSchema, measureDiffCoverage } from './compose/diff-coverage.js';
10
- export type { DiffCoverageReport, DiffCoverageRequest } from './compose/diff-coverage.js';
1
+ export { inspect } from './compose/inspect.js';
2
+ export type { InspectRequest } from './compose/inspect.js';
3
+ export { measureDiffCoverage } from './compose/diff-coverage.js';
4
+ export type { DiffCoverageRequest } from './compose/diff-coverage.js';
11
5
  export type { DiffCoveragePorts, DiffCoverageSource } from './core/usecases/diff-coverage.js';
12
- export { reviewExitCode } from './compose/review.js';
6
+ export { review, reviewExitCode } from './compose/review.js';
13
7
  export type { ReviewRequest } from './compose/review.js';
14
8
  export type { ReviewOptions } from './core/usecases/review.js';
15
- export { compareInspections, comparisonSchema } from './core/usecases/compare.js';
16
- export { compareInspections as compare } from './core/usecases/compare.js';
17
- export { measureDiffCoverage as diffCoverage } from './compose/diff-coverage.js';
18
- export { review } from './compose/review.js';
19
- export type { InspectionComparison } from './core/usecases/compare.js';
20
- export { fileMetrics } from './report/json/projections/file-metrics.js';
21
- export { fileMetricsSchema } from './report/json/wire/file-metrics-model.js';
22
- export type { FileMetricsReport } from './report/json/wire/file-metrics-model.js';
23
- export { LocalReportStore } from './report/json/store/local-store.js';
24
- export { GitReportReader } from './api/git/git-reader.js';
25
- export { readReport, reportSchema } from './report/json/validation/report.js';
26
- export type { Diagnostic, Report, ReportReader, ReportStore } from './report/json/validation/report.js';
27
- export type { Measurement } from './core/model/measurement.js';
28
- export type { Finding, FindingLocation } from './core/model/finding.js';
29
9
  export type { FindingInput } from './api/import/finding-import.js';
30
- export type { FindingIgnoreRule, IgnoredFinding } from './core/model/finding-ignore.js';
31
- export { coverageGrade, qualitySummary } from './core/model/quality-summary.js';
32
- export type { Grade, QualitySummary } from './core/model/quality-summary.js';
33
- export { pullReviewSchema } from './core/model/pull-review.js';
34
- export { pullReviewsSchema } from './report/json/wire/pull-review-model.js';
35
- export type { IssueEffect, PullReview, ReviewedIssue, ReviewReason } from './core/model/pull-review.js';
36
- export type { PullReviews } from './report/json/wire/pull-review-model.js';
37
- export type { Subject } from './core/model/snapshot.js';
10
+ export type { FindingIgnoreRule } from './core/model/finding-ignore.js';
@@ -1,19 +1,4 @@
1
- export { pluginApi } from './core/engine/plugin.js';
2
- export { plan } from './core/engine/plan.js';
3
- export { execute } from './core/engine/execute.js';
4
- export { analyzeSnapshot, inspect } from './compose/inspect.js';
5
- export { diffCoverageSchema, measureDiffCoverage } from './compose/diff-coverage.js';
6
- export { reviewExitCode } from './compose/review.js';
7
- export { compareInspections, comparisonSchema } from './core/usecases/compare.js';
8
- export { compareInspections as compare } from './core/usecases/compare.js';
9
- export { measureDiffCoverage as diffCoverage } from './compose/diff-coverage.js';
10
- export { review } from './compose/review.js';
11
- export { fileMetrics } from './report/json/projections/file-metrics.js';
12
- export { fileMetricsSchema } from './report/json/wire/file-metrics-model.js';
13
- export { LocalReportStore } from './report/json/store/local-store.js';
14
- export { GitReportReader } from './api/git/git-reader.js';
15
- export { readReport, reportSchema } from './report/json/validation/report.js';
16
- export { coverageGrade, qualitySummary } from './core/model/quality-summary.js';
17
- export { pullReviewSchema } from './core/model/pull-review.js';
18
- export { pullReviewsSchema } from './report/json/wire/pull-review-model.js';
1
+ export { inspect } from './compose/inspect.js';
2
+ export { measureDiffCoverage } from './compose/diff-coverage.js';
3
+ export { review, reviewExitCode } from './compose/review.js';
19
4
  //# sourceMappingURL=index.js.map
@@ -1,21 +1,25 @@
1
1
  export { pluginApi } from './core/engine/plugin.js';
2
+ export { plan } from './core/engine/plan.js';
3
+ export type { InputBinding, PlanRequest, PlannedOperation } from './core/engine/plan.js';
4
+ export { execute } from './core/engine/execute.js';
5
+ export type { Outcome } from './core/engine/execute.js';
2
6
  export type { DataContract, InspectionInputs, Operation, Plugin, PluginConfigSchema, Product, RuleDescriptor } from './core/engine/plugin.js';
3
7
  export type { FileClaims, MetricDescriptor, MetricScope, PluginKind, ProductDeclaration } from './core/engine/plugin.js';
8
+ export { LocalOperationCache } from './report/json/store/operation-cache.js';
4
9
  export type { OperationCache, OperationCacheOptions } from './core/engine/operation-cache.js';
5
10
  export { codeStructure, codeStructures } from './core/model/code-structure.js';
6
11
  export type { CodeStructure, FunctionComplexity, StructureMeasure, StructuralCheck, StructuralObservation } from './core/model/code-structure.js';
7
- export type { LanguageDisplay, ProvidedLanguage } from './core/model/language.js';
12
+ export type { LanguageDisplay, LanguageSyntax, ProvidedLanguage } from './core/model/language.js';
8
13
  export type { Candidate, CloneSource } from './core/model/clone-source.js';
9
14
  export { sourceFile, sourceFiles } from './core/model/snapshot.js';
10
15
  export type { InventoryFile, SourceFile, SourceSnapshot } from './core/model/source.js';
11
16
  export { measurements } from './core/model/measurement.js';
12
17
  export type { Measurement } from './core/model/measurement.js';
13
18
  export { findingResult } from './core/model/finding.js';
14
- export type { Finding, FindingResult } from './core/model/finding.js';
19
+ export type { Finding, FindingLocation, FindingResult } from './core/model/finding.js';
15
20
  export type { SourceContext, SourcePlugin, SourceProvider } from './core/ports/source-provider.js';
16
21
  export type { ToolInvocation, ToolResult, ToolRunner } from './core/ports/tool-runner.js';
17
22
  export { DockerToolRunner } from './api/process/docker-tool-runner.js';
18
23
  export type { DockerToolLimits } from './api/process/docker-tool-runner.js';
19
24
  export { processPlugin, processPluginProtocol } from './api/process/plugin.js';
20
25
  export type { ProcessOperation, ProcessPluginManifest } from './api/process/plugin.js';
21
- export type { SourceLocator } from './core/model/source-locator.js';
@@ -1,4 +1,7 @@
1
1
  export { pluginApi } from './core/engine/plugin.js';
2
+ export { plan } from './core/engine/plan.js';
3
+ export { execute } from './core/engine/execute.js';
4
+ export { LocalOperationCache } from './report/json/store/operation-cache.js';
2
5
  export { codeStructure, codeStructures } from './core/model/code-structure.js';
3
6
  export { sourceFile, sourceFiles } from './core/model/snapshot.js';
4
7
  export { measurements } from './core/model/measurement.js';
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../core/engine/plugin.js';
2
+ import type { HostLanguageDescriptor } from '../core/ports/tool-runner.js';
3
+ /** The built-in plugins in run order. The first language plugin is the default provider. */
4
+ export declare const builtInPlugins: readonly Plugin[];
5
+ /** Languages parsed by a host tool when it is installed. */
6
+ export declare const hostLanguages: readonly HostLanguageDescriptor[];
@@ -0,0 +1,39 @@
1
+ import { coverage } from './coverage/coverage.js';
2
+ import { diffCoverage } from './coverage/diff-coverage.js';
3
+ import { duplication } from './duplication/duplication.js';
4
+ import { babelProvider } from './language-js/babel-provider.js';
5
+ import { jsSecurity } from './language-js/js-security.js';
6
+ import { maintainability } from './maintainability/maintainability.js';
7
+ import { actionsSecurity } from './security/actions-security.js';
8
+ import { dockerfile } from './security/dockerfile.js';
9
+ import { npmSupplyChain } from './security/npm-supply-chain.js';
10
+ import { secrets } from './security/secrets.js';
11
+ import { githubSource, gitlabSource, localSource } from './source/forges.js';
12
+ import { structure } from './structure/structure.js';
13
+ /** The built-in plugins in run order. The first language plugin is the default provider. */
14
+ export const builtInPlugins = [babelProvider, structure, maintainability, duplication, coverage, diffCoverage,
15
+ secrets, jsSecurity, actionsSecurity, npmSupplyChain, dockerfile, githubSource, gitlabSource, localSource];
16
+ const measures = ['functions', 'cyclomaticComplexity', 'cognitiveComplexity', 'commentLines', 'codeLines',
17
+ 'structuralRules', 'duplication'];
18
+ /** Languages parsed by a host tool when it is installed. */
19
+ export const hostLanguages = [
20
+ { id: 'go-ast', language: 'go', binary: 'go', args: ['run'], versionArgs: ['version'], script: 'go/parser.go', measures,
21
+ syntax: { lineComments: ['//'], blockComments: [['/*', '*/']],
22
+ strings: [{ quote: '"' }, { quote: "'" }, { quote: '`', multiline: true, raw: true }],
23
+ keywords: ['break', 'case', 'chan', 'const', 'continue', 'default', 'defer', 'else', 'fallthrough', 'for', 'func', 'go',
24
+ 'goto', 'if', 'import', 'interface', 'map', 'package', 'range', 'return', 'select', 'struct', 'switch', 'type', 'var',
25
+ 'true', 'false', 'nil', 'iota'],
26
+ },
27
+ },
28
+ { id: 'python-ast', language: 'python', binary: 'python3', args: ['-I', '-S'], versionArgs: ['--version'],
29
+ script: 'python/parser.py', measures: [...measures, 'classes'],
30
+ syntax: { lineComments: ['#'],
31
+ strings: [{ quote: '"""', multiline: true }, { quote: "'''", multiline: true }, { quote: '"' }, { quote: "'" }],
32
+ stringPrefixes: ['r', 'u', 'b', 'f', 't', 'br', 'rb', 'fr', 'rf', 'tr', 'rt'],
33
+ keywords: ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del',
34
+ 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not',
35
+ 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'],
36
+ },
37
+ },
38
+ ];
39
+ //# sourceMappingURL=built-in.js.map
@@ -1,26 +1,6 @@
1
- import type { DataContract, Plugin } from '../../core/engine/plugin.js';
2
- import type { Measurement } from '../../core/model/measurement.js';
3
- import type { FunctionCallCount, LineCoverage } from '../../core/model/line-coverage.js';
4
- import type { SourceLineRange } from '../../core/model/source.js';
5
- export interface CoverageInput {
6
- readonly text: string;
7
- readonly root: string;
8
- readonly sourceLines: ReadonlyMap<string, number>;
9
- readonly codeLines?: ReadonlyMap<string, ReadonlySet<number>>;
10
- readonly unclassified?: ReadonlySet<string>;
11
- readonly functionBodies?: ReadonlyMap<string, readonly SourceLineRange[]>;
12
- readonly excludes?: (path: string) => boolean;
13
- }
14
- interface CoverageResult {
15
- readonly measurements: readonly Measurement[];
16
- readonly gaps: readonly {
17
- readonly path: string;
18
- readonly reason: string;
19
- }[];
20
- readonly lineCoverage: LineCoverage;
21
- }
22
- export declare const lcovInput: DataContract<CoverageInput>;
23
- export declare const coverageResult: DataContract<CoverageResult>;
1
+ import type { Plugin } from '../../core/engine/plugin.js';
2
+ import type { FunctionCallCount } from '../../core/model/line-coverage.js';
3
+ import type { CoverageInput } from '../../core/model/coverage-input.js';
24
4
  export declare const coverage: Plugin;
25
5
  export declare function mapCoverage({ text, root, sourceLines, codeLines, unclassified, excludes }: CoverageInput): {
26
6
  files: Map<string, Map<number, number>>;
@@ -29,4 +9,3 @@ export declare function mapCoverage({ text, root, sourceLines, codeLines, unclas
29
9
  functionCalls: Map<string, readonly FunctionCallCount[]>;
30
10
  gaps: Map<string, string>;
31
11
  };
32
- export {};
@@ -4,16 +4,8 @@ import { isRecord, pluginApi } from '../../core/engine/plugin.js';
4
4
  import { comparePaths } from '../../core/model/snapshot.js';
5
5
  import { definitions, measurements } from '../../core/model/measurement.js';
6
6
  import { lcovLines } from '../../core/model/line-coverage.js';
7
- export const lcovInput = {
8
- id: 'repometry.lcov-input/v1',
9
- accepts: (value) => isRecord(value) && typeof value.text === 'string'
10
- && typeof value.root === 'string' && value.sourceLines instanceof Map
11
- && (value.codeLines === undefined || value.codeLines instanceof Map)
12
- && (value.unclassified === undefined || value.unclassified instanceof Set)
13
- && (value.functionBodies === undefined || value.functionBodies instanceof Map)
14
- && (value.excludes === undefined || typeof value.excludes === 'function'),
15
- };
16
- export const coverageResult = {
7
+ import { lcovInput } from '../../core/model/coverage-input.js';
8
+ const coverageResult = {
17
9
  id: 'repometry.coverage-result/v1',
18
10
  accepts: (value) => isRecord(value) && measurements.accepts(value.measurements)
19
11
  && Array.isArray(value.gaps) && value.gaps.every(gap => isRecord(gap) && typeof gap.path === 'string' && typeof gap.reason === 'string')
@@ -48,7 +40,12 @@ export const coverage = {
48
40
  role: 'inspection',
49
41
  inputs: { report: lcovInput },
50
42
  output: coverageResult,
51
- execute: inputs => importCoverage(inputs.read('report', lcovInput)),
43
+ execute(inputs) {
44
+ const result = importCoverage(inputs.read('report', lcovInput));
45
+ for (const { path, reason } of result.gaps)
46
+ inputs.emitDiagnostic?.(reason, path);
47
+ return result;
48
+ },
52
49
  }, {
53
50
  id: 'lines',
54
51
  role: 'inspection',
@@ -1,7 +1,3 @@
1
- import type { DataContract, Plugin } from '../../core/engine/plugin.js';
2
- import type { GitChanges } from '../../core/model/changes.js';
3
- import type { DiffCoverageResult } from '../../core/model/diff-coverage.js';
1
+ import type { Plugin } from '../../core/engine/plugin.js';
4
2
  export type { DiffCoverage } from '../../core/model/diff-coverage.js';
5
- export declare const changesInput: DataContract<GitChanges>;
6
- export declare const diffCoverageResult: DataContract<DiffCoverageResult>;
7
3
  export declare const diffCoverage: Plugin;
@@ -1,18 +1,9 @@
1
- import { isRecord, pluginApi } from '../../core/engine/plugin.js';
1
+ import { pluginApi } from '../../core/engine/plugin.js';
2
2
  import { comparePaths } from '../../core/model/snapshot.js';
3
- import { lcovInput, mapCoverage } from './coverage.js';
4
- export const changesInput = {
5
- id: 'repometry.git-line-changes/v1',
6
- accepts: (value) => isRecord(value) && value.files instanceof Map && value.gaps instanceof Map,
7
- };
8
- export const diffCoverageResult = {
9
- id: 'repometry.diff-coverage-result/v1',
10
- accepts: (value) => isRecord(value) && Array.isArray(value.files) && Array.isArray(value.gaps)
11
- && Array.isArray(value.uncovered)
12
- && (value.status === 'complete' || value.status === 'partial' || value.status === 'not-applicable')
13
- && typeof value.covered === 'number' && typeof value.total === 'number'
14
- && (value.percent === null || typeof value.percent === 'number'),
15
- };
3
+ import { mapCoverage } from './coverage.js';
4
+ import { lcovInput } from '../../core/model/coverage-input.js';
5
+ import { changesInput } from '../../core/model/changes.js';
6
+ import { diffCoverageResult } from '../../core/model/diff-coverage.js';
16
7
  export const diffCoverage = {
17
8
  id: 'diff-coverage',
18
9
  version: '1.0.0',
@@ -1,4 +1,2 @@
1
- import type { DataContract, Plugin } from '../../core/engine/plugin.js';
2
- import type { CloneSource } from '../../core/model/clone-source.js';
1
+ import type { Plugin } from '../../core/engine/plugin.js';
3
2
  export declare const duplication: Plugin;
4
- export declare const duplicationInput: DataContract<readonly CloneSource[]>;
@@ -2,15 +2,12 @@ import { pluginApi } from '../../core/engine/plugin.js';
2
2
  import { comparePaths } from '../../core/model/snapshot.js';
3
3
  import { findingResult } from '../../core/model/finding.js';
4
4
  import { definitions } from '../../core/model/measurement.js';
5
- import { isCloneSource } from '../../core/model/clone-source.js';
5
+ import { cloneSources } from '../../core/model/clone-source.js';
6
6
  import { duplicationSettings } from '../../core/profile/maintainability.js';
7
- const cloneSources = {
8
- id: 'repometry.clone-sources/v1',
9
- accepts: (value) => Array.isArray(value) && value.every(isCloneSource),
10
- };
11
7
  export const duplication = {
12
8
  id: 'duplication', version: '1.0.0', api: pluginApi,
13
9
  kinds: ['analysis'],
10
+ rules: [{ id: 'identical-code', category: 'duplication' }, { id: 'similar-code', category: 'duplication' }],
14
11
  produces: [{ contract: findingResult.id, persistence: 'report', metrics: [
15
12
  { id: definitions.duplicatedLines, label: 'Duplicated lines', unit: 'count', scope: 'file', aggregate: 'sum', better: 'lower',
16
13
  group: 'Maintainability' },
@@ -20,7 +17,6 @@ export const duplication = {
20
17
  execute(inputs) { return detectClones(inputs.read('sources', cloneSources)); },
21
18
  }],
22
19
  };
23
- export const duplicationInput = cloneSources;
24
20
  function detectClones(sources) {
25
21
  const schemes = new Map();
26
22
  for (const { path, candidates, scheme } of sources) {
@@ -11,16 +11,17 @@ import { functionFacts } from './function-facts.js';
11
11
  import { qualifiedNames } from './qualified-names.js';
12
12
  import { structuralObservations } from './structural-observations.js';
13
13
  import { jsTsExtensions } from './extensions.js';
14
+ import { jsSyntax } from './syntax.js';
14
15
  const require = createRequire(import.meta.url);
15
16
  export const parserDefaults = { sourceType: 'unambiguous', errorRecovery: false, attachComment: false };
16
17
  export const babelTypes = { '@babel/types': require('@babel/types/package.json').version };
17
18
  export const babelProvider = {
18
19
  id: 'babel-syntax',
19
- version: '1.0.0',
20
+ version: '1.1.0',
20
21
  api: pluginApi,
21
22
  kinds: ['language'],
22
23
  claims: { extensions: jsTsExtensions, languages: ['javascript', 'typescript'] },
23
- providesLanguages: [javascriptType, typescriptType],
24
+ providesLanguages: [{ ...javascriptType, syntax: jsSyntax }, { ...typescriptType, syntax: jsSyntax }],
24
25
  settings: parserDefaults,
25
26
  produces: [{ contract: codeStructure.id, persistence: 'transient' }],
26
27
  tools: { '@babel/parser': require('@babel/parser/package.json').version, ...babelTypes },
@@ -69,7 +69,7 @@ export function structuralObservations(ast, names) {
69
69
  }
70
70
  continue;
71
71
  }
72
- visit(child, frame, depth + Number(block || node.type === 'TryStatement'), node);
72
+ visit(child, frame, depth + Number(block), node);
73
73
  }
74
74
  }
75
75
  function observe(rule, value, label, location, anchor) {
@@ -0,0 +1,2 @@
1
+ import type { LanguageSyntax } from '../../core/model/language.js';
2
+ export declare const jsSyntax: LanguageSyntax;
@@ -0,0 +1,11 @@
1
+ export const jsSyntax = {
2
+ lineComments: ['//'],
3
+ blockComments: [['/*', '*/']],
4
+ strings: [{ quote: "'" }, { quote: '"' }, { quote: '`', multiline: true }],
5
+ keywords: ('abstract as async await break case catch class const continue debugger declare default delete do else enum '
6
+ + 'export extends false finally for from function get if implements import in instanceof interface let new null of '
7
+ + 'package private protected public readonly return satisfies set static super switch this throw true try type typeof '
8
+ + 'undefined var void while with yield').split(' '),
9
+ regexAfter: 'return typeof instanceof in of new delete void throw case do else yield await'.split(' '),
10
+ };
11
+ //# sourceMappingURL=syntax.js.map
@@ -1,9 +1,2 @@
1
- import type { DataContract, Plugin } from '../../core/engine/plugin.js';
2
- import type { CloneSource } from '../../core/model/clone-source.js';
3
- import type { FindingResult } from '../../core/model/finding.js';
4
- interface FileQuality extends FindingResult {
5
- readonly cloneSource?: CloneSource;
6
- }
7
- export declare const fileQuality: DataContract<FileQuality>;
1
+ import type { Plugin } from '../../core/engine/plugin.js';
8
2
  export declare const maintainability: Plugin;
9
- export {};