Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created October 13, 2021 04:20
Show Gist options
  • Save xuwei-k/a5661d4c604dfc82b9bf58b7119e0cda to your computer and use it in GitHub Desktop.
Save xuwei-k/a5661d4c604dfc82b9bf58b7119e0cda to your computer and use it in GitHub Desktop.
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