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

RedundantSyntax

This rule removes redundant syntax.

Configuration

By default, this rule rewrites any syntax known as redundant.

Defaults

RedundantSyntax.finalObject = true
RedundantSyntax.stringInterpolator = true

Features

final keyword on an object

- final object foo
+ object Foo

Note: in Scala 2.12 and earlier removing the final modifier will slightly change the resulting bytecode - see this bug ticket for further information.

String interpolators

RedundantSyntax removes unnecessary string interpolators. Only out-of-the-box interpolators (s, f and raw) are supported.

Example:

- println(s"Foo")
+ println("Foo")

- println(f"Bar")
+ println("Bar")

- println(raw"Baz")
+ println("Baz")

// No change as `raw` is not redundant.
println(raw"Foo\nBar")
← ProcedureSyntaxRemoveUnused →
  • Configuration
    • Defaults
  • Features
    • final keyword on an object
    • String interpolators
Scalafix
Docs
Get startedRulesExtend Scalafix
Community
Chat on DiscordDiscuss on Scala Users
More
GitHub
Copyright © 2025 Scala Center