diff --git a/.changeset/six-radios-smile.md b/.changeset/six-radios-smile.md new file mode 100644 index 0000000000..e4f4eed450 --- /dev/null +++ b/.changeset/six-radios-smile.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-code-coverage-backend': patch +--- + +Correct the line hits calculation for Cobertura reports diff --git a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-1.json b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-1.json index b5b861254c..3bc4a532cc 100644 --- a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-1.json +++ b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-1.json @@ -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": {} } diff --git a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-2.json b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-2.json index ddfcc729fd..d8770694a9 100644 --- a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-2.json +++ b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-2.json @@ -18,15 +18,15 @@ { "filename": "src/utils.ts", "lineHits": { - "4": 104, - "7": 1178, - "12": 20, + "4": 19, + "7": 589, + "12": 18, "16": 2, - "29": 3105, + "29": 2329, "33": 1601, "37": 15, "56": 20, - "64": 42, + "64": 21, "65": 2, "1": 18, "8": 589, @@ -84,37 +84,37 @@ { "filename": "src/controller/VideoContextPlayerCoordinator.ts", "lineHits": { - "50": 8, - "74": 66, + "50": 4, + "74": 33, "137": 33, - "143": 5, - "157": 18, - "217": 5, - "240": 5, - "309": 48, - "343": 48, - "357": 48, - "405": 8, + "143": 4, + "157": 4, + "217": 4, + "240": 4, + "309": 24, + "343": 24, + "357": 24, + "405": 4, "420": 20, "442": 19, "445": 1, "460": 20, "466": 20, - "480": 16, + "480": 8, "488": 8, - "520": 16, + "520": 8, "530": 14, "619": 0, "627": 2, "636": 0, - "640": 8, - "651": 8, - "661": 12, - "673": 37, - "690": 8, - "711": 7, - "736": 4, - "740": 29, + "640": 4, + "651": 4, + "661": 4, + "673": 4, + "690": 4, + "711": 4, + "736": 2, + "740": 4, "1": 4, "2": 4, "31": 4, @@ -508,9 +508,9 @@ { "filename": "src/controller/VideoContextPlayerCoordinatorFactory.ts", "lineHits": { - "9": 8, + "9": 4, "11": 33, - "14": 66, + "14": 33, "2": 4, "3": 4, "4": 4, @@ -556,24 +556,24 @@ { "filename": "src/controller-x/VideoContextPlayerCoordinatorX.ts", "lineHits": { - "43": 6, - "59": 60, - "99": 24, + "43": 3, + "59": 30, + "99": 3, "126": 0, "132": 0, - "219": 4, - "233": 16, + "219": 3, + "233": 3, "290": 3, - "338": 34, + "338": 17, "341": 17, - "362": 34, + "362": 17, "363": 0, - "422": 10, - "435": 8, - "444": 33, - "458": 6, - "466": 4, - "477": 4, + "422": 3, + "435": 3, + "444": 3, + "458": 3, + "466": 3, + "477": 3, "507": 3, "1": 3, "2": 3, @@ -852,27 +852,27 @@ { "filename": "src/controller-x/VideoContextPlayerCoordinatorXObserver.ts", "lineHits": { - "5": 6, + "5": 3, "9": 3, - "13": 4, - "17": 7, + "13": 3, + "17": 3, "24": 3, - "26": 4, + "26": 3, "30": 3, "32": 3, - "34": 4, + "34": 3, "38": 3, "40": 3, "42": 3, - "44": 4, + "44": 3, "48": 3, "50": 3, "52": 3, - "54": 4, - "58": 4, - "62": 4, - "66": 4, - "70": 4, + "54": 3, + "58": 3, + "62": 3, + "66": 3, + "70": 3, "74": 3, "76": 3, "78": 3, @@ -904,54 +904,54 @@ { "filename": "src/events/InternalPlaybackObserver.ts", "lineHits": { - "17": 22, + "17": 11, "21": 107, - "26": 100, + "26": 11, "32": 0, "39": 0, - "42": 100, + "42": 11, "48": 89, "57": 11, "59": 0, - "63": 100, + "63": 11, "65": 89, - "69": 38, + "69": 11, "71": 27, - "75": 16, + "75": 11, "77": 5, - "81": 12, + "81": 11, "83": 1, - "87": 13, + "87": 11, "89": 2, - "93": 18, + "93": 11, "95": 7, - "99": 12, + "99": 11, "101": 1, - "106": 13, + "106": 11, "108": 2, - "113": 13, + "113": 11, "115": 2, - "120": 109, + "120": 11, "122": 98, - "126": 15, + "126": 11, "128": 4, - "132": 15, + "132": 11, "134": 4, - "138": 104, + "138": 11, "144": 93, - "149": 12, + "149": 11, "151": 1, - "156": 12, + "156": 11, "158": 1, - "163": 12, + "163": 11, "165": 1, - "170": 12, + "170": 11, "172": 1, - "177": 15, + "177": 11, "179": 4, - "184": 19, + "184": 11, "186": 8, - "191": 14, + "191": 11, "193": 3, "22": 107, "23": 107, @@ -1008,35 +1008,35 @@ { "filename": "src/events/PlaybackEventsObserver.ts", "lineHits": { - "24": 22, + "24": 11, "28": 90, - "36": 100, - "48": 23, - "52": 17, - "56": 100, + "36": 11, + "48": 11, + "52": 11, + "56": 11, "71": 11, - "75": 100, - "88": 38, - "97": 15, - "101": 12, - "105": 12, - "112": 13, - "116": 18, - "124": 12, - "129": 13, - "134": 13, - "142": 109, - "150": 15, - "157": 15, - "165": 104, - "177": 12, - "184": 12, - "191": 12, - "196": 12, - "204": 15, - "211": 19, - "219": 14, - "227": 472, + "75": 11, + "88": 11, + "97": 11, + "101": 11, + "105": 11, + "112": 11, + "116": 11, + "124": 11, + "129": 11, + "134": 11, + "142": 11, + "150": 11, + "157": 11, + "165": 11, + "177": 11, + "184": 11, + "191": 11, + "196": 11, + "204": 11, + "211": 11, + "219": 11, + "227": 11, "13": 11, "32": 90, "33": 90, @@ -1097,15 +1097,15 @@ { "filename": "src/events/TimeObservable.ts", "lineHits": { - "4": 26, - "8": 202, + "4": 13, + "8": 101, "13": 101, "14": 0, "17": 0, "22": 13, "27": 0, "31": 0, - "41": 24, + "41": 13, "46": 11, "9": 101, "10": 101, @@ -1140,22 +1140,22 @@ { "filename": "src/player/BetamaxPlayer.ts", "lineHits": { - "25": 20, + "25": 10, "31": 14, - "277": 24, - "283": 890, - "288": 456, - "47": 26, - "58": 34, - "74": 34, + "277": 18, + "283": 442, + "288": 14, + "47": 10, + "58": 17, + "74": 17, "76": 0, "87": 10, "95": 10, "108": 10, - "121": 11, + "121": 10, "134": 10, "146": 10, - "154": 11, + "154": 10, "162": 10, "168": 10, "179": 10, @@ -1163,11 +1163,11 @@ "203": 0, "216": 0, "228": 10, - "232": 27, - "244": 13, - "252": 11, - "256": 34, - "266": 459, + "232": 10, + "244": 10, + "252": 10, + "256": 17, + "266": 17, "8": 10, "9": 10, "15": 10, @@ -1260,9 +1260,9 @@ { "filename": "src/player/BetamaxPlayerFactory.ts", "lineHits": { - "6": 20, + "6": 10, "9": 68, - "15": 78, + "15": 10, "2": 10, "3": 10, "12": 68, @@ -1275,73 +1275,73 @@ { "filename": "src/player/PlaybackSession.ts", "lineHits": { - "50": 20, + "50": 10, "71": 90, - "165": 182, + "165": 90, "170": 2, - "177": 179, - "179": 102, - "90": 91, - "136": 100, - "146": 103, - "185": 178, - "189": 178, + "177": 90, + "179": 89, + "90": 90, + "136": 10, + "146": 10, + "185": 89, + "189": 89, "301": 0, "310": 0, "324": 89, - "334": 178, - "339": 979, - "343": 445, - "349": 14, - "351": 44, - "355": 20, + "334": 89, + "339": 89, + "343": 89, + "349": 10, + "351": 4, + "355": 4, "361": 10, - "365": 15, - "392": 178, + "365": 10, + "392": 89, "443": 0, - "458": 14, - "485": 99, - "501": 11, - "514": 14, - "525": 11, - "529": 23, - "558": 29, - "567": 24, - "571": 25, - "581": 15, - "596": 14, - "608": 37, + "458": 10, + "485": 10, + "501": 10, + "514": 10, + "525": 10, + "529": 10, + "558": 10, + "567": 12, + "571": 11, + "581": 10, + "596": 10, + "608": 10, "619": 10, - "623": 110, - "714": 18, - "719": 16, - "762": 11, - "768": 12, - "782": 13, - "803": 195, - "840": 11, - "844": 180, - "849": 180, - "860": 16, - "869": 221, - "875": 18, - "879": 4, - "885": 18, - "922": 13, - "939": 11, - "952": 101, - "965": 1572, - "969": 784, - "983": 11, - "987": 11, - "991": 19, - "1026": 106, - "1035": 16, - "1040": 18, + "623": 10, + "714": 10, + "719": 8, + "762": 10, + "768": 10, + "782": 10, + "803": 10, + "840": 10, + "844": 90, + "849": 90, + "860": 10, + "869": 10, + "875": 10, + "879": 2, + "885": 10, + "922": 10, + "939": 10, + "952": 10, + "965": 10, + "969": 10, + "983": 10, + "987": 10, + "991": 10, + "1026": 10, + "1035": 10, + "1040": 10, "1076": 10, - "1123": 16, - "1134": 11, - "1138": 100, + "1123": 10, + "1134": 10, + "1138": 10, "1142": 0, "1146": 0, "1150": 0, @@ -1901,9 +1901,9 @@ { "filename": "src/player/PlaybackSessionFactory.ts", "lineHits": { - "10": 20, + "10": 10, "13": 68, - "19": 27, + "19": 10, "70": 17, "2": 10, "3": 10, @@ -1960,19 +1960,19 @@ { "filename": "src/player/player.ts", "lineHits": { - "9": 24, + "9": 12, "12": 89, - "16": 101, + "16": 12, "18": 89, - "25": 198, - "29": 101, + "25": 12, + "29": 12, "37": 12, "41": 12, "45": 12, "49": 12, - "53": 38, - "57": 368, - "61": 28, + "53": 12, + "57": 12, + "61": 12, "65": 12, "69": 12, "73": 12, @@ -2019,40 +2019,40 @@ "filename": "src/plugins/SPManifestParser.ts", "lineHits": { "26": 5, - "40": 14, - "45": 14, - "60": 10, + "40": 9, + "45": 9, + "60": 5, "67": 9, "70": 9, "75": 9, - "87": 14, - "94": 10, - "113": 14, - "152": 14, + "87": 9, + "94": 5, + "113": 9, + "152": 9, "159": 13, - "173": 14, - "175": 44, - "186": 14, - "191": 23, + "173": 9, + "175": 22, + "186": 9, + "191": 5, "211": 0, "218": 0, - "226": 18, - "227": 26, - "242": 22, - "281": 14, - "289": 16, - "298": 13, - "313": 43, + "226": 5, + "227": 13, + "242": 9, + "281": 9, + "289": 8, + "298": 5, + "313": 9, "332": 0, - "366": 52, - "367": 28, - "368": 6, - "388": 68, - "399": 10, - "405": 4, - "461": 7944, - "467": 3974, - "468": 6, + "366": 26, + "367": 26, + "368": 2, + "388": 34, + "399": 8, + "405": 2, + "461": 3972, + "467": 3972, + "468": 2, "18": 9, "27": 5, "28": 5, @@ -2235,11 +2235,11 @@ { "filename": "src/plugins/SpotifyVideoMediaExtension.ts", "lineHits": { - "9": 16, + "9": 8, "12": 59, - "29": 10, - "34": 12, - "38": 10, + "29": 8, + "34": 8, + "38": 8, "2": 8, "3": 8, "13": 59, @@ -2258,8 +2258,8 @@ { "filename": "src/plugins/SpotifyVideoUrl.ts", "lineHits": { - "7": 16, - "8": 39, + "7": 8, + "8": 8, "1": 8, "9": 31, "11": 8 @@ -2473,21 +2473,21 @@ { "filename": "src/plugins/WidevineDownloader.ts", "lineHits": { - "14": 14, - "21": 14, - "190": 12, - "34": 11, + "14": 7, + "21": 7, + "190": 6, + "34": 7, "40": 4, - "44": 5, - "66": 4, + "44": 4, + "66": 3, "69": 0, - "78": 9, - "90": 8, - "107": 11, - "137": 2, + "78": 7, + "90": 7, + "107": 7, + "137": 1, "147": 1, - "165": 14, - "174": 8, + "165": 7, + "174": 7, "2": 7, "9": 7, "10": 7, @@ -2596,7 +2596,7 @@ { "filename": "src/plugins/types.ts", "lineHits": { - "19": 14, + "19": 7, "20": 7, "21": 7, "22": 7, @@ -2620,50 +2620,50 @@ { "filename": "src/tracking/DefaultEventsCalculator.ts", "lineHits": { - "34": 108, + "34": 54, "46": 7, - "95": 68, - "108": 17, - "116": 17, - "124": 92, - "145": 92, - "164": 41, - "168": 48, - "181": 41, - "185": 6, - "194": 41, - "198": 2, - "207": 42, + "95": 16, + "108": 16, + "116": 16, + "124": 16, + "145": 16, + "164": 16, + "168": 24, + "181": 16, + "185": 3, + "194": 16, + "198": 1, + "207": 16, "215": 4, - "229": 41, - "233": 2, - "242": 42, - "246": 50, - "255": 44, - "259": 12, - "276": 42, + "229": 16, + "233": 1, + "242": 16, + "246": 25, + "255": 16, + "259": 6, + "276": 16, "284": 2, - "298": 41, - "302": 2, - "311": 42, - "315": 10, - "326": 42, + "298": 16, + "302": 1, + "311": 16, + "315": 5, + "326": 16, "334": 2, - "348": 43, - "352": 22, - "386": 42, - "398": 10, - "417": 45, - "475": 43, + "348": 16, + "352": 11, + "386": 16, + "398": 5, + "417": 16, + "475": 16, "479": 83, - "483": 86, - "496": 41, + "483": 43, + "496": 16, "500": 76, - "505": 86, - "522": 41, + "505": 43, + "522": 16, "526": 76, - "531": 86, - "548": 39, + "531": 43, + "548": 16, "1": 16, "11": 16, "12": 16, @@ -2874,30 +2874,30 @@ { "filename": "src/tracking/EventsTracker.ts", "lineHits": { - "16": 32, + "16": 16, "19": 15, - "23": 17, - "40": 17, - "53": 17, - "63": 17, - "71": 17, + "23": 16, + "40": 16, + "53": 16, + "63": 16, + "71": 16, "86": 16, - "101": 28, + "101": 16, "117": 16, - "130": 21, - "145": 19, - "160": 25, - "170": 19, - "180": 21, - "195": 17, - "210": 17, - "225": 17, - "240": 17, - "248": 17, - "256": 17, - "271": 17, - "286": 17, - "301": 17, + "130": 16, + "145": 16, + "160": 16, + "170": 16, + "180": 16, + "195": 16, + "210": 16, + "225": 16, + "240": 16, + "248": 16, + "256": 16, + "271": 16, + "286": 16, + "301": 16, "14": 16, "20": 15, "29": 1, @@ -2929,11 +2929,11 @@ { "filename": "src/tracking/ProductStatesStreamingRulesProvider.ts", "lineHits": { - "4": 32, - "9": 6, + "4": 16, + "9": 3, "14": 2, "17": 0, - "21": 20, + "21": 16, "10": 3, "11": 3, "12": 3, @@ -2946,9 +2946,9 @@ { "filename": "src/tracking/VideoPlaybackEvents.ts", "lineHits": { - "1": 36, - "7": 36, - "17": 36, + "1": 18, + "7": 18, + "17": 18, "2": 18, "3": 18, "4": 18, @@ -3023,8 +3023,8 @@ { "filename": "src/tracking/types.ts", "lineHits": { - "13": 32, - "95": 32, + "13": 16, + "95": 16, "10": 16, "14": 16, "15": 16, @@ -3129,40 +3129,40 @@ { "filename": "src/tracking/utils.ts", "lineHits": { - "44": 64, - "109": 225, - "113": 1944, - "115": 1902, - "123": 514, - "128": 486, - "133": 91, - "138": 95, - "143": 239, - "148": 314, - "153": 167, - "158": 91, - "163": 91, - "168": 261, - "173": 167, + "44": 17, + "109": 17, + "113": 972, + "115": 951, + "123": 17, + "128": 17, + "133": 17, + "138": 17, + "143": 17, + "148": 17, + "153": 17, + "158": 17, + "163": 17, + "168": 17, + "173": 17, "178": 17, - "183": 139, - "188": 93, - "193": 475, - "198": 61, - "203": 95, - "208": 19, - "220": 1501, - "224": 484, - "228": 462, - "232": 900, - "236": 113, - "245": 96, - "250": 460, - "251": 56, - "254": 46, - "259": 158, + "183": 17, + "188": 17, + "193": 17, + "198": 17, + "203": 17, + "208": 17, + "220": 502, + "224": 176, + "228": 176, + "232": 326, + "236": 17, + "245": 17, + "250": 230, + "251": 28, + "254": 17, + "259": 79, "261": 19, - "269": 78, + "269": 17, "2": 17, "4": 17, "7": 17, @@ -3284,41 +3284,41 @@ "39": 24, "52": 11, "71": 6, - "79": 14, + "79": 7, "88": 11, "92": 19, - "120": 28, - "123": 36, - "145": 20, - "181": 36, - "190": 27, - "206": 25, - "223": 26, - "240": 26, - "258": 42, - "264": 48, - "272": 42, - "276": 2, - "285": 42, - "289": 2, - "298": 43, - "306": 50, - "328": 40, - "332": 46, - "341": 45, - "345": 4, - "356": 43, - "361": 50, - "371": 43, + "120": 14, + "123": 15, + "145": 15, + "181": 15, + "190": 15, + "206": 15, + "223": 15, + "240": 15, + "258": 15, + "264": 24, + "272": 15, + "276": 1, + "285": 15, + "289": 1, + "298": 15, + "306": 25, + "328": 15, + "332": 23, + "341": 15, + "345": 2, + "356": 15, + "361": 25, + "371": 15, "375": 89, - "380": 86, - "394": 43, + "380": 43, + "394": 15, "398": 87, - "403": 90, - "416": 46, + "403": 45, + "416": 15, "420": 91, - "425": 88, - "442": 40, + "425": 44, + "442": 15, "1": 15, "8": 15, "9": 15, @@ -3477,9 +3477,9 @@ { "filename": "src/tracking/endvideo/EndVideoLoggerFactory.ts", "lineHits": { - "11": 30, + "11": 15, "19": 14, - "32": 29, + "32": 15, "9": 15, "26": 14, "27": 14, @@ -3494,19 +3494,19 @@ { "filename": "src/tracking/endvideo/EndVideoLoggerTracker.ts", "lineHits": { - "24": 30, + "24": 15, "38": 14, "54": 14, "62": 0, "96": 0, - "139": 24, - "140": 18, - "141": 18, - "154": 40, - "155": 40, - "156": 40, - "166": 35, - "177": 38, + "139": 15, + "140": 9, + "141": 9, + "154": 20, + "155": 20, + "156": 20, + "166": 15, + "177": 15, "1": 15, "4": 15, "15": 15, @@ -3605,7 +3605,7 @@ { "filename": "src/tracking/endvideo/EndVideoReasonEnd.ts", "lineHits": { - "1": 30, + "1": 15, "2": 15, "3": 15, "4": 15, @@ -3626,23 +3626,23 @@ { "filename": "src/tracking/endvideo/EndVideoTracker.ts", "lineHits": { - "24": 30, + "24": 15, "64": 13, - "78": 28, - "110": 26, - "118": 27, - "131": 79, - "237": 21, - "255": 44, - "287": 28, - "295": 22, - "355": 20, - "364": 28, - "417": 28, - "419": 17, - "430": 28, - "438": 24, - "458": 25, + "78": 15, + "110": 13, + "118": 13, + "131": 15, + "237": 15, + "255": 15, + "287": 15, + "295": 13, + "355": 15, + "364": 15, + "417": 15, + "419": 13, + "430": 15, + "438": 12, + "458": 15, "1": 15, "2": 15, "15": 15, @@ -3914,9 +3914,9 @@ { "filename": "src/tracking/session/PlaybackSessionTracker.ts", "lineHits": { - "7": 32, + "7": 16, "9": 1, - "14": 17, + "14": 16, "1": 16, "10": 1, "11": 1, @@ -3936,7 +3936,7 @@ { "filename": "src/tracking/session/VideoPlaybackSessionLogger.ts", "lineHits": { - "6": 30, + "6": 15, "9": 0, "12": 15, "13": 0, diff --git a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-3.json b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-3.json index 625dcde1a0..b1f65270cb 100644 --- a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-3.json +++ b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-3.json @@ -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, diff --git a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-5.json b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-5.json index 41ab6c084f..a7da6fa0b9 100644 --- a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-5.json +++ b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-5.json @@ -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, diff --git a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-6.json b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-6.json new file mode 100644 index 0000000000..7de4e7dcf7 --- /dev/null +++ b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-jsoncoverage-files-6.json @@ -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 + } + } + } +] diff --git a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-sourcefiles-6.txt b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-sourcefiles-6.txt new file mode 100644 index 0000000000..3aa3c36039 --- /dev/null +++ b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-sourcefiles-6.txt @@ -0,0 +1,2 @@ +src/Calc/Main.cs +src/Calc/Math.cs diff --git a/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-testdata-6.xml b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-testdata-6.xml new file mode 100644 index 0000000000..84560b6c21 --- /dev/null +++ b/plugins/code-coverage-backend/src/service/__fixtures__/cobertura-testdata-6.xml @@ -0,0 +1,100 @@ + + + + /Some/Path/src/Calc/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/code-coverage-backend/src/service/converter/cobertura.test.ts b/plugins/code-coverage-backend/src/service/converter/cobertura.test.ts index dfe6c77c98..3b55930d5f 100644 --- a/plugins/code-coverage-backend/src/service/converter/cobertura.test.ts +++ b/plugins/code-coverage-backend/src/service/converter/cobertura.test.ts @@ -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( diff --git a/plugins/code-coverage-backend/src/service/converter/cobertura.ts b/plugins/code-coverage-backend/src/service/converter/cobertura.ts index 025d40a4f6..540ea95944 100644 --- a/plugins/code-coverage-backend/src/service/converter/cobertura.ts +++ b/plugins/code-coverage-backend/src/service/converter/cobertura.ts @@ -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 {