Closed connorlanigan closed 8 years ago
Can you supply a minimal sample source file to reproduce?
DataImporter.java:
package example;
public class DataImporter {
public int importData(String[] inputData){
int importedLines;
for(String line : inputData){
doImport(line);
importedLines++;
}
return importedLines;
}
}
pom.xml:
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>example</artifactId>
<version>0.0.1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<dependencies>
<dependency>
<groupId>de.skuzzle.enforcer</groupId>
<artifactId>restrict-imports-enforcer-rule</artifactId>
<version>0.4.0</version>
</dependency>
</dependencies>
<configuration>
<rules>
<restrictImports
implementation="de.skuzzle.enforcer.restrictimports.RestrictImports">
<basePackage>**</basePackage>
<bannedImports>
<bannedImport>java.util.ArrayList</bannedImport>
</bannedImports>
</restrictImports>
</rules>
</configuration>
<executions>
<execution>
<id>check-imports</id>
<phase>process-sources</phase>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Workaround implemented in https://github.com/skuzzle/restrict-imports-enforcer-rule/commit/67fc99cad1f0731ab7853ebd6a3b43e656faafb0 (accidently referenced wrong issue -.-)
Released in 0.5.0
Using a variable called
(space) leads to the aforementioned exception.
imported
produces aStringIndexOutOfBoundsException
, asde.skuzzle.enforcer.restrictimports.impl.ImportMatcherImpl#isImport
wrongly detects this line as an import statement. The search for the expectedly following(The method
de.skuzzle.enforcer.restrictimports.impl.ImportMatcherImpl#isPackage
will likely be prone to the same issue.)