LCOV Could not resolve file paths

Hi folks :wave: ,

I’m trying to configure Sonarcloud in a project. Typescript and CircleCI . For some reason I’m unable to get the code coverage.

  • The lcov.info is being generated by jest with the --coverage flag
  • The lcov.info is being detected by sonarcloud

The pipeline logs are throwing this warning:

WARN: Could not resolve 42 file paths in [/root/app/coverage/lcov.info]
WARN: First unresolved path: assets/img/image.png (Run in DEBUG mode to get full list of unresolved paths)

I found some similar issues, I tried to manually sed the path inside the lcov.file to relative and absolute but it doesn’t seem to work

sonar-project.properties:

sonar.organization=****
sonar.projectName=****
sonar.projectKey=****
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.explusions=**/*.bin, **/*.test.ts, */*.test.tsx, node_modules/**
sonar.javascript.lcov.reportPaths=coverage/lcov.info

The CircleCI pipeline looks like this:

 orbs:
   sonarcloud: sonarsource/sonarcloud@1.0.3
   ...
      - run:
          name: Run app Jest unit and integration tests and scan
          command: yarn test-ci
          environment:
            JEST_JUNIT_OUTPUT_DIR: "reports/junit/js-test-results.xml"
      - run:
          name: Upload coverage to codecov
          command: bash <(curl -s https://codecov.io/bash) -F jest
      - store_test_results:
          path: reports
      - sonarcloud/scan
   ...

Is there something I’m missing?
Thanks!

Hey there.

Does the /root/app/coverage/lcov.info file look right to you? A file reporting coverage on .png files seems pretty suspect… does this file actually contain valid coverage data?

Hey Coolin, thank for the fast reply.

The route seems good to me, it’s the absolute path of the project inside CircleCI.

This is part of my lcov.info:

SF:src/components/ExampleComponent/ExampleComponent.tsx
FN:40,(anonymous_0)
FN:79,(anonymous_1)
FN:84,(anonymous_2)
FN:89,(anonymous_3)
FN:93,(anonymous_4)
FN:97,(anonymous_5)
FN:99,(anonymous_6)
FN:103,(anonymous_7)
FN:110,(anonymous_8)
FN:114,(anonymous_9)
FN:115,(anonymous_10)
FN:122,(anonymous_11)
FN:130,(anonymous_12)
FN:140,(anonymous_13)
FN:144,(anonymous_14)
FN:153,(anonymous_15)
FN:155,(anonymous_16)
FN:178,(anonymous_17)
FN:181,(anonymous_18)
FN:194,(anonymous_19)
FN:197,(anonymous_20)
FN:215,(anonymous_21)
FN:224,(anonymous_22)
FN:232,(anonymous_23)
FN:250,(anonymous_24)
FNF:25
FNH:0
FNDA:0,(anonymous_0)
FNDA:0,(anonymous_1)
FNDA:0,(anonymous_2)
FNDA:0,(anonymous_3)
FNDA:0,(anonymous_4)
FNDA:0,(anonymous_5)
FNDA:0,(anonymous_6)
FNDA:0,(anonymous_7)
FNDA:0,(anonymous_8)
FNDA:0,(anonymous_9)
FNDA:0,(anonymous_10)
FNDA:0,(anonymous_11)
FNDA:0,(anonymous_12)
FNDA:0,(anonymous_13)
FNDA:0,(anonymous_14)
FNDA:0,(anonymous_15)
FNDA:0,(anonymous_16)
FNDA:0,(anonymous_17)
FNDA:0,(anonymous_18)
FNDA:0,(anonymous_19)
FNDA:0,(anonymous_20)
FNDA:0,(anonymous_21)
FNDA:0,(anonymous_22)
FNDA:0,(anonymous_23)
FNDA:0,(anonymous_24)
DA:40,1
DA:50,1
DA:57,1
DA:72,0
DA:73,0
DA:79,0
DA:80,0
DA:85,0
DA:86,0
DA:90,0
DA:93,0
DA:94,0
DA:97,0
DA:98,0
DA:99,0
DA:102,0
DA:103,0
DA:104,0
DA:107,0
DA:110,0
DA:111,0
DA:114,0
DA:115,0
DA:122,0
DA:123,0
DA:130,0
DA:131,0
DA:140,0
DA:144,0
DA:146,0
DA:148,0
DA:149,0
DA:154,0
DA:155,0
DA:158,0
DA:160,0
DA:179,0
DA:182,0
DA:195,0
DA:198,0
DA:216,0
DA:224,0
DA:233,0
DA:251,0
LF:44
LH:3
BRDA:102,0,0,0
BRDA:102,0,1,0
BRDA:104,1,0,0
BRDA:104,1,1,0
BRDA:146,2,0,0
BRDA:146,2,1,0
BRDA:146,3,0,0
BRDA:146,3,1,0
BRDA:162,4,0,0
BRDA:162,4,1,0
BRDA:265,5,0,0
BRDA:265,5,1,0
BRDA:284,6,0,0
BRDA:284,6,1,0
BRF:14
BRH:0
end_of_record
TN:
SF:src/components/ExampleComponent/ExampleComponent.web.tsx
FN:26,(anonymous_0)
FN:46,(anonymous_1)
FN:63,(anonymous_2)
FN:118,(anonymous_3)
FNF:4
FNH:3
FNDA:2,(anonymous_0)
FNDA:4,(anonymous_1)
FNDA:2,(anonymous_2)
FNDA:0,(anonymous_3)
DA:26,2
DA:32,1
DA:38,1
DA:46,1
DA:53,4
DA:55,4
DA:57,4
DA:59,4
DA:61,4
DA:63,4
DA:64,2
DA:67,4
DA:119,0
LF:13
LH:12
BRDA:51,0,0,0
BRDA:55,1,0,4
BRDA:55,1,1,4
BRDA:59,2,0,4
BRDA:59,2,1,4
BRDA:64,3,0,2
BRDA:64,3,1,2
BRDA:78,4,0,4
BRDA:78,4,1,0
BRDA:79,5,0,4
BRDA:79,5,1,4
BRDA:82,6,0,4
BRDA:82,6,1,0
BRDA:112,7,0,4
BRDA:112,7,1,4
BRDA:119,8,0,0
BRDA:119,8,1,0
BRDA:121,9,0,4
BRDA:121,9,1,4
BRF:19
BRH:14
end_of_record
TN:
SF:src/components/ExampleComponent/ExampleComponent.styles.ts
FNF:0
FNH:0
DA:3,2
LF:1
LH:1
BRF:0
BRH:0
end_of_record
TN:
SF:src/components/ExampleComponent2/ExampleComponent2.tsx
FN:30,(anonymous_0)
FN:50,(anonymous_1)
FN:57,(anonymous_2)
FN:63,(anonymous_3)
FN:67,(anonymous_4)
FN:86,(anonymous_5)
FN:91,(anonymous_6)
FN:93,(anonymous_7)
FN:107,(anonymous_8)
FN:111,(anonymous_9)
FN:119,(anonymous_10)
FN:126,(anonymous_11)
FN:133,(anonymous_12)
FN:143,(anonymous_13)
FN:149,(anonymous_14)
FN:152,(anonymous_15)
FNF:16
FNH:0
FNDA:0,(anonymous_0)
FNDA:0,(anonymous_1)
FNDA:0,(anonymous_2)
FNDA:0,(anonymous_3)
FNDA:0,(anonymous_4)
FNDA:0,(anonymous_5)
FNDA:0,(anonymous_6)
FNDA:0,(anonymous_7)
FNDA:0,(anonymous_8)
FNDA:0,(anonymous_9)
FNDA:0,(anonymous_10)
FNDA:0,(anonymous_11)
FNDA:0,(anonymous_12)
FNDA:0,(anonymous_13)
FNDA:0,(anonymous_14)
FNDA:0,(anonymous_15)
DA:30,2
DA:36,2
DA:42,2
DA:47,0
DA:51,0
DA:52,0
DA:53,0
DA:54,0
DA:58,0
DA:59,0
DA:60,0
DA:63,0
DA:64,0
DA:67,0
DA:68,0
DA:69,0
DA:70,0
DA:71,0
DA:74,0
DA:75,0
DA:78,0
DA:80,0
DA:81,0
DA:82,0
DA:86,0
DA:89,0
DA:91,0
DA:92,0
DA:93,0
DA:94,0
DA:95,0
DA:107,0
DA:111,0
DA:119,0
DA:120,0
DA:121,0
DA:122,0
DA:126,0
DA:127,0
DA:130,0
DA:133,0
DA:134,0
DA:136,0
DA:140,0
DA:143,0
DA:145,0
DA:146,0
DA:149,0
DA:150,0
DA:153,0
DA:155,0
LF:51
LH:3
BRDA:68,0,0,0
BRDA:68,0,1,0
BRDA:68,1,0,0
BRDA:68,1,1,0
BRDA:74,2,0,0
BRDA:74,2,1,0
BRDA:81,3,0,0
BRDA:81,3,1,0
BRDA:92,4,0,0
BRDA:92,4,1,0
BRDA:120,5,0,0
BRDA:120,5,1,0
BRDA:157,6,0,0
BRDA:157,6,1,0
BRDA:160,7,0,0
BRDA:160,7,1,0
BRDA:173,8,0,0
BRDA:173,8,1,0
BRDA:173,8,2,0
BRF:19
BRH:0
end_of_record

When I run the command in DEBUG mode, I can see that the warning is showing for all the path in the lcov.file:

WARN: unresolved path: src/components/ExampleComponent/ExampleComponent.tsx