Android checkstyle Result Analysis Description: androidcheckstyle

Source: Internet
Author: User
Tags checkstyle

Android checkstyle Result Analysis Description: androidcheckstyle

1. Missing a Javadoc comment: JavaDoc comment Missing
2. First sentence shocould end with a period: the First line of your comment should end with "."
3. expected @ throws tag for 'exception': In the annotation, add the @ throws description to the comment before the method: * @ throws Exception if has error (Exception description)
4. Parameter docType shocould be final: The docType Parameter should be of the final type. Solution: add final before the docType Parameter.
5. variable "ABC" must match pattern "^ [a-z] [a-zA-Z0-9] * $" Variable "ABC" does not comply with naming rules "^ [a-z] [a-zA-Z0-9] * $ "solution: change the name to "aBC" that complies with the rule"
6. Utility classes shocould not have a public or default constructor. Internal classes in the interface should not have public or default constructor methods.
Solution: In the internal class, define a private constructor and declare the internal class as the final type. If there is static above, final must also be placed after static
7. '{' is not preceded with whitespace. the braces must be left blank.

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

9. Method 'deletechild 'is not designed for extension-needs to be abstract, final or empty. It is not an extended or inherited Method. abstract, final, or empty must be specified.

1 Type is missing a javadoc commentClass missing Type description

2 "{" shocould be on the previous line "{" should be in the previous line. Solution: Put "{" in the previous line.

3 Methos is missing javadoc comment before the missing a javadoc comment method. Solution: add the javadoc annotation as follows:

/**

* 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 comment, You Want To Have @ throws description

Solution: add the following line in the comment before the method: * @ throws Exception if has error (Exception description)

5 "." Is preceeded with whitespace "." cannot be preceded by spaces. Solution: remove the space before "("

6 "." Is followed by whitespace "." cannot be followed by spaces. Solution: remove the space after ")".

7 "=" is not preceeded with whitespace "=" is missing a space before it. Solution: Add a space before "= ".

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

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

10 Unused @ param tag for "unused" No parameter "unused", no need to comment

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

11 Variable "CA" missing javadoc comments

Solution: add the javadoc note before the "CA" variable:/** CA. */(Note: Remember to add ".")

12 Line longer than 80characters row length exceeds 80. Solution: divide it into multiple lines for writing. If necessary, you can press ctrl + shift + f

The 13 Line contains a tab character Line contains the "tab" character. Quick Solution: You can use the format function in editplus to convert the tab character to a space, and then save the Editplus English version installation file on our host. You can copy the required information. Register Editplus and click the file registered in the installation file.


14 Redundant "Public" modifier Redundant "public" modifier. Solution: redundant "public"

15 the order of Final modifier out of order with the JSL suggestion Final modifier is incorrect.

16 Avoid using the ". *" form of importImport format Avoid using ". *"

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

18 The Unused import-java.util.listImport comes in java. util. list is not used. Solution: Remove unnecessary imported classes.

19 Duplicate import to line 13 repeated Import of the same content solution: Remove unnecessary imported classes

20 Import from illegal package Import content from illegal package

21 The "while" construct must use "{}" while "statement lacks" {}"

22 Variable "sTest1" must be private and have accessor method Variable "sTest1" should be private and there are methods to call it

23 Variable "ABC" must match pattern "^ [a-z] [a-zA-Z0-9] * $" Variable "ABC" does not comply with naming rules "^ [a-z] [a-zA-Z0-9] * $ "solution: change the name to "aBC" that complies with the rule"

24 "(" is followed by whitespace "(" cannot be followed by spaces 25 ")" is proceeded by whitespace ")" cannot be preceded by Spaces

Solution: remove the leading or trailing spaces.

25. First sentence shocould end with a period. Solution: Add "." to the end of the First line of your comment ".".


26. Redundant throws: 'namenotfoundexception 'is subclass of 'namingexception'. 'namenotfoundexception' is a subclass of 'namingexception' that repeatedly throws an exception.

