Skip to content

Commit af6dffc

Browse files
committed
Don't count subschemas as statements. They are already counted functions.
1 parent 801e47a commit af6dffc

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ aren't terms that makes sense for JSON Schema. I've mapped those concepts to
2525
what makes sense for schemas.
2626

2727
**Legend**
28-
- **Statements** = Keywords and subschemas
28+
- **Statements** = Keywords
2929
- **Branches** = true/false branches for each keyword (except for keywords that
3030
don't branch such as annotation-only keywords like `title` and `description`)
3131
- **Functions** = Subschemas

src/coverage-map-service.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ export class CoverageMapService {
6161
/** @type (coverageMap: CoverageMapData) => void */
6262
addCoverageMap(coverageMap) {
6363
for (const filePath in coverageMap) {
64-
const [schemaUri] = Object.keys(coverageMap[filePath].statementMap);
64+
const [schemaUri] = Object.keys(coverageMap[filePath].fnMap);
6565
this.#coverageMaps[schemaUri] = coverageMap;
6666

6767
for (const fileCoveragePath in coverageMap) {
68+
for (const location in coverageMap[fileCoveragePath].fnMap) {
69+
this.#filePathFor[location] = fileCoveragePath;
70+
}
6871
for (const location in coverageMap[fileCoveragePath].statementMap) {
6972
this.#filePathFor[location] = fileCoveragePath;
7073
}
@@ -157,25 +160,13 @@ export class CoverageMapService {
157160
}
158161

159162
const pointer = decodeURI(/** @type string */ (parseIri(schemaLocation).fragment));
160-
const node = getNodeFromPointer(schemaNodes[toAbsoluteIri(schemaLocation)], pointer, true);
161-
162-
const declRange = node.type === "json-property"
163-
? this.#positionToRange(node.children[0].position)
164-
: {
165-
start: { line: node.position.start.line, column: node.position.start.column - 1 },
166-
end: { line: node.position.start.line, column: node.position.start.column - 1 }
167-
};
168-
163+
const node = getNodeFromPointer(schemaNodes[toAbsoluteIri(schemaLocation)], pointer);
169164
const locRange = this.#positionToRange(node.position);
170165

171-
// Create statement
172-
fileCoverage.statementMap[schemaLocation] = locRange;
173-
fileCoverage.s[schemaLocation] = 0;
174-
175166
// Create function
176167
fileCoverage.fnMap[schemaLocation] = {
177168
name: schemaLocation,
178-
decl: declRange,
169+
decl: locRange,
179170
loc: locRange,
180171
line: node.position.start.line
181172
};

src/test-coverage-evaluation-plugin.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export class TestCoverageEvaluationPlugin {
5353
}
5454

5555
const fileCoverage = this.coverage[schemaPath];
56-
fileCoverage.s[schemaUri]++;
5756
fileCoverage.f[schemaUri]++;
5857
}
5958
}

0 commit comments

Comments
 (0)