Skip to content

Commit

Permalink
Checking in a commented-out version of my attempt to respect the whit…
Browse files Browse the repository at this point in the history
…elist list.

The problem I ran in to is that the "case Import(pkg, selectors)" has the pkg of type Tree, which when queried for the pkg.symbol only returns "util" (when you're importing java.util._ for example).  We need to figure out how to grab the ancestors (?) of the pkg to get the entire "java.util" package so that we can match on specific whitelist exclusions.
  • Loading branch information
tom.vaughan committed Jul 29, 2012
1 parent 5155d24 commit 089c33a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/scala/LinterPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,16 @@ class LinterPlugin(val global: Global) extends Plugin {

// TODO - respect the whitelist exceptions
case Import(pkg, selectors)
if packageWildcardWhitelistCheckEnabled && selectors.exists(isGlobalImport) =>
if packageWildcardWhitelistCheckEnabled
&& selectors.exists(isGlobalImport)

/* For a statement like "import java.util._",
pkg.symbol = "util"
pkg.class = class scala.reflect.generic.Trees$Select
We need to figure out how to get the "ancestor symbol(s)" of pkg to do string matching on the whole package name
&& !(packageWildcardWhitelistPackages.contains(pkg.symbol)) */ =>
println("The class of pkg is " + pkg.getClass)
annotateUnit(pkg.pos, "Wildcard imports should be avoided. Favor import selector clauses.", packageWildcardWhitelistSeverity)

case Apply(contains @ Select(seq, _), List(target))
Expand Down

0 comments on commit 089c33a

Please sign in to comment.