Created
October 9, 2017 02:45
-
-
Save richdougherty/76f3d05ffabd80fcb04f6bf0776adc33 to your computer and use it in GitHub Desktop.
Example of custom ProblemFilter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mimaBinaryIssueFilters ++= { | |
def excludeSymbols[P <: ProblemRef]( | |
name: String, | |
symbolFilter: String => Boolean)( | |
implicit problemTag: ClassTag[P]): ProblemFilter = { | |
{ problem: Problem => | |
// Check the problem type | |
if (problemTag.runtimeClass.isAssignableFrom(problem.getClass)) { | |
// Check the problem name | |
problem.matchName.fold(false) { name: String => | |
val split: Seq[String] = name.split('.') | |
val splitName = split.take(split.length - 1).mkString(".") | |
val splitSymbol = split(split.length - 1) | |
name == splitName && symbolFilter(splitSymbol) | |
} | |
} else false | |
} | |
} | |
val contentTypeConstants = Set("CACHE_MANIFEST", "JSON", "FORM", "BINARY") | |
val httpProtocolContants = Set("HTTP_1_0", "HTTP_1_1", "CHUNKED") | |
val controllerHelperConstants: Set[String] = contentTypeConstants ++ httpProtocolContants | |
val controllerHelperClasses: Seq[String] = Seq("play.api.mvc.ControllerHelpers", "controllers.ExternalAssets", "controllers.Default", "controllers.AssetsBuilder", "controllers.AbstractController") | |
val controllerHelperFilters: Seq[ProblemFilter] = controllerHelperClasses.map { className: String => | |
excludeSymbols(className, controllerHelperConstants) | |
} | |
controllerHelperFilters ++ Seq( | |
excludeSymbols[DirectMissingMethodProblem]("play.api.http.ContentTypes", contentTypeConstants), | |
excludeSymbols[DirectMissingMethodProblem]("play.api.http.HttpProtocol", httpProtocolContants), | |
// Changing return and parameter types from DefaultApplicationLifecycle (implementation) to ApplicationLifecycle (trait) | |
ProblemFilters.exclude[IncompatibleResultTypeProblem]("play.api.BuiltInComponents.applicationLifecycle"), | |
ProblemFilters.exclude[IncompatibleResultTypeProblem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
excludeSymbols
method is not correct: It returnstrue
when it should returnfalse
and vice versa. Correct would be:These is also how the
ProblemFilters.exclude[...]("...")
method works.