Solution: If two exceptions are thrown, and one exception class is another subclass, you only need to write the parent class.

Remove the NameNotFoundException exception. The corresponding javadoc annotation exception annotation must also be removed.


27. Parameter docType shocould be final. The docType Parameter should be of the final type. Solution: add final before the docType Parameter.


28. Line has trailing spaces. Extra empty rows solution: Remove this empty row


29. Must have at least one statement. at least one statement

Solution:} catch (NumberFormatException nfe ){

LOG. error ("Auto Renews the agreement failed", nfe); // the exception capture cannot be empty. add a sentence to the exception. Such as printing

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

When defining a set and enumeration, there must be spaces behind the last ">" and no spaces before. Solution: remove the generic


31. Got an exception-java. lang. RuntimeException: Unable to get class information for @ throws tag 'systemexception'. Cause: unreasonable throws.

Solution: Make sure that some types, such as some classes and interfaces, are not throws. Remove declared exceptions. Throw an exception in the implementation class.


Online reference solution: 1. This is an error reported by CheckStyle. Refreh, clean/build this Project. If not, you can try clean all projects and restart Eclipse.

2. The compiled class is not in the classpath of checkstyle. therefore, you only need to configure the compiled class to the <checkstyle/> classpath. in addition, it seems that the line length of checkstyle is also a bit problematic. If it is not more than 120 characters, an error is returned. helpless, I changed the Maximum line with in java> code style> formatter in Eclipse to 100, and then formatted it. Basically there is no problem.


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


33. Utility classes shocould not have a public or default constructor. Internal classes in the interface should not have public or default constructor methods.

Solution: In the internal class, define a private constructor and declare the internal class as the final type. If there is static above, final must also be placed after static


34. Variable 'functioncode' must be private and have accessor methods. Change the Variable to private and provide the access method.

Solution: Change the modifier of these variables to private, then provide the set and get methods, and add the corresponding method javadoc comments and parameter comments. Add final before the return value and parameter type. And changed the place where this variable was called to access through methods.


35. '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 is the same as the local public Foo (int bar) bar variable name.
Solution: Change the parameter name in the method to public Foo (int newBar)
{
This. bar = newBar;
}.

36. Got an exception-Unexpected character 0 xfffd in identifier

This is because CheckStyle cannot identify the encoding format.

Online reference solution:

1. It can be configured in Eclipse, and 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 a UTF-8, then add the bold statement, you can.

37. Got an exception-java. lang. RuntimeException: Unable to get class information for @ throws tag * whatever *.
Online reference solution: select the CheckSytle JavaDoc --> Method JavaDoc --> logLoadErrors. If an error occurs when the CheckStyle is loaded by itself, you can create a Log. Do not make the Errors messy.
The same error may also be returned in another case. Coding Problems --> Redundant Throws --> select logLoadErrors


38. Expected @ param tag for 'datamanager '. solution to the lack of annotation for the dataManager parameter: Add @ param dataManager to the Annotation

Answers to some other online errors:
1. Parameter X shocould 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) is considered unchangeable. The final keyword must be added to the check to define public Foo (final int bar). Ignore the check.

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: redundant fields. Public OrganizationDTO getOrganization () throws Exception; at this time, public is a redundant field, because it is public when the interface is defined.

Check.

3.-Class X shoshould be declared as final.

Explanation: For the singleton design mode, a unique class object is required to be returned. However, HRFactory and ContextFactory are two optimized classes and do not need to be checked.
Check other Singleton classes.

4.-Method 'addchildrenid' is not designed for extension-needs to be
Abstract, final or empty.

Explanation: It is inherited by the parent class. This class is special and can be ignored.

5. Variable 'id' must be private and have accessor methods. Explanation: BaseHRDTO class, which is a parent class. attributes are inherited from child classes. They are special. However, for other classes, the domain name must contain the 'private' keyword. Check.

6.-Array brackets at illegal position. explanation: the code is written in different ways. Check required, only prompt

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.