Packages

package rule

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. abstract class Rule extends AnyRef

    A Scalafix Rule.

    A Scalafix Rule.

    To provide automatic fixes for this rule, override the fix method. Example:

    object ReverseNames extends Rule("ReverseNames") {
      override def fix(ctx: RuleCtx) =
        ctx.tree.collect {
          case name @ Name(value) => ctx.replaceTree(name, value.reverse)
        }.asPatch
    }

    To report violations of this rule (without automatic fix), override the check method. Example:

    // example syntactic linter
    object NoVars extends Rule("NoVars") {
      val varDefinition = LintCategory.error("varDefinition", "Var is bad!")
      override def check(ctx: RuleCtx) = ctx.tree.collect {
        case definition @ q"$_ var $_ = $_" => varDefinition.at(definition.pos)
      }
    }
    // example semantic linter
    case class NeverInferProduct(index: SemanticdbIndex)
        extends SemanticRule(index, "NeverInferProduct")
        with Product {
      val product = SymbolMatcher.exact(Symbol("_root_.scala.Product#"))
      val inferredProduct: LintCategory =
        LintCategory.error("inferredProduct", "Don't infer Product!")
      override def check(ctx: RuleCtx) =
        ctx.index.synthetics.flatMap {
          case Synthetic(pos, text, names) =>
            names.collect {
              case ResolvedName(_, product(_), _) =>
                inferredProduct.at(pos)
            }
        }
    }
  2. trait RuleCtx extends PatchOps
  3. final case class RuleIdentifier (value: String, deprecated: Option[Deprecated]) extends Product with Serializable

    A thin wrapper around a string name and optional deprecation warning.

  4. final case class RuleName (identifiers: List[RuleIdentifier]) extends Product with Serializable

    A thin wrapper around a list of RuleIdentifier.

  5. abstract class SemanticRule extends Rule

Ungrouped