From 59b7915177d6b4b3f8b37f4abd8b1a9741155247 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Thu, 9 Aug 2018 14:46:16 -0700 Subject: [PATCH] [infer] rename the severity variants Summary: The `K` prefix does not make sense anymore Reviewed By: mbouaziz Differential Revision: D9230528 fbshipit-source-id: 74ec3dca8 --- infer/src/IR/Errlog.ml | 26 +++++++++--------- infer/src/IR/Exceptions.ml | 42 ++++++++++++++--------------- infer/src/IR/Exceptions.mli | 2 +- infer/src/absint/Checkers.ml | 6 ++--- infer/src/backend/InferPrint.ml | 16 +++++------ infer/src/backend/reporting.ml | 10 +++---- infer/src/clang/ComponentKit.ml | 14 +++++----- infer/src/clang/cFrontend_errors.ml | 12 ++++----- infer/src/concurrency/RacerD.ml | 2 +- infer/src/concurrency/starvation.ml | 2 +- infer/src/eradicate/typeErr.ml | 2 +- 11 files changed, 67 insertions(+), 67 deletions(-) diff --git a/infer/src/IR/Errlog.ml b/infer/src/IR/Errlog.ml index c94a9c170..ab712d246 100644 --- a/infer/src/IR/Errlog.ml +++ b/infer/src/IR/Errlog.ml @@ -115,7 +115,7 @@ module ErrLogHash = struct end (** Type of the error log, to be reset once per function. - Map severity, fotprint / re - execution flag, error name, + Map severity, footprint / re - execution flag, error name, error description, severity, to set of err_data. *) type t = ErrDataSet.t ErrLogHash.t @@ -159,7 +159,7 @@ let size filter (err_log: t) = (** Print errors from error log *) let pp_errors fmt (errlog: t) = let f key _ = - if Exceptions.equal_severity key.severity Exceptions.Kerror then + if Exceptions.equal_severity key.severity Exceptions.Error then F.fprintf fmt "%a@ " IssueType.pp key.err_name in ErrLogHash.iter f errlog @@ -168,7 +168,7 @@ let pp_errors fmt (errlog: t) = (** Print warnings from error log *) let pp_warnings fmt (errlog: t) = let f key _ = - if Exceptions.equal_severity key.severity Exceptions.Kwarning then + if Exceptions.equal_severity key.severity Exceptions.Warning then F.fprintf fmt "%a %a@ " IssueType.pp key.err_name Localise.pp_error_desc key.err_desc in ErrLogHash.iter f errlog @@ -189,17 +189,17 @@ let pp_html source path_to_root fmt (errlog: t) = pp_eds err_datas in F.fprintf fmt "%aERRORS DURING FOOTPRINT@\n" Io_infer.Html.pp_hline () ; - ErrLogHash.iter (pp_err_log true Exceptions.Kerror) errlog ; + ErrLogHash.iter (pp_err_log true Exceptions.Error) errlog ; F.fprintf fmt "%aERRORS DURING RE-EXECUTION@\n" Io_infer.Html.pp_hline () ; - ErrLogHash.iter (pp_err_log false Exceptions.Kerror) errlog ; + ErrLogHash.iter (pp_err_log false Exceptions.Error) errlog ; F.fprintf fmt "%aWARNINGS DURING FOOTPRINT@\n" Io_infer.Html.pp_hline () ; - ErrLogHash.iter (pp_err_log true Exceptions.Kwarning) errlog ; + ErrLogHash.iter (pp_err_log true Exceptions.Warning) errlog ; F.fprintf fmt "%aWARNINGS DURING RE-EXECUTION@\n" Io_infer.Html.pp_hline () ; - ErrLogHash.iter (pp_err_log false Exceptions.Kwarning) errlog ; + ErrLogHash.iter (pp_err_log false Exceptions.Warning) errlog ; F.fprintf fmt "%aINFOS DURING FOOTPRINT@\n" Io_infer.Html.pp_hline () ; - ErrLogHash.iter (pp_err_log true Exceptions.Kinfo) errlog ; + ErrLogHash.iter (pp_err_log true Exceptions.Info) errlog ; F.fprintf fmt "%aINFOS DURING RE-EXECUTION@\n" Io_infer.Html.pp_hline () ; - ErrLogHash.iter (pp_err_log false Exceptions.Kinfo) errlog + ErrLogHash.iter (pp_err_log false Exceptions.Info) errlog (** Add an error description to the error log unless there is @@ -290,7 +290,7 @@ let log_issue procname ?clang_method_kind severity err_log loc (node_id, node_ke "@\n%a@\n@?" (Exceptions.pp_err ~node_key loc severity error.name error.description error.ocaml_pos) () ; - if not (Exceptions.equal_severity severity Exceptions.Kerror) then ( + if not (Exceptions.equal_severity severity Exceptions.Error) then ( let warn_str = let pp fmt = Format.fprintf fmt "%s %a" error.name.IssueType.unique_id Localise.pp_error_desc @@ -300,11 +300,11 @@ let log_issue procname ?clang_method_kind severity err_log loc (node_id, node_ke in let d = match severity with - | Exceptions.Kerror -> + | Exceptions.Error -> L.d_error - | Exceptions.Kwarning -> + | Exceptions.Warning -> L.d_warning - | Exceptions.Kinfo | Exceptions.Kadvice | Exceptions.Klike -> + | Exceptions.Info | Exceptions.Advice | Exceptions.Like -> L.d_info in d warn_str ; L.d_ln () ) diff --git a/infer/src/IR/Exceptions.ml b/infer/src/IR/Exceptions.ml index 4cf36818d..555061021 100644 --- a/infer/src/IR/Exceptions.ml +++ b/infer/src/IR/Exceptions.ml @@ -29,7 +29,7 @@ type err_class = Checker | Prover | Nocat | Linters [@@deriving compare] let equal_err_class = [%compare.equal : err_class] (** severity of the report *) -type severity = Kwarning | Kerror | Kinfo | Kadvice | Klike [@@deriving compare] +type severity = Advice | Error | Info | Like | Warning [@@deriving compare] let equal_severity = [%compare.equal : severity] @@ -178,7 +178,7 @@ let recognize_exception exn = ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer - ; severity= Some Kerror + ; severity= Some Error ; category= Checker } | Array_out_of_bounds_l2 (desc, ocaml_pos) -> { name= IssueType.array_out_of_bounds_l2 @@ -257,7 +257,7 @@ let recognize_exception exn = ; description= desc ; ocaml_pos= None ; visibility= Exn_developer - ; severity= Some Kinfo + ; severity= Some Info ; category= Checker } | Dangling_pointer_dereference (dko, desc, ocaml_pos) -> let visibility = @@ -299,14 +299,14 @@ let recognize_exception exn = ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user - ; severity= Some Kerror + ; severity= Some Error ; category= Checker } | Double_lock (desc, ocaml_pos) -> { name= IssueType.double_lock ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user - ; severity= Some Kerror + ; severity= Some Error ; category= Prover } | Eradicate (kind, desc) -> { name= kind @@ -320,14 +320,14 @@ let recognize_exception exn = ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user - ; severity= Some Kerror + ; severity= Some Error ; category= Prover } | Field_not_null_checked (desc, ocaml_pos) -> { name= IssueType.field_not_null_checked ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user - ; severity= Some Kwarning + ; severity= Some Warning ; category= Nocat } | Frontend_warning ((name, hum), desc, ocaml_pos) -> { name= IssueType.from_string name ?hum @@ -362,7 +362,7 @@ let recognize_exception exn = ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user - ; severity= Some Kerror + ; severity= Some Error ; category= Checker } | Inherently_dangerous_function desc -> { name= IssueType.inherently_dangerous_function @@ -439,7 +439,7 @@ let recognize_exception exn = ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user - ; severity= Some Kwarning + ; severity= Some Warning ; category= Nocat } | Precondition_not_found (desc, ocaml_pos) -> { name= IssueType.precondition_not_found @@ -453,7 +453,7 @@ let recognize_exception exn = ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer - ; severity= Some Kwarning + ; severity= Some Warning ; category= Nocat } (* always a warning *) | Retain_cycle (desc, ocaml_pos) -> @@ -468,7 +468,7 @@ let recognize_exception exn = ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user - ; severity= Some Kerror + ; severity= Some Error ; category= Nocat } | Return_expression_required (desc, ocaml_pos) -> { name= IssueType.return_expression_required @@ -482,7 +482,7 @@ let recognize_exception exn = ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user - ; severity= Some Kerror + ; severity= Some Error ; category= Nocat } | Return_statement_missing (desc, ocaml_pos) -> { name= IssueType.return_statement_missing @@ -517,7 +517,7 @@ let recognize_exception exn = ; description= desc ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user - ; severity= Some Kinfo + ; severity= Some Info ; category= Nocat } (* always an info *) | Symexec_memory_error ocaml_pos -> @@ -596,16 +596,16 @@ let print_exception_html s exn = (** string describing an error kind *) let severity_string = function - | Kwarning -> - "WARNING" - | Kerror -> + | Advice -> + "ADVICE" + | Error -> "ERROR" - | Kinfo -> + | Info -> "INFO" - | Kadvice -> - "ADVICE" - | Klike -> + | Like -> "LIKE" + | Warning -> + "WARNING" (** string describing an error class *) @@ -625,7 +625,7 @@ let print_key = false (** pretty print an error *) let pp_err ~node_key loc severity ex_name desc ocaml_pos_opt fmt () = - let kind = severity_string (if equal_severity severity Kinfo then Kwarning else severity) in + let kind = severity_string (if equal_severity severity Info then Warning else severity) in let pp_key fmt k = if print_key then F.fprintf fmt " key: %s " (Caml.Digest.to_hex k) else () in F.fprintf fmt "%a:%d: %s: %a %a%a%a@\n" SourceFile.pp loc.Location.file loc.Location.line kind IssueType.pp ex_name Localise.pp_error_desc desc pp_key node_key L.pp_ocaml_pos_opt diff --git a/infer/src/IR/Exceptions.mli b/infer/src/IR/Exceptions.mli index 072197bd9..c334b1efd 100644 --- a/infer/src/IR/Exceptions.mli +++ b/infer/src/IR/Exceptions.mli @@ -22,7 +22,7 @@ val equal_visibility : visibility -> visibility -> bool val string_of_visibility : visibility -> string (** severity of the report *) -type severity = Kwarning | Kerror | Kinfo | Kadvice | Klike [@@deriving compare] +type severity = Advice | Error | Info | Like | Warning [@@deriving compare] val equal_severity : severity -> severity -> bool diff --git a/infer/src/absint/Checkers.ml b/infer/src/absint/Checkers.ml index a387654b2..02b995173 100644 --- a/infer/src/absint/Checkers.ml +++ b/infer/src/absint/Checkers.ml @@ -12,13 +12,13 @@ module L = Logging module ST = struct let report_error tenv proc_name proc_desc kind loc ?(field_name= None) ?(origin_loc= None) - ?(exception_kind= fun k d -> Exceptions.Checkers (k, d)) ?(severity= Exceptions.Kwarning) + ?(exception_kind= fun k d -> Exceptions.Checkers (k, d)) ?(severity= Exceptions.Warning) description = let log = match severity with - | Exceptions.Kwarning -> + | Exceptions.Warning -> Reporting.log_warning_deprecated - | Exceptions.Kerror -> + | Exceptions.Error -> Reporting.log_error_deprecated | _ -> L.(die InternalError) "Severity not supported" diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index 82766804c..01642f8de 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -65,7 +65,7 @@ let compute_hash (severity: string) (bug_type: string) (proc_name: Typ.Procname. let loc_trace_to_jsonbug_record trace_list ekind = match ekind with - | Exceptions.Kinfo -> + | Exceptions.Info -> [] | _ -> let trace_item_to_record trace_item = @@ -125,7 +125,7 @@ let summary_values summary = ; verr= Errlog.size (fun severity in_footprint -> - Exceptions.equal_severity severity Exceptions.Kerror && in_footprint ) + Exceptions.equal_severity severity Exceptions.Error && in_footprint ) err_log ; vflags= attributes.ProcAttributes.proc_flags ; vfile= SourceFile.to_string attributes.ProcAttributes.loc.Location.file @@ -165,7 +165,7 @@ let should_report (issue_kind: Exceptions.severity) issue_type error_desc eclass if not Config.filtering || Exceptions.equal_err_class eclass Exceptions.Linters then true else let issue_kind_is_blacklisted = - match issue_kind with Kinfo -> true | Kerror | Kwarning | Kadvice | Klike -> false + match issue_kind with Info -> true | Advice | Error | Like | Warning -> false in if issue_kind_is_blacklisted then false else @@ -474,7 +474,7 @@ module Stats = struct let type_str = key.err_name.IssueType.unique_id in if key.in_footprint && error_filter key.err_name then match key.severity with - | Exceptions.Kerror -> + | Exceptions.Error -> found_errors := true ; stats.nerrors <- stats.nerrors + 1 ; let error_strs = @@ -488,13 +488,13 @@ module Stats = struct in let trace = loc_trace_to_string_list linereader 1 err_data.loc_trace in stats.saved_errors <- List.rev_append (error_strs @ trace @ [""]) stats.saved_errors - | Exceptions.Kwarning -> + | Exceptions.Warning -> stats.nwarnings <- stats.nwarnings + 1 - | Exceptions.Kinfo -> + | Exceptions.Info -> stats.ninfos <- stats.ninfos + 1 - | Exceptions.Kadvice -> + | Exceptions.Advice -> stats.nadvice <- stats.nadvice + 1 - | Exceptions.Klike -> + | Exceptions.Like -> stats.nlikes <- stats.nlikes + 1 in Errlog.iter process_row err_log ; !found_errors diff --git a/infer/src/backend/reporting.ml b/infer/src/backend/reporting.ml index 8c56555de..bcb30cef9 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -78,20 +78,20 @@ let log_issue_deprecated ?(store_summary= false) severity proc_name ?loc ?node_i Typ.Procname.pp proc_name Typ.Procname.pp proc_name -let log_error = log_issue_from_summary Exceptions.Kerror +let log_error = log_issue_from_summary Exceptions.Error -let log_warning = log_issue_from_summary Exceptions.Kwarning +let log_warning = log_issue_from_summary Exceptions.Warning let log_error_deprecated ?(store_summary= false) = - log_issue_deprecated ~store_summary Exceptions.Kerror + log_issue_deprecated ~store_summary Exceptions.Error let log_warning_deprecated ?(store_summary= false) = - log_issue_deprecated ~store_summary Exceptions.Kwarning + log_issue_deprecated ~store_summary Exceptions.Warning let log_info_deprecated ?(store_summary= false) = - log_issue_deprecated ~store_summary Exceptions.Kinfo + log_issue_deprecated ~store_summary Exceptions.Info let log_issue_external procname ?clang_method_kind severity ?loc ?node_id ?session ?ltr diff --git a/infer/src/clang/ComponentKit.ml b/infer/src/clang/ComponentKit.ml index efab04c2a..7254c0c49 100644 --- a/infer/src/clang/ComponentKit.ml +++ b/infer/src/clang/ComponentKit.ml @@ -149,7 +149,7 @@ let mutable_local_vars_advice context an = Some { CIssue.id= "MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE" ; name= None - ; severity= Exceptions.Kadvice + ; severity= Exceptions.Advice ; mode= CIssue.On ; description= "Local variable " ^ MF.monospaced_to_string named_decl_info.ni_name @@ -186,7 +186,7 @@ let component_factory_function_advice context an = Some { CIssue.id= "COMPONENT_FACTORY_FUNCTION" ; name= None - ; severity= Exceptions.Kadvice + ; severity= Exceptions.Advice ; mode= CIssue.Off ; description= "Break out composite components" ; suggestion= @@ -240,7 +240,7 @@ let component_with_unconventional_superclass_advice context an = Some { CIssue.id= "COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS" ; name= None - ; severity= Exceptions.Kadvice + ; severity= Exceptions.Advice ; mode= CIssue.On ; description= "Never Subclass Components" ; suggestion= Some "Instead, create a new subclass of CKCompositeComponent." @@ -300,7 +300,7 @@ let component_with_multiple_factory_methods_advice context an = ~f:(fun meth_decl -> { CIssue.id= "COMPONENT_WITH_MULTIPLE_FACTORY_METHODS" ; name= None - ; severity= Exceptions.Kadvice + ; severity= Exceptions.Advice ; mode= CIssue.On ; description= "Avoid Overrides" ; suggestion= @@ -382,7 +382,7 @@ let rec component_initializer_with_side_effects_advice_ (context: CLintersContex Some { CIssue.id= "COMPONENT_INITIALIZER_WITH_SIDE_EFFECTS" ; name= None - ; severity= Exceptions.Kadvice + ; severity= Exceptions.Advice ; mode= CIssue.On ; description= "No Side-effects" ; suggestion= @@ -420,7 +420,7 @@ let component_file_line_count_info (context: CLintersContext.context) dec = ~f:(fun i -> { CIssue.id= "COMPONENT_FILE_LINE_COUNT" ; name= None - ; severity= Exceptions.Kinfo + ; severity= Exceptions.Info ; mode= CIssue.Off ; description= "Line count analytics" ; suggestion= None @@ -471,7 +471,7 @@ let component_file_cyclomatic_complexity_info (context: CLintersContext.context) Some { CIssue.id= "COMPONENT_FILE_CYCLOMATIC_COMPLEXITY" ; name= None - ; severity= Exceptions.Kinfo + ; severity= Exceptions.Info ; mode= CIssue.Off ; description= "Cyclomatic Complexity Incremental Marker" ; suggestion= None diff --git a/infer/src/clang/cFrontend_errors.ml b/infer/src/clang/cFrontend_errors.ml index aab3bff37..cf94d803f 100644 --- a/infer/src/clang/cFrontend_errors.ml +++ b/infer/src/clang/cFrontend_errors.ml @@ -160,15 +160,15 @@ let remove_new_lines_and_whitespace message = let string_to_severity = function | "WARNING" -> - Exceptions.Kwarning + Exceptions.Warning | "ERROR" -> - Exceptions.Kerror + Exceptions.Error | "INFO" -> - Exceptions.Kinfo + Exceptions.Info | "ADVICE" -> - Exceptions.Kadvice + Exceptions.Advice | "LIKE" -> - Exceptions.Klike + Exceptions.Like | s -> L.die InternalError "Severity %s does not exist" s @@ -207,7 +207,7 @@ let create_parsed_linters linters_def_file checkers : linter list = ; description= "" ; suggestion= None ; loc= Location.dummy - ; severity= Exceptions.Kwarning + ; severity= Exceptions.Warning ; doc_url= None ; mode= CIssue.On } in diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index dc5e66d4f..31a109ba2 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -915,7 +915,7 @@ let is_contaminated access wobbly_paths = let log_issue current_pname ~loc ~ltr ~access exn = - Reporting.log_issue_external current_pname Exceptions.Kerror ~loc ~ltr ~access exn + Reporting.log_issue_external current_pname Exceptions.Error ~loc ~ltr ~access exn let report_thread_safety_violation tenv pdesc ~make_description ~report_kind access thread diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index 5ebda6ab8..ed65a7a00 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -226,7 +226,7 @@ end = struct let log map = let log_report issuetype loc {pname; ltr; message} = let exn = Exceptions.Checkers (issuetype, Localise.verbatim_desc message) in - Reporting.log_issue_external pname Exceptions.Kerror ~loc ~ltr exn + Reporting.log_issue_external pname Exceptions.Error ~loc ~ltr exn in let mk_deduped_report num_of_reports ({message} as report) = { report with diff --git a/infer/src/eradicate/typeErr.ml b/infer/src/eradicate/typeErr.ml index 15bced487..7cd77e9f8 100644 --- a/infer/src/eradicate/typeErr.ml +++ b/infer/src/eradicate/typeErr.ml @@ -213,7 +213,7 @@ let add_err find_canonical_duplicate err_instance instr_ref_opt loc = module Severity = struct let get_severity ia = - if Annotations.ia_ends_with ia Annotations.generated_graphql then Some Exceptions.Kerror + if Annotations.ia_ends_with ia Annotations.generated_graphql then Some Exceptions.Error else None