1
1
import { readFileSync } from "node:fs" ;
2
2
import { fileURLToPath } from "node:url" ;
3
3
import { parseIri } from "@hyperjump/uri" ;
4
+ import { getKeyword } from "@hyperjump/json-schema/experimental" ;
4
5
import { fromJson , getNodeFromPointer } from "./json-util.js" ;
5
6
6
7
/**
@@ -33,7 +34,9 @@ export class TestCoverageEvaluationPlugin {
33
34
34
35
const schemaPath = fileURLToPath ( keywordLocation ) ;
35
36
this . coverageMap [ schemaPath ] . s [ keywordLocation ] ++ ;
36
- this . coverageMap [ schemaPath ] . b [ keywordLocation ] [ Number ( ! valid ) ] ++ ;
37
+ if ( keywordLocation in this . coverageMap [ schemaPath ] . b ) {
38
+ this . coverageMap [ schemaPath ] . b [ keywordLocation ] [ Number ( valid ) ] ++ ;
39
+ }
37
40
}
38
41
39
42
/** @type NonNullable<EvaluationPlugin["afterSchema"]> */
@@ -106,7 +109,7 @@ export class TestCoverageEvaluationPlugin {
106
109
if ( Array . isArray ( keywordNode ) ) {
107
110
const [ keywordUri , keywordLocation ] = keywordNode ;
108
111
109
- if ( keywordLocation in this . coverageMap [ schemaPath ] . branchMap ) {
112
+ if ( keywordLocation in this . coverageMap [ schemaPath ] . statementMap ) {
110
113
continue ;
111
114
}
112
115
@@ -118,24 +121,18 @@ export class TestCoverageEvaluationPlugin {
118
121
this . coverageMap [ schemaPath ] . statementMap [ keywordLocation ] = range ;
119
122
this . coverageMap [ schemaPath ] . s [ keywordLocation ] = 0 ;
120
123
121
- // Create branch
122
- if ( annotationKeywords . has ( keywordUri ) ) {
123
- this . coverageMap [ schemaPath ] . branchMap [ keywordLocation ] = {
124
- line : range . start . line ,
125
- type : "keyword" ,
126
- loc : range ,
127
- locations : [ range ]
128
- } ;
129
- this . coverageMap [ schemaPath ] . b [ keywordLocation ] = [ 0 ] ;
130
- } else {
131
- this . coverageMap [ schemaPath ] . branchMap [ keywordLocation ] = {
132
- line : range . start . line ,
133
- type : "keyword" ,
134
- loc : range ,
135
- locations : [ range , range ]
136
- } ;
137
- this . coverageMap [ schemaPath ] . b [ keywordLocation ] = [ 0 , 0 ] ;
124
+ if ( annotationKeywords . has ( keywordUri ) || getKeyword ( keywordUri ) . simpleApplicator ) {
125
+ continue ;
138
126
}
127
+
128
+ // Create branch
129
+ this . coverageMap [ schemaPath ] . branchMap [ keywordLocation ] = {
130
+ line : range . start . line ,
131
+ type : "keyword" ,
132
+ loc : range ,
133
+ locations : [ range , range ]
134
+ } ;
135
+ this . coverageMap [ schemaPath ] . b [ keywordLocation ] = [ 0 , 0 ] ;
139
136
}
140
137
}
141
138
}
0 commit comments