自动检查Java代码以获取正确的约定和文档

||                                                                                                                   关闭。这个问题是题外话。它当前不接受答案。                                                      
已邀请:
您可以使用Checkstyle。但是,标准检查(Sun编码标准)非常严格,您可能要根据自己的喜好从用于配置的XML中删除一些检查     
尽管诸如Checkstyle之类的工具可以检查对样式约定的遵守情况,但不应将其用于评估文档。是的,checkstyle可以检查文档是否存在,但是不能检查该文档是否正确或以任何有用的方式-无用的文档总比没有好,因为它至少不会使源代码混乱。例如,checkstyle将考虑:
/**
 * Gets the amount.
 * @return the amount
 */
BigDecimal getAmount() {
    return amount;
}


/**
 * Sets the amount.
 * @param amount the amount to set
 */
void setAmount(BigDecimal amount) {
    this.amount = amount;
}
更好(因为存在注释并且记录了所有参数和返回值)
/**
 * @return the amount of this transaction (positive for deposits, negative for withdrawals)
 */
BigDecimal getAmount() {
    return amount;
}


/**
 * @see #getAmount()
 */
void setAmount(BigDecimal amount) {
    this.amount = amount;
}
因为后者没有记录方法参数... 简而言之,足够的文档不能被机器验证,容易获得的度量标准仅显示了一部分情况,在我看来,这是非常不相关的部分。     

要回复问题请先登录注册