MCPcopy Index your code
hub / github.com/SchemaStore/schemastore / taskCoverage

Function taskCoverage

cli.js:2159–2260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2157 // ---------------------------------------------------------------------------
2158
2159 async function taskCoverage() {
2160 const coverageSchemas = SchemaValidation.coverage ?? []
2161 if (coverageSchemas.length === 0) {
2162 console.info(
2163 'No schemas opted into coverage. Add schemas to "coverage" in schema-validation.jsonc',
2164 )
2165 return
2166 }
2167
2168 const spinner = ora()
2169 spinner.start()
2170 let hasFailure = false
2171 let hasMatch = false
2172
2173 for (const entry of coverageSchemas) {
2174 const schemaName = entry.schema
2175 const strict = entry.strict ?? false
2176 if (argv['schema-name'] && argv['schema-name'] !== schemaName) {
2177 continue
2178 }
2179 hasMatch = true
2180
2181 const schemaId = schemaName.replace('.json', '')
2182 spinner.text = `Running coverage checks on "${schemaName}"${strict ? ' (strict)' : ''}`
2183
2184 // Load schema
2185 const schemaFile = await toFile(path.join(SchemaDir, schemaName))
2186 const schema = /** @type {Record<string, unknown>} */ (schemaFile.json)
2187
2188 // Load positive test files
2189 const positiveTests = new Map()
2190 const posDir = path.join(TestPositiveDir, schemaId)
2191 for (const testfile of await fs.readdir(posDir).catch(() => [])) {
2192 if (isIgnoredFile(testfile)) continue
2193 const file = await toFile(path.join(posDir, testfile))
2194 positiveTests.set(testfile, file.json)
2195 }
2196
2197 // Load negative test files
2198 const negativeTests = new Map()
2199 const negDir = path.join(TestNegativeDir, schemaId)
2200 for (const testfile of await fs.readdir(negDir).catch(() => [])) {
2201 if (isIgnoredFile(testfile)) continue
2202 const file = await toFile(path.join(negDir, testfile))
2203 negativeTests.set(testfile, file.json)
2204 }
2205
2206 // Run all 8 checks
2207 const results = [
2208 { name: '1. Unused $defs', result: checkUnusedDefs(schema) },
2209 {
2210 name: '2. Description Coverage',
2211 result: checkDescriptionCoverage(schema),
2212 },
2213 {
2214 name: '3. Test Completeness',
2215 result: checkTestCompleteness(schema, positiveTests),
2216 },

Callers

nothing calls this directly

Calls 12

checkUnusedDefsFunction · 0.90
checkDescriptionCoverageFunction · 0.90
checkTestCompletenessFunction · 0.90
checkEnumCoverageFunction · 0.90
checkPatternCoverageFunction · 0.90
checkRequiredCoverageFunction · 0.90
checkDefaultCoverageFunction · 0.90
checkNegativeIsolationFunction · 0.90
printCoverageReportFunction · 0.90
toFileFunction · 0.85
isIgnoredFileFunction · 0.85
printErrorAndExitFunction · 0.85

Tested by

no test coverage detected