@code-pushup/jsdocs-plugin 0.67.0 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/lib/runner/doc-processor.d.ts +14 -22
- package/src/lib/runner/doc-processor.js +34 -41
- package/src/lib/runner/doc-processor.js.map +1 -1
- package/src/lib/runner/models.d.ts +0 -19
- package/src/lib/runner/runner.d.ts +4 -2
- package/src/lib/runner/runner.js +16 -14
- package/src/lib/runner/runner.js.map +1 -1
- package/src/lib/runner/utils.d.ts +9 -8
- package/src/lib/runner/utils.js +35 -29
- package/src/lib/runner/utils.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/jsdocs-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.0",
|
|
4
4
|
"description": "Code PushUp plugin for tracking documentation coverage 📚",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-jsdocs#readme",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"type": "module",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@code-pushup/models": "0.
|
|
39
|
-
"@code-pushup/utils": "0.
|
|
38
|
+
"@code-pushup/models": "0.69.0",
|
|
39
|
+
"@code-pushup/utils": "0.69.0",
|
|
40
40
|
"zod": "^3.22.4",
|
|
41
41
|
"ts-morph": "^24.0.0"
|
|
42
42
|
},
|
|
@@ -1,45 +1,37 @@
|
|
|
1
1
|
import { ClassDeclaration, JSDoc, SourceFile, SyntaxKind, VariableStatement } from 'ts-morph';
|
|
2
|
+
import { type FileCoverage } from '@code-pushup/utils';
|
|
2
3
|
import type { JsDocsPluginTransformedConfig } from '../config.js';
|
|
3
|
-
import type {
|
|
4
|
+
import type { CoverageType } from './models.js';
|
|
5
|
+
type Node = {
|
|
6
|
+
getKind: () => SyntaxKind;
|
|
7
|
+
getName: () => string | undefined;
|
|
8
|
+
getStartLineNumber: () => number;
|
|
9
|
+
getEndLineNumber: () => number;
|
|
10
|
+
getJsDocs: () => JSDoc[];
|
|
11
|
+
};
|
|
4
12
|
/**
|
|
5
13
|
* Gets the variables information from the variable statements
|
|
6
14
|
* @param variableStatements - The variable statements to process
|
|
7
15
|
* @returns The variables information with the right methods to get the information
|
|
8
16
|
*/
|
|
9
|
-
export declare function getVariablesInformation(variableStatements: VariableStatement[]):
|
|
10
|
-
getName: () => string;
|
|
11
|
-
getKind: () => SyntaxKind;
|
|
12
|
-
getJsDocs: () => JSDoc[];
|
|
13
|
-
getStartLineNumber: () => number;
|
|
14
|
-
}[];
|
|
17
|
+
export declare function getVariablesInformation(variableStatements: VariableStatement[]): Node[];
|
|
15
18
|
/**
|
|
16
19
|
* Processes documentation coverage for TypeScript files in the specified path
|
|
17
20
|
* @param config - The configuration object containing patterns to include for documentation analysis
|
|
18
21
|
* @returns Object containing coverage statistics and undocumented items
|
|
19
22
|
*/
|
|
20
|
-
export declare function processJsDocs(config: JsDocsPluginTransformedConfig):
|
|
21
|
-
export declare function getAllNodesFromASourceFile(sourceFile: SourceFile): (
|
|
22
|
-
getName: () => string;
|
|
23
|
-
getKind: () => SyntaxKind;
|
|
24
|
-
getJsDocs: () => JSDoc[];
|
|
25
|
-
getStartLineNumber: () => number;
|
|
26
|
-
} | ClassDeclaration | import("ts-morph").FunctionDeclaration | import("ts-morph").MethodDeclaration | import("ts-morph").PropertyDeclaration | import("ts-morph").TypeAliasDeclaration | import("ts-morph").EnumDeclaration | import("ts-morph").InterfaceDeclaration)[];
|
|
23
|
+
export declare function processJsDocs(config: JsDocsPluginTransformedConfig): Record<CoverageType, FileCoverage[]>;
|
|
24
|
+
export declare function getAllNodesFromASourceFile(sourceFile: SourceFile): (Node | ClassDeclaration | import("ts-morph").FunctionDeclaration | import("ts-morph").MethodDeclaration | import("ts-morph").PropertyDeclaration | import("ts-morph").TypeAliasDeclaration | import("ts-morph").EnumDeclaration | import("ts-morph").InterfaceDeclaration)[];
|
|
27
25
|
/**
|
|
28
26
|
* Gets the documentation coverage report from the source files
|
|
29
27
|
* @param sourceFiles - The source files to process
|
|
30
28
|
* @returns The documentation coverage report
|
|
31
29
|
*/
|
|
32
|
-
export declare function getDocumentationReport(sourceFiles: SourceFile[]):
|
|
33
|
-
/**
|
|
34
|
-
* Merges two documentation results
|
|
35
|
-
* @param accumulatedReport - The first empty documentation result
|
|
36
|
-
* @param currentFileReport - The second documentation result
|
|
37
|
-
* @returns The merged documentation result
|
|
38
|
-
*/
|
|
39
|
-
export declare function mergeDocumentationReports(accumulatedReport: DocumentationReport, currentFileReport: Partial<DocumentationReport>): DocumentationReport;
|
|
30
|
+
export declare function getDocumentationReport(sourceFiles: SourceFile[]): Record<CoverageType, FileCoverage[]>;
|
|
40
31
|
/**
|
|
41
32
|
* Gets the nodes from a class
|
|
42
33
|
* @param classNodes - The class nodes to process
|
|
43
34
|
* @returns The nodes from the class
|
|
44
35
|
*/
|
|
45
36
|
export declare function getClassNodes(classNodes: ClassDeclaration[]): (import("ts-morph").MethodDeclaration | import("ts-morph").PropertyDeclaration)[];
|
|
37
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClassDeclaration, JSDoc, Project, SourceFile, SyntaxKind, VariableStatement, } from 'ts-morph';
|
|
2
|
-
import { objectFromEntries, objectToEntries } from '@code-pushup/utils';
|
|
3
|
-
import {
|
|
2
|
+
import { objectFromEntries, objectToEntries, } from '@code-pushup/utils';
|
|
3
|
+
import { createInitialCoverageTypesRecord, getCoverageTypeFromKind, singularCoverageType, } from './utils.js';
|
|
4
4
|
/**
|
|
5
5
|
* Gets the variables information from the variable statements
|
|
6
6
|
* @param variableStatements - The variable statements to process
|
|
@@ -13,6 +13,7 @@ export function getVariablesInformation(variableStatements) {
|
|
|
13
13
|
getKind: () => variable.getKind(),
|
|
14
14
|
getJsDocs: () => variable.getJsDocs(),
|
|
15
15
|
getStartLineNumber: () => variable.getStartLineNumber(),
|
|
16
|
+
getEndLineNumber: () => variable.getEndLineNumber(),
|
|
16
17
|
};
|
|
17
18
|
// Map each declaration to combine parent info with declaration-specific info
|
|
18
19
|
return variable.getDeclarations().map(declaration => ({
|
|
@@ -49,13 +50,15 @@ export function getAllNodesFromASourceFile(sourceFile) {
|
|
|
49
50
|
* @returns The documentation coverage report
|
|
50
51
|
*/
|
|
51
52
|
export function getDocumentationReport(sourceFiles) {
|
|
52
|
-
|
|
53
|
+
return sourceFiles.reduce((acc, sourceFile) => {
|
|
53
54
|
const filePath = sourceFile.getFilePath();
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const nodes = getAllNodesFromASourceFile(sourceFile);
|
|
56
|
+
const coverageTypes = getCoverageFromAllNodesOfFile(nodes, filePath);
|
|
57
|
+
return objectFromEntries(objectToEntries(coverageTypes).map(([type, file]) => [
|
|
58
|
+
type,
|
|
59
|
+
[...acc[type], file],
|
|
60
|
+
]));
|
|
61
|
+
}, createInitialCoverageTypesRecord([]));
|
|
59
62
|
}
|
|
60
63
|
/**
|
|
61
64
|
* Gets the coverage from all nodes of a file
|
|
@@ -66,44 +69,34 @@ export function getDocumentationReport(sourceFiles) {
|
|
|
66
69
|
function getCoverageFromAllNodesOfFile(nodes, filePath) {
|
|
67
70
|
return nodes.reduce((acc, node) => {
|
|
68
71
|
const nodeType = getCoverageTypeFromKind(node.getKind());
|
|
69
|
-
const
|
|
70
|
-
const updatedIssues = node.getJsDocs().length === 0
|
|
71
|
-
? [
|
|
72
|
-
...currentTypeReport.issues,
|
|
73
|
-
{
|
|
74
|
-
file: filePath,
|
|
75
|
-
type: nodeType,
|
|
76
|
-
name: node.getName() || '',
|
|
77
|
-
line: node.getStartLineNumber(),
|
|
78
|
-
},
|
|
79
|
-
]
|
|
80
|
-
: currentTypeReport.issues;
|
|
72
|
+
const isCovered = node.getJsDocs().length > 0;
|
|
81
73
|
return {
|
|
82
74
|
...acc,
|
|
83
75
|
[nodeType]: {
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
...acc[nodeType],
|
|
77
|
+
total: acc[nodeType].total + 1,
|
|
78
|
+
...(isCovered
|
|
79
|
+
? {
|
|
80
|
+
covered: acc[nodeType].covered + 1,
|
|
81
|
+
}
|
|
82
|
+
: {
|
|
83
|
+
missing: [
|
|
84
|
+
...acc[nodeType].missing,
|
|
85
|
+
{
|
|
86
|
+
kind: singularCoverageType(nodeType),
|
|
87
|
+
name: node.getName(),
|
|
88
|
+
startLine: node.getStartLineNumber(),
|
|
89
|
+
endLine: node.getEndLineNumber(),
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
}),
|
|
86
93
|
},
|
|
87
94
|
};
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* @param currentFileReport - The second documentation result
|
|
94
|
-
* @returns The merged documentation result
|
|
95
|
-
*/
|
|
96
|
-
export function mergeDocumentationReports(accumulatedReport, currentFileReport) {
|
|
97
|
-
return objectFromEntries(objectToEntries(accumulatedReport).map(([key, value]) => {
|
|
98
|
-
const node = value;
|
|
99
|
-
const type = key;
|
|
100
|
-
return [
|
|
101
|
-
type,
|
|
102
|
-
{
|
|
103
|
-
nodesCount: node.nodesCount + (currentFileReport[type]?.nodesCount ?? 0),
|
|
104
|
-
issues: [...node.issues, ...(currentFileReport[type]?.issues ?? [])],
|
|
105
|
-
},
|
|
106
|
-
];
|
|
95
|
+
}, createInitialCoverageTypesRecord({
|
|
96
|
+
path: filePath,
|
|
97
|
+
covered: 0,
|
|
98
|
+
total: 0,
|
|
99
|
+
missing: [],
|
|
107
100
|
}));
|
|
108
101
|
}
|
|
109
102
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc-processor.js","sourceRoot":"","sources":["../../../../../../packages/plugin-jsdocs/src/lib/runner/doc-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,UAAU,EACV,UAAU,EACV,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,
|
|
1
|
+
{"version":3,"file":"doc-processor.js","sourceRoot":"","sources":["../../../../../../packages/plugin-jsdocs/src/lib/runner/doc-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,UAAU,EACV,UAAU,EACV,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAEL,iBAAiB,EACjB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAUpB;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACrC,kBAAuC;IAEvC,OAAO,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3C,+BAA+B;QAC/B,MAAM,UAAU,GAAG;YACjB,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE;YACjC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE;YACrC,kBAAkB,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,kBAAkB,EAAE;YACvD,gBAAgB,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,gBAAgB,EAAE;SACpD,CAAC;QAEF,6EAA6E;QAC7E,OAAO,QAAQ,CAAC,eAAe,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACpD,GAAG,UAAU;YACb,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE;SACrC,CAAC,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAqC;IAErC,MAAM,OAAO,G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/** The possible coverage types for documentation analysis */
|
|
2
2
|
export type CoverageType = 'classes' | 'methods' | 'functions' | 'interfaces' | 'enums' | 'variables' | 'properties' | 'types';
|
|
3
|
-
/** The undocumented node is the node that is not documented and has the information for the report. */
|
|
4
|
-
export type UndocumentedNode = {
|
|
5
|
-
file: string;
|
|
6
|
-
type: CoverageType;
|
|
7
|
-
name: string;
|
|
8
|
-
line: number;
|
|
9
|
-
class?: string;
|
|
10
|
-
};
|
|
11
|
-
/** The documentation data has the issues and the total nodes count from a specific CoverageType. */
|
|
12
|
-
export type DocumentationData = {
|
|
13
|
-
issues: UndocumentedNode[];
|
|
14
|
-
nodesCount: number;
|
|
15
|
-
};
|
|
16
|
-
/** The documentation report has all the documentation data for each coverage type. */
|
|
17
|
-
export type DocumentationReport = Record<CoverageType, DocumentationData>;
|
|
18
|
-
/** The processed documentation result has the documentation data for each coverage type and with coverage stats. */
|
|
19
|
-
export type DocumentationCoverageReport = Record<CoverageType, DocumentationData & {
|
|
20
|
-
coverage: number;
|
|
21
|
-
}>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { AuditOutputs, RunnerFunction } from '@code-pushup/models';
|
|
2
|
+
import { type FileCoverage } from '@code-pushup/utils';
|
|
2
3
|
import type { JsDocsPluginTransformedConfig } from '../config.js';
|
|
3
|
-
import type {
|
|
4
|
+
import type { CoverageType } from './models.js';
|
|
4
5
|
export declare function createRunnerFunction(config: JsDocsPluginTransformedConfig): RunnerFunction;
|
|
5
6
|
/**
|
|
6
7
|
* Transforms the coverage report into audit outputs.
|
|
7
8
|
* @param coverageResult - The coverage result containing undocumented items and coverage statistics
|
|
8
9
|
* @param options - Configuration options specifying which audits to include and exclude
|
|
10
|
+
* @param gitRoot - Root directory in repo for relative file paths
|
|
9
11
|
* @returns Audit outputs with coverage scores and details about undocumented items
|
|
10
12
|
*/
|
|
11
|
-
export declare function trasformCoverageReportToAuditOutputs(coverageResult:
|
|
13
|
+
export declare function trasformCoverageReportToAuditOutputs(coverageResult: Record<CoverageType, FileCoverage[]>, options: Pick<JsDocsPluginTransformedConfig, 'onlyAudits' | 'skipAudits'>, gitRoot: string): AuditOutputs;
|
package/src/lib/runner/runner.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import { filesCoverageToTree, getGitRoot, objectToEntries, toNumberPrecision, } from '@code-pushup/utils';
|
|
1
2
|
import { processJsDocs } from './doc-processor.js';
|
|
2
3
|
import { coverageTypeToAuditSlug } from './utils.js';
|
|
3
4
|
export function createRunnerFunction(config) {
|
|
4
|
-
return () => {
|
|
5
|
+
return async () => {
|
|
5
6
|
const coverageResult = processJsDocs(config);
|
|
6
|
-
|
|
7
|
+
const gitRoot = await getGitRoot();
|
|
8
|
+
return trasformCoverageReportToAuditOutputs(coverageResult, config, gitRoot);
|
|
7
9
|
};
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Transforms the coverage report into audit outputs.
|
|
11
13
|
* @param coverageResult - The coverage result containing undocumented items and coverage statistics
|
|
12
14
|
* @param options - Configuration options specifying which audits to include and exclude
|
|
15
|
+
* @param gitRoot - Root directory in repo for relative file paths
|
|
13
16
|
* @returns Audit outputs with coverage scores and details about undocumented items
|
|
14
17
|
*/
|
|
15
|
-
export function trasformCoverageReportToAuditOutputs(coverageResult, options) {
|
|
16
|
-
return
|
|
18
|
+
export function trasformCoverageReportToAuditOutputs(coverageResult, options, gitRoot) {
|
|
19
|
+
return objectToEntries(coverageResult)
|
|
17
20
|
.filter(([type]) => {
|
|
18
21
|
const auditSlug = coverageTypeToAuditSlug(type);
|
|
19
22
|
if (options.onlyAudits?.length) {
|
|
@@ -24,19 +27,18 @@ export function trasformCoverageReportToAuditOutputs(coverageResult, options) {
|
|
|
24
27
|
}
|
|
25
28
|
return true;
|
|
26
29
|
})
|
|
27
|
-
.map(([type,
|
|
28
|
-
const
|
|
30
|
+
.map(([type, files]) => {
|
|
31
|
+
const tree = filesCoverageToTree(files, gitRoot, `Documented ${type}`);
|
|
32
|
+
const coverage = tree.root.values.coverage;
|
|
33
|
+
const missingCount = files.reduce((acc, file) => acc + file.missing.length, 0);
|
|
34
|
+
const MAX_DECIMAL_PLACES = 4;
|
|
29
35
|
return {
|
|
30
36
|
slug: `${type}-coverage`,
|
|
31
|
-
value:
|
|
32
|
-
score: coverage
|
|
33
|
-
displayValue: `${
|
|
37
|
+
value: missingCount,
|
|
38
|
+
score: toNumberPrecision(coverage, MAX_DECIMAL_PLACES),
|
|
39
|
+
displayValue: `${missingCount} undocumented ${type}`,
|
|
34
40
|
details: {
|
|
35
|
-
|
|
36
|
-
message: `Missing ${type} documentation for ${name}`,
|
|
37
|
-
source: { file, position: { startLine: line } },
|
|
38
|
-
severity: 'warning',
|
|
39
|
-
})),
|
|
41
|
+
trees: [tree],
|
|
40
42
|
},
|
|
41
43
|
};
|
|
42
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../../../packages/plugin-jsdocs/src/lib/runner/runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../../../packages/plugin-jsdocs/src/lib/runner/runner.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,UAAU,oBAAoB,CAClC,MAAqC;IAErC,OAAO,KAAK,IAA2B,EAAE;QACvC,MAAM,cAAc,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,OAAO,GAAG,MAAM,UAAU,EAAE,CAAC;QACnC,OAAO,oCAAoC,CACzC,cAAc,EACd,MAAM,EACN,OAAO,CACR,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AAC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AAC"}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { SyntaxKind } from 'ts-morph';
|
|
2
|
-
import type { CoverageType
|
|
2
|
+
import type { CoverageType } from './models.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates an empty unprocessed coverage report.
|
|
5
|
+
* @param initialValue - Initial value for each coverage type
|
|
5
6
|
* @returns The empty unprocessed coverage report.
|
|
6
7
|
*/
|
|
7
|
-
export declare function
|
|
8
|
+
export declare function createInitialCoverageTypesRecord<T>(initialValue: T): Record<CoverageType, T>;
|
|
8
9
|
/**
|
|
9
10
|
* Converts the coverage type to the audit slug.
|
|
10
11
|
* @param type - The coverage type.
|
|
11
12
|
* @returns The audit slug.
|
|
12
13
|
*/
|
|
13
14
|
export declare function coverageTypeToAuditSlug(type: CoverageType): string;
|
|
14
|
-
/**
|
|
15
|
-
* Calculates the coverage percentage for each coverage type.
|
|
16
|
-
* @param result - The unprocessed coverage result.
|
|
17
|
-
* @returns The processed coverage result.
|
|
18
|
-
*/
|
|
19
|
-
export declare function calculateCoverage(result: DocumentationReport): DocumentationCoverageReport;
|
|
20
15
|
/**
|
|
21
16
|
* Maps the SyntaxKind from the library ts-morph to the coverage type.
|
|
22
17
|
* @param kind - The SyntaxKind from the library ts-morph.
|
|
23
18
|
* @returns The coverage type.
|
|
24
19
|
*/
|
|
25
20
|
export declare function getCoverageTypeFromKind(kind: SyntaxKind): CoverageType;
|
|
21
|
+
/**
|
|
22
|
+
* Convert plural coverage type to singular form
|
|
23
|
+
* @param type Coverage type (plural)
|
|
24
|
+
* @returns Singular form of coverage type
|
|
25
|
+
*/
|
|
26
|
+
export declare function singularCoverageType(type: CoverageType): string;
|
package/src/lib/runner/utils.js
CHANGED
|
@@ -2,18 +2,19 @@ import { SyntaxKind } from 'ts-morph';
|
|
|
2
2
|
import { SYNTAX_COVERAGE_MAP } from './constants.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates an empty unprocessed coverage report.
|
|
5
|
+
* @param initialValue - Initial value for each coverage type
|
|
5
6
|
* @returns The empty unprocessed coverage report.
|
|
6
7
|
*/
|
|
7
|
-
export function
|
|
8
|
+
export function createInitialCoverageTypesRecord(initialValue) {
|
|
8
9
|
return {
|
|
9
|
-
enums:
|
|
10
|
-
interfaces:
|
|
11
|
-
types:
|
|
12
|
-
functions:
|
|
13
|
-
variables:
|
|
14
|
-
classes:
|
|
15
|
-
methods:
|
|
16
|
-
properties:
|
|
10
|
+
enums: initialValue,
|
|
11
|
+
interfaces: initialValue,
|
|
12
|
+
types: initialValue,
|
|
13
|
+
functions: initialValue,
|
|
14
|
+
variables: initialValue,
|
|
15
|
+
classes: initialValue,
|
|
16
|
+
methods: initialValue,
|
|
17
|
+
properties: initialValue,
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
@@ -24,26 +25,6 @@ export function createEmptyCoverageData() {
|
|
|
24
25
|
export function coverageTypeToAuditSlug(type) {
|
|
25
26
|
return `${type}-coverage`;
|
|
26
27
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Calculates the coverage percentage for each coverage type.
|
|
29
|
-
* @param result - The unprocessed coverage result.
|
|
30
|
-
* @returns The processed coverage result.
|
|
31
|
-
*/
|
|
32
|
-
export function calculateCoverage(result) {
|
|
33
|
-
return Object.fromEntries(Object.entries(result).map(([key, value]) => {
|
|
34
|
-
const type = key;
|
|
35
|
-
return [
|
|
36
|
-
type,
|
|
37
|
-
{
|
|
38
|
-
coverage: value.nodesCount === 0
|
|
39
|
-
? 100
|
|
40
|
-
: Number(((1 - value.issues.length / value.nodesCount) * 100).toFixed(2)),
|
|
41
|
-
issues: value.issues,
|
|
42
|
-
nodesCount: value.nodesCount,
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
28
|
/**
|
|
48
29
|
* Maps the SyntaxKind from the library ts-morph to the coverage type.
|
|
49
30
|
* @param kind - The SyntaxKind from the library ts-morph.
|
|
@@ -56,4 +37,29 @@ export function getCoverageTypeFromKind(kind) {
|
|
|
56
37
|
}
|
|
57
38
|
return type;
|
|
58
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Convert plural coverage type to singular form
|
|
42
|
+
* @param type Coverage type (plural)
|
|
43
|
+
* @returns Singular form of coverage type
|
|
44
|
+
*/
|
|
45
|
+
export function singularCoverageType(type) {
|
|
46
|
+
switch (type) {
|
|
47
|
+
case 'classes':
|
|
48
|
+
return 'class';
|
|
49
|
+
case 'enums':
|
|
50
|
+
return 'enum';
|
|
51
|
+
case 'functions':
|
|
52
|
+
return 'function';
|
|
53
|
+
case 'interfaces':
|
|
54
|
+
return 'interface';
|
|
55
|
+
case 'methods':
|
|
56
|
+
return 'method';
|
|
57
|
+
case 'properties':
|
|
58
|
+
return 'property';
|
|
59
|
+
case 'types':
|
|
60
|
+
return 'type';
|
|
61
|
+
case 'variables':
|
|
62
|
+
return 'variable';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
59
65
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../packages/plugin-jsdocs/src/lib/runner/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../packages/plugin-jsdocs/src/lib/runner/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,YAAe;IAEf,OAAO;QACL,KAAK,EAAE,YAAY;QACnB,UAAU,EAAE,YAAY;QACxB,KAAK,EAAE,YAAY;QACnB,SAAS,EAAE,YAAY;QACvB,SAAS,EAAE,YAAY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