Skip to content

Commit

Permalink
use SymbolInformation when filter Mockito
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Jan 13, 2024
1 parent 3a2243c commit bef0449
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions rules/src/main/scala/fix/DiscardValue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ object DiscardValue {
}
}

private object Mockito {
def unapply(x: Term)(implicit doc: SemanticDocument): Boolean =
x.symbol.info.map(_.symbol.value).contains("org/mockito/Mockito#")
}

private object MockitoVerify {
def unapply(x: Term)(implicit doc: SemanticDocument): Boolean =
x.symbol.info.map(_.owner.value).contains("org/mockito/Mockito#")
}

def fix(
message: SemanticType => String,
severity: LintSeverity,
Expand All @@ -111,9 +121,9 @@ object DiscardValue {
false
case x =>
x.collectFirst {
case Term.Apply.After_4_6_0(Term.Select(Term.Name("Mockito"), _), _) =>
case Term.Apply.After_4_6_0(Term.Select(Mockito(), _), _) =>
()
case Term.Apply.After_4_6_0(Term.Name("verify"), _) =>
case Term.Apply.After_4_6_0(MockitoVerify(), _) =>
()
case Term.Apply.After_4_6_0(
Term.Select(MockitoInOrder(), Term.Name("verify")),
Expand Down

0 comments on commit bef0449

Please sign in to comment.