Scalastyle

Rules

This is a collection of all the Scalastyle rules created by sonar-scala in the Scalastyle rules repository.

  1. Avoid block imports MinorMinor

    Checks that block imports are not used.

    Block imports, e.g. import a.{b, c} can lead to annoying merge errors in large code bases that are maintained by lot of developers. This rule allows to ensure that only single imports are used in order to minimize merge errors in import declarations.

    org.scalastyle.scalariform.BlockImportChecker
  2. Avoid curlies imports MinorMinor

    Checks that curlies imports are not used.

    Curlies imports, e.g. import a.{b, c}, can lead to annoying merge errors in large code bases that are maintained by lot of developers. This rule allows to ensure that only single imports, no renaming and no hiding imports are used in order to minimize merge errors in import declarations.

    org.scalastyle.scalariform.CurliesImportChecker
  3. Avoid wildcard imports MinorMinor

    Avoid wildcard imports.

    Importing all classes from a package or static members from a class leads to tight coupling between packages or classes and might lead to problems when a new version of a library introduces name clashes.

    org.scalastyle.scalariform.UnderscoreImportChecker
  4. Class name MinorMinor

    Check that class names match a regular expression.

    The Scala style guide recommends that class names conform to certain standards.

    org.scalastyle.scalariform.ClassNamesChecker
  5. Class type parameter name MinorMinor

    Checks that type parameter to a class matches a regular expression.

    Scala generic type names are generally single upper case letters. This check checks for classes and traits. Note that this check only checks the innermost type parameter, to allow for List[T].

    org.scalastyle.scalariform.ClassTypeParameterChecker
  6. Clone method MinorMinor

    Check that classes and objects do not define the clone() method.

    The clone method is difficult to get right. You can use the copy constructor of case classes rather than implementing clone. For more information on clone(), see Effective Java by Joshua Bloch pages.

    org.scalastyle.scalariform.NoCloneChecker
  7. Covariant equals MinorMinor

    Check that classes and objects do not define equals without overriding equals(java.lang.Object).

    Mistakenly defining a covariant equals() method without overriding method equals(java.lang.Object) can produce unexpected runtime behaviour.

    org.scalastyle.scalariform.CovariantEqualsChecker
  8. Cyclomatic complexity MinorMinor

    Checks that the cyclomatic complexity of a method does exceed a value.

    If the code is too complex, then this can make code hard to read.

    org.scalastyle.scalariform.CyclomaticComplexityChecker
  9. Empty interpolated string MinorMinor

    The interpolation for this string literal is not necessary.

    Empty interpolated strings are harder to read and not necessary.

    org.scalastyle.scalariform.EmptyInterpolatedStringChecker
  10. Equals hashCode MinorMinor

    Check that if a class implements either equals or hashCode, it should implement the other.

    Defining either equals or hashCode in a class without defining the is a known source of bugs. Usually, when you define one, you should also define the other.

    org.scalastyle.scalariform.EqualsHashCodeChecker
  11. Field name MinorMinor

    Check that field names match a regular expression.

    A consistent naming convention for field names can make code easier to read and understand.

    org.scalastyle.scalariform.FieldNamesChecker
  12. File length MinorMinor

    Check the number of lines in a file.

    Files which are too long can be hard to read and understand.

    org.scalastyle.file.FileLengthChecker
  13. File line length MinorMinor

    Check the number of characters in a line.

    Lines that are too long can be hard to read and horizontal scrolling is annoying.

    org.scalastyle.file.FileLineLengthChecker
  14. Finalize method MinorMinor

    Check that classes and objects do not define the finalize() method.

    finalize() is called when the object is garbage collected, and garbage collection is not guaranteed to happen. It is therefore unwise to rely on code in finalize() method.

    org.scalastyle.scalariform.NoFinalizeChecker
  15. Group imports MinorMinor

    Checks that imports are grouped together, not throughout the file.

    If imports are spread throughout the file, knowing what is in scope at any one place can be difficult to work out.

    org.scalastyle.scalariform.ImportGroupingChecker
  16. If block braces MinorMinor

    Checks that if statements have braces.

    Some people find if clauses with braces easier to read.

    The singleLineAllowed property allows if constructions of the type:

    if (bool_expression) expression1 else expression2

    The doubleLineAllowed property allows if constructions of the type:

    if (bool_expression) expression1 else expression2

    Note: If you intend to enable only if expressions in the format below, disable the IfBraceChecker altogether.

    if (bool_expression) expression1 else expression2
    org.scalastyle.scalariform.IfBraceChecker
  17. Illegal imports MinorMinor

    Check that a class does not import certain classes.

    Use of some classes can be discouraged for a project. For instance, use of sun._ is generally discouraged because they are internal to the JDK and can be changed.

    org.scalastyle.scalariform.IllegalImportsChecker
  18. Import Order MinorMinor

    Checks that imports are grouped and ordered according to the style configuration.

    Consistent import ordering improves code readability and reduces unrelated changes in patches.

    org.scalastyle.scalariform.ImportOrderChecker
  19. Line contains Tab MinorMinor

    Check that there are no tabs in a file.

    Some say that tabs are evil.

    org.scalastyle.file.FileTabChecker
  20. Literal passed as argument without name MinorMinor

    Checks that argument literals are named.

    Nameless literals make code harder to understand (consider updateEntity(1, true) and updateEntity(id = 1, enabled = true)).

    org.scalastyle.scalariform.NamedArgumentChecker
  21. Long literal uppercase L MinorMinor

    Checks that if a long literal is used, then an uppercase L is used.

    A lowercase L (l) can look similar to a number 1 with some fonts.

    org.scalastyle.scalariform.UppercaseLChecker
  22. Lowercase pattern match MinorMinor

    Checks that a case statement pattern match is not lower case, as this can cause confusion.

    A lower case pattern match clause with no other tokens is the same as _; this is not true for patterns which start with an upper case letter. This can cause confusion, and may not be what was intended:

    val foo = "foo"
    val Bar = "bar"
    "bar" match { case Bar => "we got bar" } // result = "we got bar"
    "bar" match { case foo => "we got foo" } // result = "we got foo"
    "bar" match { case `foo` => "we got foo" } // result = MatchError

    This checker raises a warning with the second match. To fix it, use an identifier which starts with an upper case letter (best), use case _ or, if you wish to refer to the value, add a type : Any, e.g.:

    val lc = "lc"
    "something" match { case lc: Any => "lc" } // result = "lc"
    "something" match { case _ => "lc" } // result = "lc"
    org.scalastyle.scalariform.LowercasePatternMatchChecker
  23. Magic Number MinorMinor

    Checks for use of magic numbers.

    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.

    org.scalastyle.scalariform.MagicNumberChecker
  24. Maximum parameters MinorMinor

    Maximum number of parameters for a method.

    A method which has more than a certain number of parameters can be hard to understand.

    org.scalastyle.scalariform.ParameterNumberChecker
  25. Method argument name MinorMinor

    Check that method argument names match a regular expression.

    The Scala style guide recommends that method argument names conform to certain standards.

    org.scalastyle.scalariform.MethodArgumentNamesChecker
  26. Method length MinorMinor

    Checks that methods do not exceed a maximum length.

    Long methods can be hard to read and understand.

    org.scalastyle.scalariform.MethodLengthChecker
  27. Method name MinorMinor

    Check that method names match a regular expression.

    The Scala style guide recommends that method names conform to certain standards. If the methods are overriding another method, and the overridden method cannot be changed, then use the ignoreOverride parameter.

    org.scalastyle.scalariform.MethodNamesChecker
  28. Multiple string literals MinorMinor

    Checks that a string literal does not appear multiple times.

    Code duplication makes maintenance more difficult, so it can be better to replace the multiple occurrences with a constant.

    org.scalastyle.scalariform.MultipleStringLiteralsChecker
  29. Newline at EOF MinorMinor

    Checks that a file ends with a newline character.

    Some version control systems don't cope well with files which don't end with a newline character.

    org.scalastyle.file.NewLineAtEofChecker
  30. No Newline at EOF MinorMinor

    Checks that a file does not end with a newline character.

    Because Mirco Dotta wanted it.

    org.scalastyle.file.NoNewLineAtEofChecker
  31. No mutable fields MinorMinor

    Checks that classes and objects do not define mutable fields.

    var (mutable fields) are deprecated if you're using a strict functional style.

    org.scalastyle.scalariform.VarFieldChecker
  32. No mutable local variables MinorMinor

    Checks that functions do not define mutable variables.

    var (mutable local variables) are deprecated if you're using a strict functional style.

    org.scalastyle.scalariform.VarLocalChecker
  33. No redundant if expressions MinorMinor

    Checks that if expressions are not redundant, i.e. easily replaced by a variant of the condition.

    If expressions with boolean constants in both branches can be eliminated without affecting readability. Prefer simply cond to if (cond) true else false and !cond to if (cond) false else true.

    org.scalastyle.scalariform.RedundantIfChecker
  34. No space after tokens MinorMinor

    Ensure single space after certain token(s).

    Correct formatting can help readability.

    org.scalastyle.scalariform.EnsureSingleSpaceAfterTokenChecker
  35. No space before tokens MinorMinor

    Ensure single space before certain token(s).

    Correct formatting can help readability.

    org.scalastyle.scalariform.EnsureSingleSpaceBeforeTokenChecker
  36. No use of Java @Deprecated MinorMinor

    Checks that Java @Deprecated is not used, Scala @deprecated should be used instead.

    You should be using the Scala @deprecated instead.

    org.scalastyle.scalariform.DeprecatedJavaChecker
  37. No use of Java @Override MinorMinor

    Checks that Java @Override is not used.

    You should be using the Scala override keyword instead.

    org.scalastyle.scalariform.OverrideJavaChecker
  38. No while loops MinorMinor

    Checks that while is not used.

    while loops are deprecated if you're using a strict functional style.

    org.scalastyle.scalariform.WhileChecker
  39. No whitespace after left bracket ''['' MinorMinor

    No whitespace after left bracket ''[''.

    If there is whitespace after a left bracket, this can be confusing to the reader.

    org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker
  40. No whitespace before left bracket ''['' MinorMinor

    No whitespace before left bracket ''[''.

    If there is whitespace before a left bracket, this can be confusing to the reader.

    org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker
  41. No whitespace before right bracket '']'' MinorMinor

    No whitespace before right bracket '']''.

    If there is whitespace before a right bracket, this can be confusing to the reader.

    org.scalastyle.scalariform.NoWhitespaceBeforeRightBracketChecker
  42. Non ASCII characters are not allowed MinorMinor

    Some editors are unfriendly to non ASCII characters.

    Scala allows unicode characters as operators and some editors misbehave when they see non-ascii character. In a project collaborated by a community of developers. This check can be helpful in such situations.

    "value" match {
      case "value" => println("matched")
      ...
    }

    is preferred to

    "value" match {
      case "value" ⇒ println("matched")
      ...
    }

    To fix it, replace the (unicode operator) with =>.

    org.scalastyle.scalariform.NonASCIICharacterChecker
  43. Null MinorMinor

    Check that null is not used.

    Scala discourages use of null, preferring Option.

    org.scalastyle.scalariform.NullChecker
  44. Number of methods in type MinorMinor

    Check that a class / trait / object does not have too many methods.

    If a type declares too many methods, this can be an indication of bad design.

    org.scalastyle.scalariform.NumberOfMethodsInTypeChecker
  45. Number of types MinorMinor

    Checks that there are not too many types declared in a file.

    If there are too many classes/objects defined in a single file, this can cause the code to be difficult to understand.

    org.scalastyle.scalariform.NumberOfTypesChecker
  46. Object name MinorMinor

    Check that object names match a regular expression.

    The Scala style guide recommends that object names conform to certain standards.

    org.scalastyle.scalariform.ObjectNamesChecker
  47. Omit braces in case clauses MinorMinor

    Checks that braces aren't used in case clauses.

    Braces aren't required in case clauses. They should be omitted according to Scala Style Guide.

    org.scalastyle.scalariform.CaseBraceChecker
  48. Package name MinorMinor

    Check that package names match a regular expression.

    The Scala style guide recommends that package names conform to certain standards.

    org.scalastyle.scalariform.PackageNamesChecker
  49. Package object name MinorMinor

    Check that package object names match a regular expression.

    The Scala style guide recommends that package object names conform to certain standards.

    org.scalastyle.scalariform.PackageObjectNamesChecker
  50. Pattern match align MinorMinor

    Check that pattern match arrows align.

    Correct formatting can help readability.

    org.scalastyle.scalariform.PatternMatchAlignChecker
  51. Public method must have type MinorMinor

    Check that a method has an explicit return type, it is not inferred.

    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.

    org.scalastyle.scalariform.PublicMethodsHaveTypeChecker
  52. Redundant braces in class definition MinorMinor

    If a class/trait has no members, the braces are unnecessary.

    If a class / trait has no members, then braces are unnecessary, and can be removed.

    org.scalastyle.scalariform.EmptyClassChecker
  53. Regular expression in a token MinorMinor

    Checks that a regular expression cannot be matched in a token, if found reports this.

    Some checks can be carried by just the presence of a particular token.

    org.scalastyle.scalariform.TokenChecker
  54. Return MinorMinor

    Check that return is not used.

    Use of return is not usually necessary in Scala. In fact, use of return can discourage a functional style of programming.

    org.scalastyle.scalariform.ReturnChecker
  55. Simplify Boolean expression MinorMinor

    Boolean expression can be simplified.

    A boolean expression which can be simplified can make code easier to read.

    org.scalastyle.scalariform.SimplifyBooleanExpressionChecker
  56. Space after plus MinorMinor

    Check that the plus sign is followed by a space.

    An expression with spaces around + can be easier to read.

    org.scalastyle.scalariform.SpacesAfterPlusChecker
  57. Space after the start of the comment MinorMinor

    Checks a space after the start of the comment.

    To bring consistency with how comments should be formatted, leave a space right after the beginning of the comment.

    package foobar
    
    object Foobar {
      /**WRONG
        *
        */
      /** Correct
        *
        */
      val d = 2 /*Wrong*/ //Wrong
      /**
        * Correct
        */
      val e = 3 /** Correct*/ // Correct
    }
    org.scalastyle.scalariform.SpaceAfterCommentStartChecker
  58. Space after tokens MinorMinor

    Disallow space after certain token(s).

    Correct formatting can help readability.

    org.scalastyle.scalariform.DisallowSpaceAfterTokenChecker
  59. Space before plus MinorMinor

    Check that the plus sign is preceded by a space.

    An expression with spaces around + can be easier to read.

    org.scalastyle.scalariform.SpacesBeforePlusChecker
  60. Space before tokens MinorMinor

    Disallow space before certain token(s).

    Correct formatting can help readability.

    org.scalastyle.scalariform.DisallowSpaceBeforeTokenChecker
  61. Structural type MinorMinor

    Check that structural types are not used.

    Structural types in Scala can use reflection - this can have unexpected performance consequences. Warning: This check can also wrongly pick up type lamdbas and other such constructs. This checker should be used with care. You always have the alternative of the scalac checking for structural types.

    org.scalastyle.scalariform.StructuralTypeChecker
  62. TODO/FIXME comment MinorMinor

    Check for use of TODO/FIXME single line comments.

    Some projects may consider TODO or FIXME comments in a code bad style. They would rather you fix the problem.

    org.scalastyle.scalariform.TodoCommentChecker
  63. Usage of ??? operator MinorMinor

    Checks that the code does not have ??? operators.

    The ??? operator denotes that an implementation is missing. This rule helps to avoid potential runtime errors because of not implemented code.

    org.scalastyle.scalariform.NotImplementedErrorUsage
  64. Use : Unit = for procedures MinorMinor

    Use a : Unit = for procedure declarations.

    A procedure style declaration can cause confusion - the developer may have simply forgotten to add a =, and now their method returns Unit rather than the inferred type:

    def foo() { println("hello"); 5 }

    This checker raises a warning with the first line. To fix it, use an explicit return type, or add a = before the body.

    def foo() = { println("hello"); 5 }
    org.scalastyle.scalariform.ProcedureDeclarationChecker
  65. Use braces in for comprehensions MinorMinor

    Checks that braces are used in for comprehensions.

    Usage of braces (rather than parentheses) within a for comprehension mean that you don't have to specify a semi-colon at the end of every line:

    for { // braces
      t <- List(1,2,3)
      if (t % 2 == 0)
    } yield t

    is preferred to

    for ( // parentheses
      t <- List(1,2,3);
      if (t % 2 == 0)
    ) yield t

    To fix it, replace the () with {}. And then remove the ; at the end of the lines.

    The singleLineAllowed property allows for constructions of the type:

    for (i <- List(1,2,3)) yield i
    org.scalastyle.scalariform.ForBraceChecker
  66. Use correct indentation MinorMinor

    Checks that lines are indented by a multiple of the tab size.

    Code that is not indented consistently can be hard to read.

    org.scalastyle.file.IndentationChecker
  67. Use parentheses in for loops MinorMinor

    Checks that parentheses are used in for loops.

    For-comprehensions which lack a yield clause is actually a loop rather than a functional comprehension and it is usually more readable to string the generators together between parentheses rather than using the syntactically-confusing } { construct:

    for (x <- board.rows; y <- board.files) {
      printf("(%d, %d)", x, y)
    }

    is preferred to

    for {
      x <- board.rows
      y <- board.files
    } {
      printf("(%d, %d)", x, y)
    }
    org.scalastyle.scalariform.ForLoopChecker
  68. While body should have braces MinorMinor

    Checks that while body have braces.

    While cannot be used in a pure-functional manner, that's why it's recommended to never omit braces according to Scala Style Guide.

    org.scalastyle.scalariform.WhileBraceChecker
  69. Whitespace at end of line MinorMinor

    Check that there is no trailing whitespace at the end of lines.

    Whitespace at the end of a line can cause problems when diffing between files or between versions.

    org.scalastyle.file.WhitespaceEndOfLineChecker
  70. XML literals MinorMinor

    Check that XML literals are not used.

    Some projects prefer not to have XML literals. They could use a templating engine instead.

    org.scalastyle.scalariform.XmlLiteralChecker

Templates

  1. Class name MinorMinor template

    Check that class names match a regular expression.

    The Scala style guide recommends that class names conform to certain standards.

    org.scalastyle.scalariform.ClassNamesChecker-template
  2. Class type parameter name MinorMinor template

    Checks that type parameter to a class matches a regular expression.

    Scala generic type names are generally single upper case letters. This check checks for classes and traits. Note that this check only checks the innermost type parameter, to allow for List[T].

    org.scalastyle.scalariform.ClassTypeParameterChecker-template
  3. Cyclomatic complexity MinorMinor template

    Checks that the cyclomatic complexity of a method does exceed a value.

    If the code is too complex, then this can make code hard to read.

    org.scalastyle.scalariform.CyclomaticComplexityChecker-template
  4. Field name MinorMinor template

    Check that field names match a regular expression.

    A consistent naming convention for field names can make code easier to read and understand.

    org.scalastyle.scalariform.FieldNamesChecker-template
  5. File length MinorMinor template

    Check the number of lines in a file.

    Files which are too long can be hard to read and understand.

    org.scalastyle.file.FileLengthChecker-template
  6. File line length MinorMinor template

    Check the number of characters in a line.

    Lines that are too long can be hard to read and horizontal scrolling is annoying.

    org.scalastyle.file.FileLineLengthChecker-template
  7. If block braces MinorMinor template

    Checks that if statements have braces.

    Some people find if clauses with braces easier to read.

    The singleLineAllowed property allows if constructions of the type:

    if (bool_expression) expression1 else expression2

    The doubleLineAllowed property allows if constructions of the type:

    if (bool_expression) expression1 else expression2

    Note: If you intend to enable only if expressions in the format below, disable the IfBraceChecker altogether.

    if (bool_expression) expression1 else expression2
    org.scalastyle.scalariform.IfBraceChecker-template
  8. Illegal imports MinorMinor template

    Check that a class does not import certain classes.

    Use of some classes can be discouraged for a project. For instance, use of sun._ is generally discouraged because they are internal to the JDK and can be changed.

    org.scalastyle.scalariform.IllegalImportsChecker-template
  9. Literal passed as argument without name MinorMinor template

    Checks that argument literals are named.

    Nameless literals make code harder to understand (consider updateEntity(1, true) and updateEntity(id = 1, enabled = true)).

    org.scalastyle.scalariform.NamedArgumentChecker-template
  10. Magic Number MinorMinor template

    Checks for use of magic numbers.

    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.

    org.scalastyle.scalariform.MagicNumberChecker-template
  11. Match Header MinorMinor template

    Check the first lines of each file matches the text.

    A lot of projects require a header with a copyright notice, or they require a license in each file. This does a simple text comparison between the header and the first lines of the file. You can have multiple lines, but make sure you surround the text with a CDATA section. You can also specify a regular expression, as long as you set the regex parameter to true.

    org.scalastyle.file.HeaderMatchesChecker-template
  12. Maximum parameters MinorMinor template

    Maximum number of parameters for a method.

    A method which has more than a certain number of parameters can be hard to understand.

    org.scalastyle.scalariform.ParameterNumberChecker-template
  13. Method argument name MinorMinor template

    Check that method argument names match a regular expression.

    The Scala style guide recommends that method argument names conform to certain standards.

    org.scalastyle.scalariform.MethodArgumentNamesChecker-template
  14. Method length MinorMinor template

    Checks that methods do not exceed a maximum length.

    Long methods can be hard to read and understand.

    org.scalastyle.scalariform.MethodLengthChecker-template
  15. Method name MinorMinor template

    Check that method names match a regular expression.

    The Scala style guide recommends that method names conform to certain standards. If the methods are overriding another method, and the overridden method cannot be changed, then use the ignoreOverride parameter.

    org.scalastyle.scalariform.MethodNamesChecker-template
  16. Missing or badly formed ScalaDoc MinorMinor template

    Checks that the ScalaDoc on documentable members is well-formed.

    Scaladoc is generally considered a good thing. Within reason.

    Ignore tokens is a comma separated string that may include the following: PatDefOrDcl (variables), TmplDef (classes, traits), TypeDefOrDcl (type definitions), FunDefOrDcl (functions). Supported indentation styles are "scaladoc" (for ScalaDoc-style comments, with two spaces before the asterisk), "javadoc" (for JavaDoc-style comments, with a single space before the asterisk) or "anydoc" to support any style (any number of spaces before the asterisk). For backwards compatibility, if left empty, "anydoc" will be assumed.

    org.scalastyle.scalariform.ScalaDocChecker-template
  17. Multiple string literals MinorMinor template

    Checks that a string literal does not appear multiple times.

    Code duplication makes maintenance more difficult, so it can be better to replace the multiple occurrences with a constant.

    org.scalastyle.scalariform.MultipleStringLiteralsChecker-template
  18. Non ASCII characters are not allowed MinorMinor template

    Some editors are unfriendly to non ASCII characters.

    Scala allows unicode characters as operators and some editors misbehave when they see non-ascii character. In a project collaborated by a community of developers. This check can be helpful in such situations.

    "value" match {
      case "value" => println("matched")
      ...
    }

    is preferred to

    "value" match {
      case "value" ⇒ println("matched")
      ...
    }

    To fix it, replace the (unicode operator) with =>.

    org.scalastyle.scalariform.NonASCIICharacterChecker-template
  19. Null MinorMinor template

    Check that null is not used.

    Scala discourages use of null, preferring Option.

    org.scalastyle.scalariform.NullChecker-template
  20. Number of methods in type MinorMinor template

    Check that a class / trait / object does not have too many methods.

    If a type declares too many methods, this can be an indication of bad design.

    org.scalastyle.scalariform.NumberOfMethodsInTypeChecker-template
  21. Number of types MinorMinor template

    Checks that there are not too many types declared in a file.

    If there are too many classes/objects defined in a single file, this can cause the code to be difficult to understand.

    org.scalastyle.scalariform.NumberOfTypesChecker-template
  22. Object name MinorMinor template

    Check that object names match a regular expression.

    The Scala style guide recommends that object names conform to certain standards.

    org.scalastyle.scalariform.ObjectNamesChecker-template
  23. Package name MinorMinor template

    Check that package names match a regular expression.

    The Scala style guide recommends that package names conform to certain standards.

    org.scalastyle.scalariform.PackageNamesChecker-template
  24. Package object name MinorMinor template

    Check that package object names match a regular expression.

    The Scala style guide recommends that package object names conform to certain standards.

    org.scalastyle.scalariform.PackageObjectNamesChecker-template
  25. Public method must have type MinorMinor template

    Check that a method has an explicit return type, it is not inferred.

    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.

    org.scalastyle.scalariform.PublicMethodsHaveTypeChecker-template
  26. Regular expression MinorMinor template

    Checks that a regular expression cannot be matched, if found reports this.

    Some checks can be carried out with a regular expression.

    org.scalastyle.file.RegexChecker-template
  27. Regular expression in a token MinorMinor template

    Checks that a regular expression cannot be matched in a token, if found reports this.

    Some checks can be carried by just the presence of a particular token.

    org.scalastyle.scalariform.TokenChecker-template
  28. TODO/FIXME comment MinorMinor template

    Check for use of TODO/FIXME single line comments.

    Some projects may consider TODO or FIXME comments in a code bad style. They would rather you fix the problem.

    org.scalastyle.scalariform.TodoCommentChecker-template
  29. Use braces in for comprehensions MinorMinor template

    Checks that braces are used in for comprehensions.

    Usage of braces (rather than parentheses) within a for comprehension mean that you don't have to specify a semi-colon at the end of every line:

    for { // braces
      t <- List(1,2,3)
      if (t % 2 == 0)
    } yield t

    is preferred to

    for ( // parentheses
      t <- List(1,2,3);
      if (t % 2 == 0)
    ) yield t

    To fix it, replace the () with {}. And then remove the ; at the end of the lines.

    The singleLineAllowed property allows for constructions of the type:

    for (i <- List(1,2,3)) yield i
    org.scalastyle.scalariform.ForBraceChecker-template
  30. Use correct indentation MinorMinor template

    Checks that lines are indented by a multiple of the tab size.

    Code that is not indented consistently can be hard to read.

    org.scalastyle.file.IndentationChecker-template
  31. Whitespace at end of line MinorMinor template

    Check that there is no trailing whitespace at the end of lines.

    Whitespace at the end of a line can cause problems when diffing between files or between versions.

    org.scalastyle.file.WhitespaceEndOfLineChecker-template