-
Notifications
You must be signed in to change notification settings - Fork 746
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
Collecting ideas for a new set of configuration options #648
Comments
Customizing the severity level of the builtin checks, applied globally to the compilation: |
Disabling warning-level checks in code marked with the |
Forgoing the default set of built-in checks, and instead supplying a user-defined list of checks to activate: |
Automatically enabling every check built-in to Error Prone, even those we aren't comfortable enabling by default due to a high false positive rate, or that can crash on some forms of code.
|
Demote all error-level checks to warning-level (this allows you to see all of the error prone errors at once as opposed to build, fix, build, fix, etc.)
|
Passing in configuration data to individual checks, customizing their behavior above and beyond the severity of those checks:
|
#488 - Allow severity/enable/disablement of checks by some nominal "category" as opposed to just by name (all of the Guice-related checks, for example). @Stephan202 |
#599/#511 - Tell error prone to stop all analysis on files matching a specific regular expression or other predicate. @kageiit, @vanniktech, @msridhar |
#486 - Allow checks with the "suggestion" severity to be raised to "warning". |
(Separate comment, to allow voting on the one above.) Thanks for opening this discussion! You asked for Github links; our code is closed source but I can share our config here. We've configured Error Prone inside a Maven profile which is enabled by default. Relevant section of the configuration: <compilerArgs combine.children="append">
<arg>-Werror</arg>
<!-- We want to enable almost all error-prone
bug pattern checkers, so we enable all and then
selectively deactivate some. -->
<arg>-XepAllDisabledChecksAsWarnings</arg>
<!-- The JAXB-generated classes exhibit some
error-prone bug patterns. Nothing we can do
about that, so we simply tell error-prone not
to warn about generated code. -->
<arg>-XepDisableWarningsInGeneratedCode</arg>
<!-- See https://github.com/google/error-prone/issues/491. -->
<arg>-Xep:ArgumentParameterMismatch:OFF</arg>
<!-- See https://github.com/google/error-prone/issues/490. -->
<arg>-Xep:ArgumentParameterSwap:OFF</arg>
<!-- Disabled for now, but TBD. -->
<arg>-Xep:MethodCanBeStatic:OFF</arg>
<!-- Disabled for now, but TBD. -->
<arg>-Xep:PrivateConstructorForUtilityClass:OFF</arg>
<!-- Deals with an Android-specific limitation
not applicable to us. See also
https://github.com/google/error-prone/issues/488. -->
<arg>-Xep:StaticOrDefaultInterfaceMethod:OFF</arg>
<!-- Interesting idea, but way too much work for now. -->
<arg>-Xep:Var:OFF</arg>
<!-- The following bug patterns by default have
"SUGGESTION" severity. We raise them to the
"WARNING" level. See also
https://github.com/google/error-prone/issues/486. -->
<arg>-Xep:ConstantField:WARN</arg>
<arg>-Xep:EmptySetMultibindingContributions:WARN</arg>
<arg>-Xep:MixedArrayDimensions:WARN</arg>
<arg>-Xep:MultipleTopLevelClasses:WARN</arg>
<arg>-Xep:MultiVariableDeclaration:WARN</arg>
<arg>-Xep:PackageLocation:WARN</arg>
<arg>-Xep:PrivateConstructorForNoninstantiableModuleTest:WARN</arg>
<arg>-Xep:RemoveUnusedImports:WARN</arg>
<arg>-Xep:ThrowsUncheckedException:WARN</arg>
<arg>-Xep:UnnecessaryStaticImport:WARN</arg>
<arg>-Xep:UseBinds:WARN</arg>
<arg>-Xep:WildcardImport:WARN</arg>
</compilerArgs> If I could have one wish granted on this topic, then it'd be for the suggestions in #486 to be implemented. That way I won't have to maintain the list of checks you see above ^. (Each time I upgrade Error Prone I run a script over its source code to collect the set of rules with a suggestion-level severity. The ones I like are promoted to WARN. That's how I noticed #472. I'd prefer to have all new checks enabled by default, then disable the ones that won't fly.) NB: We also have another Maven profile using which we can apply Refaster rewrite rules to our code base. Relevant snippet: <compilerArgs combine.children="append">
<arg>-XepPatchChecks:${errorprone.patchchecks}</arg>
<arg>-XepPatchLocation:IN_PLACE</arg>
</compilerArgs> |
;-) Edwin from gerrit team was fixing sporadically some error prone warnings, and I failed to see any rules of why he was suddenly fixing warning foo, bar but only in file baz. It turned out, that some specific tool chain at Google exposes those warnings for the files included in review during import into Google's own VCS. The good news is, you don't need to wait until #667 is fixed to see the whole truth, (by that I mean all default EP warnings). For meantime, there is a (way too intrusive) workaround for Bazel. Example: With this Bazel patch applied I was able to generate all default EP warnings report for Gerrit Code Review in this issue. Needless to say, it would be great to have a way to do it without patching Bazel. |
Should there a way to read the flags from one configuration file rather than a long command line list? There are command line maximum length limit on some platforms, yes, I am talking Windows. |
@hkdennis2k, yes, a configuration file is definitely in scope for this. Please vote for this comment if you want to specify configuration via a file rather than command-line flags. |
#572 - whitelisting for @DoNotMock |
Please just fix #472 . It should be easy fix. |
I would really like to be able tell ErrorProne to write its scanner results to a file like JUnit does. This would enable integration with build tooling like Bamboo. |
Not eager to add yet another request here, but... 😄 It'd be cool if beyond generated code, there were a way to disable all warning-level checks on all code, i.e., |
Add a way to control warnings & errors for generated code, ideally to have it separate from main source code. My use case is: |
#808 DisableErrorsInGeneratedCode |
How about FailOnWarnings |
@codylerum you can have the compiler fail on warnings by passing |
@Stephan202 Thanks that did the trick. To others wanting to enable this using maven just add |
I would really like a way to treat a warning as an error if the number of occurrences of the warning exceeds a configured value. This would allow gradually fixing warnings while people may be attempting to add new instances of the same warning. Some types of warning are so common throughout our codebase that if they were fixed in a single code review, the review would be so large that nobody would read it thoroughly. |
We ended up doing this in Gerrit Code Review:
And conducting this file here, with the list of warnings to be treated as errors: https://github.com/GerritCodeReview/gerrit/blob/master/tools/BUILD#L30-L96 |
As discussed in #4546, I would like the build to fail if there are any errors or warnings, but all errors and warnings should be reported. |
A number of recent github issues (#647, #599, #512, #488) are focused around customizing and/or configuring Error Prone's behavior.
Historically, Error Prone has offered a (very) limited amount of configuration:
OFF
,WARNING
, andERROR
-XepDisableWarningsInGeneratedCode
)In the past year, we've added a few more configuration flags
-XepAllDisabledChecksAsWarnings
- Turns on all of the optional checks as warnings for those wanting to see everything-XepAllErrorsAsWarnings
- Demote all error-level checks to warning-level (this allows you to see all of the error prone errors at once as opposed to build, fix, build, fix, etc.)-XepDisableAllChecks
- Completely disable all of the checks, allowing you to then turn on individual checks one at a time (used in a chain like-XepDisableAllChecks -Xep:EqualsIncompatibleType:ERROR
)-XepPatchLocation
andXepPatchChecks
- used to control the patching feature.We have a new flag that's only available in the newest snapshots
-XepOpt:[Namespace:]FlagName[=Value]
- Pass any number of arbitrary flags to individual bug checkers or collections thereof (individual checkers can be customizedWe've generally responded to requests for configuration changes by adding new flags, and dealing with the combinations of these flags has been a bit arbitrary.
We'd like to solicit feedback from the community to help us build a newer configuration model:
The text was updated successfully, but these errors were encountered: