本文介绍了是否有一个简单的CLI Java linter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找能够在CLI上运行的Java linter,它与Eclipse分开,我可以将其称为git的提交钩子,也可以从我们的自动构建脚本中调用.这样的东西存在吗?

I've been trying to find a Java linter capable of running on the CLI that is separate from Eclipse that I can call as a commit hook for git or from our automated build script. Does such a thing exist?

理想情况下,它需要检查未使用的导入和变量,是否遵循样式准则,是否正确使用了异常等等.尽管这些功能的某些子集比我们现在拥有的功能更好-没有了!

Ideally it needs to check for unused imports and variables, that style guidelines are followed, exceptions are used properly, etc. Though some subset of those features would be better that what we have now - nothing!

推荐答案

  • SpotBugs (以前的查找错误),用于查找现有错误.很好!
  • PMD 用于查找可能导致错误(例如未使用的变量)的模式
  • Checkstyle 以实施编码标准和约定(例如,空白,Javadoc)
  • 容易出错会直接进入应用程序的编译步骤
    • SpotBugs (earlier Findbugs) for finding existing bugs. VERY GOOD!
    • PMD for finding patterns that can lead to bugs (e.g. unused variables)
    • Checkstyle to enforce coding standards and conventions (e.g. whitespace, Javadoc)
    • Error Prone hooks right into your application's compile step
    • 所有这些工具都有一些重叠的规则.还有许多其他类似的工具,但是这些工具最受欢迎且受支持.

      All these tools have some overlapping rules. There are many other similar tools, but these are the most popular and supported.

      这篇关于是否有一个简单的CLI Java linter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 01:07