skuzzle / restrict-imports-enforcer-rule

Gradle plugin & Maven Enforcer rule that restricts usage of unwanted imports in Java, Kotlin and Groovy source files.
MIT License
75 stars 12 forks source link

Block comments can lead to mismatches #18

Closed skuzzle closed 6 years ago

skuzzle commented 6 years ago

Leading block comments will cause the class's own package not to be recognized so that it can not be matched against the base package.

Then there is the possibilty of maximum strange comments like the following:

package de.skuzzle.test;
/*Why
would you place a block comment like
this?*/import de.skuzzle.sample.Test;

In this case the import line would not be recognized as such.

The problem arises because we are currently reading the java file line by line. Maybe the best solution to this is to build a real parser which only parses the beginning of the file until the last import statement. Parsing every Java file into a full syntax tree seems to be too unefficient.

skuzzle commented 6 years ago

Fixed in 0.11.0