For the last months I've been slowly improved the Eclipse automated PDE build process for our application.
The first thing I tried was automating the test cases. The next step was some scripting code to generate an installer automatically, for both linux and windows.
Now I want to add some static code analysis reports to the process. In my company we use Checkstyle for this purpose.
I understand that it is possible to automate the Checkstyle plugin in such a way that it can generate a report from the build process. It would be useful to distribute the checkstyle results together with the unit test report, which are being generated already.
Does anyone has some good example of how this can be achieved in a relatively painless way?
There's a Checkstyle Ant Task defined in the Checkstyle JAR file. Use it as follows:
<taskdef resource="checkstyletask.properties" classpath="/path/to/checkstyle-all-4.4.jar"/>
<checkstyle config="/path/to/my/checkstyle_config.xml">
<fileset dir="src/checkstyle" includes="**/*.java"/>
</checkstyle>
You might want to look at a CI server like Hudson, which you can use to automate your builds and with which you can easily integrate a number of plugins for FindBugs, CheckStyle, etc.
Related
Does anyone know a jenkins plugin for Java that analyses the coding styles and fails the build (not only provide a report) in case there are styles violations?
You can use Findbugs and Checkstyle for the same.
https://plugins.jenkins.io/checkstyle
https://plugins.jenkins.io/findbugs
Jacoco is used to unit test coverage and not really for static analysis.
the solution is to use a plugin of your build tool(like jacoco plugin in your pom for maven build).
And then configure your jenkins pipline to fail if quality is not satisfying
New to Sonar. Am comfortable with checkstyle and jacoco.
What I am exploring is in a a gradle project, give developers ability to run style checks and code coverage reports locally, but then use bamboo to publish reports in sonar.
Is this a viable option ? I can see that jacoco plugin and sonar plugin can be in the same build.gradle and so guessing that jacoco reports can be got from sonar. However am unsure how checkstyle integration works. From what I see, I can add a checkstyle plugin to sonar, but then I will have to define rules in SonarQube. I will like to keep checkstyle configuration locally so developers can run a local check before commiting code.
Bear with me if the questions are naive.
Your goal: enable developers to run the same set of rules locally that are applied in a SonarQube scan.
The means: SonarLint offers a "connected mode" for IntelliJ, Eclipse, and Visual Studio. Assuming you're using the SonarQube Analyzers, they'll get on-the-fly checking as they code using the same rule set locally as is applied in an analysis. If the profile changes on the server, it can be manually re-synchronized in the IDE.
The hitch: to make this work seamlessly, you should look at replacing your Checkstyle rules with the ones offered by the SonarQube Analyzer for Java (i.e. the Java plugin). Almost all of the "valuable" rules from Checkstyle have been replaced in the Java plugin.
I have a few modules(projects and subprojects) in my application (in Gradle) and i have added plugins: PMD, checkstyle, findbugs. Those plugins create their own reports in their directory (for example: PMD makes directory "PMD" in directory "reports" and put there report). I would like to have a one report for all those plugins. It is possible to do that? And if yes, how do that?
You can't simply configure them to create a shared report together. However, you can use for this purpose either SonarQube or QualityGate. Both tools can execute the above mentioned plugins and they can generate a summarized report as you required.
You probably want take a look at SonarQube. It basically gathers reports of mentioned tools and shows them via nice web app. It can also gather test coverage reports and is free.
Not sure how it can be integrated with Gradle, but we have it integrated with Jenkins. There is also Eclipse plugin I used.
QualityGate (that was mentioned by Csuki) is paid solution.
My development environment includes Maven, Failsafe and Spring testing IS (AbstractJUnit4SpringContextTests).
I'm looking for a way to collect statistics about the integration tests run.
Information such as Test duration, process memory, etc...
What is the best way to collect such information with the above configuration (and to integrate with the maven flow).
as far as i recall, the surefire plugin is able to write reports to some directory (which will be used by e.g. jenkins to present results)
There is a maven plugin for Sonar. It is highly configurable, maybe solution to your problem.
The failsafe plugin generates a xml file with the tests result. this can be used, for example by a jenkins plugin.
We use Hudson for our continuous integration which provides us with easy to browse build reports showing compiler warnings, unit test results and coverage (EMMA), pmd, checkstyle and findbugs violations.
Although we each have the relevant plugins installed locally in Eclipse, it often seems easier to simply commit to SVN in order to trigger a Hudson build and generate a build report showing the above info rather than checking with each plugin.
Is there something that developers could install locally (i.e. an Eclipse plugin perhaps) to generate similar reports? Or would it be feasible to somehow use Hudson for this purpose?
You can also install Sonar, which includes all the tools you list (except EMMA which is a plugin). Try it, it's free and open source ! http://sonar.codehaus.org
You Can install hudson locally easily. It is a runnable jar.
Try it. You'll like it.