-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: remove covered line adjustment in deploy coverage reports
- Loading branch information
Showing
15 changed files
with
189 additions
and
541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
/* eslint-disable no-param-reassign */ | ||
|
||
import { CloverCoverageObject, CloverFile } from './types.js'; | ||
import { normalizePathToUnix } from './normalizePathToUnix.js'; | ||
|
||
export function handleCloverFormat( | ||
filePath: string, | ||
fileName: string, | ||
lines: Record<string, number>, | ||
uncoveredLines: number[], | ||
coveredLines: number[], | ||
coverageObj: CloverCoverageObject | ||
): void { | ||
const cloverFile: CloverFile = { | ||
'@name': fileName, | ||
'@path': normalizePathToUnix(filePath), | ||
metrics: { | ||
'@statements': uncoveredLines.length + coveredLines.length, | ||
'@coveredstatements': coveredLines.length, | ||
'@conditionals': 0, | ||
'@coveredconditionals': 0, | ||
'@methods': 0, | ||
'@coveredmethods': 0, | ||
}, | ||
line: [], | ||
}; | ||
|
||
for (const [lineNumber, isCovered] of Object.entries(lines)) { | ||
cloverFile.line.push({ | ||
'@num': Number(lineNumber), | ||
'@count': isCovered === 1 ? 1 : 0, | ||
'@type': 'stmt', | ||
}); | ||
} | ||
|
||
coverageObj.coverage.project.file.push(cloverFile); | ||
const projectMetrics = coverageObj.coverage.project.metrics; | ||
|
||
projectMetrics['@statements'] += uncoveredLines.length + coveredLines.length; | ||
projectMetrics['@coveredstatements'] += coveredLines.length; | ||
projectMetrics['@elements'] += uncoveredLines.length + coveredLines.length; | ||
projectMetrics['@coveredelements'] += coveredLines.length; | ||
projectMetrics['@files'] += 1; | ||
projectMetrics['@classes'] += 1; | ||
projectMetrics['@loc'] += uncoveredLines.length + coveredLines.length; | ||
projectMetrics['@ncloc'] += uncoveredLines.length + coveredLines.length; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
/* eslint-disable no-param-reassign */ | ||
|
||
import { CoberturaCoverageObject, CoberturaClass, CoberturaPackage } from './types.js'; | ||
import { normalizePathToUnix } from './normalizePathToUnix.js'; | ||
|
||
export function handleCoberturaFormat( | ||
filePath: string, | ||
fileName: string, | ||
lines: Record<string, number>, | ||
uncoveredLines: number[], | ||
coveredLines: number[], | ||
coverageObj: CoberturaCoverageObject, | ||
packageObj: CoberturaPackage | ||
): void { | ||
const classObj: CoberturaClass = { | ||
'@name': fileName, | ||
'@filename': normalizePathToUnix(filePath), | ||
'@line-rate': (coveredLines.length / (coveredLines.length + uncoveredLines.length)).toFixed(4), | ||
'@branch-rate': '1', | ||
methods: {}, | ||
lines: { | ||
line: [], | ||
}, | ||
}; | ||
|
||
for (const [lineNumber, isCovered] of Object.entries(lines)) { | ||
classObj.lines.line.push({ | ||
'@number': Number(lineNumber), | ||
'@hits': isCovered === 1 ? 1 : 0, | ||
'@branch': 'false', | ||
}); | ||
} | ||
|
||
coverageObj.coverage['@lines-valid'] += uncoveredLines.length + coveredLines.length; | ||
coverageObj.coverage['@lines-covered'] += coveredLines.length; | ||
packageObj.classes.class.push(classObj); | ||
|
||
packageObj['@line-rate'] = Number( | ||
(coverageObj.coverage['@lines-covered'] / coverageObj.coverage['@lines-valid']).toFixed(4) | ||
); | ||
coverageObj.coverage['@line-rate'] = packageObj['@line-rate']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
/* eslint-disable no-param-reassign */ | ||
|
||
import { SonarCoverageObject, SonarClass } from './types.js'; | ||
import { normalizePathToUnix } from './normalizePathToUnix.js'; | ||
|
||
export function handleSonarFormat( | ||
filePath: string, | ||
lines: Record<string, number>, | ||
coverageObj: SonarCoverageObject | ||
): void { | ||
const fileObj: SonarClass = { | ||
'@path': normalizePathToUnix(filePath), | ||
lineToCover: [], | ||
}; | ||
|
||
for (const lineNumberString in lines) { | ||
if (!Object.hasOwn(lines, lineNumberString)) continue; | ||
const covered = lines[lineNumberString] === 1 ? 'true' : 'false'; | ||
fileObj.lineToCover.push({ | ||
'@lineNumber': Number(lineNumberString), | ||
'@covered': covered, | ||
}); | ||
} | ||
|
||
coverageObj.coverage.file.push(fileObj); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.