First my Sonarqube version is 4.5.2.
I want to exclude from analyze two files : fr.foo.foo1.MyClass1 and fr.foo.foo1.MyClass2, there is another classes in the foo1 package that I want still in the anlyse.
I try to set in the tab exclusions/files : exclude sources : **/fr/foo/foo1/MyClass1.java and **/fr/foo/foo1/MyClass2.java but the classes still in the analyse.
the only way I find to exclude the classes is to set the parameter to **/fr/foo/foo1/** but all the classes in the package are excluded or I want only the two classes MyClass1 and MyClass2.
The image below show how I set the exclusion in Sonar :
Any ideas ?
Thanks
Stef
Related
I would like to write some tests for my dbt model. I only want the tests to test certain rows (data within the last month). I could write a where clause for every single test in yml file like so:
- not_null
config:
where: "current_date-date_column<=30"
However, I was wondering if there is some shortcut to put the clause on the model and have the where clause apply to all tests of the model (which is a lot easier to write and also means I don't have to worry about forgetting if I add more tests).
This article givers an example on how to do that for project level but I don't want the whole project just one model.
Any config that can be applied in the dbt_project.yml can be scoped to specific directories or resources. However, tests are their own resources, independent of the models they test, and currently (dbt v1.2), it is not possible apply config to all tests for a given model.
As a workaround, you could consider putting the .yml file that defines the tests for that model in a directory by itself, and applying the config to a directory.
Apply where to a whole project:
tests:
+where: "date_column = current_date"
Apply where only to .yml files nested in the models/marts/finance/ directory:
tests:
my_project:
marts:
finance:
+where: "date_column = current_date"
Apply where to a specific test:
tests:
my_project:
marts:
finance:
not_null_revenue_id:
+where: "date_column = current_date"
See the docs for resource-path for more info
I have a maven job that runs a pom.xml file with some goals I provide like below:
Pom File: pom.xml
goals: test -DsuiteName=testng.xml
Now I want to add a radio button parameter into this job "Run_Failed_Cases_Only", if user selects this then instead of testng.xml I want to pass testng-failed.xml file. like below:
Pom File: pom.xml
goals: test -DsuiteName=testng-failed.xml
So what I want is if there is any way I can use windows batch command step, that will check if "Run_Failed_Cases_Only" is selected then pass a variable $goals to the build step as per the condition below:
if(Run_Failed_Cases_Only is selected)
$goals = "test -DsuiteName=testng-failed.xml"
else
$goals = test -DsuiteName=testng.xml
then I will use this variable in the goals text box.
When you have created the Maven Project job, select the option This project is parametrized from General tab. If the Extensible Choice Plugin is not installed, install it then you can find the same here in This project is parametrized
Please find the screenshot below.
Then, you can use the specific condition based on the choice parameter.
OR
Alternatively, You can also use Generator Choice parameter available in This project is parameterized to get the result.
Please find the screenshot.
Then, you can use the specific condition based on the choice.
Solved this by using Extended Choice Parameter and providing different display name and values like below:
then used this parameter as variable in POM like below:
In Gradle there is a copy task where I can specify a from, a into and a duplicatesStrategy. However, the duplicatesStrategy is only an enum with limited options like override, ignore or fail.
Instead of just overriding I would like to be able to call a "content merge function" which takes the two files (the existing and the new one) as input parameters and outputs the resulting file.
from("fromdir") {
into 'targetdir'
duplicatesStrategy = { newFile,existingFile ->
return mergeFiles(newFile,existingFiles)
}
}
Is that possible in any way?
Context: The task should copy doc book xml files from multiple projects into one. One Project can override parts of the documentation of another project, so there has to be some "logic" to merge the resulting documentation correctly.
I would solve it using
duplicatesStrategy 'exclude'
Then in a separate task iterate and check for differences and handle the merge of them there. Preferably in an own task implementation using a third-party merge tool. My searches found no existing merge tasks.
I've got a project I'm working on and some of the files violate some of the rules, but in ways that are not real issues, and are thus distracting noise. However, I don't want to disable these rules globally, and I would prefer not to have to mark 'em as false positives one by one.
Is there a way to disable Sonar rules for specific files, and if so, how?
Since SonarQube 4.0, you can define issue exclusion patterns based on rule key and file path pattern.
On previous versions, you can rely upon the Switch Off Violations plugin.
You can annotate a class or a method with SuppressWarnings.
Here is an example:
#java.lang.SuppressWarnings("squid:S00111")
squid:S00111 in this case is a Sonar issue ID. You can find this issue id from the Sonar web ui.
Building on Mithfindel's answer and dpk's comment, this removes the warning
System.out and System.err should not be used as loggers
from all classes in packages named log (or any subpackage thereof) by adding an ignore pattern for the rule squid:S106:
For a list of the keys to all your rules go to your profile under Quality Profiles and select Download to get a .csv file containing all the rules' keys.
I'm using SonarQube version 4.1.1.
You can set specific files and rules under sonar-project.properties with following contents:
# Ignore Issues
sonar.issue.ignore.multicriteria=e1,e2
# Skip Bold Check
sonar.issue.ignore.multicriteria.e1.ruleKey=Web:BoldCheck
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.html
# Skip Tag Check
sonar.issue.ignore.multicriteria.e2.ruleKey=Web:S1234
sonar.issue.ignore.multicriteria.e2.resourceKey=**/*.html
Change the ruleKey and resourceKey based on your specific need.
Using below annotation we can ignore the rule from the specific files
For one rule
#java.lang.SuppressWarnings("squid:S2696")
#Slf4j
#Service
public class PaymentServiceImpl implements PaymentService {....
For more than one rule
#java.lang.SuppressWarnings({"squid:S2696", "squid:S1172", "squid:CommentedOutCodeLine"})
#Slf4j
#Service
public class PaymentServiceImpl implements PaymentService {...
Yes, it is possible.
1.Goto Administration tab->Analysis Scope->Issues
2.There , you will find "Ignore Issues on Multiple Criteria".
3.Provide Rule ID in "Rule Key pattern" textbox [Rule ID can be found by clicking on the particular rule and find it in top right corner]
4.Provide Filepath for which you need to ignore rule in "File Path Pattern" textbox
5.Click on Save Issues settings
Image to know where Rule ID will be present in the page
Image where Rule key pattern and File Key pattern text boxes are present
I have a very large code base.
I would like to execute findbugs programmatically on selected class files with just a selected set of rules at a time so that the analysis can finish in a few seconds. Documentation for includes/excludes say that only matching patterns will be reported, but does not clarify whether all the rules will be processed or only the selected ones.
Would like to know where I can start?
If you are using ant and findbugs anttask, to run a selected set of bug-detectors, use the "visitors" parameter/attribute.
More details here:
http://findbugs.sourceforge.net/manual/anttask.html
To run on selected classes only, I just jar-ed the selected classes in a separate jar and pointed the ant task to it via the "class" sub-tag.