Checkstyle of Java Static code review

Source: Internet
Author: User

Technical director to patrol, it happened that a period of time before a problem has not been resolved, pull Daniel Open to ask. As a result, the problem is solved, with another problem, or a request, a little technical content, but a very troublesome thing: the code format.

Before I write code, because the screen is relatively small, so as far as possible line write not write two lines, each line is a logical fragment, late review is super convenient, but "this is just my own habit only", but I feel so write, super cool Ah! But, however, the technical director sternly demanded that it be written according to the company's own set of standards.

Later, I also thought about it, I wrote the reason is that the development of the notebook screen is relatively small, the code does not see the whole so to come, but, others, especially the latter in the operation of the OPS, their machine situation with my completely different ah, in case they are 90 inch super screen it? Imagine my code floating on the top of the screen, thinking of a worm, ugly.

Ah, well, our buddies still follow the company's request, in case the project of the tray is a force supremacy of the people, then wait for the knife full street chase.

Nonsense said a lot, is the heart of the vomit groove, now, put a set of checkstyle standards, in case later installed force.

  1 <?xml version= "1.0" encoding= "UTF-8"?> 2 <! DOCTYPE module Public "-//puppy crawl//dtd Check Configuration 1.3//en" "Http://www.puppycrawl.com/dtds/configuration_ 1_3.dtd "> 3 4 <!--5 This configuration file is written by the Eclipse-cs plugin Configuration Editor 6-- > 7 <!--8 Checkstyle-configuration:vastio Checks 9 description:none and one <module name= "Chec Ker "> <property name=" severity "value=" Warning "/> <module name=" TreeWalker "> <module na Me= "Javadocmethod" > <property name= "severity" value= "Ignore"/> + <property name= "Suppressloade     Rrors "value=" true "/> <metadata name=" net.sf.eclipsecs.core.lastEnabledSeverity "value=" Inherit "/> 18       </module> <module name= "Javadoctype" > <property name= "severity" value= "Ignore"/> 21    <metadata name= "net.sf.eclipsecs.core.lastEnabledSeverity" value= "Inherit"/> 22 </module> <module name= "javadocvariable" > <property name= "severity" value= "Ignore"/> 25 <metadata name= "net.sf.eclipsecs.core.lastEnabledSeverity" value= "Inherit"/> </module> &l     T;module name= "Constantname" > <property name= "applytoprivate" value= "false"/> </module> 30 <module name= "Localfinalvariablename"/> <module name= "localvariablename"/> + <module name= " MemberName "/> <module name=" MethodName "/>, <module name=" PackageName "/> + <module Name = "ParameterName"/> <module name= "Staticvariablename"/> Notoginseng <module name= "TypeName"/> Odule name= "Avoidstarimport"/>, <module name= "Illegalimport"/> + <module name= "RedundantImport"/&gt ; <module name= "Unusedimports"/> <module name= "methodlength"/> "<module name=" ParameterNu Mber "/> <Module name= "LineLength" > <property name= "Max" value= ""/>, <property name= "Tabwidth" value = "4"/> </module> <module name= "Emptyforiteratorpad"/>, <module name= "Methodparampad" /> <module name= "Nowhitespaceafter"/> Wuyi <module name= "Nowhitespacebefore"/> <module N Ame= "Operatorwrap"/> <module name= "Parenpad"/> Wu <module name= "Typecastparenpad"/> Odule name= "Whitespaceafter"/> <module name= "Whitespacearound" > <property name= "tokens" value= "Band,band_assign,bor,bor_assign,bsr,bsr_assign,bxor,bxor_assign,colon,div,div_assign,equal,ge,gt,land,lcurly, Le,literal_assert,literal_catch,literal_do,literal_else,literal_finally,literal_for,literal_if,literal_return, Literal_synchronized,literal_try,literal_while,lor,lt,minus,minus_assign,mod,mod_assign,not_equal,plus,plus_ Assign,question,rcurly,sl,slist,sl_assign,sr,sr_assign,star,stAr_assign,literal_assert,type_extension_and,wildcard_type "/> </module> <module name=" ModifierOrd  Er "/> <module name=" Redundantmodifier "/>, <module name=" Avoidnestedblocks "/>-<module  Name= "Emptyblock"/> <module name= "leftcurly"/> "<module name=" needbraces/>  Name= "rightcurly"/> <module name= "avoidinlineconditionals"/>, <module name= "EmptyStatement"/> <module name= "Equalshashcode"/> <module name= "HiddenField" > <property name= "Ignorec Onstructorparameter "value=" true "/> <property name=" Ignoresetter "value=" true "/> </module>     <module name= "Illegalinstantiation" > <property name= "Classes" value= "Java.lang.Boolean"/> 75     </module> <module name= "innerassignment"/> <module name= "Missingswitchdefault"/> 78 <module name= "RedundAntthrows "> <property name=" severity "value=" Ignore "/>" <property name= "Suppressloaderrors" V Alue= "true"/> Bayi <metadata name= "net.sf.eclipsecs.core.lastEnabledSeverity" value= "Inherit"/> in the </m     odule> <module name= "simplifybooleanexpression"/> + <module name= "Simplifybooleanreturn"/> 85 <module name= "Finalclass"/> <module name= "Hideutilityclassconstructor"/>, <module name= "Int Erfaceistype "/> <module name=" Visibilitymodifier "/>-<module name=" Arraytypestyle "/>-&l T;module name= "todocomment"/> <module name= "Upperell"/> <module name= "Operatorwrap"/> t;/module> 94 <module name= "Javadocpackage" > <property name= "severity" value= "Ignore"/>-&lt ; metadata name= "net.sf.eclipsecs.core.lastEnabledSeverity" value= "Inherit"/> </module> 98 <module Name = "Newlineatendoffile"/> <module name= "translation"/>100 <module name= "filelength"/>101 <module name= "FileTabCharacter" > 102 <property name= "severity" value= "Ignore"/>103 <metadata name= "Net.sf.eclipsecs.core.lastEnabledSeveri Ty "value=" Inherit "/>104 </module>105 <module name=" Regexpsingleline ">106 <property name=" format "Value=" \s+$ "/>107 <property name=" message "value=" line has trailing spaces. " />108 </module>109 </module>

The specific code meaning too lazy analysis, directly to use the OK.

Attached usage:

There are corresponding Plugin in the IDE such as Eclipse or IntelliJ idea. The corresponding Plugin market installation can be searched.

Take IntelliJ idea as an example.

Menu Select the File>setting,plugins tab in the search Checkstyle and findbugs to install. Installation may need to be FQ, can also go to the idea official website plug-in page to download, and then manually added to idea.

Menu Selection file>setting, other Settings, there will be an option for the plugin after installation.

CheckStyle new Configuration file in the option, select "Use a local CheckStyle file", file: Select the Checkstyle.xml files in this project, Description arbitrarily named, than such as "Vastio Java Style".

Set the newly added Configuration File to Active.

Finally, confirm that the real-time scan in the Editor:Inspections:CheckStyle in Setting is open.

Checkstyle of Java Static code review

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.