New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegexpOnFilenameCheck: NullPointerException when relative path is used to run checkstyle CLI #5278

Closed
kevin-wayne opened this Issue Nov 19, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@kevin-wayne

kevin-wayne commented Nov 19, 2017

/var/tmp $ cat HelloWorld.java

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

/var/tmp $ cat config.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">
    <module name="RegexpOnFilename">
        <property name="fileNamePattern" value="."/>
        <property name="fileExtensions" value="java"/>
    </module>
</module>

/var/tmp $ java -Duser.language=en -Duser.country=US -jar checkstyle-8.4-all.jar -c config.xml HelloWorld.java

Starting audit...
com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing HelloWorld.java
	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:297)
	at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:215)
	at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:523)
	at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:437)
	at com.puppycrawl.tools.checkstyle.Main.main(Main.java:210)
Caused by: java.lang.NullPointerException
	at com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameCheck.getFolderPath(RegexpOnFilenameCheck.java:286)
	at com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameCheck.processFiltered(RegexpOnFilenameCheck.java:253)
	at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:82)
	at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:318)
	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:288)
	... 4 more
Checkstyle ends with 1 errors.


/var/tmp $ java -Duser.language=en -Duser.country=US -jar checkstyle-8.4-all.jar -c config.xml /var/tmp/HelloWorld.java

Starting audit...
[ERROR] /var/tmp/HelloWorld.java:0: File match folder pattern '' and file pattern '.'. [RegexpOnFilename]
Audit done.
Checkstyle ends with 1 errors.

The CLI tool throws a NullPointerException when using RegexpOnFilename with a relative path (but works with an absolute path). Seems to be the same issue as #5127 (and perhaps the fix for #5127 already fixes this).


@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Nov 19, 2017

Member

It is a similar problem but the fix for the other issue won't fix this one as it is all related to how each Check is coded.

Member

rnveach commented Nov 19, 2017

It is a similar problem but the fix for the other issue won't fix this one as it is all related to how each Check is coded.

romani added a commit that referenced this issue Nov 24, 2017

romani added a commit that referenced this issue Nov 24, 2017

@romani romani added this to the 8.5 milestone Nov 24, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Nov 24, 2017

Member

fix is merged

Member

romani commented Nov 24, 2017

fix is merged

@romani romani closed this Nov 24, 2017

timurt added a commit to timurt/checkstyle that referenced this issue Dec 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment