checkstyle disable specific check - ant

I am using Ant and want to enable checkstyle for all packages,source, etc. Ideally it would have been as simple as adding a dependency on checkstyle on my existing build target but that broke the build because of violations. I don't want to do disabling using the comment style as that imply a change to the source files.
THE disabling I want to do is a specific type of check (e.g. trailing whitespace due to millions of violating lines in the existing codebase)
Is there a way to configure checkstyle to do that?

You can enable and disable checks by adding or removing them from the Checkstyle configuration file that you specify when running the Checkstyle Ant task. Checkstyle runs exactly the checks that are present in the configuration XML (e.g. the Sun Checks).
It is not possible to disable a check which is present in the configuration:
<module name="EmptyBlock">
<property name="enabled" value="false" /> <!-- won't work -->
</module>
It is also not possible to tell Checkstyle to run "all checks except EmptyBlock", because there is no such thing as "all checks" - the set of available checks depends entirely on the configuration XML. However, it may be a good addition to the Checkstyle tool to support disabling of checks like shown above, as this would make life easier for people not using a configuration GUI.
If you don't want Checkstyle violations to fail the build, set the failOnViolation parameter of the Checkstyle Ant task to false. You can also use the maxWarnings and maxErrors parameters in order to set thresholds for how many warnings or errors to tolerate before the build should break.
Which violations are counted as errors and which as warnings depends on the severity property of the individual check in the Checkstyle configuration that you specify (docs). The default severity is 'warning'.

Related

Where should I define properties in sonar-groovy?

I went through the https://github.com/pmayweg/sonar-groovy
In README.md it specified few properties need to mention, but I am not able to identify where and in which file I have to mention them.
Actual information defined in pmayweg/sonar-groovy/README.md:
CodeNarc It is possible to reuse a previously generated report from CodeNarc by setting the sonar.groovy.codenarc.reportPaths property.
Groovy File Suffixes It is possible to define multiple groovy file suffixes to be recognized by setting the sonar.groovy.file.suffixes property. Note that by default, only files having .groovythe as extension will be analyzed.
Unit Tests Execution Reports Import unit tests execution reports (JUnit XML format) by setting the sonar.junit.reportsPath property. Default location is target/surefire-reports.
JaCoCo and Binaries The groovy plugin requires access to source binaries when analyzing JaCoCo reports. Consequently, property sonar.groovy.binaries has to be configured for the analysis (comma-separated paths to binary folders). For Maven and gradle projects, the property is automatically set.
Finally, I find out
sonar-scanner.properties in sonar-scanner/conf or
sonar-project.properties in your project.

Few doubts regarding Maven junit tests parallel execution

I was looking into how to improve overall execution time for JUnit test cases for my project. For the reference here that we are using the followings:
Maven 3.3.9
Junit 4.12
Maven Surefire Plugin 2.18.1
I was going through "Maven Surefire Plugin Parallel Test Execution" official documentation.
Could someone please clarify following doubts w.r.t. Surefire plugin configuration in pom.xml:
If useUnlimitedThreads attribute is set to true then is it recommended to provide threadcount attribute?
Based on above, what would happen if useUnlimitedThreads=true and threadcount=4 (for example). Would threadcount value still be considered while executing JUnit?
If we want to leverage "threadcount" along with useUnlimitedThreads=false then how to decide no. of threads? My perspective is that we should use useUnlimitedThreads=true with no threadcount configuration.
If we use configuration [useUnlimitedThreads=false and threadCount=4] then how to decide perCoreThreadCount boolean flag value? Default value is true. Also, how declaring it to false might impact execution time?
What is the significance of parallelOptimized attribute? How it might impact execution time?

Treat warnings as errors in Jenkins

I want to treat warnings as errors in Jenkins, but not when I build locally. So I can't just enable it from the project settings because that would apply locally as well. I also don't want to use a separate configuration, I want to build in Debug for Jenkins.
That leaves specifying it as a command line parameter when running msbuild, how can I do that?
I think you should take a look to the Warnings Plugin of Jenkins. It is specifically done to parse ("standards") compiler output and group/count warnings. It can also mark your build failed if too many warnings appeared (with the support of the generic Static Code analysis plugin).
You can configure the health of your build according to the number of warnings detected (first line in the following picture). Health will not fail the build, just change the weather associated (sunny, cloudy, rainy... ;) ).
To change the state of the build, this will be done in the last lines of the following picture. In my configuration, if more than 10 warnings are found, builmd will become Unstable, and more than 100 will fail the build. Adjust the values for your needs ;)
Warnings plugin configuration

Only display codenarc priorities 1 and 2 in Jenkins violations report

Is there a way I can exclude priority 3 violations from the Jenkins graph? The other codenarc report types like 'html' or 'sortable' have a maxPriority option which does exactly what I want, but that option doesn't exist for the type=xml report.
Help?
Details:
I use codenarc as a lint-like source code analysis tool for my Groovy / Grails project.
The Jenkins Violations Plugin supports codenarc (among others) and allows the Jenkins job to not only display an HTML codenarc report, but also Fail the build if, say, you have 1 or more high priority violations.
This is all great but I don't want any priority 3 (low level) violations to appear in the nifty graph which the violations plugin creates in Jenkins.
It's more an issue of visual appeal than anything else. I don't want low level violations to appear at all.
Am I left with only the option of removing all priority 3 references by post-processing the xml file that is initially generated? Regex to the rescue. In that case I guess I add a Build Step that is a Groovy Script which runs before the Violations are evaluated?

How do I get Intellij not to analyze my ant build files?

I'm using ant as my primary builder for a flex project in IntelliJ. Every time I build, IntelliJ runs the code analysis tool and finds a bunch of errors in my build file, which pops up the "Messages" window every time. Actually, the errors that it finds are complaining mostly about properties which are defined in a separate file, which it doesn't actually parse when running the analysis.
Edit: Additionally, I am making use of ant tasks which generate properties on the fly, which IntelliJ is unaware of.
Is there any way to turn off file inspection for ant build files during the build process?
That sounds weird. IDEA on the fly inspections which you get while editing the build.xml file should not pop-up when you actually build the project unless they are really errors and are reported by Ant to IDEA while the build file is executed.
IDEA can perform additional validation and report errors on Make for certain components (see Settings | Compiler | Validation), but it doesn't include Ant build files and is not triggered when you just run the Ant target.
If you don't want to see warnings from the Ant Messages Window, you need to toggle off the "Show All Messages" button.
If you don't want IDEA to analyze your build.xml file for errors, click the Hector icon in the status bar and disable the inspections per file by changing the highlighting level from the Inspections to Syntax.
Clarify the problem if it's not the case (knowing IDEA version would be also useful).
Does the .properties file exist, and is it in your CLASSPATH? IntelliJ is very smart about figuring that stuff out. When IntelliJ complains, I usually assume that I'm making a mistake. That posture usually gets me to a solution pretty quickly.
You can disable Ant plugin altogether. IDEA becomes quite slow on large Ant builds, so found this to be of help:
Crtl+Alt+S (for settings) -> Plugins -> Ant Support (uncheck)

Resources