11import { readFileSync } from "node:fs" ;
22import { fileURLToPath } from "node:url" ;
33import { parseIri } from "@hyperjump/uri" ;
4+ import { getKeyword } from "@hyperjump/json-schema/experimental" ;
45import { fromJson , getNodeFromPointer } from "./json-util.js" ;
56
67/**
@@ -33,7 +34,9 @@ export class TestCoverageEvaluationPlugin {
3334
3435 const schemaPath = fileURLToPath ( keywordLocation ) ;
3536 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+ }
3740 }
3841
3942 /** @type NonNullable<EvaluationPlugin["afterSchema"]> */
@@ -106,7 +109,7 @@ export class TestCoverageEvaluationPlugin {
106109 if ( Array . isArray ( keywordNode ) ) {
107110 const [ keywordUri , keywordLocation ] = keywordNode ;
108111
109- if ( keywordLocation in this . coverageMap [ schemaPath ] . branchMap ) {
112+ if ( keywordLocation in this . coverageMap [ schemaPath ] . statementMap ) {
110113 continue ;
111114 }
112115
@@ -118,24 +121,18 @@ export class TestCoverageEvaluationPlugin {
118121 this . coverageMap [ schemaPath ] . statementMap [ keywordLocation ] = range ;
119122 this . coverageMap [ schemaPath ] . s [ keywordLocation ] = 0 ;
120123
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 ;
138126 }
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 ] ;
139136 }
140137 }
141138 }
0 commit comments