Skip to content

Commit c5e3fae

Browse files
authored
Merge pull request #333 from dwijnand/cleanup-ProblemFilters-and-Problems
Cleanup ProblemFilters and Problems
2 parents a0c1bcf + 8306a8a commit c5e3fae

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
package com.typesafe.tools.mima.core
2-
import scala.reflect.ClassTag
2+
3+
import scala.reflect.{ ClassTag, classTag }
34
import java.util.regex.Pattern
45

56
object ProblemFilters {
67

78
private case class ExcludeByName[P <: ProblemRef: ClassTag](name: String) extends ProblemFilter {
89
private[this] val pattern = Pattern.compile(name.split("\\*", -1).map(Pattern.quote).mkString(".*"))
10+
911
override def apply(problem: Problem): Boolean = {
10-
!(implicitly[ClassTag[P]].runtimeClass.isAssignableFrom(problem.getClass) &&
12+
!(classTag[P].runtimeClass.isAssignableFrom(problem.getClass) &&
1113
pattern.matcher(problem.matchName.getOrElse("")).matches)
1214
}
1315

14-
override def toString(): String = """ExcludeByName[%s]("%s")""".format(implicitly[ClassTag[P]].runtimeClass.getSimpleName, name)
16+
override def toString() = s"""ExcludeByName[${classTag[P].runtimeClass.getSimpleName}]("$name")"""
1517
}
1618

17-
def exclude[P <: ProblemRef: ClassTag](name: String): ProblemFilter = {
18-
ExcludeByName[P](name)
19-
}
19+
def exclude[P <: ProblemRef: ClassTag](name: String): ProblemFilter = ExcludeByName[P](name)
2020

2121
/**
2222
* Creates exclude filter by taking name of a problem and name of a match (e.g. class/method name).
@@ -26,12 +26,12 @@ object ProblemFilters {
2626
* @throws ClassNotFoundException if the class corresponding to the problem cannot be located
2727
*/
2828
def exclude(problemName: String, name: String): ProblemFilter = {
29-
val problemClass: Class[_ <: ProblemRef] = Class.forName("com.typesafe.tools.mima.core." + problemName).asInstanceOf[Class[_ <: ProblemRef]]
29+
val problemClass: Class[_ <: ProblemRef] =
30+
Class.forName(s"com.typesafe.tools.mima.core.$problemName").asInstanceOf[Class[_ <: ProblemRef]]
3031
exclude(name)(ClassTag(problemClass))
3132
}
3233

3334
@deprecated("Replace with ProblemFilters.exclude[Problem](\"my.package.*\")", "0.1.15")
34-
def excludePackage(packageName: String): ProblemFilter = {
35-
exclude[Problem](packageName + ".*")
36-
}
35+
def excludePackage(packageName: String): ProblemFilter = exclude[Problem](s"$packageName.*")
36+
3737
}

core/src/main/scala/com/typesafe/tools/mima/core/Problems.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ trait ProblemRef {
1010
def matchName: Option[String] = None
1111

1212
// description of how to make a filter rule
13-
def howToFilter: Option[String] = matchName.map{ name =>
14-
"""ProblemFilters.exclude[%s]("%s")""".format(this.getClass.getSimpleName, name)
15-
}
13+
def howToFilter: Option[String] =
14+
matchName.map(name => s"""ProblemFilters.exclude[${getClass.getSimpleName}]("$name")""")
1615
}
1716

1817
trait TemplateRef extends ProblemRef {

0 commit comments

Comments
 (0)