diff --git a/infer/src/atd/jsonbug.atd b/infer/src/atd/jsonbug.atd index a5ae04b71..a3278412c 100644 --- a/infer/src/atd/jsonbug.atd +++ b/infer/src/atd/jsonbug.atd @@ -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; diff --git a/infer/src/backend/DifferentialFilters.ml b/infer/src/backend/DifferentialFilters.ml index 3b6c432e2..8757a537e 100644 --- a/infer/src/backend/DifferentialFilters.ml +++ b/infer/src/backend/DifferentialFilters.ml @@ -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. diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index 66d95aad5..5cec9f77b 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -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 diff --git a/infer/src/unit/DifferentialTestsUtils.ml b/infer/src/unit/DifferentialTestsUtils.ml index 3a2b388ba..49a2f35ce 100644 --- a/infer/src/unit/DifferentialTestsUtils.ml +++ b/infer/src/unit/DifferentialTestsUtils.ml @@ -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