#46 CheckStyle: update to work with checkstyle 4.4

closed-out-of-date
None
5
2015-01-19
2008-11-25
Nick Clarke
No

Improved/fixed version of CheckStyle plugin. Changes made starting from 0.2.2.1 release.

This updates the plugin to work with version 4.4 of the checkstyle library - the latest non-beta version.

The attached zip contains everything EXCEPT the checkstyle library jar - I can't attach it because it's too large for the tracker patch upload; you need to download the 4.4 version from here, and put checkstyle-all-4.4.jar in the /lib directory of the plugin sources:
https://sourceforge.net/project/showfiles.php?group_id=29721&package_id=21696&release_id=561755

Main changes made:

1. Modified to load some properties (though not tasks yet) from shared plugin build system

2. Upgraded to checkstyle 4.4 lib in build system and plugin dependency

3. Modified to work with checkstyle 4.4. The main problem was that checkstyle couldn't load dtds from inside its jar because it was using the thread context classloader to load resources, and it couldn't see them. Fixed by setting up thread context classloader when initialising Checker in CheckStyleThread.

4. Set a PropertyResolver on the Checker that returns empty strings so that checkstyle config xml files with '${...}' properties have a chance at working (assuming an empty string is actually a valid value where it's substituted). If in future we need real values we could use com.puppycrawl.tools.checkstyle.PropertiesExpander instead and let the values be set from an external properties file or in plugin options.

5. Rename plugin actions and menu text. Actions:
chkBuffer -> checkstyle.checkBuffer
chkAllBuffers -> checkstyle.checkAllBuffers

6. Allow setting project classpath to fix 'Unable to get class information for ...' errors in RedundantThrows checkstyle module and others.

Adding the compiled versions of the files being checked to the classloader fixes these errors - these checkstyle modules need to analyse the inheritance hierarchy, hence it needs the .class files.

Implemented by adding the files to the thread context classloader (see 3 above) running the Checker - using Checker's setClassloader() method does not work for some reason.

Plugin option dialog allows input of a regular jars-and-classdirs classpath, plus a list of dirs to be searched for .jar files.

Discussion

  • Nick Clarke
    Nick Clarke
    2008-11-25

    Full plugin sources after changes, except checkstyle jar (see above)

     
  • Nick Clarke
    Nick Clarke
    2009-04-24

    Missing build.properties file referenced by ant build script in previous attachment - expected to be in parent directory; you will need to set paths in it for your system

     
    Attachments
  • Alan Ezust
    Alan Ezust
    2014-04-26

    Sorry for the long delay in response, but this is not a patch, so I can't accept it.
    Furthermore, it seems kpouer has been committing fixes to the SVN version but never bothered to release a newer version.
    Can you use SVN? Can you please check trunk out from there, try that version, and submit a patch?
    I can't accept this in its current state because it would be too tricky to merge it with trunk.

     
  • Alan Ezust
    Alan Ezust
    2014-04-26

    • status: open --> closed-out-of-date
    • assigned_to: Matthieu Casanova
    • Group: --> 4.3
     
  • Alan Ezust
    Alan Ezust
    2014-04-26

    • status: closed-out-of-date --> pending
     
  • Out of date, 5.5 is already in use

     
    • status: pending --> closed-out-of-date