Skip to content

Commit

Permalink
Fixes scapegoat-scala#340. Excusing arguments annotated with @unused
Browse files Browse the repository at this point in the history
  • Loading branch information
mccartney committed Oct 14, 2020
1 parent 4a61bc3 commit 5851f13
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class UnusedMethodParameter
}
}

private def isParameterExcused(param: ValDef): Boolean =
param.symbol.annotations.exists(_.atp.toString == "scala.annotation.unused")

/**
* For constructor params, some params become vals / fields of the class:
* 1. all params in the first argument list for case classes
Expand Down Expand Up @@ -109,8 +112,9 @@ class UnusedMethodParameter
for {
vparams <- vparamss
vparam <- vparams
} if (!usesParameter(vparam.name.toString, rhs))
} if (!isParameterExcused(vparam) && !usesParameter(vparam.name.toString, rhs)) {
context.warn(tree.pos, self, s"Unused method parameter ($vparam).")
}
case _ => continue(tree)
}
}
Expand Down

0 comments on commit 5851f13

Please sign in to comment.