JackTheKnife
JackTheKnife

Reputation: 4154

SonarQube with ReactJS - false positive on duplicates and coverage on new code

I'm trying to analyze ongoing ReactJS project using SonarQube (first time with that tool) version 6.7.5 but after second code scan I'm getting Quality Gate failed due to 0% Coverage on New Code and 5% Duplicated Lines on New Code.

First problem - I have no clue why I'm getting it at all (no coverage on new code) when I see new code got picked up by SonarQube. It looks like most of functional components are not covered by tests.

Second problem - duplicates. Most of them are false positive like import statements or declarations (ex. react-table and columns declaration). Is there any way to mark them as non-duplicate? Or is there any workaround to get those kind of code blocks as valid (not dups)?

Upvotes: 3

Views: 2684

Answers (1)

Danielle Booysen
Danielle Booysen

Reputation: 23

To touch on your first question: Do you have the prerequisites set up? https://docs.sonarqube.org/latest/analysis/languages/javascript/

And have you configured reportPaths and a reporter? I think that SonarQube needs this to run concurrently with your testing framework's coverage tool to analyse the overall project coverage data. https://docs.sonarqube.org/latest/analysis/coverage/

Your second issue might be sorted by the first solution. (I'm actually here because of my own problem: SonarQube isn't analysing a React component / JSX correctly and is seeing it as a code duplication. It's not my project, so I might just have to ask higher up to upgrade SonarQube... hopefully that solves it for me.)

Upvotes: 1

Related Questions