MCPcopy Create free account
hub / github.com/openai/plugins / parseCoverageJson

Function parseCoverageJson

plugins/plugin-eval/src/evaluators/coverage.js:63–84  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

61}
62
63async function parseCoverageJson(filePath) {
64 const payload = await readJson(filePath);
65 if (payload.total?.lines?.pct != null) {
66 return Number(payload.total.lines.pct);
67 }
68
69 const fileEntries = Object.values(payload).filter((value) => value && typeof value === "object" && value.s);
70 let totalStatements = 0;
71 let coveredStatements = 0;
72 for (const entry of fileEntries) {
73 for (const count of Object.values(entry.s)) {
74 totalStatements += 1;
75 if (Number(count) > 0) {
76 coveredStatements += 1;
77 }
78 }
79 }
80 if (totalStatements === 0) {
81 return null;
82 }
83 return Number(((coveredStatements / totalStatements) * 100).toFixed(2));
84}
85
86async function parseCoverageFile(filePath) {
87 if (filePath.endsWith("lcov.info")) {

Callers 1

parseCoverageFileFunction · 0.85

Calls 3

readJsonFunction · 0.90
filterMethod · 0.80
valuesMethod · 0.80

Tested by

no test coverage detected