[infer][java] skip reports on generated methods

Summary: Assuming generated methods are starting with `$`

Reviewed By: sblackshear

Differential Revision: D5207626

fbshipit-source-id: c516096
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent c51458f7a8
commit 7dd7b460e0

@ -691,6 +691,10 @@ module Procname = {
fun fun
| Java j => String.is_prefix prefix::"lambda$" j.method_name | Java j => String.is_prefix prefix::"lambda$" j.method_name
| _ => false; | _ => false;
let java_is_generated =
fun
| Java j => String.is_prefix prefix::"$" j.method_name
| _ => false;
/** Prints a string of a java procname with the given level of verbosity */ /** Prints a string of a java procname with the given level of verbosity */
let java_to_string ::withclass=false (j: java) verbosity => let java_to_string ::withclass=false (j: java) verbosity =>

@ -416,6 +416,9 @@ module Procname: {
/** Check if the proc name comes from a lambda expression */ /** Check if the proc name comes from a lambda expression */
let java_is_lambda: t => bool; let java_is_lambda: t => bool;
/** Check if the proc name comes from generated code */
let java_is_generated: t => bool;
/** Check if the last parameter is a hidden inner class, and remove it if present. /** Check if the last parameter is a hidden inner class, and remove it if present.
This is used in private constructors, where a proxy constructor is generated This is used in private constructors, where a proxy constructor is generated
with an extra parameter and calls the normal constructor. */ with an extra parameter and calls the normal constructor. */

@ -44,12 +44,16 @@ let log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?linters_
let log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters_def_file exn = let log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters_def_file exn =
let is_generated_method =
Typ.Procname.java_is_generated (Specs.get_proc_name summary) in
let should_suppress_lint = let should_suppress_lint =
Config.curr_language_is Config.Java && Config.curr_language_is Config.Java &&
Annotations.ia_is_suppress_lint Annotations.ia_is_suppress_lint
(fst summary.Specs.attributes.ProcAttributes.method_annotation) in (fst summary.Specs.attributes.ProcAttributes.method_annotation) in
if not should_suppress_lint if should_suppress_lint || is_generated_method
then then
() (* Skip the reporting *)
else
let err_log = summary.Specs.attributes.ProcAttributes.err_log in let err_log = summary.Specs.attributes.ProcAttributes.err_log in
log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?linters_def_file exn log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?linters_def_file exn

@ -152,4 +152,7 @@ public class ReturnNotNullable {
return stream.map(x -> null); // Intentionaly not reporting here return stream.map(x -> null); // Intentionaly not reporting here
} }
Object $generatedReturnsNullOk() {
return null;
}
} }

Loading…
Cancel
Save