简体   繁体   中英

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 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, eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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