Created
January 24, 2020 02:58
-
-
Save artem-zinnatullin/242ccc8e4b45a532b75e66f3fea408e8 to your computer and use it in GitHub Desktop.
ErrorProne Integration with Buck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def apply_error_prone(**kwargs): | |
# Error Prone should be on by default in Bazel. | |
if IS_BAZEL: | |
return kwargs | |
has_java_files = False | |
for src in kwargs.get("srcs", []): | |
if src.endswith(".java"): | |
has_java_files = True | |
break | |
if not has_java_files: | |
return kwargs | |
kwargs["javac_jar"] = "//tools/error-prone:javac" | |
kwargs["annotation_processor_deps"] = kwargs.get("annotation_processor_deps", []) + [ | |
"//tools/error-prone:error_prone_core", | |
"//tools/error-prone:error_prone_type_annotations", | |
"//tools/error-prone:error_prone_annotations", | |
"//tools/error-prone:error_prone_annotation", | |
"//tools/error-prone:error_prone_check_api", | |
"//tools/error-prone:jcip-annotations", | |
"//tools/error-prone:pcollections", | |
"//third_party/com.google.guava:guava", | |
"//third_party/com.google.guava:failureaccess", | |
"//third_party/com.google.auto:auto-common", | |
"//third_party/com.google.code.findbugs:jsr305", | |
"//third_party/com.google.protobuf:protobuf-java", | |
"//tools/error-prone:jFormatString", | |
"//tools/error-prone:dataflow", | |
"//tools/error-prone:nullaway", | |
] | |
kwargs["extra_arguments"] = kwargs.get("extra_arguments", []) + [ | |
"-XDcompilePolicy=simple", | |
"-Xplugin:ErrorProne " + | |
"-XepDisableAllChecks " + # Disable all standard checks because Error Prone is slow. | |
"-Xep:NullAway:ERROR " + # Report NullAway violations as errors and break compilation. | |
"-XepExcludedPaths:.*/(buck-out|generated/source|build/classes)/.* " + # Exclude generated code from ErrorProne analysis. | |
"-XepDisableWarningsInGeneratedCode " + | |
"-XepOpt:NullAway:JarInferEnabled=false " + # Disable jar infer mode. | |
"-XepOpt:NullAway:AnnotatedPackages=com.lyft,me.lyft " + # Packages to check with NullAway. | |
"-XepOpt:NullAway:ExcludedFieldAnnotations=javax.inject.Inject " + | |
"-XepOpt:NullAway:KnownInitializers=" + | |
"com.somepackage.SomeClass.someMethod," + | |
"com.somepackage.AnotherClass.anotherMethod," | |
, | |
] | |
return kwargs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment