Packages

c

org.scalastyle.scalariform

ImportOrderChecker

class ImportOrderChecker extends ScalariformChecker

Style checker that enforces import ordering. The following configuration parameters are available:

  • groups: a comma-separated list of group names to consider.
  • maxBlankLines: maximum number of blank lines to allow between groups. The default is "1". A value less than 1 disables the blank line limit.
  • group.[groupName]: a regular expression that matches imports that should be in the given group.
  • lexicographic: if true, imports are ordered lexicographically (classes, wildcards, then packages; case-sensitive ordering within); if false, apply the original case-insensitive ordering (with wildcards coming first, before classes).

For example, to check that "java" and "javax" imports are in a separate group at the top of the import list, you'd use this config:

<parameter name="groups">java,others</parameter> <parameter name="group.java">javax?\..+</parameter> <parameter name="group.other">.+</parameter>

Other non-configurable rules: - Within each group, import clauses are ordered alphabetically if 'lexicographic' is specified; else puts wildcards, then classes and packages, with case-insensitive sort. - In multi-import statements, entries are ordered alphabetically, with method / packages (assumed to be any string starting with a lower case letter) coming before classes.

Currently, this checker only looks at the top-level list of imports.

Linear Supertypes
ScalariformChecker, Checker[CompilationUnit], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ImportOrderChecker
  2. ScalariformChecker
  3. Checker
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ImportOrderChecker()

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def charsBetweenTokens(left: Token, right: Token): Int
    Definition Classes
    Checker
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. val customErrorKey: Option[String]
    Definition Classes
    Checker
  8. val customMessage: Option[String]
    Definition Classes
    Checker
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. val errorKey: String
    Definition Classes
    ImportOrderChecker → Checker
  12. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. def getBoolean(parameter: String, defaultValue: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Checker
  14. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  15. def getInt(parameter: String, defaultValue: Int): Int
    Attributes
    protected
    Definition Classes
    Checker
  16. def getString(parameter: String, defaultValue: String): String
    Attributes
    protected
    Definition Classes
    Checker
  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. def isNotObject(s: String): Boolean
    Attributes
    protected
    Definition Classes
    Checker
  20. def isObject(s: String): Boolean
    Attributes
    protected
    Definition Classes
    Checker
  21. val level: Level
    Definition Classes
    Checker
  22. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. final def notify(): Unit
    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  25. val parameters: Map[String, String]
    Definition Classes
    Checker
  26. def setCustomErrorKey(customErrorKey: Option[String]): Unit
    Definition Classes
    Checker
  27. def setCustomMessage(customMessage: Option[String]): Unit
    Definition Classes
    Checker
  28. def setLevel(level: Level): Unit
    Definition Classes
    Checker
  29. def setParameters(parameters: Map[String, String]): Unit
    Definition Classes
    ImportOrderChecker → Checker
  30. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  31. def toString(): String
    Definition Classes
    AnyRef → Any
  32. def toStyleError[T <: FileSpec](file: T, p: ScalastyleError, level: Level, lines: Lines): Message[T]
    Attributes
    protected
    Definition Classes
    Checker
  33. def verify(ast: CompilationUnit): List[ScalastyleError]
    Definition Classes
    ImportOrderChecker → Checker
  34. def verify[T <: FileSpec](file: T, level: Level, ast: CompilationUnit, lines: Lines): List[Message[T]]
    Definition Classes
    Checker
  35. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from ScalariformChecker

Inherited from Checker[CompilationUnit]

Inherited from AnyRef

Inherited from Any

Ungrouped