Use of Checkstyle

zhaozj2021-02-11  181

The first part Checkstyle

Introduction CheckStyle is a development tool that can help programmers write Java code that meets the coding specification. The programmer is very annoying the program's Check work. Checkstyle can automate this cumbersome but very important job, saving the programmer's time, and also improves the quality of the inspection. Checkstyle has become a preferred tool for strengthening coding specifications. NtcheckStyle is an installable module that automates the integration of Checkstyle and NetBeans environments. The use of Checkstyle after integration is very convenient. Installation You can install nbcheckstyle directly in NetBeans.

The installation method is: · Select the menu "Tools / Update Center". · Select the "Install Manual Downlined Module" radio button. · Add the NbcheckStyle module according to the wizard, then select "Install" After installing the nbcheckstyle module in NetBeans, the checkStyle tool is automatically added to the Tools submenu of the code editing window (right-click the mouse) submenu. Also, you can get the checkStyle command from the main menu "Tools". CheckStyle's output is output directly to NetBeans's standard output window, then you can modify your source code by following the output results until the programming specification is fully compliant. Of course, you can also ignore some of the unqualified results information as required. If you need to modify the default specification of the CheckStyle, you can set the checkstyle's properties through the menu "Tools / Options ...". The second part of the CHECKSTYLE code specification in the Checkstyle tool is mainly referred to by Sun's coding specification, and the default value is the most commonly used. However, you can also customize the specifications suitable for your team according to the needs of the company or the habit of developers. You can modify the corresponding settings in the Options window in NetBeans.

The third part of the results of checkstyle

CheckStyle will output the results of the check to NetBeans's standard window, which explains some common output results for reference.

Serial number output content meaning

1 Type Is Missing A Javadoc CommentClass Lack of Type Description

2 "{" Should Be on the prep "{" should be in the front line

3Methos is Missing a javadoc comment method lacks Javadoc comments in front of

4EXPECTED @Throws tag for "exception" I wish to have @throws in the comment.

5 "." Is Precededed with Whitespace "." No spaces in front of

6 "." Is Followed by Whitespace "." There is no space behind it.

7 "=" is not precedededed with whitespace "=" before the lack of space

8 "=" is not followed with white whitespace "=" lacks space

9 "}" Should Be on The Same Line "}" should be in the same line with the following statement

10UNUSED @Param Tag for "unused" no parameter "unused", no comment

11variable "ca" Missing Javadoc variable "CA" lacks Javadoc comments

12LINE LONGER THAN 80CHARACTERS exceeds 80

13LINE Contains a Tab Character line contains "tab" characters

14Redundant "public" modifier redundancy "public" Modifier15Final Modifier out of Order with the JSL SUGGESTIONFINAL MODIFIER sequence error

16Avoid Using The ". *" Form of ImportImport format ". *"

17Redundant Import from The Same Package from IMPORT content from the same package

18Unused import-java.util.listimport coming in java.util.list is not used

19Duplicate Import to Line 13 Repeat IMPORT Same Content

20IMPORT from Illegal Package from illegal package import content

21 "While" Construct Must Use "{}" "while" statement lacks "{}"

22variable "STEST1" Must Be Private And Have Accessor Method Variable "STEST1" should be private, and there is a way to call it

"ABC" ABC "Must Match Pattern" ^ [A-Z] [A-ZA-Z0-9] * $ "Variable" ABC "does not meet the naming rules" ^ [a-z] [A-ZA-Z0-9] * $ "

24 "(" Is Followed by Whitespace "(" There is no space 25 ")" Is procededed by white whitespace "" no space

转载请注明原文地址:https://www.9cbs.com/read-5340.html

New Post(0)