667481 members! Sign up to stay informed.

Sponsored Links


Resources

Enterprise Java
Research Library

Get Java white papers, product information, case studies and webcasts

News News News Messages: 27 Messages: 27 Messages: 27 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

Checkstyle 3.4 released

Posted by: Oliver Burn on May 18, 2004 DIGG
Announcing that Checkstyle version 3.4 has been released and is available from http://checkstyle.sourceforge.net. See the release notes for the many changes since the last widely announced release - http://checkstyle.sourceforge.net/releasenotes.html.

Checkstyle is a tool for performing analysis on Java source code. It is most infamous for performing syntax checks and enforcing coding standards. However, it is very flexible and includes checks for:

  * J2EE coding problems (http://tinyurl.com/2y9vz)
  * Unused declarations (http://tinyurl.com/32vcd)
  * Metrics analysis (http://tinyurl.com/28jma)
  * Coding Problems (http://tinyurl.com/36jo9)
  * Class Design (http://tinyurl.com/2hnjx)
  * Many others including Javadoc Comments, Naming Conventions, Headers, Imports, Size Violations, Whitespace, Modifiers, Blocks, Duplicate Code, Miscellaneous others.

The Checkstyle architecture has been designed to allow custom checks to be easily developed. See http://checkstyle.sourceforge.net/writingchecks.html for more details.

Plenty of documentation is available at http://checkstyle.sourceforge.net.

Third-party plug-ins are available for Maven, jEdit, NetBeans, Centipede, JBuilder, Eclipse/WSAD, Emacs JDE, BlueJ.

Regards,
Oliver

PS: The Checkstyle team are not responsible for any suffering caused by inappropriate use! :-)

Threaded replies

·  Checkstyle 3.4 released by Oliver Burn on Tue May 18 08:53:25 EDT 2004
  ·  Checkstyle 3.4 released by Konstantin Ignatyev on Tue May 18 10:35:05 EDT 2004
    ·  Filtering errors by Daniel Grenner on Tue May 18 10:57:33 EDT 2004
      ·  Filtering errors by Konstantin Ignatyev on Tue May 18 11:17:35 EDT 2004
        ·  Filtering errors by D S on Tue May 18 11:29:17 EDT 2004
          ·  Filtering errors by Konstantin Ignatyev on Tue May 18 11:38:58 EDT 2004
            ·  Filtering errors by D S on Tue May 18 12:11:24 EDT 2004
              ·  Filtering errors by Konstantin Ignatyev on Tue May 18 12:38:10 EDT 2004
        ·  XDoclet? (Was: Filtering errors) by Craig Cottingham on Tue May 18 12:38:44 EDT 2004
          ·  XDoclet? (Was: Filtering errors) by Konstantin Ignatyev on Tue May 18 12:50:57 EDT 2004
        ·  Filtering errors by Pavel Vlasov on Tue May 18 15:09:31 EDT 2004
        ·  Filtering errors by Oliver Burn on Tue May 18 19:26:20 EDT 2004
    ·  Custom Check - re filtering results by Adam Judson on Tue May 18 14:56:06 EDT 2004
  ·  Thanks ;) by Yoav Shapira on Tue May 18 10:43:45 EDT 2004
  ·  Theoretical basis for the metrics by Haagen Hasle on Tue May 18 10:44:38 EDT 2004
    ·  Theoretical basis for the metrics by Oliver Burn on Tue May 18 19:00:30 EDT 2004
  ·  Checkstyle 3.4 released by John Davies on Tue May 18 10:46:51 EDT 2004
  ·  Is it similar to hammurapi? by Marcin Gryszkalis on Tue May 18 12:28:34 EDT 2004
  ·  Checkstyle 3.4 released - Ant task bombs with Ant 1.6. by George Coller on Tue May 18 12:58:56 EDT 2004
    ·  Checkstyle 3.4 released - Ant task bombs with Ant 1.6. More by George Coller on Tue May 18 13:07:01 EDT 2004
      ·  Checkstyle 3.4 released - Ant task bombs with Ant 1.6. More by Oliver Burn on Tue May 18 18:56:23 EDT 2004
      ·  Ant task bombs with Ant 1.6. Fixed, thank you. by George Coller on Wed May 19 13:19:29 EDT 2004
    ·  Checkstyle 3.4 released - Ant task bombs with Ant 1.6. by scot mcphee on Tue May 18 19:46:33 EDT 2004
      ·  Checkstyle 3.4 released - Ant task bombs with Ant 1.6. by scot mcphee on Tue May 18 19:52:20 EDT 2004
    ·  Checkstyle 3.4 released - Ant task bombs with Ant 1.6. by Daniel Grenner on Wed May 19 04:07:07 EDT 2004
      ·  Categorizing of deviations by Igor Semenko on Wed May 19 04:20:28 EDT 2004
        ·  We use it with Ant 1.6.1 as well... by Yoav Shapira on Wed May 19 09:35:04 EDT 2004
    ·  How I fixed it (at least I thought I did) by Bing Wu on Thu Jun 03 15:56:38 EDT 2004
  Message #122579 Post reply Post reply Post reply Go to top Go to top Go to top

Checkstyle 3.4 released

Posted by: Konstantin Ignatyev on May 18, 2004 in response to Message #122562
Suggestion: Ideally I should be able to review that error or suggestion and mark it as OK, the tool will see the mark and do not show that ‘violation’ again.
For instance I really want to hide a field with local variable by whatever reason: I should be able to mark such place as reviewed and be OK.

  Message #122584 Post reply Post reply Post reply Go to top Go to top Go to top

Thanks ;)

Posted by: Yoav Shapira on May 18, 2004 in response to Message #122562
Kudos and thanks to the CheckStyle team. I've been using it for years now, and it's been consistently helpful. I hope the 3.4 release improves the performance of the usage checks (unused method, can-be-private, etc.).

  Message #122585 Post reply Post reply Post reply Go to top Go to top Go to top

Theoretical basis for the metrics

Posted by: Haagen Hasle on May 18, 2004 in response to Message #122562
Could you tell me what the theoretical basis of the metrics you compute is? NPathComplexity mentions Nejmeh (that I have never heard of), and CyclomaticComplexity sounds like McCabe, but I'm not sure.

If you can give a short description of the background of the metrics, or point me to an url with a paper describing them, I would be very thankful.

Hågen

  Message #122588 Post reply Post reply Post reply Go to top Go to top Go to top

Checkstyle 3.4 released

Posted by: John Davies on May 18, 2004 in response to Message #122562
This should be compulsory, if you've got a coding standard, use this, it's a must!

Works a treat with Maven too.

-John-

  Message #122592 Post reply Post reply Post reply Go to top Go to top Go to top

Filtering errors

Posted by: Daniel Grenner on May 18, 2004 in response to Message #122579
It is possible to filter messages by configuring a filter submodule. See http://checkstyle.sourceforge.net/config.html#filters for details. The SuppressionFilter is probably the most appropriate for what you are suggesting.

/Daniel

  Message #122602 Post reply Post reply Post reply Go to top Go to top Go to top

Filtering errors

Posted by: Konstantin Ignatyev on May 18, 2004 in response to Message #122592
The SuppressionFilter is probably the most appropriate for what you are suggesting.
Yes, that filter can do the trick but it is not inconvenient for use IMO:
Such check as
<suppress checks="MagicNumberCheck"
              files="JavadocStyleCheck.java"
              lines="221"/>
implies that I should edit the file and edit the file again when I edit main source file. Looks like error prone and inconvenient routine. How about some source code level remarks like:
// @checkstyle:ignoreNextLines n=1
for( int myStupidLongNameForLoopingVariable = 0;

  Message #122606 Post reply Post reply Post reply Go to top Go to top Go to top

Filtering errors

Posted by: D S on May 18, 2004 in response to Message #122602
It's an open source project. If it doesn't do what you want, feel free to write your own improved version.

  Message #122607 Post reply Post reply Post reply Go to top Go to top Go to top

Filtering errors

Posted by: Konstantin Ignatyev on May 18, 2004 in response to Message #122606
It's an open source project. If it doesn't do what you want, feel free to write your own improved version.
This exact attitude kills Open Source. No! Somebody (me) should not start new project just because an existing does not do exactly what that someone wants!!!
Contribute!!! Ideas, code, submit bugs, etc.

  Message #122620 Post reply Post reply Post reply Go to top Go to top Go to top

Filtering errors

Posted by: D S on May 18, 2004 in response to Message #122607
If an open source project doesn't do what you want you have three choices:

1. Bitch and whine about the fact that it doesn't do what you want and expect someone else to fix it for you for free.
2. Take the code and create your own version with the features you want. Whether you keep this version for your own private use or make it publicly available is up to you (depending on the licence terms).
3. Take the code and add the features you want and submit it back to the original project so that others can benefit from your work, if it's judged good enough and useful enough.

You seem to have opted for choice number 1.

  Message #122624 Post reply Post reply Post reply Go to top Go to top Go to top

Is it similar to hammurapi?

Posted by: Marcin Gryszkalis on May 18, 2004 in response to Message #122562
I tested hammurapi today and it seems to be pretty good (although seeing
these 100+ warnings per file is not really fun ;) ). Is checkstyle
something similar? Maybe somebody could post little comparision?

regards
marcin

  Message #122626 Post reply Post reply Post reply Go to top Go to top Go to top

Filtering errors

Posted by: Konstantin Ignatyev on May 18, 2004 in response to Message #122620
Bitch and whine about the fact that it doesn't do what you want
Name depends on attitude. Are you trying to say that Open Source authors should accept no feature requests?
and expect someone else to fix it for you for free.
Yes, I do expect. Why not? Authors know codebase way better and what might be one hour work for them will require week or more from a lazy guy like me.

  Message #122627 Post reply Post reply Post reply Go to top Go to top Go to top

XDoclet? (Was: Filtering errors)

Posted by: Craig Cottingham on May 18, 2004 in response to Message #122602
Such check as<suppress checks="MagicNumberCheck"              files="JavadocStyleCheck.java"              lines="221"/>implies that I should edit the file and edit the file again when I edit main source file. Looks like error prone and inconvenient routine. How about some source code level remarks like:// @checkstyle:ignoreNextLines n=1for( int myStupidLongNameForLoopingVariable = 0;
Could XDoclet be used to generate the suppressions file?

  Message #122629 Post reply Post reply Post reply Go to top Go to top Go to top

XDoclet? (Was: Filtering errors)

Posted by: Konstantin Ignatyev on May 18, 2004 in response to Message #122627
Could XDoclet be used to generate the suppressions file?
Good idea. Although I think XDoclet will not serve well because it does not care about line numbers IMO, so it will require a human to take care of line numbers and their changes.
But a simple regexp based parser might work very well: algorithm might look like this: on a first pass parse all files line-by-line and search for comments like // @checkstyle:ignoreNextLines n=5, as the parser will have exact line number where such comment was discovered it may generate suppress file correctly and keep track of line number changes automatically.

  Message #122631 Post reply Post reply Post reply Go to top Go to top Go to top

Checkstyle 3.4 released - Ant task bombs with Ant 1.6.

Posted by: George Coller on May 18, 2004 in response to Message #122562
There may be incompatibility with using the checkstyle ant task and ant 1.6's new import feature.

I get a
Can't find/access AST Node typecom.puppycrawl.tools.checkstyle.api.DetailAST
with a matching
0: Got an exception - java.lang.ClassCastException
for every file in the source.

Using the supplied ant task.

Did some googling and saw that Maven had a similiar problem a year ago.

Guess I'll try a prior release or wait for a patch.

  Message #122633 Post reply Post reply Post reply Go to top Go to top Go to top

Checkstyle 3.4 released - Ant task bombs with Ant 1.6. More

Posted by: George Coller on May 18, 2004 in response to Message #122631
Just a little more information on incompatiblity with 1.6:

Checkstyle ANT Task documentation at: http://checkstyle.sourceforge.net/anttask.html
says that the task has been tested using ANT 1.5.

Darn. We are using subant and import extensively so rolling back to 1.5 is out. Guess I will wait for the patch.

  Message #122652 Post reply Post reply Post reply Go to top Go to top Go to top

Custom Check - re filtering results

Posted by: Adam Judson on May 18, 2004 in response to Message #122579
Rather than filter out results, I'd suggest writing a custom check to replace the one you'd like to filter.

As you have the source of the check you'd like to change, it should be simple to copy it and modify it to scan for
// checkstyle:skip next line
and throw away the error.

I'm not sure I'd suggest going down this path though, as adding a facility to allow users to defeat the style checking system seems somewhat risky. I'd preffer to suffer through some noise in the result set.

  Message #122657 Post reply Post reply Post reply Go to top Go to top Go to top

Filtering errors

Posted by: Pavel Vlasov on May 18, 2004 in response to Message #122602
Check out Hammurapi waivers. They aren't bound to line numbers but to parse tree path. So if you have a waiver in, say, second for loop in third try block in method a() of class B you can freely modify all the rest of your code and the waiver will stay in place. If you modify that method, then waiver can become invalid. I think it is more robust way of binding to position in the source file comparing with line numbers.

  Message #122692 Post reply Post reply Post reply Go to top Go to top Go to top

Checkstyle 3.4 released - Ant task bombs with Ant 1.6. More

Posted by: Oliver Burn on May 18, 2004 in response to Message #122633
Have you actually tried it? We use Checkstyle 3.4 successfully at work with Ant 1.6.1 and IBM JDK 1.3.1.

  Message #122694 Post reply Post reply Post reply Go to top Go to top Go to top

Theoretical basis for the metrics

Posted by: Oliver Burn on May 18, 2004 in response to Message #122585
A good description of metrics can be found at http://metrics.sourceforge.net/. This is the excellent plug-in for Eclipse. Search for Metrics - Meanings.

  Message #122699 Post reply Post reply Post reply Go to top Go to top Go to top

Filtering errors

Posted by: Oliver Burn on May 18, 2004 in response to Message #122602
There was a long discussion about whether to use an embedded notation to suppress errors. Ultimately it was decided to not use this approach as:

- It stopped Java code being polluted with "noise"

- It allowed a central place where suppressions were entered - and hence monitored.

- It allowed for more powerful suppressions like, ignore all complexity errors in package a.b.c.


In practice, I use it on a large commercial project, this approach has worked well. But yeh, YMMV.

  Message #122704 Post reply Post reply Post reply Go to top Go to top Go to top

Checkstyle 3.4 released - Ant task bombs with Ant 1.6.

Posted by: scot mcphee on May 18, 2004 in response to Message #122631
George, we use Checkstyle with Ant 1.6.1 and have no problems with it.

  Message #122705 Post reply Post reply Post reply Go to top Go to top Go to top

Checkstyle 3.4 released - Ant task bombs with Ant 1.6.

Posted by: scot mcphee on May 18, 2004 in response to Message #122704
In fact we define a custom checkstyle macro with a standard set of stuff being done using the macrodef tag in a 'commons' ant build.xml and import this into our other builds, using checkstyle 3.4, ant 1.6.1 and ibm jdk 1.3.1 as oliver said and this this works great under cygwin, aix, and eclipse on NT environments.

You can see samples of the macrodef and import in action on my blog entry;

http://modular.autonomous.org/blog/2004/05/10/1084170945000.html

You will see the two example I use are clover and checkstyle.

  Message #122735 Post reply Post reply Post reply Go to top Go to top Go to top

Checkstyle 3.4 released - Ant task bombs with Ant 1.6.

Posted by: Daniel Grenner on May 19, 2004 in response to Message #122631
The reason for this problem is probably due to the way the classpath is set up, and not Ant 1.6 (I had the same problem with Ant 1.5 before I found a fix).

To fix the problem make sure you do not have any old version of "antlr" in your classpath (either as antlr.jar, or bundled inside something else, which e.g. is done in weblogic.jar).

/Daniel.

  Message #122738 Post reply Post reply Post reply Go to top Go to top Go to top

Categorizing of deviations

Posted by: Igor Semenko on May 19, 2004 in response to Message #122735
We've got huge code base with lots of deviations, we can't fix them all at once but we do want to keep track of different categories.
Example categories are:
- Whitespace issues
- Coding issues
- Documentation issues
- Complexity issues
- Block issues
...

As I can see possible implementations are:
1. add <property name="severity" value="XXXX"/> for each module used (checkstyle.xml), where XXXX can be "whitespace", "coding", "bug"...
2. patch SeverityLevel.java from checkstyle to accept any severity level defined in checkstyle.xml, not only "warning", "error", "ignore" and "info"
3. write/adjust .xsl file which uses custom severity levels in generated xml output to group checkstyle errors.
 
Any better ideas?
Thanks.

  Message #122766 Post reply Post reply Post reply Go to top Go to top Go to top

We use it with Ant 1.6.1 as well...

Posted by: Yoav Shapira on May 19, 2004 in response to Message #122738
... no problems, but we don't use import yet. The ANTLR on the classpath sounds like a good thing to check ;)

  Message #122801 Post reply Post reply Post reply Go to top Go to top Go to top

Ant task bombs with Ant 1.6. Fixed, thank you.

Posted by: George Coller on May 19, 2004 in response to Message #122633
Thank you everybody who responded to my post.

It turns out it was weblogic.jar in my classpath that was stopping checkstyle from working. After removing it, checkstyle worked great. Weblogic also uses classes from Antlr (whatever that is, must be a java parser or something similiar).

I'm happy now, was hoping it was something small on my part.

  Message #124570 Post reply Post reply Post reply Go to top Go to top Go to top

How I fixed it (at least I thought I did)

Posted by: Bing Wu on June 03, 2004 in response to Message #122631
I had the exact same problem earlier. I ran ant from Cygwin. The script "ant" came with 1.6 release. It failed with those " Can't find/access AST Node typecom.puppycrawl.tools.checkstyle.api.DetailAST " messages.

Then I manually invoked ant: java -classpath "$ant_home/lib/ant.jar;$ant_home/lib/ant-launcher.jar" org....AntLauncher my_target

It all worked fine. Then I looked at the "ant" script that I used earlier. It was almost the same except it didn't include ant.jar in -classpath switch.

Don't know why. I have a really strange environment here: couple of ant versions plus Eclipse's own. So didn't try debug any further. Hope this helps though.

Bing

New content on TheServerSide.comNew content on TheServerSide.comNew content on TheServerSide.com

Dependency Injection in Java EE 6 - Part 1

Reza Rahman explores the features of the proposed JSR 299, Contexts and Dependency Injection for Java EE (CDI). When approved, it promises to be a key feature of Java EE 6. (November 2, Article)

SAML: It's Not just for Web services

SAML is an XML-based standard for exchanging authentication and authorization data between security domains. The single most important problem that SAML was created to solve is the Web browser Single Sign-On problem. Many organizations are debating whether to stay with version 1.1 or move to 2.0. This article makes observations about both options. (September 28, Article)

Programming is Also Teaching Your Team

Joe Ottinger takes a look at how people learn, and applies it to the practice of programming. He notes that understanding how people learn is an essential part of working in a programming team. (September 22, Article)

Can Java EE Deliver The Asynchronous Web?

Stephen Maryka gave us an article about the Asynchronous Web and posed a number of questions that get examined like an approach to delivering Asynchronous Web capabilities through extensions to existing Java EE technologies. (July 14, Article)

JSF Flex

JavaServer Faces Flex goal is to provide users capability in creating standard Flex components, part of flexSDK which is open sourced through MPL license, as normal JSF components. This article by Ji Hoon Kim will provide an overview of creating a simple multilingual JSF page consisting of JSF Flex tags. (June 29, Article)

The Rules of SOA - A Road to a Successful SOA Implementation

In this session Jeff explores the key characteristics of successful SOA projects. He covers some of the patterns, and anti-patterns, tool sets, and strategies that he himself learned the hard way. Last, he provides a strategy and blueprint for achieving a high likelihood of success in your SOA project. (June 23, Tech Talk)

Ari Zilka Talks About Terracotta 3.1

Ari Zilka, CTO of Terracotta, Inc., talks about the new features in Terracotta 3.1, announced during JavaOne and available now. (June 15, Tech Talk)

Enterprise Application Integration, and Spring

In this Tech Talk, Josh Long explores an integration challenge using Spring Integration and walks through the implementation, employing and expanding on the basic patterns of Enterprise Application Integration to tie together components into a function integration solution, and then demonstrates how Spring Integration helps address the integration requirements. (June 15, Tech Talk)

Google Web Toolkit: An Introduction

In this Tech Talk, David Geary teaches you: The basics of Google Web Toolkit; How to implement Ajax-enabled applications in Java; Internationalization; Hooking into the browser history mechanism; Remote procedure calls. (June 4, Tech Talk)

Just Enough Early Architecture to Guide Development

Jon Kern discusses the best architecture/technical solutions and ensure that they are repeated by all developers. By tackling the architecture up-front in a serial manner, subsequent parallel development will be much more manageable and predictable. (May 28, Tech Talk)

Productive Programmer: On the Lam from the Furniture Police

This keynote describes the frustrations of modern knowledge workers in their quest to actually get some work done, and solutions for how to guard yourself against all those distractions. Neal Ford talks about environments, coding, acceleration, automation, and avoiding repetition as ways to defeat the misguided attempts to sap your ability to produce good work. (May 26, Tech Talk)

Auto-Scaling Your Existing Web Application

Gil demonstrates how new, aggressive uses of already abundant compute capacity by common applications offer competitive value for application designers. (May 21, Tech Talk)

Automating Hibernate Mapping and Queries For Java Web Development

Chris Keene introduces WaveMaker as a new way to automate the ability to generate Hibernate classes in order to more quickly bring OR mapping into an application. (May 19, Article)

Auto-Scaling Your Existing Web Application

In this session Nati Shalom demonstrates how to take a standard Java EE web application and scale it out or down dynamically without changes to the application code. Seeing as most web applications are over-provisioned to meet infrequent peak loads, this is a dramatic change because it enables growing your application as needed, when needed, without paying for unutilized resources. (May 19, Tech Talk)

Free Book PDF Download: Mastering EJB Third Edition

Mastering EJB was one of the original and most influential EJB books in the industry. Mastering EJB III now returns with two new expert co-authors, updated for EJB 2.1 and 30% new chapters including security, integration, best practices, open source, and more.
(Book PDF Download)

Application Server Matrix

The Application Server Matrix is a detailed listing of J2EE vendors and their application server products, with information on latest version numbers, J2EE spec support and licensing, pricing, platform support, and links to product downloads and reviews.
(Application Server Comparison Matrix)

News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
Java Solutions
All Content Copyright ©2007 TheServerSide Privacy Policy
Site Map