Described earlier jenkins+gerrit+git build CI system, in fact, there are many useful plug-ins in CI system, these plug-ins can help developers to find the code in the bug or non-standard place. The following is the introduction of CI-related plug-ins
PMD: PMD is a static code analysis tool that can automatically detect various potential defects as well as unsafe or non-optimized code. PMD carries out static checks of Java code through its built-in coding rules, including testing for potential bugs, unused code, duplicated code, creating new objects in the loop body, and so on.
CheckStyle: Checkstyle is a tool that helps Java developers comply with certain coding specifications. By examining code coding format, naming convention, Javadoc, class design and other aspects of code specification and style check, so as to effectively constrain the developers to better follow the code writing specifications.
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/86/A6/wKiom1fGiPvg5a8ZAAKiR-ztHJo729.png "title=" 1.png " alt= "Wkiom1fgipvg5a8zaakir-zthjo729.png"/>
Plug-in usage:
1, the project configuration:
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/86/A6/wKiom1fGicPD57wBAAEXB-tSNRc022.png "title=" 2.png " alt= "Wkiom1fgicpd57wbaaexb-tsnrc022.png"/>
Add directive findbugs:findbugs PMD:PMD Checkstyle:checkstyle to goals and options
2. Add Plugin in Pom.xml file
FindBugs plugin, add to reporting session
<reporting> <plugins> <plugin> <groupid>org.codehaus.mojo</groupid > <artifactid>findbugs-maven-plugin </artifactid> <version>2.5.2</ version> <configuration> <findbugsxmloutput>true</ findbugsxmloutput> < findbugsxmlwithmessages>true</findbugsxmlwithmessages> <xmlOutput>true</xmlOutput> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jxr-plugin</artifactId> <version>2.3</version> </plugin> <plugin> <groupId> org.apache.maven.plugins</groupid> <artifactId>maven-pmd-plugin</artifactId> <version>2.5</version> </plugin> </plugins></reporting>
Checkstyle plugin, add to plugin session
<plugin> <groupid>org.apache.maven.plugins</ groupid> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.17</version> < executions> <execution> <id>validate</id> <phase>validate</phase> <configuration> <configlocation>checkstyle.xml</ configlocation> <encoding> utf-8</encoding> <consoleOutput>true</consoleOutput> <failsonerror>true</ failsonerror> <linkXRef>false</linkxref> </configuration > <goals> <goal> check</goal> </goals> </execution> </ executions> </plugin>
checkstyle template
<?xml version= "1.0" encoding= "UTF-8"? ><! doctype module public "-//puppy crawl//dtd check configuration 1.3//en" "HTTP://WWW.PUPPYCRAWL.COM/DTDS/CONFIGURATION_1_3.DTD" ><!-- this configuration file was written by the eclipse-cs plugin configuration editor--><!-- Checkstyle-configuration: jenkis description: none--><module name= "Checker" > <property name= "severity" value= "Warning"/> <module name= "TreeWalker" > <module name= "Constantname"/> <module name= "Localfinalvariablename"/> <module name= " MemberName "/> <module name=" MethodName "/> &Nbsp; <module name= "PackageName"/> <module name= " Staticvariablename "/> <module name=" TypeName "/> <module name= "Avoidstarimport"/> <module name= "IllegalImport"/> <module name= "Redundantimport"/> <module Name= "Unusedimports"/> <module name= "LineLength"/> <module name= "Methodlength"/> <module name= "ParameterNumber" > <property name= "tokens" value= "METHOD_DEF"/> </module> <module name= "EmptyForIteratorPad"/> <module name= "Genericwhitespace"/> <module name= " Methodparampad "/> <module name= "Nowhitespaceafter"/> <module name= " Nowhitespacebefore "/> <module name=" Operatorwrap "/> <module name= "Parenpad"/> <module name= "TypecastParenPad"/> <module name= "Whitespaceafter"/> <module Name= "Whitespacearound"/> <module name= "Modifierorder"/> <module name= "Redundantmodifier"/> <module name= " Avoidnestedblocks "/> <module name=" Emptyblock "/> <module name= "leftcurly" > <property name= "option" Value= "NL"/> <property name= "tokens" value= "ANNOTATION_DEF, Literal_catch,class_def,ctor_def,literal_do, Literal_else,enum_constant_def,enum_def,literal_finally,literal_for,literal_if,interface_def,method_def, Literal_switch,literal_synchronized,literal_try,literal_while "/> </module> <module name= "Needbraces" > <property name= "tokens" value= "Literal_do,literal_else,literal_for,literal_if,literal_while"/> </module> <module name= "Rightcurly" > <property name= "option" value= "Alone"/> <property name= "tokens" value= "Literal_catch,literal_else,literal_finally,literal_if,literal_try" /> </module> <module name= " Avoidinlineconditionals "/> <module name=" Emptystatement "/> <module name= "Equalshashcode"/> <module name=" > < "HiddenField" Property name= "tokens" value= "Variable_def"/> <property name= "Ignoreconstructorparameter" value= "true"/> <property name= "Ignoresetter" value= "true"/> <property name= " Settercanreturnitsclass " value=" true "/> <property name=" Ignoreabstractmethods " value=" true "/> </module> <module name= "Illegalinstantiation"/> <module name= "InnerAssignment" /> <module name= "MagicNumber" > < Property name= "Ignorehashcodemethod" value= "true"/> < Property name= "Ignoreannotation " value=" true "/> <property name=" ignoreFieldDeclaration " value=" true "/> <property name=" ConstantWaiverParentToken " value= "Div,minus,unary_minus,star,plus,unary_plus,assign,array_init,expr,elist,method_call,literal_new, Typecast "/> </module> <module name=" Missingswitchdefault "/> <module name=" Simplifybooleanexpression "/> <module name= "Simplifybooleanreturn"/> <module Name= "Finalclass"/> <module name= "Hideutilityclassconstructor"/> <module name= "Interfaceistype"/> <module name= " Visibilitymodifier "/> <module name=" Arraytypestyle "/> <module name= "TodocoMment "/> <module name=" Upperell "/> <module name= "leftcurly" > <property name= "option" value= "NL"/ > </module> <module name= "RightCurly" > <property name= "option" value= "Alone"/> <property name= "tokens" value= "literal_catch,literal_else,literal_finally,literal_if, Literal_try "/> </module> <module name=" Leftcurly "> <property name=" option " value=" NL "/> <property name= "tokens" value= "Annotation_def,literal_catch,class_ Def,ctor_def,literal_do,literal_else,enum_constant_def,enum_def,literal_finally,literal_for,literal_if, interface_def,method_def,literal_sWitch,literal_synchronized,literal_try,literal_while "/> </module> <module name= "Emptylineseparator" > <property name= "tokens" value= "class_def,ctor_def,enum_def,import,instance_init,interface_def,method_def, Package_def,static_init,variable_def "/> </module> </module> <module name= "translation"/> <module name= "FileLength"/> <module name= "Filetabcharacter"/></module>
The PMD plugin can no longer be added to the Pom.xml file
Set use rank as priority
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/86/A6/wKioL1fGjE6zPHzkAAEAhng6sBI572.png "title=" 3.png " alt= "Wkiol1fgje6zphzkaaeahng6sbi572.png"/>
FindBugs Report
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/86/A6/wKioL1fGjKuCJcrTAARK9AsFzr8106.png "title=" 4.png " alt= "Wkiol1fgjkucjcrtaark9asfzr8106.png"/>
This article is from the "Zengestudy" blog, make sure to keep this source http://zengestudy.blog.51cto.com/1702365/1844811
Use of CI plugins such as FindBugs, PMD, Checkstyle, etc.