Scalafix

Scalafix

  • User guide
  • Developer guide
  • Browse sources
  • GitHub

›Rules

Usage

  • Installation
  • Configuration
  • Suppressing rules

Rules

  • Built-in rules
  • DisableSyntax
  • ExplicitResultTypes
  • LeakingImplicitClassVal
  • NoAutoTupling
  • NoValInForComprehension
  • OrganizeImports
  • ProcedureSyntax
  • RedundantSyntax
  • RemoveUnused
  • Using external rules
  • Community rules

Misc

  • Related projects
Edit

Built-in Rules

Scalafix comes with a small set of built-in rules. Rules are either syntactic or semantic.

Syntactic: the rule can run directly on source code without compilation. Syntactic rules are simple to run but they can only do limited code analysis since they do not have access to information such as symbols and types.

Semantic: the rule requires input sources to be compiled beforehand with the Scala compiler and the SemanticDB compiler plugin enabled. Semantic rules are more complicated to run but they can do more advanced code analysis based on symbols and types.

Semantic Rules

NameDescription
ExplicitResultTypesInserts type annotations for inferred public members.
NoAutoTuplingInserts explicit tuples for adapted argument lists for compatibility with -Yno-adapted-args
OrganizeImportsOrganize import statements
RemoveUnusedRemoves unused imports and terms that reported by the compiler under -Wunused

Syntactic Rules

NameDescription
DisableSyntaxReports an error for disabled features such as var or XML literals.
LeakingImplicitClassValAdds 'private' to val parameters of implicit value classes
NoValInForComprehensionRemoves deprecated val inside for-comprehension binders
ProcedureSyntaxReplaces deprecated Scala 2.x procedure syntax with explicit ': Unit ='
RedundantSyntaxRemoves redundant syntax such as `final` modifiers on an object
← Suppressing rulesDisableSyntax →
Scalafix
Docs
Get startedRulesExtend Scalafix
Community
Chat on DiscordDiscuss on Scala Users
More
GitHub
Copyright © 2025 Scala Center