Skip to content
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

Auto-unboxing issue in CheckstyleAuditListener #199

Closed
tsjensen opened this issue Mar 21, 2019 · 2 comments
Closed

Auto-unboxing issue in CheckstyleAuditListener #199

tsjensen opened this issue Mar 21, 2019 · 2 comments
Labels
Milestone

Comments

@tsjensen
Copy link
Contributor

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.

tsjensen added a commit to checkstyle-addons/sonar-checkstyle that referenced this issue Mar 21, 2019
tsjensen added a commit to checkstyle-addons/sonar-checkstyle that referenced this issue Mar 21, 2019
@rnveach
Copy link
Member

rnveach commented Mar 21, 2019

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.

@rnveach
Copy link
Member

rnveach commented Mar 21, 2019

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?

tsjensen added a commit to checkstyle-addons/sonar-checkstyle that referenced this issue Mar 21, 2019
tsjensen added a commit to checkstyle-addons/sonar-checkstyle that referenced this issue Mar 21, 2019
tsjensen added a commit to checkstyle-addons/sonar-checkstyle that referenced this issue Mar 21, 2019
Return 1 if the Checkstyle event contained anything other than a real
line number. Do not use null anymore for this.
tsjensen added a commit to checkstyle-addons/sonar-checkstyle that referenced this issue Mar 21, 2019
Return 1 if the Checkstyle event contained anything other than a real
line number. Do not use null anymore for this.
tsjensen added a commit to checkstyle-addons/sonar-checkstyle that referenced this issue Mar 21, 2019
Return 1 if the Checkstyle event contained anything other than a real
line number. Do not use null anymore for this.
tsjensen added a commit to checkstyle-addons/sonar-checkstyle that referenced this issue Mar 21, 2019
Return 1 if the Checkstyle event contained anything other than a real
line number. Do not use null anymore for this.
romani pushed a commit that referenced this issue Mar 22, 2019
Return 1 if the Checkstyle event contained anything other than a real
line number. Do not use null anymore for this.
@romani romani added this to the 4.19 milestone Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants