Violations

Plugin Information

Plugin ID violations
Latest Release 0.7.4
Latest Release Date May 14, 2009
Changes in Latest Release via Fisheye
Maintainer(s) n/a (java.net id: preilly)
Issue Tracking Open Issues


This plug-in generates reports static code violation detectors such as checkstyle, pmd, cpd, findbugs, fxcop, stylecop and simian.
This description is for version 0.6.0 of the plugin.  This version works with hudson 1.200 and higher.  It should also work with previous versions of hudson.


Note: Since version 0.6.0 the violations plugin works with the hudson maven2 project type..





Description

The violations plug-in scans for violation xml files of particular types in the build workspace, gathers the violations and reports on the numbers for each type. The currently supported types are:

type url version notes
checkstyle http://checkstyle.sourceforge.net/ 4.2  
pmd http://pmd.sourceforge.net 4.0  
cpd http://pmd.sourceforge.net/cpd.html 4.0  
findbugs http://findbugs.sourceforge.net/ 1.3.3rc2 There are some issues with the maven plugin of findbugs - one needs to set the sourcepath field and it also appears that some violations are reported against incorrect files.
  http://fb-contrib.sourceforge.net/ 3.4.2 A findbugs plugin
pylint http://www.logilab.org/857    
fxcop http://blogs.msdn.com/fxcop/ 1.35+  
stylecop http://code.msdn.microsoft.com/sourceanalysis 4.2+  
simian http://www.redhillconsulting.com.au/products/simian/    

Configuration

Note: the following snapshots are from version 0.4, version 0.5 is similar (with pylint, fxcop, stylecop and simian added).

Configuration should be easy, First you need to have activate the static code analysizers in your build. Then activate the Violations plugin as shown below. 
 
 

The fields are:

name description
Per file display limit This is used to limit the number of violations displayed per file per violation type.
type The violation type.
sun icon This is the lowest number of violations of this type to generate the sunny weather report. For example the value 10 means that violations 0 to 10 will cause a sunny report, 11 and higher will be cloudy or worse.
stormy icon The is the lowest number of violations of this type to generate the stormy weather report.
XML filename pattern This is an ant type pattern to match violation files of this type in the workspace. Multiple patterns may be separated by commas.
Source Path Pattern This is an optional field. It is used to resolve classnames to source file names. It is only currently used by the findbugs violations type.
Faux Project Path This is an optional field. It is used if you just want to run hudson as a reporting engine for a project not in hudson's workspace. For example, the violations plugin has a hudson job that cd's to the cvs directory, creates the checkstyle, pmd and cpd reports and the invokes violations plugin with the faux project path set to (PATH TO CVS DIR)/plugins/violations.

After configuration, the Violations plugin will collect violations from the next build. The following pages are created or modified.

Project Page

The project page is modified to add a violation icon ( ) and a violation trend graph:

Clicking on the violations link brings one to the current violations report. 

Build page


The build page also has the violations trend and the violations icon. Clinking on the violations link brings one to the violations report for this particular build.

 Violations report page

Note the following snapshots are from 0.4, 0.5 is similar, except that the +/- notation has been removed.

The start of the violations report page looks like this:

For each violation type a trend and file summary is shown as follows:
The order of the table can be changed by clinking on the column header.

 Per File Report

Linking on the file link brings on to the file report. This will show all the violations (up to a limit specified in the config page) of a file, Each violation has a line number, an icon representing the severity and a description of the violation. Hovering over the icon will give more detail on the violation - and for findbugs, this will be the long detailed message. After the list of violations, snipets from the source file will be shown for each violation. This will only happen if the violations plugin can find the file in question.

 
.
 Hovering over the violations icon on the highlighted line will cause a pop-up of the violations on the line:

Version History

Version 0.7.3: Feb 11, 2009

Version 0.7.1: August 25, 2008

  • Bugfix: updated support for stylecop v4.3 issue #2242

Version 0.7.0: May 28, 2008

  • Enhancement: add support for stylecop

Version 0.6.0: May 5, 2008

  • Enhancement: add support for M2 job type
  • Enhancement: support for setting the build to unstable if the number of violations
    of a certain type exceed a threshold.

Version 0.5.8 April 22, 2008

  • Enhancement: add simian violations

Version 0.5.7 April 16, 2008

  • Bugfix(1550): fix for invalid decoding of some cpd.xml files
  • Bugfix(1558): fix for missing dependence on xpp3

Version 0.5.6 April 8, 2008

  • Bugfix(1129): fix for .. in paths in checkstyle reports

Version 0.5.5 March 30, 2008

  • Bugfix(1281) pmd priorities were incorrect
  • Bugfix(1217) reading of xml files used incorect character encoding
  • Feature(1217) allow user to specify encoding of source files
  • Feature readin in fb-contrib findbugs descriptions
  • Bugfix: fix of
    Version 0.5.4 Feb 25 2008
  • Bugfix: Fix so pylint errors are marked as errors.

Version 0.5.3 Oct 22 2007

  • Bugfix: Fix for cpd on dos

Version 0.5.2 Oct 10 2007

  • Bugfix: Fix a bug where the filename is an absolute dos type name (Brian Dueck)

Version 0.5.1 Sep 28 2007

  • Bugfix: remove use of a jdk6 constructor

Version 0.5 Sep 24 2007

  • Bugfix: fix serialization with slaves
  • Enhancement: add fxcop and pylint violations (Erik Ramfelt)
  • Enhancement: allow non xml report files
  • Enhancement:: change +/- to use colors

Version 0.4 Aug 15 2007

  • Bugfix: fix handling of findbugs for files without debug info issue #722
  • Enhancement: show severity levels
  • Enhancement: provide trend graph for severity levels on the report page
  • Enhancement: add detail hover for findbugs on the file page
  • Enhancement: add  +- changes on the report and build pages.
  • Enhancement: make the file list table sortable.

Version 0.3 Aug 10 2007

  • Bugfixe: fix  NPEs when reading  findbugs violation files
  • Bugfix: in getting the sourcelines from findbugs violation files
  • Enhancement: allow user to optionally specify a source path pattern to resolve classes (used by the findbugs parser)
  • Enhancement:: allow user to optionally specify a different project path for resolving file names.

Version 0.2 Aug 08 2007

  • Bug fix for maven findbugs plugin

Version 0.1 Aug 08 2007

  •  initial release 

Labels:

