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

RequireThisCheck: NPE on method from base class with validateOnlyOverlapping off #4856

Closed
rnveach opened this Issue Jul 29, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@rnveach
Member

rnveach commented Jul 29, 2017

Identified at #4853 (comment) and taken from https://raw.githubusercontent.com/sevntu-checkstyle/sevntu.checkstyle/7003e1e7ba87e50fd5654805ee6c4288544d8a97/sevntu-checks/src/test/resources/com/github/sevntu/checkstyle/checks/coding/InputAvoidModifiersForTypesCheck.java ,

$ cat TestClass.java
package com.github.sevntu.checkstyle.checks.coding;

import java.util.logging.Logger;

public class InputAvoidModifiersForTypesCheck
{
    public class Check {
        private Logger log1 = Logger.getLogger(getClass().getName());
    }
}

$ cat TestConfig.xml
<!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="RequireThisCheck">
  <property name="validateOnlyOverlapping" value="false" />
</module>
    </module>
</module>

$ java -jar checkstyle-8.1-all.jar -c TestConfig.xml TestClass.java
Starting audit...
com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing TestClass.java
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:295)
    at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:213)
    at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:508)
    at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:431)
    at com.puppycrawl.tools.checkstyle.Main.main(Main.java:209)
Caused by: java.lang.NullPointerException
    at com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck.getMethodWithoutThis(RequireThisCheck.java:801)
    at com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck.processIdent(RequireThisCheck.java:262)
    at com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck.visitToken(RequireThisCheck.java:231)
    at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:419)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:556)
    at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:359)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:205)
    at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:79)
    at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:316)
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:286)
    ... 4 more
Checkstyle ends with 1 errors.

@rnveach rnveach added the approved label Jul 29, 2017

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Jul 30, 2017

Member

I trimmed the test case down to the smallest denominator.

Member

rnveach commented Jul 30, 2017

I trimmed the test case down to the smallest denominator.

rnveach added a commit to rnveach/checkstyle that referenced this issue Jul 30, 2017

@rnveach rnveach changed the title from RequireThisCheck: NPE with validateOnlyOverlapping off to RequireThisCheck: NPE on method from base class with validateOnlyOverlapping off Jul 30, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Jul 31, 2017

romani added a commit that referenced this issue Aug 1, 2017

@romani romani added the bug label Aug 1, 2017

@romani romani added this to the 8.2 milestone Aug 1, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Aug 1, 2017

Member

fix is merged

Member

romani commented Aug 1, 2017

fix is merged

@romani romani closed this Aug 1, 2017

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