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

試著忘記壹切 提交于 2019-12-24 20:17:00

问题


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)?


回答1:


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.)



来源:https://stackoverflow.com/questions/59419678/sonarqube-with-reactjs-false-positive-on-duplicates-and-coverage-on-new-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!