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

org.wartremover.warts.RedundantIsInstanceOf.scala Maven / Gradle / Ivy

The newest version!
package org.wartremover
package warts

import scala.annotation.nowarn

object RedundantIsInstanceOf extends WartTraverser {
  override def apply(u: WartUniverse): u.Traverser =
    new u.Traverser {
      import u.universe._
      @nowarn("msg=lineContent")
      override def traverse(tree: u.universe.Tree): Unit = {
        tree match {
          case _ if hasWartAnnotation(u)(tree) || isSynthetic(u)(tree) =>
          case TypeApply(Select(e, TermName("isInstanceOf")), t :: Nil)
              if (e.tpe <:< t.tpe) && tree.pos.lineContent.contains("isInstanceOf") =>
            error(u)(tree.pos, "redundant isInstanceOf")
            super.traverse(tree)
          case _ =>
            super.traverse(tree)
        }
      }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy