I wish to change the rule 'Left curly braces should be located at the end of lines of code' since we are using a different convention.
Thanks in advance!
As Sonarqube intends to provide the least possible configuration possible on rules: you should deactivate the rule with key squid:LeftCurlyBraceEndLineCheck and I am guessing that you want to activate the rule : squid:LeftCurlyBraceStartLineCheck
Please note that those rules have nothing to do with Checkstyle.
Related
Instead of excluding or ignore rules in sonar's property file, I'd like to have only a few certain rules for sonar to analyse, so I don't need to exclude a large number of rules out of 344 rules for c++. How can I do that? (I'm not adding customized rules)
I imageine the syntax would be: (in .properties file)
sonar.issue.include.multicriteria=***
sonar.issue.include.multicriteria.***.ruleKey=cpp:S984
....
EDIT:
1, I need to configure this in a CLI environment.
2, It's about one project, two rule sets. one rule sets for local use and the other one for CI/CD use.
You need to craft a Quality Profile that contains only your rules of interest, and then either make it the default profile for C++, or explicitly assign your project to it.
BTW, correctly setting exclusions in properties (versus through the UI) is quite tricky. I'm not sure about the correctness of the ruleKey field name, and you're probably missing another field in there, but your syntax seems to be on the right track.
Some lines of codes don't need to be checked by Sonar (Sonarqube.org). How can I just disable checking on these lines? Is there any way like just addding annotation "#" to make these lines invisible for Sonar? Thank you!
There are several ways. See FrequentlyAskedQuestions-NOSONAR and further down that page to see both a comment (//NOSONAR) and annotation (#SuppressWarnings) options, as well as some other ways to disable checking.
From official docs:
How do I get rid of issues that are False-Positives?
False-Positive and Won't Fix You can mark individual issues False Positive or Won't Fix through the issues interface. If you're using
Short-lived branch and PR analysis provided by the Developer Edition,
issues marked False Positive or Won't Fix will retain that status
after merge. This is the preferred approach.
//NOSONAR Most language analyzers support the use of the generic mechanism: //NOSONAR at the end of the line of the issue. This will
suppress the all issues - now and in the future - that might be raised
on the line.
I am trying to understand the different rules of EasyList of Adblock Plus but have not been able to find a definitive guide. Could someone point me to the right place or describe the different rules and symbols, e.g., #, ##, ###, $, ##, ||, ^, and so on? When is the matching done with url, and when is it done with class and id attributes? Which rules define whitelists and which ones define blacklists?
Found it at https://adblockplus.org/en/filters. The page describes the different types of filters as well as tips for creating them.
is there a possibility to duplicate existing checkstyle rules? I want Sonarqube to differ guideline rules.
Example:
The rule for method complexity should mark the method as [MINOR] when there is more than 10 lines of code per method and as [MAJOR] when there is more than 30 lines of code per method.
Maybe there is a particular plugin for this special case?
Thanks in advance
This is currently a limitation in SonarQube. However, it can be done partially.
For Checkstyle based rules, you can copy some rules (those that have a Copy Rule button; screenshot here under "Multiple activation of rules"). I've personally used this for the Comment Pattern Matcher and created a rule that matches TODO comments as INFO severity and another that matches FIXME comments as CRITICAL. As I understand your question, that is what you are looking for. I don't think this is possible for all parameterizable rules, though.
Also, for PMD based rules, there is this blog post which describes how to use the XPath rule template in order to create custom PMD rules. This could be a workaround for those PMD based rules that don't have a Copy Rule button.
The feature we would need is a Copy Rule button for every parameterizable rule. AFAIK, this does not exist yet.
I would like to force 4 spaces as the default and required indentation for my whole js codebase.
I have managed to the jshint wro4j plugin to work and obey options:
<options>browser,newcap,noarg,nonew,undef,trailing</options>
However, for indentation, I need to specify the spaces required:
/*jshint indent:4 */
but there appears to be no facility to do this?
I'm not sure how I should be applying this option correctly as any of the layouts I've tried throw errors as being invalid options.
You can force the indentation rule check by adding the following rules:
<option>indent,white</option>
By default the indentation is set to 4 characters. If you want to set a different value, use this:
<option>indent=2,white</option>