All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scalafix.internal.rule.ConfigRule.scala Maven / Gradle / Ivy

package scalafix.internal.rule

import scalafix._
import scalafix.internal.config._
import scalafix.rule.Rule
import metaconfig.ConfError
import metaconfig.Configured

object ConfigRule {
  def apply(
      patches: ConfigRulePatches,
      getSemanticdbIndex: LazySemanticdbIndex): Configured[Option[Rule]] = {
    val configurationPatches = patches.all
    if (configurationPatches.isEmpty) Configured.Ok(None)
    else {
      getSemanticdbIndex(RuleKind.Semantic) match {
        case None =>
          ConfError
            .message(".scalafix.conf patches require the Semantic API.")
            .notOk
        case Some(index) =>
          val rule = Rule.constant(
            ".scalafix.conf",
            configurationPatches.asPatch,
            index
          )
          Configured.Ok(Some(rule))
      }
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy