[nullsafe] Store method name and param types in output json

Summary:
They are indirectly encoded in "procedure" field already, but:
1/ To extract name and params one needs to parse the procedure on the
client side
2/ We already have class, package, and field: method and its params is a
consistent change

Reviewed By: artempyanykh

Differential Revision: D24731064

fbshipit-source-id: fae478e7e
master
Mitya Lyubarskiy 4 years ago committed by Facebook GitHub Bot
parent c3f1ff0386
commit 4aea679d30

@ -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 *)

@ -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

@ -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

Loading…
Cancel
Save