[infer] use the key field as a simple mean to identify bugs independently form the analysis or version of Infer

Reviewed By: sblackshear

Differential Revision: D7345234

fbshipit-source-id: 9b23b27
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent 7c7b239248
commit 3784b7eca7

@ -29,6 +29,7 @@ type jsonbug = {
file : string;
bug_trace : json_trace_item list;
key : string;
node_key : string;
hash : string;
?dotty : string option;
?infer_source_loc: loc option;

@ -124,8 +124,8 @@ let skip_duplicated_types_on_filenames renamings (diff: Differential.t) : Differ
in
let cmp ((issue1, _) as issue_with_previous_file1) ((issue2, _) as issue_with_previous_file2) =
[%compare : Caml.Digest.t * string * issue_file_with_renaming]
(issue1.Jsonbug_t.key, issue1.Jsonbug_t.bug_type, issue_with_previous_file1)
(issue2.Jsonbug_t.key, issue2.Jsonbug_t.bug_type, issue_with_previous_file2)
(issue1.Jsonbug_t.node_key, issue1.Jsonbug_t.bug_type, issue_with_previous_file1)
(issue2.Jsonbug_t.node_key, issue2.Jsonbug_t.bug_type, issue_with_previous_file2)
in
let introduced, preexisting, fixed =
(* All comparisons will be made against filenames *before* renamings.

@ -45,7 +45,13 @@ let error_desc_to_plain_string error_desc =
let error_desc_to_dotty_string error_desc = Localise.error_desc_get_dotty error_desc
let compute_hash (kind: string) (type_str: string) (proc_name: Typ.Procname.t) (filename: string)
let compute_key (bug_type: string) (proc_name: Typ.Procname.t) (filename: string) =
let base_filename = Filename.basename filename
and simple_procedure_name = Typ.Procname.get_method proc_name in
String.concat ~sep:"|" [base_filename; simple_procedure_name; bug_type]
let compute_hash (kind: string) (bug_type: string) (proc_name: Typ.Procname.t) (filename: string)
(qualifier: string) =
let base_filename = Filename.basename filename in
let hashable_procedure_name = Typ.Procname.hashable_name proc_name in
@ -55,7 +61,7 @@ let compute_hash (kind: string) (type_str: string) (proc_name: Typ.Procname.t) (
Str.global_replace (Str.regexp "\\(line \\|column \\|n\\$\\)[0-9]+") "_" qualifier
in
Utils.better_hash
(kind, type_str, hashable_procedure_name, base_filename, location_independent_qualifier)
(kind, bug_type, hashable_procedure_name, base_filename, location_independent_qualifier)
|> Caml.Digest.to_hex
@ -266,7 +272,8 @@ module IssuesJson = struct
; procedure_start_line
; file
; bug_trace= loc_trace_to_jsonbug_record err_data.loc_trace key.err_kind
; key= err_data.node_id_key.node_key |> Caml.Digest.to_hex
; node_key= err_data.node_id_key.node_key |> Caml.Digest.to_hex
; key= compute_key bug_type procname file
; hash= compute_hash kind bug_type procname file qualifier
; dotty= error_desc_to_dotty_string key.err_desc
; infer_source_loc= json_ml_loc

@ -13,8 +13,9 @@ let create_fake_jsonbug ?(bug_class= "bug_class") ?(kind= "kind") ?(bug_type= "b
?(qualifier= "qualifier") ?(severity= "severity") ?(visibility= "visibility") ?(line= 1)
?(column= 1) ?(procedure= "procedure") ?(procedure_id= "procedure_id")
?(procedure_start_line= 1) ?(file= "file/at/a/certain/path.java") ?(bug_trace= [])
?(key= "1234") ?(hash= "1") ?(dotty= None) ?(infer_source_loc= None)
?(linters_def_file= Some "file/at/certain/path.al") ?doc_url () : Jsonbug_t.jsonbug =
?(node_key= "File|method|TYPE") ?(key= "1234") ?(hash= "1") ?(dotty= None)
?(infer_source_loc= None) ?(linters_def_file= Some "file/at/certain/path.al") ?doc_url ()
: Jsonbug_t.jsonbug =
{ bug_class
; kind
; bug_type
@ -28,6 +29,7 @@ let create_fake_jsonbug ?(bug_class= "bug_class") ?(kind= "kind") ?(bug_type= "b
; procedure_start_line
; file
; bug_trace
; node_key
; key
; hash
; dotty

Loading…
Cancel
Save