简体   繁体   English

如何解决checkstyle_error.xml错误

[英]how to resolve checkstyle_error.xml errors

In my project checkstyle_error.xml shows this error Parameter role should be final. 在我的项目中,checkstyle_error.xml显示此错误Parameter role should be final.

for public void setRole(String role) { but i am not getting why it should be final. for public void setRole(String role) {但我不明白为什么它应该是最终的。 And may more space and tab char related error. 并可能会有更多空间和Tab字符相关的错误。 can any one tell me why is this. 谁能告诉我为什么。 any good tutorial to find checkstyle error convention. 任何好的方法来查找checkstyle错误约定。

some more errors i got are: 我得到的一些其他错误是:

1.   Unused @param tag for 'Integer' 


     /**
         *  Sets id.
         *  @param Integer id
         */
        public void setId(Integer id) {
            this.id = id;
        }

2.    Expected @param tag for 'id&apos



    public void setId(Integer id) {
            this.id = id;
        }
  • Whenever you don't understand a checkstyle error message, looking at the list of checks may be helpful, eg rules concerning whitespace . 每当您不了解checkstyle错误消息时,查看检查列表可能会有所帮助,例如有关空白的规则

  • Why you want to use final parameters : 为什么要使用最终参数

    It's a handy way to protect against an insidious bug that erroneously changes the value of your parameters. 这是一种防止错误更改参数值的隐患的简便方法。 Generally speaking, short methods are a better way to protect from this class of errors, but final parameters can be a useful addition to your coding style. 一般而言,短方法是防止此类错误的更好方法,但是最终参数可能是编码风格的有用补充。

  • Why you don't want to use tab characters : 为什么您不想使用制表符

    Developers should not need to configure the tab width of their text editors in order to be able to read source code. 开发人员无需配置文本编辑器的制表符宽度即可读取源代码。

  • How to write Javadoc comments 1: @param id your comment goes here instead of @param Integer id . 如何编写Javadoc注释 1: @param id your comment goes here而不是@param Integer id The error message says that there is a @param tag for a parameter called Integer , when there is no such parameter. 错误消息指出,当没有这样的参数时,对于名为Integer的参数有一个@param标记。

  • How to write Javadoc comments 2: Your method is missing any Javadoc, especially a @param tag for the id parameter (that's what the error message says). 如何编写Javadoc注释2:您的方法缺少任何Javadoc,尤其是id参数的@param标记(这就是错误消息所显示的内容)。

It wants: 它想要:

public void setRole(final String role)

since you never reassign the role variable. 因为您永远不会重新分配role变量。 I think this is a bit demanding, and most style guides would not require it. 我认为这有点苛刻,大多数样式指南都不需要。 In general , parameters are final, and I might expect a comment if it wasn't. 通常 ,参数是最终的,如果不是 ,我可能希望发表评论 However, it does add a little clarity to use the final keyword. 但是,使用final关键字确实增加了一些清晰度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM