Checkstyle vs. PMD

前端 未结 17 933
独厮守ぢ
独厮守ぢ 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:06

    Both softwares are useful. Checkstyle will help you during your programming by checking your coding style i.e braces, naming etc. Simple things but very numerous!

    PMD will help you by checking more complicate rules like during the design of your classes, or for more special problems like implementing correctly the clone function. Simply, PMD will check your programming style

    However, both softwares suffers from similar rules sometimes bad explained. With a bad configuration, you may check things twice or two opposite things i.e "Remove useless constructors" and "Always one constructor".

    0 讨论(0)
  • 2020-12-12 12:11

    You should definitely use FindBugs. In my experience, the false-positive rate is very low, and even the least-critical warnings it reports are worth addressing to some extent.

    As for Checkstyle vs. PMD, I would not use Checkstyle since it is pretty much only concerned with style. In my experience, Checkstyle will report on a ton of things that are completely irrelevant. PMD on the other hand is also able to point out questionable coding practices and its output is generally more relevant and useful.

    0 讨论(0)
  • 2020-12-12 12:12

    We use both:

    • Checkstyle to make sure that everyone in the team write code in a similar maner
    • PMD to find problematic code areas and next refactoring targets
    0 讨论(0)
  • 2020-12-12 12:12

    Sonar (http://www.sonarsource.org/) is a very useful open platform to manage code quality, and includes Checkstyle, PMD, Findbugs and much more.

    This also indicates that all 3 tools have their right to exist...

    0 讨论(0)
  • 2020-12-12 12:12

    Checkstyle and PMD both are good at checking coding standards and are easy to extend. But PMD has additional rules to check for cyclomatic complexity,Npath complexity,etc which allows you write healthy code.

    Another advantage of using PMD is CPD (Copy/Paste Detector).It finds out code duplication across projects and is not constrained to JAVA.It works for JSP too. Neal Ford has a good presentation on Metrics Driven Agile Development, which talks about many tools that are helpful for Java/Java EE Development

    0 讨论(0)
提交回复
热议问题