Error-prone: Compiler flag to ignore generated code is undocumented

Created on 22 Sep 2016  路  12Comments  路  Source: google/error-prone

The compiler flag -XepDisableWarningsInGeneratedCode isn't in the official documentation

The release instructions doesn't specify how one adds documentation for command line flags. It seems to be a manual process.

Most helpful comment

Very useful flag that isn't documented at all. I'd love to see this rectified.

All 12 comments

Cool, didn't know about this flag. Cursory inspection indicates that generated code is identified by the presence of the @Generated annotation. I've just tested this; works well. I can now re-enable a bug pattern to which some of our wsimport/xjc-generated code does not comply. Nice :)

Very useful flag that isn't documented at all. I'd love to see this rectified.

Even with this flag I'm still getting warnings regarding Dagger's generated code.

I am also seeing issues with Databinding.

@tbroyer Hows does it work? Are we forced to write a custom patch?

@jaredsburrows Not sure I understand your question, but -XepDisableWarningsInGeneratedCode will disable/remove/ignore warnings (not errors!) in code annotated with @Generated: https://github.com/google/error-prone/issues/329#issuecomment-117318164

You said in your previous comment:

This has been added in 9f9f23a a few days ago.

The -XepDisableWarningsInGeneratedCode argument has been in error prone for some time right? https://github.com/google/error-prone/blame/master/check_api/src/main/java/com/google/errorprone/ErrorProneOptions.java#L56

This issue is about the flag's documentation. http://errorprone.info/docs/flags
The flag itself has been added in 2.0.6.

just encountered this due in part to the immutables library, and I too am noticing there is not a corresponding flag to ignore ERROR which I have some of, because I set MissingOverride and Var to error so that they fail the test, of course I don't care if generated code does this. could open a new bug to add that flag.

my current workaround is to ignore the directory, even thought eh classes are appropriately annotated with @Generated

tasks.withType(JavaCompile) {
    options.compilerArgs += [
        '-XepExcludedPaths:.*/build/classes/.*',
        '-Xep:MissingOverride:ERROR',
        '-Xep:Var:ERROR',
    ]
}

@xenoterracide you can now disable EP on generated code entirely if desired with the -XepExcludedPaths flag. It's documented here

@xenoterracide you may also be interested in https://github.com/google/error-prone/issues/808

Was this page helpful?
0 / 5 - 0 ratings