layout | title |
---|---|
scalastyle |
Scalastyle: Implemented Rules |
There are 37 rules which are currently implemented:
- id - file.size.limit
- description - Check the number of lines in a file
- class - org.scalastyle.file.FileLengthChecker
- default level - WarningLevel
Files which are too long can be hard to read and understand.
Parameter | Description | Type | Default Value |
---|---|---|---|
maxFileLength | Maximum file length | integer | 1500 |
<check enabled="true" class="org.scalastyle.file.FileLengthChecker" level="warning"> <parameters> <parameter name="maxFileLength">800</parameter> </parameters> </check>
- id - line.size.limit
- description - Check the number of characters in a line
- class - org.scalastyle.file.FileLineLengthChecker
- default level - WarningLevel
Parameter | Description | Type | Default Value |
---|---|---|---|
maxLineLength | Maximum line length | integer | 160 |
tabSize | Tab size | integer | 4 |
TBD
- id - line.contains.tab
- description - Check that there are no tabs in a file
- class - org.scalastyle.file.FileTabChecker
- default level - WarningLevel
No parameters
TBD
- id - header.matches
- description - Check the first lines of each file matches the text
- class - org.scalastyle.file.HeaderMatchesChecker
- default level - WarningLevel
Parameter | Description | Type | Default Value |
---|---|---|---|
header | Header | string |
TBD
- id - newline.at.eof
- description - Checks that a file ends with a newline character
- class - org.scalastyle.file.NewLineAtEofChecker
- default level - WarningLevel
Some version control systems don't cope well with files which don't end with a newline character.
No parameters
<check enabled="true" class="org.scalastyle.file.NewLineAtEofChecker" level="warning"></check>
org.scalastyle.file.NoNewLineAtEofChecker - Checks that a file does not end with a newline character
- id - no.newline.at.eof
- description - Checks that a file does not end with a newline character
- class - org.scalastyle.file.NoNewLineAtEofChecker
- default level - WarningLevel
Because Mirco Dotta wanted it.
No parameters
<check enabled="true" class="org.scalastyle.file.NoNewlineAtEofChecker" level="warning"></check>
org.scalastyle.file.RegexChecker - Checks that a regular expression cannot be matched, if found reports this
- id - regex
- description - Checks that a regular expression cannot be matched, if found reports this
- class - org.scalastyle.file.RegexChecker
- default level - WarningLevel
Parameter | Description | Type | Default Value |
---|---|---|---|
regex | Regular expression | string |
<check enabled="true" class="org.scalastyle.file.RegexChecker" level="warning"> <parameters> <parameter name="regex">(?m)^\s*$(\r|)\n^\s*$(\r|)\n</parameter> </parameters> <customMessage>No double blank lines</customMessage> </check>
org.scalastyle.file.WhitespaceEndOfLineChecker - Check that there is no trailing whitespace at the end of lines
- id - whitespace.end.of.line
- description - Check that there is no trailing whitespace at the end of lines
- class - org.scalastyle.file.WhitespaceEndOfLineChecker
- default level - WarningLevel
No parameters
TBD
- id - class.name
- description - Check that class names match a regular expression
- class - org.scalastyle.scalariform.ClassNamesChecker
- default level - WarningLevel
Parameter | Description | Type | Default Value |
---|---|---|---|
regex | Regular expression | string | ^[A-Z][A-Za-z]*$ |
TBD
org.scalastyle.scalariform.CovariantEqualsChecker - Check that classes and objects do not define equals without overriding equals(java.lang.Object).
- id - covariant.equals
- description - Check that classes and objects do not define equals without overriding equals(java.lang.Object).
- class - org.scalastyle.scalariform.CovariantEqualsChecker
- default level - WarningLevel
No parameters
TBD
org.scalastyle.scalariform.CyclomaticComplexityChecker - Checks that the cyclomatic complexity of a method does exceed a value
- id - cyclomatic.complexity
- description - Checks that the cyclomatic complexity of a method does exceed a value
- class - org.scalastyle.scalariform.CyclomaticComplexityChecker
- default level - WarningLevel
If the code is too complex, then this can make code hard to read.
Parameter | Description | Type | Default Value |
---|---|---|---|
maximum | Maximum | integer | 10 |
<check enabled="true" class="org.scalastyle.scalariform.CyclomaticComplexityChecker" level="warning"> <parameters> <parameter name="maximum">10</parameter> </parameters> </check>
org.scalastyle.scalariform.EqualsHashCodeChecker - Check that if a class implements either equals or hashCode, it should implement the other
- id - equals.hash.code
- description - Check that if a class implements either equals or hashCode, it should implement the other
- class - org.scalastyle.scalariform.EqualsHashCodeChecker
- default level - WarningLevel
No parameters
TBD
- id - if.brace
- description - Checks that if statement have braces
- class - org.scalastyle.scalariform.IfBraceChecker
- default level - WarningLevel
A lowercase L (l) can look similar to a number 1 with some fonts.
Parameter | Description | Type | Default Value |
---|---|---|---|
singleLineAllowed | Single Line Allowed | boolean | true |
doubleLineAllowed | Double Line Allowed | boolean | false |
<check enabled="true" class="org.scalastyle.scalariform.IfBraceChecker" level="warning"> <parameters> <parameter name="singleLineAllowed">true</parameter> <parameter name="doubleLineAllowed">false</parameter> </parameters> </check>
org.scalastyle.scalariform.IllegalImportsChecker - Check that a class does not import certain classes
- id - illegal.imports
- description - Check that a class does not import certain classes
- class - org.scalastyle.scalariform.IllegalImportsChecker
- default level - WarningLevel
Parameter | Description | Type | Default Value |
---|---|---|---|
illegalImports | Illegal Imports | string | sun._,java.awt._ |
TBD
- id - magic.number
- description - Checks for use of magic numbers
- class - org.scalastyle.scalariform.MagicNumberChecker
- default level - WarningLevel
Replacing a magic number with a named constant can make code easier to read and understand, and can avoid some subtle bugs.
A simple assignment to a val is not considered to be a magic number, for example:
val foo = 4
is not a magic number, but
var foo = 4
is considered to be a magic number.
Parameter | Description | Type | Default Value |
---|---|---|---|
ignore | Ignore | string | -1,0,1,2 |
<check enabled="true" class="org.scalastyle.scalariform.MagicNumberChecker" level="warning"> <parameters> <parameter name="ignore">-1,0,1,2,3</parameter> </parameters> </check>
- id - method.length
- description - Checks that methods do not exceed a maximum length
- class - org.scalastyle.scalariform.MethodLengthChecker
- default level - WarningLevel
Long methods can be hard to read and understand.
Parameter | Description | Type | Default Value |
---|---|---|---|
maxLength | Maximum length | integer | 50 |
<check enabled="true" class="org.scalastyle.scalariform.MethodLengthChecker" level="warning"> <parameters> <parameter name="maxLength">50</parameter> </parameters> </check>
- id - method.name
- description - Check that method names match a regular expression
- class - org.scalastyle.scalariform.MethodNamesChecker
- default level - WarningLevel
The Scala style guide recommends that method names conform to certain standards.
Parameter | Description | Type | Default Value |
---|---|---|---|
regex | Regular expression | string | ^[a-z][A-Za-z0-9]*$ |
<check enabled="true" class="org.scalastyle.scalariform.MethodNamesChecker" level="warning"> <parameters> <parameter name="regex">^[A-Za-z]*$</parameter> </parameters> </check>
org.scalastyle.scalariform.NoCloneChecker - Check that classes and objects do not define the clone() method
- id - no.clone
- description - Check that classes and objects do not define the clone() method
- class - org.scalastyle.scalariform.NoCloneChecker
- default level - WarningLevel
No parameters
TBD
org.scalastyle.scalariform.NoFinalizeChecker - Check that classes and objects do not define the finalize() method
- id - no.finalize
- description - Check that classes and objects do not define the finalize() method
- class - org.scalastyle.scalariform.NoFinalizeChecker
- default level - WarningLevel
No parameters
TBD
org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker - No whitespace after left bracket '['
- id - no.whitespace.after.left.bracket
- description - No whitespace after left bracket '['
- class - org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker
- default level - WarningLevel
No parameters
TBD
org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker - No whitespace before left bracket '['
- id - no.whitespace.before.left.bracket
- description - No whitespace before left bracket '['
- class - org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker
- default level - WarningLevel
No parameters
TBD
- id - null
- description - Check that null is not used
- class - org.scalastyle.scalariform.NullChecker
- default level - WarningLevel
No parameters
TBD
org.scalastyle.scalariform.NumberOfMethodsInTypeChecker - Check that a class / trait / object does not have too many methods
- id - number.of.methods
- description - Check that a class / trait / object does not have too many methods
- class - org.scalastyle.scalariform.NumberOfMethodsInTypeChecker
- default level - WarningLevel
If a type declares too many methods, this can be an indication of bad design.
Parameter | Description | Type | Default Value |
---|---|---|---|
maxMethods | Maximum methods | integer | 30 |
<check enabled="true" class="org.scalastyle.scalariform.NumberOfMethodsInTypeChecker" level="warning"> <parameters> <parameter name="maxMethods">30</parameter> </parameters> </check>
org.scalastyle.scalariform.NumberOfTypesChecker - Checks that there are not too many types declared in a file
- id - number.of.types
- description - Checks that there are not too many types declared in a file
- class - org.scalastyle.scalariform.NumberOfTypesChecker
- default level - WarningLevel
If there are too many classes/objects defined in a single file, this can cause the code to be difficult to understand.
Parameter | Description | Type | Default Value |
---|---|---|---|
maxTypes | Maximum Number | integer | 20 |
<check enabled="true" class="org.scalastyle.scalariform.NumberOfTypesChecker" level="warning"> <parameters> <parameter name="maxTypes">20</parameter> </parameters> </check>
- id - object.name
- description - Check that object names match a regular expression
- class - org.scalastyle.scalariform.ObjectNamesChecker
- default level - WarningLevel
Parameter | Description | Type | Default Value |
---|---|---|---|
regex | Regular expression | string | ^[A-Z][A-Za-z]*$ |
TBD
org.scalastyle.scalariform.PackageObjectNamesChecker - Check that package object names match a regular expression
- id - package.object.name
- description - Check that package object names match a regular expression
- class - org.scalastyle.scalariform.PackageObjectNamesChecker
- default level - WarningLevel
Parameter | Description | Type | Default Value |
---|---|---|---|
regex | Regular expression | string | ^[a-z][A-Za-z]*$ |
TBD
- id - parameter.number
- description - Maximum number of parameters for a method
- class - org.scalastyle.scalariform.ParameterNumberChecker
- default level - WarningLevel
Parameter | Description | Type | Default Value |
---|---|---|---|
maxParameters | Maximum Number | integer | 8 |
TBD
org.scalastyle.scalariform.PublicMethodsHaveTypeChecker - Check that a method has an explicit return type, it is not inferred
- id - public.methods.have.type
- description - Check that a method has an explicit return type, it is not inferred
- class - org.scalastyle.scalariform.PublicMethodsHaveTypeChecker
- default level - WarningLevel
A public method declared on a type is effectively an API declaration. Explicitly declaring a return type means that other code which depends on that type won't break unexpectedly.
No parameters
<check enabled="true" class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker" level="warning"></check>
- id - return
- description - Check that return is not used
- class - org.scalastyle.scalariform.ReturnChecker
- default level - WarningLevel
No parameters
TBD
- id - simplify.boolean.expression
- description - Boolean expression can be simplified
- class - org.scalastyle.scalariform.SimplifyBooleanExpressionChecker
- default level - WarningLevel
No parameters
TBD
- id - spaces.after.plus
- description - Check that the plus sign is followed by a space
- class - org.scalastyle.scalariform.SpacesAfterPlusChecker
- default level - WarningLevel
No parameters
TBD
org.scalastyle.scalariform.SpacesBeforePlusChecker - Check that the plus sign is preceded by a space
- id - spaces.before.plus
- description - Check that the plus sign is preceded by a space
- class - org.scalastyle.scalariform.SpacesBeforePlusChecker
- default level - WarningLevel
No parameters
TBD
- id - structural.type
- description - Check that structural types are not used.
- class - org.scalastyle.scalariform.StructuralTypeChecker
- default level - WarningLevel
No parameters
TBD
org.scalastyle.scalariform.UppercaseLChecker - Checks that if a long literal is used, then an uppercase L is used
- id - uppercase.l
- description - Checks that if a long literal is used, then an uppercase L is used
- class - org.scalastyle.scalariform.UppercaseLChecker
- default level - WarningLevel
A lowercase L (l) can look similar to a number 1 with some fonts.
No parameters
<check enabled="true" class="org.scalastyle.scalariform.UppercaseLChecker" level="warning"></check>
org.scalastyle.scalariform.VarFieldChecker - Checks that classes and objects do not define mutable fields
- id - var.field
- description - Checks that classes and objects do not define mutable fields
- class - org.scalastyle.scalariform.VarFieldChecker
- default level - WarningLevel
var (mutable fields) are deprecated if you're using a strict functional style
No parameters
<check enabled="true" class="org.scalastyle.scalariform.VarFieldChecker" level="warning"></check>
- id - var.local
- description - Checks that functions do not define mutable variables
- class - org.scalastyle.scalariform.VarLocalChecker
- default level - WarningLevel
vars (mutable local variables) loops are deprecated if you're using a strict functional style
No parameters
<check enabled="true" class="org.scalastyle.scalariform.VarLocalChecker" level="warning"></check>
- id - while
- description - Checks that while is not used
- class - org.scalastyle.scalariform.WhileChecker
- default level - WarningLevel
while loops are deprecated if you're using a strict functional style
No parameters
<check enabled="true" class="org.scalastyle.scalariform.WhileChecker" level="warning"></check>