Skip to content

Instantly share code, notes, and snippets.

@softmentor
Created May 8, 2014 07:07
Show Gist options
  • Save softmentor/cfcb17603924eaacb43f to your computer and use it in GitHub Desktop.
Save softmentor/cfcb17603924eaacb43f to your computer and use it in GitHub Desktop.
Mozilla java checkstyle rules
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!--
This file contains a Checkstyle configuration that checks for compliance with
Mozilla's Java style conventions.
The file defines the modules and properties in alpabetical order. Each property
should be documented with what it does.
-->
<module name="Checker">
<module name="TreeWalker">
<!-- Cache to make checkstyle run faster. -->
<property name="cacheFile" value="${checkstyle.cache.file}"/>
<!-- Annotations. http://checkstyle.sourceforge.net/config_annotation.html -->
<module name="AnnotationUseStyle"/>
<module name="MissingDeprecated"/>
<module name="MissingOverride"/>
<module name="SuppressWarnings"/>
<!-- Block checks. See http://checkstyle.sourceforge.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Class Design. http://checkstyle.sourceforge.net/config_design.html -->
<module name="DesignForExtension"/>
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="InnerTypeLast"/>
<module name="MutableException"/>
<module name="VisibilityModifier"/>
<!-- Common coding problems. See http://checkstyle.sf.net/config_coding.html -->
<module name="ArrayTrailingComma"/>
<module name="CovariantEquals"/>
<module name="DeclarationOrder"/>
<module name="DefaultComesLast"/>
<module name="DoubleCheckedLocking"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="EqualsAvoidNull"/>
<module name="ExplicitInitialization"/>
<module name="HiddenField"/>
<module name="IllegalCatch"/>
<module name="IllegalInstantiation"/>
<module name="IllegalThrows"/>
<module name="IllegalToken"/>
<module name="IllegalType"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MissingCtor"/>
<module name="MissingSwitchDefault"/>
<module name="ModifiedControlVariable"/>
<module name="MultipleStringLiterals"/>
<module name="MultipleVariableDeclarations"/>
<module name="NestedForDepth"/>
<module name="NoClone"/>
<module name="NoFinalizer"/>
<module name="OneStatementPerLine"/>
<module name="PackageDeclaration"/>
<module name="ParameterAssignment"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="StringLiteralEquality"/>
<module name="UnnecessaryParentheses"/>
<!-- Duplicate code. http://checkstyle.sourceforge.net/config_duplicates.html -->
<!-- Header. See http://checkstyle.sourceforge.net/config_header.html -->
<!-- TODO detect MPL 2.0 in all files. -->
<!-- Imports. See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="ImportOrder">
<!-- Android's import guidelines: http://source.android.com/source/code-style.html#order-import-statements -->
<property name="groups" value="android,ch,com,net,org,java,javax"/>
<property name="separated" value="true"/>
</module>
<module name="AvoidStaticImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<!-- Javadoc. See http://checkstyle.sourceforge.net/config_javadoc.html -->
<module name="JavadocMethod"/>
<module name="JavadocStyle"/>
<module name="JavadocType"/>
<module name="JavadocVariable"/>
<!-- Metrics. See http://checkstyle.sourceforge.net/config_metrics.html -->
<!-- Miscellaneous. See http://checkstyle.sourceforge.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="Indentation"/>
<module name="OuterTypeFilename"/>
<module name="TodoComment">
<property name="format" value="FIX ?ME|TO-?DO|XXX"/>
</module>
<module name="UpperEll"/>
<!-- Modifiers. See http://checkstyle.sourceforge.net/config_modifier.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Naming Conventions. See http://checkstyle.sourceforge.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName">
<!-- We require member names to be prefixed with 'm'. -->
<property name="format" value="^m[A-Z][a-zA-Z0-9]*$" />
</module>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName">
<!-- We require static member names to be prefixed with 's'. -->
<property name="format" value="^s[A-Z][a-zA-Z0-9]*$" />
</module>
<module name="TypeName"/>
<!-- Regular expressions. See http://checkstyle.sourceforge.net/config_regexp.html -->
<!-- Size violations. See http://checkstyle.sourceforge.net/config_sizes.html -->
<module name="AnonInnerLength"/>
<module name="LineLength">
<property name="max" value="100" />
</module>
<module name="MethodCount"/>
<module name="MethodLength"/>
<module name="OuterTypeNumber"/>
<module name="ParameterNumber"/>
<!-- Whitespace. See http://checkstyle.sourceforge.net/config_whitespace.html -->
<module name="EmptyForInitializerPad"/>
<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>
<module name="FileLength"/>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="NewlineAtEndOfFile"/>
<module name="RegexpSingleline">
<!-- Check for trailing whitespace. -->
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<!-- Suppress known warnings until they can be fixed. -->
<module name="SuppressionFilter">
<property name="file" value="${checkstyle.suppressions.file}"/>
</module>
</module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment