I am running sonar-scanner through Jenkins CI for a React / Typescript project. I am able to get a code coverage and it works as expected. However I do not get any other information other than that. No code duplication, no code smell, no vulnerabilities etc. I cannot thing of anything that I am doing wrong and I haven’t found anything in the docs that could help me.
Can you share a screenshot of what you’re seeing?
Dashboard on sonar cloud looks like this:
Now if I check one of the files that I added called fake-util.util.ts
I can see that there are two identical utils, fakeUtil and fakeUtil2
:
Also aside from the duplicated lines there are some empty functions (called lol
and lal
) which are also unused which should show up as code smells. But neither the duplication nor the code smells are picked up.
What you’re looking at is a Pull Request analysis, which only raises issues on changed lines of changed files. Your functions lol
and lal
didn’t change in the pull request, so no issues are reported.
Do you see more results once you run an analysis of your main branch?
@Colin the functions lol
and lal
did not exist before and where added in this PR. What I am expecting, is that since they are functions that are declared but never called that there should be a code smell thrown. Also at the same time I would expect to be notified about the duplication. We were using sonar before but running the analysis through the Gitlab CI and back then we would get proper report on PRs. We migrated to Jenkins and we have been trying to bring sonar back but we keep facing issues. Should I perhaps be looking for a different kind of analysis here?
@Colin also the test coverage itself does not work properly. I have added a function and once I add a tests for that function I can see on sonar cloud and on the github PR decorator that the coverage is about 60%. However if I remove all the test I would expect to get a coverage of 0% and failure of the quality gate. However instead I see a the following:
Again these expectations come from how sonar reports were working with our gitlab CI. It’s very possible I am doing things wrong and that is why I am reaching out here. Feel free to request any further information about my configuration and I will provide you with it.