Skip to content

Instantly share code, notes, and snippets.

@aoiroaoino
Created April 14, 2022 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aoiroaoino/20a01d56b1bf7b1e04618a6e8442fd0b to your computer and use it in GitHub Desktop.
Save aoiroaoino/20a01d56b1bf7b1e04618a6e8442fd0b to your computer and use it in GitHub Desktop.
class ExplicitLocale extends SyntacticRule("ExplicitLocale") {
override def fix(implicit doc: SyntacticDocument): Patch =
doc.tree.collect {
case t @ Term.Select(_, tn) if targets.contains(tn.value) =>
t.parent match {
case Some(Term.Apply(Term.Select(_, _), args)) if args.nonEmpty =>
Patch.empty
case _ =>
Patch.lint(ExplicitLocaleWarn(t.pos))
}
case _ =>
Patch.empty
}.asPatch
}
object ExplicitLocale {
val targets = Seq("toLowerCase", "toUpperCase")
}
final case class ExplicitLocaleWarn(override val position: Position) extends Diagnostic {
override def severity: LintSeverity = LintSeverity.Warning
override def message: String = ExplicitLocale.targets.mkString("", ", ", " は Locale を明示的に指定しましょう。")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment