If you look at this site analysing JavaScript with Sonar you see that there are lots of errors reported on the JavaScript libraries.
http://nemo.sonarsource.org/drilldown/violations/jquery?rids%5B%5D=421365&severity=MAJOR
How can I prevent Sonar reporting the errors in the JavaScript libraries that I am using (since I can't fix any issues)?
At the same time, if I do manage to exclude the library, I don't want errors like "undefined variables" to appear in my files because they are referencing the JavaScript library.
If it makes any difference, I am using ExtJS 4.0.
Specifying an exclusion means that everything under your sonar. sources directory will be included in analysis except the files with paths that match your exclusion pattern. To use exclusions to analyze everything but the specified files, go to Project Settings > General Settings > Analysis Scope > Files.
Choosing Files To specify which files are are and are not included in an analysis go to Administration > General Settings > Analysis Scope > Files. Use exclusion to analyze everything but the specified files: sonar. exclusions - to exclude source code files.
In Java, we can exclude Sonar checks using the built-in @SuppressWarnings annotation. This works exactly the same way as suppressing compiler warnings. All we have to do is specify the rule identifier, in this case java:S106.
sonar.exclusions will exclude mentioned files or directories from analysis. sonar.coverage.exclusions still exists and will exclude mentioned files or directories from code coverage like in question asked. But it's not mentioned in current documentation.
You can add the library as a source file exclusion inside of Analysis Scope configuration, and you should use some willcards to help you.
I am using Maven and ExtJS 4.1 in my project. I have managed to run the analysis only on my source code by putting these lines in my pom.xml
:
<properties>
<sonar.language>js</sonar.language>
<sonar.exclusions>extjs/**</sonar.exclusions>
</properties>
<build>
<sourceDirectory>src/main/webapp</sourceDirectory>
</build>
I don't know whether you're using Maven as well, but perhaps this will give you some hints.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With