Android Checkstyle Results Analysis description

Source: Internet
Author: User
Tags checkstyle

1.Missing a Javadoc comment: missing Javadoc comment
2.First sentence should end with a period: you should add a "." To the end of the first line of your comment.
3.Expected @throws tag for ' Exception ': In the comments you want to have @throws instructions, add such a line to the comment before the method: * @throws Exception if has error (Exception description)
4.Parameter DocType should be final: The parameter docType should be the final type workaround: Add a final before the parameter DocType
5.Variable "ABC" must match pattern "^[a-z][a-za-z0-9]*$" variable "abc" does not conform to the naming convention "^[a-z][a-za-z0-9]*$" Workaround: Change the name to a rule-compliant name "ABC"
6.Utility classes should not has a public or default constructor. The inner class in the interface should not be constructed in the same way
WORKAROUND: In the inner class, define a private construction method, and then the inner class is declared as the final type. If there is static in front, final must also be placed after static
7. ' {' is not preceded with whitespace. Curly braces must be empty after a square

8. ' Public ' modifier out of order with the JLS suggestions. Public Order Error

9.Method ' Deletechild ' isn't designed for extension-needs to be abstract, final or empty. is not an extension or an inherited method, you must specify Abstract,final or empty

1Type is missing a Javadoc commentclass missing type description

2 "{" Should is on the previous line "{" should be in the previous row. Workaround: Put "{" On the previous line

3Methos is missing a Javadoc comment method is missing the Javadoc comment before. Workaround: Add a Javadoc comment similar to this:

/**

* Set default mock parameter. (method description)

* @param additionalparameters parameter additional (parameter name)

* @return Data Manager (return value description)

* @throws Exception if has error (exception description)

*/

4 expected @throws tag for "Exception" in the comments want to have @throws description

Workaround: Add such a line to the comment before the method: * @throws Exception if has error (exception description)

5 "." is preceeded with whitespace "." Cannot have spaces in front of it. Workaround: Remove the "(" preceding space

6 "." is followed by whitespace "." Cannot have a space behind it. Workaround: Remove the space behind the ")"

7 "=" is a preceeded with whitespace "=" Before the space is missing. Workaround: Add a space before "="

8 "=" is not followed with whitespace "=" after space is missing. Workaround: Add a space after "="

9 "}" should is on the same line "}" should be in the same row as the next statement. Workaround: Put "}" in front of the next line

10Unused @param tag for "unused" without parameter "unused", no comment required

Workaround: "* @param unused parameter additional (parameter name)" Remove the comment of this line unused parameter "

11Variable "Ca" missing Javadoc variable "CA" missing Javadoc comment

Workaround: Add the Javadoc comment before the "CA" variable:/** ca. */(Note: Be sure to include "." )

12Line longer than 80characters line length exceeds 80. Workaround: Divide it into multiple lines of writing. When necessary, you can ctrl+shift+f

13Line contains a tab character line contains the "tab" character. Quick FIX: You can use the Format function in EditPlus to convert the tab character to a space, and then save the EditPlus English version of the installation file on my machine. A copy of what is needed. Register EditPlus, click the file registered in the installation file


14Redundant "public" modifier redundant "public" modifier. WORKAROUND: Redundant "public"

15Final modifier out of order with the JSL suggestion Final modifier sequence error

16Avoid using the ". *" form of importimport format avoids using ". *"

17Redundant import from the same pack import content from the same package

18Unused Import-java.util.listimport came in Java.util.list was not used. Workaround: Remove unnecessary classes that are imported

19Duplicate Import to Line 13 Duplicate import same content workaround: Remove unnecessary classes that are imported

20Import from illegal packages import content from an illegal package

' While ' construct must use ' {} ' while ' statement is missing ' {} '

22Variable "STest1" must be private and has accessor method variable "STest1" should be private, and there are methods to call it

23Variable "ABC" must match pattern "^[a-z][a-za-z0-9]*$" variable "abc" does not conform to the naming convention "^[a-z][a-za-z0-9]*$" Workaround: Change the name to a rule-named "ABC" ”

"is followed by whitespace" ("cannot have space after") "is proceeded by whitespace") "cannot have spaces before

Workaround: Remove the front or back spaces

25. First sentence should end with a period. Workaround: Your comments should be preceded by a "." In the end of the text line.


26, redundant throws: ' Namenotfoundexception ' is subclass of ' namingexception '. ' Namenotfoundexception ' is a subclass of ' namingexception ' that repeatedly throws an exception.

Workaround: If you throw two exceptions, one exception class is another subclass, then you only need to write the parent class

Remove the namenotfoundexception exception, the corresponding Javadoc comment Exception comment Description also need to remove


27, Parameter DocType should be final. The parameter doctype should be the final type workaround: Add a final before the parameter doctype


28, line has trailing spaces. Extra empty line Workaround: Remove this line of blank lines


