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

unsupported lint option: redundantNullComparison #237

Open
mkondratek opened this issue Apr 8, 2020 · 5 comments
Open

unsupported lint option: redundantNullComparison #237

mkondratek opened this issue Apr 8, 2020 · 5 comments
Assignees

Comments

@mkondratek
Copy link

Hi!

I have encountered some problem related to lint options.

My Gradle check (compileJava actually) task result fails with:
warning: Unsupported lint option: redundantNullComparison; All options: [cast, debugSpew, cast:redundant, cast:unsafe] error: warnings found and -Werror specified

A part of build.gradle:

plugins {
  //...
  id 'org.checkerframework' version '0.4.14' apply false
}

subprojects {
  //...
  apply plugin: 'org.checkerframework'
  checkerFramework {
    excludeTests = true
    checkers = [
      'org.checkerframework.checker.formatter.FormatterChecker',
      'org.checkerframework.checker.guieffect.GuiEffectChecker',
      'org.checkerframework.checker.index.IndexChecker',
      'org.checkerframework.checker.nullness.NullnessChecker',
      'org.checkerframework.checker.optional.OptionalChecker',
      'org.checkerframework.checker.regex.RegexChecker',
    ]
    extraJavacArgs = [
            '-Alint=redundantNullComparison',
            '-AassumeAssertionsAreEnabled',
            "-Astubs=$rootDir/config/checker/",
            '-AsuppressWarnings=type.anno.before.modifier',
    ]
  }
}

org.checkerframework version: 0.4.14

@wmdietl
Copy link

wmdietl commented Apr 8, 2020

Thanks for the report!
This can be reproduced on the command-line and isn't an issue of the gradle plugin.
I'll try transferring the issue to typetools/checker-framework...

The issue can be reproduced with only nullness and guieffect checkers.
Those are the only two that have supported lint options:
https://github.com/typetools/checker-framework/blob/master/checker/src/main/java/org/checkerframework/checker/guieffect/GuiEffectChecker.java#L9
https://github.com/typetools/checker-framework/blob/master/checker/src/main/java/org/checkerframework/checker/nullness/NullnessChecker.java#L19

The mechanism to select the type system doesn't seem to work, though, and isn't documented. I'll fix this.

@wmdietl wmdietl self-assigned this Apr 8, 2020
@wmdietl
Copy link

wmdietl commented Apr 8, 2020

@kelloggm I can't transfer the issue. Can you?

@kelloggm kelloggm transferred this issue from kelloggm/checkerframework-gradle-plugin Apr 8, 2020
@kelloggm
Copy link
Owner

kelloggm commented Apr 8, 2020

@wmdietl It seems like GitHub doesn't permit transfers between repositories that aren't owned by the same account. I've transferred it to my fork of the CF, but that's probably not what you had in mind :)

It might be better to open a new issue on the CF itself and close this one.

@wmdietl
Copy link

wmdietl commented Apr 8, 2020

That seems good enough...

The fix is here
typetools#3239
and I'll add a reference to this issue.

@wmdietl
Copy link

wmdietl commented Apr 9, 2020

Each -processor is executed independently, so when we check the supported lint flags for one checker, we don't know whether there is another checker that might support that flag.

So it is unfortunately required that this invocation:

/checker/bin/javac -Alint=redundantNullComparison
 -processor nullness,guieffect  Repro.java
Repro.java:8: warning: [known.nonnull] redundant check; "o" is non-null
            if (o == null) {
                  ^
warning: Unsupported lint option: redundantNullComparison; All options: [cast, debugSpew, cast:redundant, cast:unsafe]
2 warnings

issues a warning.

Once the fix in typetools#3239 is merged (and the next time we made a release), you can use one of the following two ways to pass the flag only to the correct checker:

$ ./checker/bin/javac -Aorg.checkerframework.checker.nullness.NullnessChecker_lint=redundantNullComparison -processor nullness,guieffect  Repro.java
Repro.java:8: warning: [known.nonnull] redundant check; "o" is non-null
            if (o == null) {
                  ^
1 warning

$ ./checker/bin/javac -ANullnessChecker_lint=redunda
ntNullComparison -processor nullness,guieffect  Repro.java
Repro.java:8: warning: [known.nonnull] redundant check; "o" is non-null
            if (o == null) {
                  ^
1 warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants