|
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
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! :-)
|
|
Message #122579
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Checkstyle 3.4 released
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 ;)
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
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
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 #122602
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Filtering errors
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
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
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
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?
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
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)
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)
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.
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 matching0: 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
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
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
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
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 #122699
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Filtering errors
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.
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.
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.
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
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...
... 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.
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)
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 |
 |
 |
Reza Rahman continues to explore 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.
(January 21, Article)
Ted Neward is an independent consultant specializing in high-scale enterprise systems, and an authority in Java and .NET technologies. He is the author and co-author of several books, including Effective Enterprise Java. At TheServerSide Java Symposium in March, he will be presenting sessions on pragmatic architecture, ECMAScript and Scala.
(January 15, Article)
Now that Oracle is absorbing Sun Microsystems, there mixed views on what should come of the Java Community Process (JCP). While some say Oracle should become the new steward of Java and keep the JCP much as it was, others argue that it may be time to open-source this widespread language.
(November 24, Article)
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 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)
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)
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)
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)
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, CTO of Terracotta, Inc., talks about the new features in Terracotta 3.1, announced during JavaOne and available now.
(June 15, Tech Talk)
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)
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)
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)
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)
Gil demonstrates how new, aggressive uses of already abundant compute capacity by common applications offer competitive value for application designers.
(May 21, Tech Talk)
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)
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)
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)
|
|