Commit 901fefc9 authored by Andrew Grieve's avatar Andrew Grieve Committed by Chromium LUCI CQ

Android: Add a way to apply errorprone suggested fixes

Bug: 1029038
Change-Id: Ia9a0f0caaa30894d984f0aee91bcd2b492d2362d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2607548
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarSam Maier <smaier@chromium.org>
Commit-Queue: Sam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840170}
parent b6e12d2c
...@@ -29,6 +29,10 @@ _JAVAC_EXTRACTOR = os.path.join(build_utils.DIR_SOURCE_ROOT, 'third_party', ...@@ -29,6 +29,10 @@ _JAVAC_EXTRACTOR = os.path.join(build_utils.DIR_SOURCE_ROOT, 'third_party',
'android_prebuilts', 'build_tools', 'common', 'android_prebuilts', 'build_tools', 'common',
'framework', 'javac_extractor.jar') 'framework', 'javac_extractor.jar')
# Add a check here to cause the suggested fix to be applied while compiling.
# Use this when trying to enable more checks.
ERRORPRONE_CHECKS_TO_APPLY = []
# Full list of checks: https://errorprone.info/bugpatterns # Full list of checks: https://errorprone.info/bugpatterns
ERRORPRONE_WARNINGS_TO_DISABLE = [ ERRORPRONE_WARNINGS_TO_DISABLE = [
# The following are super useful, but existing issues need to be fixed first # The following are super useful, but existing issues need to be fixed first
...@@ -656,14 +660,25 @@ def main(argv): ...@@ -656,14 +660,25 @@ def main(argv):
# Make everything a warning so that when treat_warnings_as_errors is false, # Make everything a warning so that when treat_warnings_as_errors is false,
# they do not fail the build. # they do not fail the build.
errorprone_flags += ['-XepAllErrorsAsWarnings'] errorprone_flags += ['-XepAllErrorsAsWarnings']
for warning in ERRORPRONE_WARNINGS_TO_DISABLE: # Don't check generated files.
errorprone_flags.append('-Xep:{}:OFF'.format(warning)) errorprone_flags += ['-XepDisableWarningsInGeneratedCode']
for warning in ERRORPRONE_WARNINGS_TO_ENABLE: errorprone_flags.extend('-Xep:{}:OFF'.format(x)
errorprone_flags.append('-Xep:{}:WARN'.format(warning)) for x in ERRORPRONE_WARNINGS_TO_DISABLE)
errorprone_flags.extend('-Xep:{}:WARN'.format(x)
for x in ERRORPRONE_WARNINGS_TO_ENABLE)
if ERRORPRONE_CHECKS_TO_APPLY:
errorprone_flags += [
'-XepPatchLocation:IN_PLACE',
'-XepPatchChecks:,' + ','.join(ERRORPRONE_CHECKS_TO_APPLY)
]
javac_args += ['-XDcompilePolicy=simple', ' '.join(errorprone_flags)] javac_args += ['-XDcompilePolicy=simple', ' '.join(errorprone_flags)]
# This flag quits errorprone after checks and before code generation, since # This flag quits errorprone after checks and before code generation, since
# we do not need errorprone outputs, this speeds up errorprone by 4 seconds # we do not need errorprone outputs, this speeds up errorprone by 4 seconds
# for chrome_java. # for chrome_java.
if not ERRORPRONE_CHECKS_TO_APPLY:
javac_args += ['-XDshould-stop.ifNoError=FLOW'] javac_args += ['-XDshould-stop.ifNoError=FLOW']
if options.java_version: if options.java_version:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment