Merge pull request #19523 from ganhammar/fix/potentially-correct-cobertura-line-hits-calculation
Potentially correct Cobertura line hits calculation
This commit is contained in:
+58
-58
@@ -2,10 +2,10 @@
|
||||
{
|
||||
"filename": "src/main/scala/com/example/Main.scala",
|
||||
"lineHits": {
|
||||
"100": 4,
|
||||
"103": 2,
|
||||
"104": 4,
|
||||
"105": 4,
|
||||
"100": 2,
|
||||
"103": 1,
|
||||
"104": 2,
|
||||
"105": 2,
|
||||
"112": 2,
|
||||
"114": 4,
|
||||
"115": 2,
|
||||
@@ -25,14 +25,14 @@
|
||||
"148": 1,
|
||||
"149": 1,
|
||||
"150": 1,
|
||||
"160": 2,
|
||||
"163": 8,
|
||||
"164": 4,
|
||||
"166": 2,
|
||||
"167": 4,
|
||||
"168": 6,
|
||||
"169": 6,
|
||||
"170": 4,
|
||||
"160": 1,
|
||||
"163": 4,
|
||||
"164": 2,
|
||||
"166": 1,
|
||||
"167": 2,
|
||||
"168": 3,
|
||||
"169": 3,
|
||||
"170": 2,
|
||||
"178": 1,
|
||||
"179": 1,
|
||||
"181": 1,
|
||||
@@ -40,46 +40,46 @@
|
||||
"183": 3,
|
||||
"187": 1,
|
||||
"188": 3,
|
||||
"202": 4,
|
||||
"203": 6,
|
||||
"204": 4,
|
||||
"202": 2,
|
||||
"203": 3,
|
||||
"204": 2,
|
||||
"210": 5,
|
||||
"26": 4,
|
||||
"27": 4,
|
||||
"28": 4,
|
||||
"30": 4,
|
||||
"33": 4,
|
||||
"35": 2,
|
||||
"36": 2,
|
||||
"37": 4,
|
||||
"38": 2,
|
||||
"42": 2,
|
||||
"44": 2,
|
||||
"46": 2,
|
||||
"48": 2,
|
||||
"50": 2,
|
||||
"52": 2,
|
||||
"53": 2,
|
||||
"55": 2,
|
||||
"56": 2,
|
||||
"58": 2,
|
||||
"60": 2,
|
||||
"61": 2,
|
||||
"64": 2,
|
||||
"65": 6,
|
||||
"68": 4,
|
||||
"73": 2,
|
||||
"75": 10,
|
||||
"77": 4,
|
||||
"26": 2,
|
||||
"27": 2,
|
||||
"28": 2,
|
||||
"30": 2,
|
||||
"33": 2,
|
||||
"35": 1,
|
||||
"36": 1,
|
||||
"37": 2,
|
||||
"38": 1,
|
||||
"42": 1,
|
||||
"44": 1,
|
||||
"46": 1,
|
||||
"48": 1,
|
||||
"50": 1,
|
||||
"52": 1,
|
||||
"53": 1,
|
||||
"55": 1,
|
||||
"56": 1,
|
||||
"58": 1,
|
||||
"60": 1,
|
||||
"61": 1,
|
||||
"64": 1,
|
||||
"65": 3,
|
||||
"68": 2,
|
||||
"73": 1,
|
||||
"75": 5,
|
||||
"77": 2,
|
||||
"83": 1,
|
||||
"84": 2,
|
||||
"85": 3,
|
||||
"86": 3,
|
||||
"87": 1,
|
||||
"88": 6,
|
||||
"95": 2,
|
||||
"97": 8,
|
||||
"99": 2
|
||||
"95": 1,
|
||||
"97": 4,
|
||||
"99": 1
|
||||
},
|
||||
"branchHits": {}
|
||||
},
|
||||
@@ -100,9 +100,9 @@
|
||||
"123": 3,
|
||||
"124": 1,
|
||||
"129": 7,
|
||||
"132": 2,
|
||||
"133": 4,
|
||||
"134": 2,
|
||||
"132": 1,
|
||||
"133": 2,
|
||||
"134": 1,
|
||||
"138": 1,
|
||||
"139": 2,
|
||||
"140": 2,
|
||||
@@ -125,13 +125,13 @@
|
||||
"33": 2,
|
||||
"34": 2,
|
||||
"37": 0,
|
||||
"42": 4,
|
||||
"44": 2,
|
||||
"45": 2,
|
||||
"46": 2,
|
||||
"49": 4,
|
||||
"50": 10,
|
||||
"52": 4,
|
||||
"42": 2,
|
||||
"44": 1,
|
||||
"45": 1,
|
||||
"46": 1,
|
||||
"49": 2,
|
||||
"50": 5,
|
||||
"52": 2,
|
||||
"59": 5,
|
||||
"61": 4,
|
||||
"64": 2,
|
||||
@@ -157,9 +157,9 @@
|
||||
{
|
||||
"filename": "src/main/scala/com/example/utils/Util.scala",
|
||||
"lineHits": {
|
||||
"13": 2,
|
||||
"8": 4,
|
||||
"7": 2
|
||||
"7": 1,
|
||||
"8": 2,
|
||||
"13": 1
|
||||
},
|
||||
"branchHits": {}
|
||||
}
|
||||
|
||||
+392
-392
File diff suppressed because it is too large
Load Diff
+15
-15
@@ -11,8 +11,8 @@
|
||||
"lineHits": {
|
||||
"17": 41,
|
||||
"34": 41,
|
||||
"70": 82,
|
||||
"72": 82,
|
||||
"70": 41,
|
||||
"72": 41,
|
||||
"74": 41,
|
||||
"31": 41,
|
||||
"32": 41,
|
||||
@@ -55,10 +55,10 @@
|
||||
{
|
||||
"filename": "src/atoms/Container/components.ts",
|
||||
"lineHits": {
|
||||
"5": 70,
|
||||
"19": 70,
|
||||
"20": 70,
|
||||
"23": 70,
|
||||
"5": 35,
|
||||
"19": 35,
|
||||
"20": 35,
|
||||
"23": 35,
|
||||
"4": 13,
|
||||
"13": 13
|
||||
},
|
||||
@@ -83,23 +83,23 @@
|
||||
{
|
||||
"filename": "src/molecules/Hero/components.ts",
|
||||
"lineHits": {
|
||||
"26": 20,
|
||||
"26": 10,
|
||||
"28": 10,
|
||||
"94": 10,
|
||||
"103": 20,
|
||||
"103": 10,
|
||||
"121": 10,
|
||||
"182": 20,
|
||||
"182": 10,
|
||||
"203": 5,
|
||||
"218": 5,
|
||||
"236": 10,
|
||||
"241": 10,
|
||||
"249": 8,
|
||||
"236": 5,
|
||||
"241": 5,
|
||||
"249": 4,
|
||||
"254": 4,
|
||||
"264": 4,
|
||||
"277": 8,
|
||||
"277": 4,
|
||||
"282": 4,
|
||||
"294": 8,
|
||||
"299": 6,
|
||||
"294": 4,
|
||||
"299": 3,
|
||||
"25": 2,
|
||||
"29": 10,
|
||||
"37": 3,
|
||||
|
||||
+30
-30
@@ -16,34 +16,34 @@
|
||||
"filename": "src/graphql/resolvers.ts",
|
||||
"lineHits": {
|
||||
"22": 17,
|
||||
"28": 14,
|
||||
"36": 16,
|
||||
"27": 8,
|
||||
"35": 8,
|
||||
"28": 4,
|
||||
"36": 4,
|
||||
"27": 4,
|
||||
"35": 4,
|
||||
"43": 9,
|
||||
"51": 15,
|
||||
"56": 8,
|
||||
"61": 8,
|
||||
"50": 8,
|
||||
"55": 8,
|
||||
"60": 8,
|
||||
"51": 4,
|
||||
"56": 4,
|
||||
"61": 4,
|
||||
"50": 4,
|
||||
"55": 4,
|
||||
"60": 4,
|
||||
"128": 7,
|
||||
"139": 4,
|
||||
"145": 8,
|
||||
"160": 8,
|
||||
"177": 7,
|
||||
"185": 13,
|
||||
"70": 12,
|
||||
"78": 8,
|
||||
"81": 8,
|
||||
"145": 4,
|
||||
"160": 4,
|
||||
"177": 4,
|
||||
"185": 4,
|
||||
"70": 4,
|
||||
"78": 4,
|
||||
"81": 4,
|
||||
"84": 4,
|
||||
"97": 12,
|
||||
"103": 8,
|
||||
"114": 8,
|
||||
"144": 8,
|
||||
"159": 8,
|
||||
"176": 8,
|
||||
"184": 8,
|
||||
"97": 4,
|
||||
"103": 4,
|
||||
"114": 4,
|
||||
"144": 4,
|
||||
"159": 4,
|
||||
"176": 4,
|
||||
"184": 4,
|
||||
"1": 4,
|
||||
"2": 4,
|
||||
"3": 4,
|
||||
@@ -130,9 +130,9 @@
|
||||
"filename": "src/graphql/router.ts",
|
||||
"lineHits": {
|
||||
"21": 1,
|
||||
"22": 2,
|
||||
"43": 21,
|
||||
"53": 40,
|
||||
"22": 1,
|
||||
"43": 3,
|
||||
"53": 18,
|
||||
"12": 3,
|
||||
"14": 3,
|
||||
"23": 1,
|
||||
@@ -182,7 +182,7 @@
|
||||
{
|
||||
"filename": "src/graphql/schema.ts",
|
||||
"lineHits": {
|
||||
"9": 7,
|
||||
"9": 3,
|
||||
"1": 3,
|
||||
"2": 3,
|
||||
"4": 3,
|
||||
@@ -205,8 +205,8 @@
|
||||
{
|
||||
"filename": "src/graphql/transforms.ts",
|
||||
"lineHits": {
|
||||
"9": 10,
|
||||
"20": 5,
|
||||
"9": 4,
|
||||
"20": 4,
|
||||
"13": 6,
|
||||
"14": 2,
|
||||
"15": 6,
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
[
|
||||
{
|
||||
"filename": "src/Calc/Main.cs",
|
||||
"lineHits": {
|
||||
"5": 4,
|
||||
"6": 4,
|
||||
"7": 1,
|
||||
"8": 0,
|
||||
"9": 2,
|
||||
"10": 1,
|
||||
"11": 4
|
||||
},
|
||||
"branchHits": {
|
||||
"5": {
|
||||
"covered": 5,
|
||||
"missed": 1,
|
||||
"available": 6
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "src/Calc/Math.cs",
|
||||
"lineHits": {
|
||||
"5": 1,
|
||||
"6": 0,
|
||||
"7": 2,
|
||||
"8": 2,
|
||||
"9": 0,
|
||||
"11": 3,
|
||||
"12": 1,
|
||||
"14": 1,
|
||||
"15": 1
|
||||
},
|
||||
"branchHits": {
|
||||
"8": {
|
||||
"covered": 1,
|
||||
"missed": 1,
|
||||
"available": 2
|
||||
},
|
||||
"11": {
|
||||
"covered": 2,
|
||||
"missed": 0,
|
||||
"available": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,2 @@
|
||||
src/Calc/Main.cs
|
||||
src/Calc/Math.cs
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<coverage line-rate="0.8125" branch-rate="0.8" version="1.9" timestamp="1692517802" lines-covered="13" lines-valid="16" branches-covered="8" branches-valid="10">
|
||||
<sources>
|
||||
<source>/Some/Path/src/Calc/</source>
|
||||
</sources>
|
||||
<packages>
|
||||
<package name="Calc" line-rate="0.8125" branch-rate="0.8" complexity="12">
|
||||
<classes>
|
||||
<class name="Calc.Main" filename="Main.cs" line-rate="0.8571" branch-rate="0.8332999999999999" complexity="6">
|
||||
<methods>
|
||||
<method name="Calc" signature="(System.Int32,System.Int32,System.String)" line-rate="0.8571" branch-rate="0.8332999999999999" complexity="6">
|
||||
<lines>
|
||||
<line number="5" hits="4" branch="True" condition-coverage="83.33% (5/6)">
|
||||
<conditions>
|
||||
<condition number="15" type="jump" coverage="100%" />
|
||||
<condition number="28" type="jump" coverage="50%" />
|
||||
<condition number="41" type="jump" coverage="100%" />
|
||||
</conditions>
|
||||
</line>
|
||||
<line number="6" hits="4" branch="False" />
|
||||
<line number="7" hits="1" branch="False" />
|
||||
<line number="8" hits="0" branch="False" />
|
||||
<line number="9" hits="2" branch="False" />
|
||||
<line number="10" hits="1" branch="False" />
|
||||
<line number="11" hits="4" branch="False" />
|
||||
</lines>
|
||||
</method>
|
||||
</methods>
|
||||
<lines>
|
||||
<line number="5" hits="4" branch="True" condition-coverage="83.33% (5/6)">
|
||||
<conditions>
|
||||
<condition number="15" type="jump" coverage="100%" />
|
||||
<condition number="28" type="jump" coverage="50%" />
|
||||
<condition number="41" type="jump" coverage="100%" />
|
||||
</conditions>
|
||||
</line>
|
||||
<line number="6" hits="4" branch="False" />
|
||||
<line number="7" hits="1" branch="False" />
|
||||
<line number="8" hits="0" branch="False" />
|
||||
<line number="9" hits="2" branch="False" />
|
||||
<line number="10" hits="1" branch="False" />
|
||||
<line number="11" hits="4" branch="False" />
|
||||
</lines>
|
||||
</class>
|
||||
<class name="Calc.Math" filename="Math.cs" line-rate="0.7777" branch-rate="0.75" complexity="6">
|
||||
<methods>
|
||||
<method name="Addition" signature="(System.Int32,System.Int32)" line-rate="1" branch-rate="1" complexity="1">
|
||||
<lines>
|
||||
<line number="5" hits="1" branch="False" />
|
||||
</lines>
|
||||
</method>
|
||||
<method name="Subtraction" signature="(System.Int32,System.Int32)" line-rate="0" branch-rate="1" complexity="1">
|
||||
<lines>
|
||||
<line number="6" hits="0" branch="False" />
|
||||
</lines>
|
||||
</method>
|
||||
<method name="Division" signature="(System.Int32,System.Int32)" line-rate="0.8571" branch-rate="0.75" complexity="4">
|
||||
<lines>
|
||||
<line number="7" hits="2" branch="False" />
|
||||
<line number="8" hits="2" branch="True" condition-coverage="50% (1/2)">
|
||||
<conditions>
|
||||
<condition number="7" type="jump" coverage="50%" />
|
||||
</conditions>
|
||||
</line>
|
||||
<line number="9" hits="0" branch="False" />
|
||||
<line number="11" hits="3" branch="True" condition-coverage="100% (2/2)">
|
||||
<conditions>
|
||||
<condition number="22" type="jump" coverage="100%" />
|
||||
</conditions>
|
||||
</line>
|
||||
<line number="12" hits="1" branch="False" />
|
||||
<line number="14" hits="1" branch="False" />
|
||||
<line number="15" hits="1" branch="False" />
|
||||
</lines>
|
||||
</method>
|
||||
</methods>
|
||||
<lines>
|
||||
<line number="5" hits="1" branch="False" />
|
||||
<line number="6" hits="0" branch="False" />
|
||||
<line number="7" hits="2" branch="False" />
|
||||
<line number="8" hits="2" branch="True" condition-coverage="50% (1/2)">
|
||||
<conditions>
|
||||
<condition number="7" type="jump" coverage="50%" />
|
||||
</conditions>
|
||||
</line>
|
||||
<line number="9" hits="0" branch="False" />
|
||||
<line number="11" hits="3" branch="True" condition-coverage="100% (2/2)">
|
||||
<conditions>
|
||||
<condition number="22" type="jump" coverage="100%" />
|
||||
</conditions>
|
||||
</line>
|
||||
<line number="12" hits="1" branch="False" />
|
||||
<line number="14" hits="1" branch="False" />
|
||||
<line number="15" hits="1" branch="False" />
|
||||
</lines>
|
||||
</class>
|
||||
</classes>
|
||||
</package>
|
||||
</packages>
|
||||
</coverage>
|
||||
@@ -24,7 +24,7 @@ import { getVoidLogger } from '@backstage/backend-common';
|
||||
|
||||
describe('convert cobertura', () => {
|
||||
const converter = new Cobertura(getVoidLogger());
|
||||
[1, 2, 3, 4, 5].forEach(idx => {
|
||||
[1, 2, 3, 4, 5, 6].forEach(idx => {
|
||||
let fixture: CoberturaXML;
|
||||
parseString(
|
||||
fs.readFileSync(
|
||||
|
||||
@@ -113,7 +113,13 @@ export class Cobertura implements Converter {
|
||||
.filter(Boolean)
|
||||
.flatMap(m => m.lines)
|
||||
.filter(Boolean)
|
||||
.flatMap(l => l.line);
|
||||
.flatMap(l => l.line)
|
||||
.filter(
|
||||
({ $: methodLine }) =>
|
||||
classLines.some(
|
||||
({ $: classLine }) => methodLine.number === classLine.number,
|
||||
) === false,
|
||||
);
|
||||
const lines = [classLines, methodLines].flat().filter(Boolean);
|
||||
const lineHits = lines.map(l => {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user