@produtype/core 0.28.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How closely this analyzer read each language it found.
|
|
3
|
+
*
|
|
4
|
+
* The product's whole argument is that it says only what it can show. It has been
|
|
5
|
+
* saying, with the same confidence in both cases, things it read from a syntax tree and
|
|
6
|
+
* things it guessed from a word — and the report gave a reader no way to tell which.
|
|
7
|
+
*
|
|
8
|
+
* Measured rather than asserted: 68 keyword searches against 1 structural claim, and 6
|
|
9
|
+
* of 18 readable extensions covered by a parser. A report on a Go project and a report
|
|
10
|
+
* on a TypeScript project looked equally sure of themselves, and were not.
|
|
11
|
+
*
|
|
12
|
+
* Three depths, in the order they deserve to be trusted:
|
|
13
|
+
*
|
|
14
|
+
* - `parsed`: a syntax tree answered the question. `{m.role === 'user' ? 'You' : 'Bot'}`
|
|
15
|
+
* is a label and `if (!roles.includes(actor.role)) return res.status(403)` is a guard,
|
|
16
|
+
* and nothing about the words tells them apart.
|
|
17
|
+
* - `searched`: the file was read as text and matched against keywords. Everything this
|
|
18
|
+
* analyzer has always done, and where every defect of 18 September lived.
|
|
19
|
+
* - `skipped`: the language was seen and not read at all.
|
|
20
|
+
*/
|
|
21
|
+
export type ReadingDepth = 'parsed' | 'searched' | 'skipped';
|
|
22
|
+
export interface LanguageReading {
|
|
23
|
+
language: string;
|
|
24
|
+
files: number;
|
|
25
|
+
depth: ReadingDepth;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* What was read, and how, for every language present in the repository.
|
|
29
|
+
*
|
|
30
|
+
* Counts source files rather than all files: a language that appears only in an ignored
|
|
31
|
+
* directory was not read because it was not the project's, which is a different fact and
|
|
32
|
+
* one the reader does not need here.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readingDepths(sourceFiles: string[], unreadable: Array<{
|
|
35
|
+
language: string;
|
|
36
|
+
files: number;
|
|
37
|
+
}>): LanguageReading[];
|
|
38
|
+
/**
|
|
39
|
+
* The sentence a reader needs, or nothing.
|
|
40
|
+
*
|
|
41
|
+
* Silent where everything was parsed: a report that congratulates itself on reading
|
|
42
|
+
* properly is noise. It speaks when some of the reading was shallower than the rest,
|
|
43
|
+
* which is the case that misleads.
|
|
44
|
+
*/
|
|
45
|
+
export declare function describeReadingDepth(readings: LanguageReading[]): string | undefined;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readingDepths = readingDepths;
|
|
4
|
+
exports.describeReadingDepth = describeReadingDepth;
|
|
5
|
+
const catalogue_1 = require("./catalogue");
|
|
6
|
+
/**
|
|
7
|
+
* The extensions a parser reads today.
|
|
8
|
+
*
|
|
9
|
+
* One list, so that adding Python to the structural layer changes what the report claims
|
|
10
|
+
* about Python in the same commit that makes it true. A second copy of this would drift
|
|
11
|
+
* within a week, which is the failure this file exists to stop somebody else making.
|
|
12
|
+
*/
|
|
13
|
+
const PARSED_EXTENSIONS = /\.(ts|tsx|js|jsx|mjs|cjs)$/;
|
|
14
|
+
/** Languages whose files are read as text but never parsed. */
|
|
15
|
+
function depthFor(files) {
|
|
16
|
+
if (files.length === 0)
|
|
17
|
+
return 'skipped';
|
|
18
|
+
return files.every((file) => PARSED_EXTENSIONS.test(file)) ? 'parsed' : 'searched';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* What was read, and how, for every language present in the repository.
|
|
22
|
+
*
|
|
23
|
+
* Counts source files rather than all files: a language that appears only in an ignored
|
|
24
|
+
* directory was not read because it was not the project's, which is a different fact and
|
|
25
|
+
* one the reader does not need here.
|
|
26
|
+
*/
|
|
27
|
+
function readingDepths(sourceFiles, unreadable) {
|
|
28
|
+
const readings = [];
|
|
29
|
+
for (const { label, extensions } of catalogue_1.LANGUAGES) {
|
|
30
|
+
const files = sourceFiles.filter((file) => extensions.test(file));
|
|
31
|
+
if (files.length === 0)
|
|
32
|
+
continue;
|
|
33
|
+
readings.push({ language: label, files: files.length, depth: depthFor(files) });
|
|
34
|
+
}
|
|
35
|
+
for (const entry of unreadable) {
|
|
36
|
+
readings.push({ language: entry.language, files: entry.files, depth: 'skipped' });
|
|
37
|
+
}
|
|
38
|
+
return readings.sort((left, right) => right.files - left.files);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The sentence a reader needs, or nothing.
|
|
42
|
+
*
|
|
43
|
+
* Silent where everything was parsed: a report that congratulates itself on reading
|
|
44
|
+
* properly is noise. It speaks when some of the reading was shallower than the rest,
|
|
45
|
+
* which is the case that misleads.
|
|
46
|
+
*/
|
|
47
|
+
function describeReadingDepth(readings) {
|
|
48
|
+
const searched = readings.filter((entry) => entry.depth === 'searched');
|
|
49
|
+
const skipped = readings.filter((entry) => entry.depth === 'skipped');
|
|
50
|
+
if (searched.length === 0 && skipped.length === 0)
|
|
51
|
+
return undefined;
|
|
52
|
+
const parts = [];
|
|
53
|
+
if (searched.length > 0) {
|
|
54
|
+
parts.push(`${searched.map((entry) => entry.language).join(', ')} ${searched.length === 1 ? 'was' : 'were'} read as text and matched against keywords, not parsed`);
|
|
55
|
+
}
|
|
56
|
+
if (skipped.length > 0) {
|
|
57
|
+
parts.push(`${skipped.map((entry) => `${entry.language} (${entry.files} files)`).join(', ')} not read at all`);
|
|
58
|
+
}
|
|
59
|
+
return `How this repository was read: ${parts.join('; ')}. A keyword can appear in a comment, a test fixture or a variable name, so findings in those languages rest on weaker evidence than the ones this analyzer parsed.`;
|
|
60
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildReport = buildReport;
|
|
4
4
|
const ruleEngine_1 = require("../rules/ruleEngine");
|
|
5
|
+
const readingDepth_1 = require("../analyzer/readingDepth");
|
|
5
6
|
const score_1 = require("./score");
|
|
6
7
|
const types_1 = require("./types");
|
|
7
8
|
const evaluateExpectations_1 = require("../expectations/evaluateExpectations");
|
|
@@ -296,6 +297,12 @@ function buildReport(analysis, options) {
|
|
|
296
297
|
// to know that one rests on seventeen verdicts and the other on nine.
|
|
297
298
|
assessedChecks,
|
|
298
299
|
verifiedChecks: passedChecksForMaturity,
|
|
300
|
+
/**
|
|
301
|
+
* How closely each language was read, so a reader can weigh a finding by more than
|
|
302
|
+
* its severity. A keyword match in Go and a parsed guard in TypeScript were being
|
|
303
|
+
* presented with the same confidence.
|
|
304
|
+
*/
|
|
305
|
+
readingDepth: (0, readingDepth_1.readingDepths)(analysis.files.source, analysis.files.unreadable),
|
|
299
306
|
detectors: detectorDiagnostics(analysis),
|
|
300
307
|
selectedProfile: requestedProfile,
|
|
301
308
|
inferredProfile: productProfile?.inferredProfile,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.renderMarkdown = renderMarkdown;
|
|
4
|
+
const readingDepth_1 = require("../analyzer/readingDepth");
|
|
4
5
|
function profileSummary(report) {
|
|
5
6
|
const profile = report.productProfile;
|
|
6
7
|
if (!profile) {
|
|
@@ -242,6 +243,16 @@ function renderMarkdown(report) {
|
|
|
242
243
|
]
|
|
243
244
|
: []),
|
|
244
245
|
`- Diagnostics: ${report.diagnostics.analyzedFileCount} analyzed / ${report.diagnostics.skippedFileCount} skipped / ${report.diagnostics.workspaceCount} workspaces / ${report.diagnostics.detectorCount} detectors`,
|
|
246
|
+
/**
|
|
247
|
+
* How the code was read, beside how much of it there was.
|
|
248
|
+
*
|
|
249
|
+
* A keyword match in Go and a parsed guard in TypeScript were printed with the same
|
|
250
|
+
* confidence, and nothing in the report distinguished them. Silent when everything
|
|
251
|
+
* was parsed: a report congratulating itself on reading properly is noise.
|
|
252
|
+
*/
|
|
253
|
+
...((0, readingDepth_1.describeReadingDepth)(report.diagnostics.readingDepth)
|
|
254
|
+
? [`- ${(0, readingDepth_1.describeReadingDepth)(report.diagnostics.readingDepth)}`]
|
|
255
|
+
: []),
|
|
245
256
|
`- Expectation mode: ${report.diagnostics.expectationMode}`,
|
|
246
257
|
`- ProdKit version: ${report.diagnostics.prodkitVersion}`,
|
|
247
258
|
`- Detector diagnostics: ${report.diagnostics.detectors.filter((d) => d.status === 'completed').length} completed / ${report.diagnostics.detectors.filter((d) => d.status === 'skipped').length} skipped`,
|
package/dist/report/types.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export interface Finding {
|
|
|
47
47
|
}
|
|
48
48
|
export type MaturityLevel = 'prototype' | 'early' | 'partial' | 'production_ready';
|
|
49
49
|
export type ExpectationMode = 'observed-only' | 'explicit-profile' | 'auto-applied' | 'auto-inconclusive';
|
|
50
|
+
import type { LanguageReading } from '../analyzer/readingDepth';
|
|
50
51
|
export interface ReportDiagnostics {
|
|
51
52
|
analyzedFileCount: number;
|
|
52
53
|
skippedFileCount: number;
|
|
@@ -56,6 +57,14 @@ export interface ReportDiagnostics {
|
|
|
56
57
|
assessedChecks: number;
|
|
57
58
|
/** Of those, the ones that ran and found what they were looking for. */
|
|
58
59
|
verifiedChecks: number;
|
|
60
|
+
/**
|
|
61
|
+
* How closely each language present was read.
|
|
62
|
+
*
|
|
63
|
+
* A finding matched from a keyword in Go and a finding read from a syntax tree in
|
|
64
|
+
* TypeScript were presented with identical confidence. They are not the same kind of
|
|
65
|
+
* fact, and the reader is entitled to know which one they have.
|
|
66
|
+
*/
|
|
67
|
+
readingDepth: LanguageReading[];
|
|
59
68
|
detectors: Array<{
|
|
60
69
|
id: string;
|
|
61
70
|
status: 'completed' | 'skipped';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@produtype/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.1",
|
|
4
4
|
"description": "Deterministic CLI and library that analyzes a web application repository and reports how far it is from production-ready for the kind of product it is meant to be.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|