plugin-publisher plugin-publisher Delete
plugin-maven plugin-maven Delete
plugin-report plugin-report Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
  1. Sep 09, 2007

    Mark Crocker says:

    "Configuration should be easy"... um, ok.  Then where is this configuration...

    "Configuration should be easy"... um, ok.  Then where is this configuration page available from?  None of the configuration pages that I can find have a'Report Violations' check box like the one shown above.  Am I missing something?  How do I get to this page?

  2. Sep 11, 2007

    Anonymous says:

    Yes, I am having the same problem. Can anyone point out where this page is? &nb...

    Yes, I am having the same problem. Can anyone point out where this page is?

     Thanks,

    Frank LaFond

    1. Sep 13, 2007

      Anonymous says:

      I found it. To open up the display like the one shown above, look for a checkbox...

      I found it. To open up the display like the one shown above, look for a checkbox "Report Violations" on the "configure" page for the project to be analyzed. It will pop open the section shown above.

       - Frank.

      1. Sep 13, 2007

        Anonymous says:

        I have installed last version of Hudson and last version it of violations plufin...

        I have installed last version of Hudson and last version it of violations plufins, but no chekbox appears. What is the Problem?

        1. Nov 16, 2007

          peterkittreilly says:

          -- Stephen has just shown me the comments section of the wiki --...

          -- Stephen has just shown me the comments section of the wiki --

          The violations plugin currently only works for free-style projects and not for maven 2 hudson projects.

  3. Sep 11, 2007

    Anonymous says:

    I am having the same problem. the plugin is started, i can't found de configurat...

    I am having the same problem. the plugin is started, i can't found de configuration page.

  4. Sep 11, 2007

    Anonymous says:

    I tried to install lastest versions of hudson and this plug-in but the violation...

    I tried to install lastest versions of hudson and this plug-in but the violations Icon and configuration page never apear

  5. Sep 12, 2007

    Anonymous says:

    I've been having the same problem, graph shows up as a broken image. Started wit...

    I've been having the same problem, graph shows up as a broken image. Started with latest version of violations (.4) and hudson 1.32.

  6. Sep 13, 2007

    Anonymous says:

    PLEASE!!!!!! post any solution for this Issue!!&...

    PLEASE!!!!!! post any solution for this Issue!!!

  7. Sep 13, 2007

    Kohsuke Kawaguchi says:

    Please use the issue tracker for filing issues, so that it gets proper attention...

    Please use the issue tracker for filing issues, so that it gets proper attention.

  8. Sep 14, 2007

    Anonymous says:

    Maybe this plugin doesn't work with your project type (e.g. native m2)?

    Maybe this plugin doesn't work with your project type (e.g. native m2)?

  9. Sep 17, 2007

    Anonymous says:

    For the "graph shows up as a broken image" issue, see here: https://hudson.dev....

    For the "graph shows up as a broken image" issue, see here:

    https://hudson.dev.java.net/issues/show_bug.cgi?id=820

  10. Oct 05, 2007

    Anonymous says:

    What directory is the "XML filename pattern" relative to? i.e. I have an ant bas...

    What directory is the "XML filename pattern" relative to? i.e. I have an ant based build that outputs my PMD report to a file called build/reports/pmd/pmd_report.xml. I've tried specifying an XML filename pattern value as "build/reports/pmd/pmd_report.xml" but the Hudson build output shows "pmd no report".

     Any ideas?

    1. Feb 29, 2008

      Anonymous says:

      Hi, I'm also having problems with this. I have an ant based build that output a ...

      Hi, I'm also having problems with this. I have an ant based build that output a checkstyle report, but when i put the path to the report file in the "XML filename pattern" field hudson can't find it. Any help would be much appreciated.

  11. Oct 15, 2007

    Anonymous says:

    Firstly thx for the great plugin. Secondly I hit a small snag. When using the p...

    Firstly thx for the great plugin.

    Secondly I hit a small snag. When using the plugin with checkstyle, cpd and pmd, I notice a good integration between the cpd and checkstyle report. Ie. when clicking an entry I get an overview of the cpd and checkstyle violations, linked to the appropriate code snippets. Form pmd however this integration is not available.

    Could pmd be integrated in the same way? Otherwise point me in the appropriate direction for fixing it myself

    thx

    1. Nov 16, 2007

      peterkittreilly says:

      There are two known possible reasons:   The PMD from the the maven p...

      There are two known possible reasons: 

      1.  The PMD from the the maven pmd plugin does not contain complete information on the location of source files.  If this is your case, you need to set the base directory of source files in the violation plugin.
      2. If the class files do not have debug information (for example if they are compiled with ant's <javac> without setting the debug attribute), the pmd code is not in a position to know the source files and the line number of the violation, so the violations plugin using the class name instead.

      The PMD from the the maven pmd plugin does not contain complete information on the location of source files

  12. Oct 25, 2007

    Anonymous says:

    Do I have to install PMD to use it? I allways get an error in the console log: j...

    Do I have to install PMD to use it?
    I allways get an error in the console log:
    java.io.IOException: Expecting tag pmd
    at hudson.plugins.violations.parse.AbstractParser.expectNextTag(AbstractParser.java:268)
    at hudson.plugins.violations.types.pmd.PMDParser.execute(PMDParser.java:38)
    at hudson.plugins.violations.parse.AbstractTypeParser.parse(AbstractTypeParser.java:60)
    at hudson.plugins.violations.ViolationsCollector.doType(ViolationsCollector.java:158)
    at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:103)
    at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:27)
    at hudson.FilePath.act(FilePath.java:280)
    at hudson.plugins.violations.ViolationsPublisher.perform(ViolationsPublisher.java:73)
    at hudson.model.Build$RunnerImpl.post2(Build.java:138)
    at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:244)
    at hudson.model.Run.run(Run.java:597)
    at hudson.model.Build.run(Build.java:103)
    at hudson.model.ResourceController.execute(ResourceController.java:70)
    at hudson.model.Executor.run(Executor.java:62)
     
     I am using unmodified pmd 4.0 rules

    1. Oct 25, 2007

      Kohsuke Kawaguchi says:

      I recommend you file an issue in the issue tracker.

      I recommend you file an issue in the issue tracker.

    2. Nov 16, 2007

      peterkittreilly says:

      Most likely you have an incorrect file specification, and non pmd xml files have...

      Most likely you have an incorrect file specification, and non pmd xml files have been included in the fileset given to the violations plugin.

  13. Feb 08, 2008

    Carlos Abreu says:

    Hi everyone, i would like to know if it possible to customize the Checkstyle val...

    Hi everyone, i would like to know if it possible to customize the Checkstyle validation properties. Just like in eclipse IDE, because i have a custom checkstyle configuration file and i wanna use him.

    Thanks in advance,

    Carlos Abreu 

  14. Apr 16, 2008

    Pons Bernard says:

    Well i'm systematically getting this error when i try to use checkstyle rules :F...

    Well i'm systematically getting this error when i try to use checkstyle rules :FATAL: Expecting tag checkstyle
    java.io.IOException: Expecting tag checkstyle
    at hudson.plugins.violations.parse.AbstractParser.expectNextTag(AbstractParser.java:268)
    at hudson.plugins.violations.types.checkstyle.CheckstyleParser.execute(CheckstyleParser.java:39)
    at hudson.plugins.violations.parse.AbstractTypeParser.parse(AbstractTypeParser.java:59)
    at hudson.plugins.violations.ViolationsCollector.doType(ViolationsCollector.java:158)
    at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:103)

    How come you expect a checkstyle tag in a checkstyle.xml file?

    1. Apr 16, 2008

      peterkittreilly says:

      You need to specific the checkstyle *result* file and not the checkstyle...

      You need to specific the checkstyle *result* file and not the checkstyle config file.

      So for example if the result file is build/checkstyle/raw.xml, use **/build/**/raw.xml.

      If the result file is target/checkstyle-result.xml (default maven checkstyle:checkstyle),

      use **/target/checkstyle-result.xml.

  15. May 06, 2008

    rafael munoz says:

    How can I integrate CPD with this? I'm using the last CPD version which is the...

    How can I integrate CPD with this?

    I'm using the last CPD version which is the one point by the http://pmd.sourceforge.net/cpd.html (corresponding a PMD 4.2.1) but it's generating a simple text file, not a XML file that the violations plugin can understand.

    Do I have to use another CPD version? If I have to, how can I do it? PMD and CPD share the same library (pmd-4.2.1.jar).

  16. May 15, 2008

    Peter Hrastnik says:

    Is there a way to customize the mapping between the violation type's severity an...

    Is there a way to customize the mapping between the violation type's severity and the violation plugin's severities? I'm asking because for checkstyle, the checkstyle severity "error" (the highest severity level in checkstyle) is mapped to "medium high" in the violation plugin. As a result, in the case of checkstyle the violation report is misleading because it shows only medium and low violations, although checkstyle errors may be present.
    So I think "error" should be really mapped to "high" in order to be represented accordingly in the violations report.

    Thanx for the great plugin,
        Peter.

  17. Jul 14, 2008

    Gilad Gruber says:

    I amusing hudson 1.233 and when I try to use the violations plugin I get the fol...

    I amusing hudson 1.233 and when I try to use the violations plugin I get the following exception:

    14/07/2008 17:25:51 hudson.ExpressionFactory2$JexlExpression evaluate
    WARNING: Caught exception evaluating: it.findReport(). Reason: java.lang.NullPointerException
    java.lang.NullPointerException
            at hudson.plugins.violations.hudson.maven.ViolationsAggregatedReport.init(ViolationsAggregatedReport.java:60)
            at hudson.plugins.violations.hudson.maven.ViolationsAggregatedReport.<init>(ViolationsAggregatedReport.java:28)
            at hudson.plugins.violations.hudson.maven.ViolationsMavenAggregatedBuildAction.getReport(ViolationsMavenAggregatedBuildAction.java:54)
            at hudson.plugins.violations.hudson.maven.ViolationsMavenAggregatedBuildAction.getReport(ViolationsMavenAggregatedBuildAction.java:23)
            at hudson.plugins.violations.ViolationsReport.findViolationsReport(ViolationsReport.java:486)
            at hudson.plugins.violations.hudson.AbstractViolationsBuildAction.findReport(AbstractViolationsBuildAction.java:150)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.apache.commons.jexl.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:259)
            at org.apache.commons.jexl.parser.ASTMethod.execute(ASTMethod.java:104)
            at org.apache.commons.jexl.parser.ASTReference.execute(ASTReference.java:83)
            at org.apache.commons.jexl.parser.ASTReference.value(ASTReference.java:57)
            at org.apache.commons.jexl.parser.ASTReferenceExpression.value(ASTReferenceExpression.java:51)
            at org.apache.commons.jexl.ExpressionImpl.evaluate(ExpressionImpl.java:80)
            at hudson.ExpressionFactory2$JexlExpression.evaluate(ExpressionFactory2.java:71)
            at org.apache.commons.jelly.tags.core.SetTag.doTag(SetTag.java:84)
            at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262)
            at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
            at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
            at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262)
            at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
            at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
            at org.apache.commons.jelly.impl.StaticTag.doTag(StaticTag.java:65)
            at org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:112)
            at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
            at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
            at org.apache.commons.jelly.impl.StaticTag.doTag(StaticTag.java:65)
            at org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:112)
            at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
            at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
            at org.apache.commons.jelly.impl.StaticTag.doTag(StaticTag.java:65)
            at org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:112)
            at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
            at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
            at org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:42)
            at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262)
            at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
            at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
            at org.apache.commons.jelly.tags.core.IfTag.doTag(IfTag.java:42)
            at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262)
            at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
            at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
            at org.apache.commons.jelly.tags.core.JellyTag.doTag(JellyTag.java:45)
            at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262)
            at org.apache.commons.jelly.impl.DynamicTag.doTag(DynamicTag.java:80)
            at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262)
            at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
            at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
            at org.apache.commons.jelly.tags.core.JellyTag.doTag(JellyTag.java:45)
            at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262)
            at org.kohsuke.stapler.jelly.IncludeTag.doTag(IncludeTag.java:96)
            at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262)
            at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
            at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
            at org.apache.commons.jelly.tags.core.ForEachTag.doTag(ForEachTag.java:150)
            at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:262)
            at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
            at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)

    Any ideas?

     THanks in advance,

    Gilad

    1. Dec 02, 2008

      John Allen says:

      same here, there's a bug for it: https://hudson.dev.java.net/issues/show_bug.cgi...
  18. Jun 13

    Todd Linnertz says:

    Could this plugin be extened to read file output from SourceMonitor (http://www....

    Could this plugin be extened to read file output from SourceMonitor (http://www.campwoodsw.com/sourcemonitor.html)?

  19. Aug 09

    Maximillian Dornseif says:

    Im quite seasoned in Python an pylint but very unfamilar with the java way of do...

    Im quite seasoned in Python an pylint but very unfamilar with the java way of doing things. It seems that to use hudson with pylint I need one or many "violation xml files". Do I understand correct that the "violation xml files" should be the output of the checker tools?

    I have problems to understand how things have to fit together to get the pylint output into hudson.

    Any hints?

    1. Aug 11

      Maximillian Dornseif says:

      The XML part threw me off. I now found out that running pylint -f parseable mym...

      The XML part threw me off. I now found out that running

      pylint -f parseable mymodule | tee pylint.out

      and entering "**/pylint.out" into the "XML filename pattern" fieled in the Violations configuration has the desired effect.

      --md

  20. Sep 03

    sebestenyb says:

    Hello also need some help with some path issues. I have the hudson install in ...

    Hello

    also need some help with some path issues.
    I have the hudson install in

    /home/hudson/.hudson

    I have a project in my workspace:

    home/hudson/.hudson/jobs/MyProject/workspace/ContactForm/

    The source directory is:

    home/hudson/.hudson/jobs/MyProject/workspace/ContactForm/src/

    I can generate and pickup the pmd.xml file as below:

    home/hudson/.hudson/jobs/MyProject/workspace/ContactForm/pmd.xml

    The FlexPMD generates the pmd.xml with looks-like full paths:

    home/hudson/.hudson/jobs/MyProject/workspace/ContactForm/src/com/arcad/projects/solerati/contactform/views/ColorsList.mxml

    So what do I have to write into the config of the plugin to get the Violations to pick up the sources, and link them in the file details page?

    Thanks in advance, B