diff --git a/infer/src/atd/jsonbug.atd b/infer/src/atd/jsonbug.atd index 026e1115f..cc5751b6b 100644 --- a/infer/src/atd/jsonbug.atd +++ b/infer/src/atd/jsonbug.atd @@ -62,9 +62,15 @@ type field_name = { field: string; } +type issue_method = { + name: string; + params: string list; +} + type nullsafe_extra = { class_name: string; package: string nullable; + ?method_info: issue_method option; (* The method the issue is detected on. Not present for issues not associated with a method (e.g. meta issues) *) ?field: field_name option; (* For field-specific issues (e.g. Field Not Nullable and Field Not Initialized). *) ?nullable_methods: method_info list option; (* If the issue is related to unsafe use of methods being nullable, here's the list of them *) ?unvetted_3rd_party: string list option; (* If the issue is related to the use of a not yet registered third-party methods, here's the list of their signatures *) diff --git a/infer/src/nullsafe/ClassLevelAnalysis.ml b/infer/src/nullsafe/ClassLevelAnalysis.ml index 74c9545cc..c995f59bd 100644 --- a/infer/src/nullsafe/ClassLevelAnalysis.ml +++ b/infer/src/nullsafe/ClassLevelAnalysis.ml @@ -186,6 +186,7 @@ let report_meta_issue_for_top_level_class tenv source_file class_name class_stru Jsonbug_t. { class_name ; package + ; method_info= None ; meta_issue_info= Some meta_issue_info ; unvetted_3rd_party= None ; nullable_methods= None @@ -218,6 +219,7 @@ let analyze_nullsafe_annotations tenv source_file class_name class_struct issue_ Jsonbug_t. { class_name ; package + ; method_info= None ; meta_issue_info= None ; unvetted_3rd_party= None ; nullable_methods= None @@ -266,6 +268,7 @@ let report_annotation_graph source_file class_name class_struct annotation_graph Jsonbug_t. { class_name ; package + ; method_info= None ; meta_issue_info= None ; unvetted_3rd_party= None ; nullable_methods= None diff --git a/infer/src/nullsafe/NullsafeIssue.ml b/infer/src/nullsafe/NullsafeIssue.ml index a1a370d0a..d58d07c13 100644 --- a/infer/src/nullsafe/NullsafeIssue.ml +++ b/infer/src/nullsafe/NullsafeIssue.ml @@ -86,6 +86,8 @@ let to_nullable_method_json nullable_methods = ; call_line= call_loc.Location.line } ) +let java_type_to_string java_type = Pp.string_of_pp (Typ.pp_java ~verbose:true) java_type + let get_nullsafe_extra {third_party_dependent_methods; nullable_methods; field_name} proc_name = let class_name = Procname.Java.get_simple_class_name proc_name in let package = Procname.Java.get_package proc_name in @@ -110,9 +112,12 @@ let get_nullsafe_extra {third_party_dependent_methods; nullable_methods; field_n ; package_name= JavaClassName.package java_class_name ; field } ) in + let method_params = Procname.Java.get_parameters proc_name |> List.map ~f:java_type_to_string in + let method_info = Jsonbug_t.{name= Procname.Java.get_method proc_name; params= method_params} in Jsonbug_t. { class_name ; package + ; method_info= Some method_info ; meta_issue_info= None ; unvetted_3rd_party ; nullable_methods