开发者

how to resolve checkstyle_error.xml errors

In my project checkstyle_error.xml shows this error Parameter role should be final.

for public void setRole(String role) { but i am not getting why it should be final. And may more space and tab char related error. can any one tell me why is开发者_JS百科 this. any good tutorial to find checkstyle error convention.

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, e.g. rules concerning whitespace.

  • 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. The error message says that there is a @param tag for a parameter called Integer, when there is no such parameter.

  • 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).


It wants:

public void setRole(final String role)

since you never reassign the role variable. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