Checkstyle vs. PMD

前端 未结 17 969
独厮守ぢ
独厮守ぢ 2020-12-12 11:38

We are introducing static analysis tools into the build system for our Java product. We are using Maven2 so Checkstyle and PMD integration come for free. However it looks li

17条回答
  •  执笔经年
    2020-12-12 12:05

    If we choose one, which one should we use and why?

    These tools are not competing but are complementary and should be used simultaneously.

    The convention type (Checkstyle) 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.

    Checkstyle examples:

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

    while PMD reminds you bad practices:

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

    source: http://www.sonarsource.org/what-makes-checkstyle-pmd-findbugs-and-macker-complementary/

提交回复
热议问题