ForbidCertainImportsCheck: null excludes gives no violations #552

Closed
rnveach opened this Issue Dec 8, 2016 · 1 comment

Projects

None yet

2 participants

@rnveach
Contributor
rnveach commented Dec 8, 2016 edited
$ cat TestClass.java
package com.github.sevntu.checkstyle.checks.coding;

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; // forbidden

public class InputForbidsCertainImports
{
    public int a()
    {
        
        AutomaticBean smth = new com.puppycrawl.tools.checkstyle.api.AutomaticBean(); // forbidden!
        return 5;
    }
}


$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="charset" value="UTF-8"/>

    <module name="TreeWalker">
<module name="com.github.sevntu.checkstyle.checks.coding.ForbidCertainImportsCheck">
<property name="packageNameRegexp" value=".+\.sevntu\..+"/>
<property name="forbiddenImportsRegexp" value=".+\.api\..+"/>
</module>
    </module>
</module>

$ java -classpath sevntu-checks-1.22.0.jar;checkstyle-7.3-all.jar com.puppycrawl.tools.checkstyle.Main -c TestConfig.xml TestClass.java
Starting audit...
Audit done.

Issue only presents itself when no forbiddenImportsExcludesRegexp is given. Once it is set, 2 violations show up for lines 3 and 10.
It makes no sense that no exclusions would prevent any violations from showing.

@rnveach rnveach added a commit to rnveach/sevntu.checkstyle that referenced this issue Dec 8, 2016
@rnveach rnveach Issue #552: no exclusions in ForbidCertainImports gave no violations e2a2b33
@rnveach rnveach added a commit to rnveach/sevntu.checkstyle that referenced this issue Dec 8, 2016
@rnveach rnveach Issue #552: no exclusions in ForbidCertainImports gave no violations cbb9d12
@rnveach rnveach added a commit to rnveach/sevntu.checkstyle that referenced this issue Dec 8, 2016
@rnveach rnveach Issue #552: no exclusions in ForbidCertainImports gave no violations 7ba9ef7
@romani romani added this to the 1.23 milestone Dec 8, 2016
@romani
Member
romani commented Dec 8, 2016

fix is merged

@romani romani closed this Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment