Created
October 13, 2021 04:20
-
-
Save xuwei-k/a5661d4c604dfc82b9bf58b7119e0cda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalafix.Diagnostic | |
import scalafix.Patch | |
import scalafix.lint.LintSeverity | |
import scalafix.v1.SyntacticDocument | |
import scalafix.v1.SyntacticRule | |
import scala.meta.Lit | |
import scala.meta.Term | |
import scala.meta.inputs.Position | |
class NoElse extends SyntacticRule("NoElse") { | |
override def fix(implicit doc: SyntacticDocument): Patch = { | |
doc.tree.collect { | |
case t @ Term.If(_, _, Lit.Unit()) => | |
Patch.lint( | |
NoElseWarn(t.pos) | |
) | |
}.asPatch | |
} | |
} | |
case class NoElseWarn(override val position: Position) extends Diagnostic { | |
override def message = "ifに対してelseがありません" | |
override def severity = LintSeverity.Warning | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment