Checkstyle, PMD, Findbugs comparison

Source: Internet
Author: User
Tags checkstyle

When people talk about the code rule engine. Everyone likes to stand on their own and say that they prefer tools, rather than other tools.

For instance, a PMD supporter cocould say:

"Checkstyle is a stupid tool consuming time to search for tab characters when PMD is a smart one that can do the job alone as a good soldier, findbugs is very good for resource consumption and Macer is... Uh, what is Macer? "

Time to breathe! There is in fact no need to take such position since those tools are not competing but are complementary and shoshould be used simultaneously as it is the case in sonar. each of them is mainly targeting a certain type of coding rules:Conventions(Checkstyle ),Bad practices(PMD) andPotential bugs(Findbugs ).

TheConventionType covers naming, comments and format conventions. Here are a few examples:

  • Is there javadoc on public methods?
  • Is the project following Sun naming conventions?
  • Is the code written with a consistent format?

The convention type has often the reputation of being fairly useless as the rules are very simple. how to explain then that most open source projects provide a checkstyle file in their development guide, when the same projects generally throw out anything useless? It is true to say that the convention rules do not have impact on stability, performance or reliability of an application. however, the convention type is the glue that enables people to work together and to free up their creativity instead of spending time and energy at understanding inconsistent code.

TheBad practicesType consists of well known behaviors that almost systematically lead to difficulties over time. Here are a few examples of bad practices:

  • Catching an exception without doing anything
  • Having dead code
  • Too compute complex methods
  • Direct use of implementations instead of interfaces
  • Implementing the hashcode () method without the not equals (Object object) Method

PMD is a kind of angel that always looks over your shoulder to remind you of bad practices, in the same way that your common sense reminds you to iterate with your customer when developing a complete functionality and to answer questions from your coworkers.

ThePotential bugsType helps you detect what is not clearly visible in the Code and understand why sequences of code cocould lead to potential bugs. Here are a few examples of potential bugs:

  • Synchronization on Boolean cocould lead to deadlock
  • May expose internal representation by returning reference to mutable object
  • Method uses the same code for two branches

Bugs are like human relations, it is not always easy to understand the problem as there are too parameters to take into account. can be a good idea to sometimes to see an analyst to help resolve them :-). findbugs is a kind of analyst for your source code!

What's about Macer? Whereas checkstyle, PMD and findbugs focus their attention on analyzing sources and applying rules, Macer takes a big step back to identity authentication tural issues. Here are few examples of specified tural rules:

  • Classes in the UI Layer may not directly access the data object layer, or use classes in Java. SQL
  • External systems may not access internal implementation classes (suffixed with 'impl ')
  • One functional module may access another only through its API
  • Only classes implementing interfaces in javax. EJB, and certain framework packages, may use the EJB APIs

Macer looks at your application in the same way a man on the moon looks at earth: hey guys, what is happening? Pacific ocean is too close to European continent! Once you have a clear idea of what your architecture shoshould look like, you can easily model it with a Macer to keep your architecture consistent over time. with Macer you can define your tural conventions and identify your tural bad practices.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.