Skip to content

Auto-unboxing issue in CheckstyleAuditListener #199

Description

@tsjensen

Sonar version: 7.6
Checkstyle sonar plugin verson: 4.18

Steps to reproduce or description of problem:

Run any check which reports line 0 for an issue. This used to be the required behavior for checks that flag the entire file, and have no relation to the AST. For example FileSetChecks.
I know there was a breaking change in checkstyle/checkstyle#6000, changing the "magic" line number to 1. This kind of neutralizes this problem.
BUT: I noticed the problem running custom checks at work. I would expect some custom checks to be around that haven't noticed checkstyle/checkstyle#6000.

The error caused is this:

Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing C:\path\to\File.java
        at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:304)
        at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:217)
        at org.sonar.plugins.checkstyle.CheckstyleExecutor.executeWithClassLoader(CheckstyleExecutor.java:111)
        ... 71 more
Caused by: java.lang.NullPointerException
        at org.sonar.plugins.checkstyle.CheckstyleAuditListener.addError(CheckstyleAuditListener.java:106)
        at com.puppycrawl.tools.checkstyle.Checker.fireErrors(Checker.java:401)
        at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:292)
        ... 73 more

I have already fixed this, it's a small thing. PR upcoming.

Activity

  1. added 2 commits that reference this issue on Mar 21, 2019
  2. rnveach commented on Mar 21, 2019

    @rnveach
    Contributor

    Code is at

    which does indeed return a class Integer

    I'm not sure why code would rather use null instead of 0. Seems odd.

    // checkstyle returns 0 if there is no relation to a file content,
    // but we use null
    if (line != 0) {

    I guess this is because it has to select a line and was expecting to not select anything with null. I would think this is the code we change to not return null but instead default to 1.

  3. rnveach commented on Mar 21, 2019

    @rnveach
    Contributor

    This used to be the required behavior for checks that flag the entire file

    So why wasn't this an issue in sonar before but it is now? Or was this always a problem and no one run checks that flagged line 0 to notice?

  4. added 6 commits that reference this issue on Mar 21, 2019
  5. added 2 commits that reference this issue on Mar 22, 2019
  6. added this to the 4.19 milestone on Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions