Contents
How do I add custom rules to SonarQube?
Adding coding rules using Java
- Create a SonarQube plugin.
- Put a dependency on the API of the language plugin for which you are writing coding rules.
- Create as many custom rules as required.
- Generate the SonarQube plugin (jar file).
- Place this jar file in the SONARQUBE_HOME/extensions/plugins directory.
How do I modify SonarQube rules?
You can’t modify an existing rule. A workaround is to write a custom rule. However, you should first seriously consider whether the behavior you want to achieve is really specific to your own environment. If that’s not the case, you can suggest a change to the existing rule by joining the SonarQube google group.
How do I add AEM rules in SonarQube?
Download aemrules-x.y.jar or build AEM Rules for SonarQube plugin. Paste it into sonarqube/extensions/plugins directory. Restart SonarQube. Go to rules section and activate AEM rules in your profile.
What is duplicated in SonarQube?
A piece of code is considered as duplicated as soon as there is the same sequence of 10 successive statements whatever the number of tokens and lines. This threshold cannot be overridden.
How do you exclude rules in SonarQube?
To use exclusions to analyze everything but the specified files, go to Project Settings > General Settings > Analysis Scope > Files.
- Source File Exclusions – to exclude source code files.
- Test File Exclusions – to exclude test files.
How do I assign a problem in SonarQube?
New issues are automatically assigned during analysis to the last committer on the issue line if the committer can be correlated to a SonarQube user. Note that currently, issues on any level above a file, e.g. directory / module / project, cannot be automatically assigned.
Tags are a way to categorize rules and issues. Issues inherit the tags on the rules that raised them. Some tags are language-specific, but many more appear across languages. Users can add tags to rules and issues, but most rules have some tags out of the box.
How to create custom rules in SonarQube template?
You can navigate from a template to the details of custom rules defined from it by clicking the link in the “Custom Rules” section. Custom Rules are considered like any other rule, except that you can edit or delete them: Note: When deleting a custom rule, it is not physically removed from the SonarQube instance.
What do you need to know about SonarQube Java?
Before we start with the implementation of the rule itself, you need a little background. Prior to running any rule, the SonarQube Java Analyzer parses a given Java code file and produces an equivalent data structure: the Syntax Tree.
How to write custom rules for sonar analyzer?
Then your logical choice may be to implement your own set of custom Java rules. This document is an introduction to custom rule writing for the SonarQube Java Analyzer. It will cover all the main concepts of static analysis required to understand and develop effective rules, relying on the API provided by the SonarSource Analyzer for Java.
How to add XPath rules to SonarQube plugin?
1 Writing a SonarQube plugin in Java that uses SonarQube APIs to add new rules 2 Adding XPath rules directly through the SonarQube web interface 3 Importing Generic Issue Reports generated by an independently run tool