29.Must has at least one statement. At least one statement

Workaround:} catch (NumberFormatException nfe) {

Log.error ("Auto renews the agreement failed", NFE);//abnormal catch inside cannot be empty, add a sentence in the exception. such as printing and so on

30, ' > ' is not followed by whitespace. And there is ' (' are preceded with whitespace.

When defining collections and enumerations, there are spaces after the last ">", "(" There are no spaces in front of them.) Workaround: Remove generics


31, Got an exception-java.lang.runtimeexception:unable-get class information for @throws tag ' systemexception '. Reason: Unreasonable The throws.

Workaround: To ensure that certain types, such as some classes, interfaces are not throws. Remove the exception to the declaration. Throwing Exceptions in the implementation class


Online reference Solution: 1, this is the fault of the Checkstyle newspaper. Refreh is often required to clean/build this project. If not, you can try clean all projects, restart Eclipse.

2, because the compiled class is not in the Checkstyle classpath. So, as long as the compiled class is configured in the <checkstyle/> classpath there is no problem. In addition, Also found Checkstyle line length seems to have a problem, obviously not more than 120 characters, but still error. Helpless, I put eclipse in Java > code style > Formatter in the maximum line wit H changed to 100, then format, basically no problem.


32, File does not end with a newline. Workaround: Delete the error class, create a new class with the same name, and copy the code all over.


33, Utility classes should not has a public or default constructor. There should be no public or default construction method in the inner class of the interface

WORKAROUND: In the inner class, define a private construction method, and then the inner class is declared as the final type. If there is static in front, final must also be placed after static


34, Variable ' Functioncode ' must be private and has accessor methods. Variable to private and provide access method

Workaround: Change the modifier of these variables to private, then provide the Set,get method, and add the corresponding method Javadoc comment, parameter comment. and add final before the return value and the parameter type. and change the place where this variable was called to access by method


A. ' X ' hides a field.

public class Foo
{
private int bar;

public Foo (int bar)
{
This.bar = bar;
}

Public final int Getbar ()
{
return bar;
}
}

The global private int bar; and the bar variable name of the local public Foo (int bar) repeats.
Workaround: Change the name of the parameter inside the method to be public Foo (int newBar)
{
This.bar = NewBar;
}。

36, Got an exception-unexpected character 0xfffd in identifier

This is because Checkstyle does not recognize the coding format that is being developed.

Online Reference Solutions:

1. Can be configured in eclipse, can be specified in Other-->checker

2, you can modify the Checkstyle configuration file:

<module name= "Checker" >

<property name= "severity" value= "Warning"/>

<property name= "CharSet" value= "UTF-8"/>

<module name= "TreeWalker" >

If it is UTF-8, then add the bold statement, you can.

37. Got an exception-java.lang.runtimeexception:unable-get class information for @throws tag *whatever*.
Online reference workaround: Check Checksytle JavaDoc---JavaDoc---and logloaderrors. If it is checkstyle self-loading error, hit a log on it, do not make the whole errors scary.
There is also a place where the same mistakes can be wrapped up. Coding problems--and redundant Throws--logloaderrors Select to


38, expected @param tag for ' DataManager '. Comment workaround for missing dataManager parameter: Add @param dataManager in comments DataManager

Some other wrong answers on the Web:
1. Parameter X should be final.
PUBlic class Foo
{
private int bar;

public Foo (int bar)
{
This.bar = bar;
}

Public final int Getbar ()
{
return bar;
}
}

Explanation: The local variable of public foo (int bar), which is considered immutable, checks for the need to add the final keyword to define public foo (final int bar) for this error, which can be ignored without checking.

2. Redundant ' X ' modifier.

Public interface Cachehrtreeservice extends Manager {

/**
* Organization Tree
* @param orgdto
* @return
* @throws Exception
*/
public void Setorganization (Organizationdto orgdto) throws Exception;

/**
* Organization Tree
* @return
* @throws Exception
*/
Public Organizationdto getorganization () throws Exception;
......
}

Explanation: Extra fields. Public Organizationdto getorganization () throws Exception; the public is the extra field at this time, because when interface is defined, it is public.

Need to be checked.

3.-Class X should be declared as final.

Explanation: For a singleton design pattern, a unique class object is required to be returned. However, Hrfactory and Contextfactory are optimized for two classes and do not require checking.
Other singleton classes still need to be checked.

4.-Method ' Addchildrenid ' isn't designed for extension-needs to be
Abstract, final or empty.

Explanation: Inherited by the parent class, this class is a bit special to ignore.

5. Variable ' ID ' must be private and has accessor methods. Explanation: Basehrdto class, parent class, attribute to subclass inheritance, special. But other classes, fame need to add the scope ' private ' keyword. Need to be checked.

6.-array brackets at illegal position. Explanation: Code writing, habits are different. Need to check, just hint

Android Checkstyle Results Analysis description

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.