[infer] fix the internal confusion between the issue kind and the severity

Summary:
The internal concept of "kind" should in fact be named "severity" to match the convention used by many other tools, whereas the internal concept of "severity", i.e "HIGH", "MEDIUM" and "LOW" was never used and in any case redundant with the concept of "info", "warning", "error".

This diff maps both the "kind" and "severity" fields to value of the form "advice", "info", "warning", and "error" to be able to progressively migrate the code using the "kind" field.

Reviewed By: mbouaziz, jvillard

Differential Revision: D9187978

fbshipit-source-id: 447d89f51
master
Jeremy Dubreil 6 years ago committed by Facebook Github Bot
parent 3767716c86
commit 8a6aa4b1fd

@ -63,11 +63,10 @@ let compute_local_exception_line loc_trace =
type node_id_key = {node_id: int; node_key: Caml.Digest.t} type node_id_key = {node_id: int; node_key: Caml.Digest.t}
type err_key = type err_key =
{ err_kind: Exceptions.err_kind { severity: Exceptions.severity
; in_footprint: bool ; in_footprint: bool
; err_name: IssueType.t ; err_name: IssueType.t
; err_desc: Localise.error_desc ; err_desc: Localise.error_desc }
; severity: string }
[@@deriving compare] [@@deriving compare]
(** Data associated to a specific error *) (** Data associated to a specific error *)
@ -102,13 +101,13 @@ module ErrLogHash = struct
(* NOTE: changing the hash function can change the order in which issues are reported. *) (* NOTE: changing the hash function can change the order in which issues are reported. *)
let hash key = let hash key =
Hashtbl.hash Hashtbl.hash
(key.err_kind, key.in_footprint, key.err_name, Localise.error_desc_hash key.err_desc) (key.severity, key.in_footprint, key.err_name, Localise.error_desc_hash key.err_desc)
let equal key1 key2 = let equal key1 key2 =
[%compare.equal : Exceptions.err_kind * bool * IssueType.t] [%compare.equal : Exceptions.severity * bool * IssueType.t]
(key1.err_kind, key1.in_footprint, key1.err_name) (key1.severity, key1.in_footprint, key1.err_name)
(key2.err_kind, key2.in_footprint, key2.err_name) (key2.severity, key2.in_footprint, key2.err_name)
&& Localise.error_desc_equal key1.err_desc key2.err_desc && Localise.error_desc_equal key1.err_desc key2.err_desc
end end
@ -116,7 +115,7 @@ module ErrLogHash = struct
end end
(** Type of the error log, to be reset once per function. (** Type of the error log, to be reset once per function.
Map err_kind, fotprint / re - execution flag, error name, Map severity, fotprint / re - execution flag, error name,
error description, severity, to set of err_data. *) error description, severity, to set of err_data. *)
type t = ErrDataSet.t ErrLogHash.t type t = ErrDataSet.t ErrLogHash.t
@ -151,7 +150,7 @@ let size filter (err_log: t) =
let count = ref 0 in let count = ref 0 in
ErrLogHash.iter ErrLogHash.iter
(fun key err_datas -> (fun key err_datas ->
if filter key.err_kind key.in_footprint then count := !count + ErrDataSet.cardinal err_datas if filter key.severity key.in_footprint then count := !count + ErrDataSet.cardinal err_datas
) )
err_log ; err_log ;
!count !count
@ -160,7 +159,7 @@ let size filter (err_log: t) =
(** Print errors from error log *) (** Print errors from error log *)
let pp_errors fmt (errlog: t) = let pp_errors fmt (errlog: t) =
let f key _ = let f key _ =
if Exceptions.equal_err_kind key.err_kind Exceptions.Kerror then if Exceptions.equal_severity key.severity Exceptions.Kerror then
F.fprintf fmt "%a@ " IssueType.pp key.err_name F.fprintf fmt "%a@ " IssueType.pp key.err_name
in in
ErrLogHash.iter f errlog ErrLogHash.iter f errlog
@ -169,7 +168,7 @@ let pp_errors fmt (errlog: t) =
(** Print warnings from error log *) (** Print warnings from error log *)
let pp_warnings fmt (errlog: t) = let pp_warnings fmt (errlog: t) =
let f key _ = let f key _ =
if Exceptions.equal_err_kind key.err_kind Exceptions.Kwarning then if Exceptions.equal_severity key.severity Exceptions.Kwarning then
F.fprintf fmt "%a %a@ " IssueType.pp key.err_name Localise.pp_error_desc key.err_desc F.fprintf fmt "%a %a@ " IssueType.pp key.err_name Localise.pp_error_desc key.err_desc
in in
ErrLogHash.iter f errlog ErrLogHash.iter f errlog
@ -185,7 +184,7 @@ let pp_html source path_to_root fmt (errlog: t) =
ErrDataSet.iter (pp_nodeid_session_loc fmt) err_datas ErrDataSet.iter (pp_nodeid_session_loc fmt) err_datas
in in
let pp_err_log do_fp ek key err_datas = let pp_err_log do_fp ek key err_datas =
if Exceptions.equal_err_kind key.err_kind ek && Bool.equal do_fp key.in_footprint then if Exceptions.equal_severity key.severity ek && Bool.equal do_fp key.in_footprint then
F.fprintf fmt "<br>%a %a %a" IssueType.pp key.err_name Localise.pp_error_desc key.err_desc F.fprintf fmt "<br>%a %a %a" IssueType.pp key.err_name Localise.pp_error_desc key.err_desc
pp_eds err_datas pp_eds err_datas
in in
@ -203,17 +202,6 @@ let pp_html source path_to_root fmt (errlog: t) =
ErrLogHash.iter (pp_err_log false Exceptions.Kinfo) errlog ErrLogHash.iter (pp_err_log false Exceptions.Kinfo) errlog
(* I use string in case we want to display a different name to the user*)
let severity_to_str severity =
match severity with
| Exceptions.High ->
"HIGH"
| Exceptions.Medium ->
"MEDIUM"
| Exceptions.Low ->
"LOW"
(** Add an error description to the error log unless there is (** Add an error description to the error log unless there is
one already at the same node + session; return true if added *) one already at the same node + session; return true if added *)
let add_issue tbl err_key (err_datas: ErrDataSet.t) : bool = let add_issue tbl err_key (err_datas: ErrDataSet.t) : bool =
@ -233,11 +221,11 @@ let update errlog_old errlog_new =
ErrLogHash.iter (fun err_key l -> ignore (add_issue errlog_old err_key l)) errlog_new ErrLogHash.iter (fun err_key l -> ignore (add_issue errlog_old err_key l)) errlog_new
let log_issue procname ?clang_method_kind err_kind err_log loc (node_id, node_key) session ltr let log_issue procname ?clang_method_kind severity err_log loc (node_id, node_key) session ltr
?linters_def_file ?doc_url ?access ?extras exn = ?linters_def_file ?doc_url ?access ?extras exn =
let lang = Typ.Procname.get_language procname in let lang = Typ.Procname.get_language procname in
let error = Exceptions.recognize_exception exn in let error = Exceptions.recognize_exception exn in
let err_kind = match error.kind with Some err_kind -> err_kind | _ -> err_kind in let severity = Option.value error.severity ~default:severity in
let hide_java_loc_zero = let hide_java_loc_zero =
(* hide java errors at location zero unless in -developer_mode *) (* hide java errors at location zero unless in -developer_mode *)
not Config.developer_mode && Language.curr_language_is Java && Int.equal loc.Location.line 0 not Config.developer_mode && Language.curr_language_is Java && Int.equal loc.Location.line 0
@ -264,7 +252,7 @@ let log_issue procname ?clang_method_kind err_kind err_log loc (node_id, node_ke
let issue = let issue =
EventLogger.AnalysisIssue EventLogger.AnalysisIssue
{ bug_type= error.name.IssueType.unique_id { bug_type= error.name.IssueType.unique_id
; bug_kind= Exceptions.err_kind_string err_kind ; bug_kind= Exceptions.severity_string severity
; clang_method_kind= (match lang with Language.Clang -> clang_method_kind | _ -> None) ; clang_method_kind= (match lang with Language.Clang -> clang_method_kind | _ -> None)
; exception_triggered_location= error.ocaml_pos ; exception_triggered_location= error.ocaml_pos
; lang= Language.to_explicit_string lang ; lang= Language.to_explicit_string lang
@ -289,11 +277,10 @@ let log_issue procname ?clang_method_kind err_kind err_log loc (node_id, node_ke
; extras } ; extras }
in in
let err_key = let err_key =
{ err_kind { severity
; in_footprint= !Config.footprint ; in_footprint= !Config.footprint
; err_name= error.name ; err_name= error.name
; err_desc= error.description ; err_desc= error.description }
; severity= severity_to_str error.severity }
in in
add_issue err_log err_key (ErrDataSet.singleton err_data) add_issue err_log err_key (ErrDataSet.singleton err_data)
in in
@ -301,9 +288,9 @@ let log_issue procname ?clang_method_kind err_kind err_log loc (node_id, node_ke
let print_now () = let print_now () =
L.(debug Analysis Medium) L.(debug Analysis Medium)
"@\n%a@\n@?" "@\n%a@\n@?"
(Exceptions.pp_err ~node_key loc err_kind error.name error.description error.ocaml_pos) (Exceptions.pp_err ~node_key loc severity error.name error.description error.ocaml_pos)
() ; () ;
if err_kind <> Exceptions.Kerror then ( if not (Exceptions.equal_severity severity Exceptions.Kerror) then (
let warn_str = let warn_str =
let pp fmt = let pp fmt =
Format.fprintf fmt "%s %a" error.name.IssueType.unique_id Localise.pp_error_desc Format.fprintf fmt "%s %a" error.name.IssueType.unique_id Localise.pp_error_desc
@ -312,7 +299,7 @@ let log_issue procname ?clang_method_kind err_kind err_log loc (node_id, node_ke
F.asprintf "%t" pp F.asprintf "%t" pp
in in
let d = let d =
match err_kind with match severity with
| Exceptions.Kerror -> | Exceptions.Kerror ->
L.d_error L.d_error
| Exceptions.Kwarning -> | Exceptions.Kwarning ->

@ -37,11 +37,10 @@ val compute_local_exception_line : loc_trace -> int option
type node_id_key = private {node_id: int; node_key: Caml.Digest.t} type node_id_key = private {node_id: int; node_key: Caml.Digest.t}
type err_key = private type err_key = private
{ err_kind: Exceptions.err_kind { severity: Exceptions.severity
; in_footprint: bool ; in_footprint: bool
; err_name: IssueType.t ; err_name: IssueType.t
; err_desc: Localise.error_desc ; err_desc: Localise.error_desc }
; severity: string }
[@@deriving compare] [@@deriving compare]
(** Data associated to a specific error *) (** Data associated to a specific error *)
@ -87,13 +86,13 @@ val pp_warnings : Format.formatter -> t -> unit
val pp_html : SourceFile.t -> DB.Results_dir.path -> Format.formatter -> t -> unit val pp_html : SourceFile.t -> DB.Results_dir.path -> Format.formatter -> t -> unit
(** Print an error log in html format *) (** Print an error log in html format *)
val size : (Exceptions.err_kind -> bool -> bool) -> t -> int val size : (Exceptions.severity -> bool -> bool) -> t -> int
(** Return the number of elements in the error log which satisfy the filter. *) (** Return the number of elements in the error log which satisfy the filter. *)
val update : t -> t -> unit val update : t -> t -> unit
(** Update an old error log with a new one *) (** Update an old error log with a new one *)
val log_issue : val log_issue :
Typ.Procname.t -> ?clang_method_kind:string -> Exceptions.err_kind -> t -> Location.t Typ.Procname.t -> ?clang_method_kind:string -> Exceptions.severity -> t -> Location.t
-> int * Caml.Digest.t -> int -> loc_trace -> ?linters_def_file:string -> ?doc_url:string -> int * Caml.Digest.t -> int -> loc_trace -> ?linters_def_file:string -> ?doc_url:string
-> ?access:string -> ?extras:Jsonbug_t.extra -> exn -> unit -> ?access:string -> ?extras:Jsonbug_t.extra -> exn -> unit

@ -23,21 +23,15 @@ let string_of_visibility vis =
match vis with Exn_user -> "user" | Exn_developer -> "developer" | Exn_system -> "system" match vis with Exn_user -> "user" | Exn_developer -> "developer" | Exn_system -> "system"
(** severity of bugs *)
type severity =
| High (** high severity bug *)
| Medium (** medium severity bug *)
| Low (** low severity bug *)
(** class of error/warning *) (** class of error/warning *)
type err_class = Checker | Prover | Nocat | Linters [@@deriving compare] type err_class = Checker | Prover | Nocat | Linters [@@deriving compare]
let equal_err_class = [%compare.equal : err_class] let equal_err_class = [%compare.equal : err_class]
(** kind of error/warning *) (** severity of the report *)
type err_kind = Kwarning | Kerror | Kinfo | Kadvice | Klike [@@deriving compare] type severity = Kwarning | Kerror | Kinfo | Kadvice | Klike [@@deriving compare]
let equal_err_kind = [%compare.equal : err_kind] let equal_severity = [%compare.equal : severity]
exception Abduction_case_not_implemented of L.ocaml_pos exception Abduction_case_not_implemented of L.ocaml_pos
@ -151,8 +145,7 @@ type t =
; description: Localise.error_desc ; description: Localise.error_desc
; ocaml_pos: L.ocaml_pos option (** location in the infer source code *) ; ocaml_pos: L.ocaml_pos option (** location in the infer source code *)
; visibility: visibility ; visibility: visibility
; severity: severity ; severity: severity option
; kind: err_kind option
; category: err_class } ; category: err_class }
let recognize_exception exn = let recognize_exception exn =
@ -163,8 +156,7 @@ let recognize_exception exn =
; description= Localise.no_desc ; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Analysis_stops (desc, ocaml_pos_opt) -> | Analysis_stops (desc, ocaml_pos_opt) ->
let visibility = if Config.analysis_stops then Exn_user else Exn_developer in let visibility = if Config.analysis_stops then Exn_user else Exn_developer in
@ -172,40 +164,35 @@ let recognize_exception exn =
; description= desc ; description= desc
; ocaml_pos= ocaml_pos_opt ; ocaml_pos= ocaml_pos_opt
; visibility ; visibility
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Array_of_pointsto ocaml_pos -> | Array_of_pointsto ocaml_pos ->
{ name= IssueType.array_of_pointsto { name= IssueType.array_of_pointsto
; description= Localise.no_desc ; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Array_out_of_bounds_l1 (desc, ocaml_pos) -> | Array_out_of_bounds_l1 (desc, ocaml_pos) ->
{ name= IssueType.array_out_of_bounds_l1 { name= IssueType.array_out_of_bounds_l1
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= High ; severity= Some Kerror
; kind= Some Kerror
; category= Checker } ; category= Checker }
| Array_out_of_bounds_l2 (desc, ocaml_pos) -> | Array_out_of_bounds_l2 (desc, ocaml_pos) ->
{ name= IssueType.array_out_of_bounds_l2 { name= IssueType.array_out_of_bounds_l2
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Array_out_of_bounds_l3 (desc, ocaml_pos) -> | Array_out_of_bounds_l3 (desc, ocaml_pos) ->
{ name= IssueType.array_out_of_bounds_l3 { name= IssueType.array_out_of_bounds_l3
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Assert_failure (f, l, c) -> | Assert_failure (f, l, c) ->
let ocaml_pos = (f, l, c, c) in let ocaml_pos = (f, l, c, c) in
@ -213,48 +200,42 @@ let recognize_exception exn =
; description= Localise.no_desc ; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= High ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Bad_footprint ocaml_pos -> | Bad_footprint ocaml_pos ->
{ name= IssueType.bad_footprint { name= IssueType.bad_footprint
; description= Localise.no_desc ; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Cannot_star ocaml_pos -> | Cannot_star ocaml_pos ->
{ name= IssueType.cannot_star { name= IssueType.cannot_star
; description= Localise.no_desc ; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Class_cast_exception (desc, ocaml_pos) -> | Class_cast_exception (desc, ocaml_pos) ->
{ name= IssueType.class_cast_exception { name= IssueType.class_cast_exception
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Codequery desc -> | Codequery desc ->
{ name= IssueType.codequery { name= IssueType.codequery
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Comparing_floats_for_equality (desc, ocaml_pos) -> | Comparing_floats_for_equality (desc, ocaml_pos) ->
{ name= IssueType.comparing_floats_for_equality { name= IssueType.comparing_floats_for_equality
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Condition_always_true_false (desc, b, ocaml_pos) -> | Condition_always_true_false (desc, b, ocaml_pos) ->
let name = if b then IssueType.condition_always_true else IssueType.condition_always_false in let name = if b then IssueType.condition_always_true else IssueType.condition_always_false in
@ -262,24 +243,21 @@ let recognize_exception exn =
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Custom_error (error_msg, desc) -> | Custom_error (error_msg, desc) ->
{ name= IssueType.from_string error_msg { name= IssueType.from_string error_msg
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Checker } ; category= Checker }
| Dummy_exception desc -> | Dummy_exception desc ->
{ name= IssueType.from_string "Analysis stops" { name= IssueType.from_string "Analysis stops"
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Low ; severity= Some Kinfo
; kind= Some Kinfo
; category= Checker } ; category= Checker }
| Dangling_pointer_dereference (dko, desc, ocaml_pos) -> | Dangling_pointer_dereference (dko, desc, ocaml_pos) ->
let visibility = let visibility =
@ -293,128 +271,112 @@ let recognize_exception exn =
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility ; visibility
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Deallocate_stack_variable desc -> | Deallocate_stack_variable desc ->
{ name= IssueType.deallocate_stack_variable { name= IssueType.deallocate_stack_variable
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Deallocate_static_memory desc -> | Deallocate_static_memory desc ->
{ name= IssueType.deallocate_static_memory { name= IssueType.deallocate_static_memory
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Deallocation_mismatch (desc, ocaml_pos) -> | Deallocation_mismatch (desc, ocaml_pos) ->
{ name= IssueType.deallocation_mismatch { name= IssueType.deallocation_mismatch
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Divide_by_zero (desc, ocaml_pos) -> | Divide_by_zero (desc, ocaml_pos) ->
{ name= IssueType.divide_by_zero { name= IssueType.divide_by_zero
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= Some Kerror
; kind= Some Kerror
; category= Checker } ; category= Checker }
| Double_lock (desc, ocaml_pos) -> | Double_lock (desc, ocaml_pos) ->
{ name= IssueType.double_lock { name= IssueType.double_lock
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= Some Kerror
; kind= Some Kerror
; category= Prover } ; category= Prover }
| Eradicate (kind, desc) -> | Eradicate (kind, desc) ->
{ name= kind { name= kind
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Empty_vector_access (desc, ocaml_pos) -> | Empty_vector_access (desc, ocaml_pos) ->
{ name= IssueType.empty_vector_access { name= IssueType.empty_vector_access
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= Some Kerror
; kind= Some Kerror
; category= Prover } ; category= Prover }
| Field_not_null_checked (desc, ocaml_pos) -> | Field_not_null_checked (desc, ocaml_pos) ->
{ name= IssueType.field_not_null_checked { name= IssueType.field_not_null_checked
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= Some Kwarning
; kind= Some Kwarning
; category= Nocat } ; category= Nocat }
| Frontend_warning ((name, hum), desc, ocaml_pos) -> | Frontend_warning ((name, hum), desc, ocaml_pos) ->
{ name= IssueType.from_string name ?hum { name= IssueType.from_string name ?hum
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= None
; kind= None
; category= Linters } ; category= Linters }
| Checkers (kind, desc) -> | Checkers (kind, desc) ->
{ name= kind { name= kind
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Null_dereference (desc, ocaml_pos) -> | Null_dereference (desc, ocaml_pos) ->
{ name= IssueType.null_dereference { name= IssueType.null_dereference
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Null_test_after_dereference (desc, ocaml_pos) -> | Null_test_after_dereference (desc, ocaml_pos) ->
{ name= IssueType.null_test_after_dereference { name= IssueType.null_test_after_dereference
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Pointer_size_mismatch (desc, ocaml_pos) -> | Pointer_size_mismatch (desc, ocaml_pos) ->
{ name= IssueType.pointer_size_mismatch { name= IssueType.pointer_size_mismatch
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= Some Kerror
; kind= Some Kerror
; category= Checker } ; category= Checker }
| Inherently_dangerous_function desc -> | Inherently_dangerous_function desc ->
{ name= IssueType.inherently_dangerous_function { name= IssueType.inherently_dangerous_function
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Internal_error desc -> | Internal_error desc ->
{ name= IssueType.internal_error { name= IssueType.internal_error
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_developer ; visibility= Exn_developer
; severity= High ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Java_runtime_exception (exn_name, _, desc) -> | Java_runtime_exception (exn_name, _, desc) ->
let exn_str = Typ.Name.name exn_name in let exn_str = Typ.Name.name exn_name in
@ -422,8 +384,7 @@ let recognize_exception exn =
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Leak (fp_part, _, (exn_vis, error_desc), done_array_abstraction, resource, ocaml_pos) -> | Leak (fp_part, _, (exn_vis, error_desc), done_array_abstraction, resource, ocaml_pos) ->
if done_array_abstraction then if done_array_abstraction then
@ -431,16 +392,14 @@ let recognize_exception exn =
; description= error_desc ; description= error_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
else if fp_part then else if fp_part then
{ name= IssueType.leak_in_footprint { name= IssueType.leak_in_footprint
; description= error_desc ; description= error_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
else else
let name = let name =
@ -458,8 +417,7 @@ let recognize_exception exn =
; description= error_desc ; description= error_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= exn_vis ; visibility= exn_vis
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Missing_fld (fld, ocaml_pos) -> | Missing_fld (fld, ocaml_pos) ->
let desc = Localise.verbatim_desc (Typ.Fieldname.to_full_string fld) in let desc = Localise.verbatim_desc (Typ.Fieldname.to_full_string fld) in
@ -467,40 +425,35 @@ let recognize_exception exn =
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Premature_nil_termination (desc, ocaml_pos) -> | Premature_nil_termination (desc, ocaml_pos) ->
{ name= IssueType.premature_nil_termination { name= IssueType.premature_nil_termination
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Parameter_not_null_checked (desc, ocaml_pos) -> | Parameter_not_null_checked (desc, ocaml_pos) ->
{ name= IssueType.parameter_not_null_checked { name= IssueType.parameter_not_null_checked
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= Some Kwarning
; kind= Some Kwarning
; category= Nocat } ; category= Nocat }
| Precondition_not_found (desc, ocaml_pos) -> | Precondition_not_found (desc, ocaml_pos) ->
{ name= IssueType.precondition_not_found { name= IssueType.precondition_not_found
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Precondition_not_met (desc, ocaml_pos) -> | Precondition_not_met (desc, ocaml_pos) ->
{ name= IssueType.precondition_not_met { name= IssueType.precondition_not_met
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Medium ; severity= Some Kwarning
; kind= Some Kwarning
; category= Nocat } ; category= Nocat }
(* always a warning *) (* always a warning *)
| Retain_cycle (desc, ocaml_pos) -> | Retain_cycle (desc, ocaml_pos) ->
@ -508,72 +461,63 @@ let recognize_exception exn =
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Registered_observer_being_deallocated (desc, ocaml_pos) -> | Registered_observer_being_deallocated (desc, ocaml_pos) ->
{ name= IssueType.registered_observer_being_deallocated { name= IssueType.registered_observer_being_deallocated
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= Some Kerror
; kind= Some Kerror
; category= Nocat } ; category= Nocat }
| Return_expression_required (desc, ocaml_pos) -> | Return_expression_required (desc, ocaml_pos) ->
{ name= IssueType.return_expression_required { name= IssueType.return_expression_required
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Stack_variable_address_escape (desc, ocaml_pos) -> | Stack_variable_address_escape (desc, ocaml_pos) ->
{ name= IssueType.stack_variable_address_escape { name= IssueType.stack_variable_address_escape
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= Some Kerror
; kind= Some Kerror
; category= Nocat } ; category= Nocat }
| Return_statement_missing (desc, ocaml_pos) -> | Return_statement_missing (desc, ocaml_pos) ->
{ name= IssueType.return_statement_missing { name= IssueType.return_statement_missing
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Return_value_ignored (desc, ocaml_pos) -> | Return_value_ignored (desc, ocaml_pos) ->
{ name= IssueType.return_value_ignored { name= IssueType.return_value_ignored
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| SymOp.Analysis_failure_exe _ -> | SymOp.Analysis_failure_exe _ ->
{ name= IssueType.failure_exe { name= IssueType.failure_exe
; description= Localise.no_desc ; description= Localise.no_desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_system ; visibility= Exn_system
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Skip_function desc -> | Skip_function desc ->
{ name= IssueType.skip_function { name= IssueType.skip_function
; description= desc ; description= desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Skip_pointer_dereference (desc, ocaml_pos) -> | Skip_pointer_dereference (desc, ocaml_pos) ->
{ name= IssueType.skip_pointer_dereference { name= IssueType.skip_pointer_dereference
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= Some Kinfo
; kind= Some Kinfo
; category= Nocat } ; category= Nocat }
(* always an info *) (* always an info *)
| Symexec_memory_error ocaml_pos -> | Symexec_memory_error ocaml_pos ->
@ -581,56 +525,49 @@ let recognize_exception exn =
; description= Localise.no_desc ; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Unary_minus_applied_to_unsigned_expression (desc, ocaml_pos) -> | Unary_minus_applied_to_unsigned_expression (desc, ocaml_pos) ->
{ name= IssueType.unary_minus_applied_to_unsigned_expression { name= IssueType.unary_minus_applied_to_unsigned_expression
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Unknown_proc -> | Unknown_proc ->
{ name= IssueType.unknown_proc { name= IssueType.unknown_proc
; description= Localise.no_desc ; description= Localise.no_desc
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Unreachable_code_after (desc, ocaml_pos) -> | Unreachable_code_after (desc, ocaml_pos) ->
{ name= IssueType.unreachable_code_after { name= IssueType.unreachable_code_after
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= Medium ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| Unsafe_guarded_by_access (desc, ocaml_pos) -> | Unsafe_guarded_by_access (desc, ocaml_pos) ->
{ name= IssueType.unsafe_guarded_by_access { name= IssueType.unsafe_guarded_by_access
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Use_after_free (desc, ocaml_pos) -> | Use_after_free (desc, ocaml_pos) ->
{ name= IssueType.use_after_free { name= IssueType.use_after_free
; description= desc ; description= desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_user ; visibility= Exn_user
; severity= High ; severity= None
; kind= None
; category= Prover } ; category= Prover }
| Wrong_argument_number ocaml_pos -> | Wrong_argument_number ocaml_pos ->
{ name= IssueType.wrong_argument_number { name= IssueType.wrong_argument_number
; description= Localise.no_desc ; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
| exn -> | exn ->
{ name= IssueType.failure_exe { name= IssueType.failure_exe
@ -638,8 +575,7 @@ let recognize_exception exn =
Localise.verbatim_desc (F.asprintf "%a: %s" Exn.pp exn (Caml.Printexc.get_backtrace ())) Localise.verbatim_desc (F.asprintf "%a: %s" Exn.pp exn (Caml.Printexc.get_backtrace ()))
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_system ; visibility= Exn_system
; severity= Low ; severity= None
; kind= None
; category= Nocat } ; category= Nocat }
@ -659,7 +595,7 @@ let print_exception_html s exn =
(** string describing an error kind *) (** string describing an error kind *)
let err_kind_string = function let severity_string = function
| Kwarning -> | Kwarning ->
"WARNING" "WARNING"
| Kerror -> | Kerror ->
@ -688,8 +624,8 @@ let err_class_string = function
let print_key = false let print_key = false
(** pretty print an error *) (** pretty print an error *)
let pp_err ~node_key loc ekind ex_name desc ocaml_pos_opt fmt () = let pp_err ~node_key loc severity ex_name desc ocaml_pos_opt fmt () =
let kind = err_kind_string (if equal_err_kind ekind Kinfo then Kwarning else ekind) in let kind = severity_string (if equal_severity severity Kinfo then Kwarning else severity) in
let pp_key fmt k = if print_key then F.fprintf fmt " key: %s " (Caml.Digest.to_hex k) else () 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 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 IssueType.pp ex_name Localise.pp_error_desc desc pp_key node_key L.pp_ocaml_pos_opt

@ -21,16 +21,10 @@ val equal_visibility : visibility -> visibility -> bool
val string_of_visibility : visibility -> string val string_of_visibility : visibility -> string
(** severity of bugs *) (** severity of the report *)
type severity = type severity = Kwarning | Kerror | Kinfo | Kadvice | Klike [@@deriving compare]
| High (** high severity bug *)
| Medium (** medium severity bug *)
| Low (** low severity bug *)
(** kind of error/warning *) val equal_severity : severity -> severity -> bool
type err_kind = Kwarning | Kerror | Kinfo | Kadvice | Klike [@@deriving compare]
val equal_err_kind : err_kind -> err_kind -> bool
(** class of error *) (** class of error *)
type err_class = Checker | Prover | Nocat | Linters type err_class = Checker | Prover | Nocat | Linters
@ -153,7 +147,7 @@ exception Wrong_argument_number of Logging.ocaml_pos
val err_class_string : err_class -> string val err_class_string : err_class -> string
(** string describing an error class *) (** string describing an error class *)
val err_kind_string : err_kind -> string val severity_string : severity -> string
(** string describing an error kind *) (** string describing an error kind *)
val handle_exception : exn -> bool val handle_exception : exn -> bool
@ -163,7 +157,7 @@ val print_exception_html : string -> exn -> unit
(** print a description of the exception to the html output *) (** print a description of the exception to the html output *)
val pp_err : val pp_err :
node_key:Caml.Digest.t -> Location.t -> err_kind -> IssueType.t -> Localise.error_desc node_key:Caml.Digest.t -> Location.t -> severity -> IssueType.t -> Localise.error_desc
-> Logging.ocaml_pos option -> Format.formatter -> unit -> unit -> Logging.ocaml_pos option -> Format.formatter -> unit -> unit
(** pretty print an error *) (** pretty print an error *)
@ -172,8 +166,7 @@ type t =
; description: Localise.error_desc ; description: Localise.error_desc
; ocaml_pos: Logging.ocaml_pos option (** location in the infer source code *) ; ocaml_pos: Logging.ocaml_pos option (** location in the infer source code *)
; visibility: visibility ; visibility: visibility
; severity: severity ; severity: severity option
; kind: err_kind option
; category: err_class } ; category: err_class }
val recognize_exception : exn -> t val recognize_exception : exn -> t

@ -13,7 +13,7 @@ module ST : sig
val report_error : val report_error :
Tenv.t -> Typ.Procname.t -> Procdesc.t -> IssueType.t -> Location.t Tenv.t -> Typ.Procname.t -> Procdesc.t -> IssueType.t -> Location.t
-> ?field_name:Typ.Fieldname.t option -> ?origin_loc:Location.t option -> ?field_name:Typ.Fieldname.t option -> ?origin_loc:Location.t option
-> ?exception_kind:(IssueType.t -> Localise.error_desc -> exn) -> ?severity:Exceptions.err_kind -> ?exception_kind:(IssueType.t -> Localise.error_desc -> exn) -> ?severity:Exceptions.severity
-> string -> unit -> string -> unit
(** Report an error. *) (** Report an error. *)
end end

@ -49,8 +49,8 @@ let compute_key (bug_type: string) (proc_name: Typ.Procname.t) (filename: string
String.concat ~sep:"|" [base_filename; simple_procedure_name; bug_type] 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) let compute_hash (severity: string) (bug_type: string) (proc_name: Typ.Procname.t)
(qualifier: string) = (filename: string) (qualifier: string) =
let base_filename = Filename.basename filename in let base_filename = Filename.basename filename in
let hashable_procedure_name = Typ.Procname.hashable_name proc_name in let hashable_procedure_name = Typ.Procname.hashable_name proc_name in
let location_independent_qualifier = let location_independent_qualifier =
@ -59,7 +59,7 @@ let compute_hash (kind: string) (bug_type: string) (proc_name: Typ.Procname.t) (
Str.global_replace (Str.regexp "\\(line \\|column \\|n\\$\\)[0-9]+") "_" qualifier Str.global_replace (Str.regexp "\\(line \\|column \\|n\\$\\)[0-9]+") "_" qualifier
in in
Utils.better_hash Utils.better_hash
(kind, bug_type, hashable_procedure_name, base_filename, location_independent_qualifier) (severity, bug_type, hashable_procedure_name, base_filename, location_independent_qualifier)
|> Caml.Digest.to_hex |> Caml.Digest.to_hex
@ -124,8 +124,8 @@ let summary_values summary =
; vsymop= Summary.Stats.symops stats ; vsymop= Summary.Stats.symops stats
; verr= ; verr=
Errlog.size Errlog.size
(fun ekind in_footprint -> (fun severity in_footprint ->
Exceptions.equal_err_kind ekind Exceptions.Kerror && in_footprint ) Exceptions.equal_severity severity Exceptions.Kerror && in_footprint )
err_log err_log
; vflags= attributes.ProcAttributes.proc_flags ; vflags= attributes.ProcAttributes.proc_flags
; vfile= SourceFile.to_string attributes.ProcAttributes.loc.Location.file ; vfile= SourceFile.to_string attributes.ProcAttributes.loc.Location.file
@ -161,7 +161,7 @@ module ProcsCsv = struct
pp "%s@\n" sv.vproof_trace pp "%s@\n" sv.vproof_trace
end end
let should_report (issue_kind: Exceptions.err_kind) issue_type error_desc eclass = 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 if not Config.filtering || Exceptions.equal_err_class eclass Exceptions.Linters then true
else else
let issue_kind_is_blacklisted = let issue_kind_is_blacklisted =
@ -231,9 +231,9 @@ module IssuesJson = struct
in in
if if
key.in_footprint && error_filter source_file key.err_name && should_report_source_file key.in_footprint && error_filter source_file key.err_name && should_report_source_file
&& should_report key.err_kind key.err_name key.err_desc err_data.err_class && should_report key.severity key.err_name key.err_desc err_data.err_class
then ( then (
let kind = Exceptions.err_kind_string key.err_kind in let severity = Exceptions.severity_string key.severity in
let bug_type = key.err_name.IssueType.unique_id in let bug_type = key.err_name.IssueType.unique_id in
let file = SourceFile.to_string source_file in let file = SourceFile.to_string source_file in
let json_ml_loc = let json_ml_loc =
@ -260,10 +260,10 @@ module IssuesJson = struct
in in
let bug = let bug =
{ Jsonbug_j.bug_class= Exceptions.err_class_string err_data.err_class { Jsonbug_j.bug_class= Exceptions.err_class_string err_data.err_class
; kind ; kind= severity
; bug_type ; bug_type
; qualifier ; qualifier
; severity= key.severity ; severity
; visibility ; visibility
; line= err_data.loc.Location.line ; line= err_data.loc.Location.line
; column= err_data.loc.Location.col ; column= err_data.loc.Location.col
@ -271,10 +271,10 @@ module IssuesJson = struct
; procedure_id= Typ.Procname.to_filename procname ; procedure_id= Typ.Procname.to_filename procname
; procedure_start_line ; procedure_start_line
; file ; file
; bug_trace= loc_trace_to_jsonbug_record err_data.loc_trace key.err_kind ; bug_trace= loc_trace_to_jsonbug_record err_data.loc_trace key.severity
; node_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 ; key= compute_key bug_type procname file
; hash= compute_hash kind bug_type procname file qualifier ; hash= compute_hash severity bug_type procname file qualifier
; dotty= error_desc_to_dotty_string key.err_desc ; dotty= error_desc_to_dotty_string key.err_desc
; infer_source_loc= json_ml_loc ; infer_source_loc= json_ml_loc
; bug_type_hum= key.err_name.IssueType.hum ; bug_type_hum= key.err_name.IssueType.hum
@ -383,7 +383,7 @@ module IssuesTxt = struct
key.in_footprint && error_filter source_file key.err_name key.in_footprint && error_filter source_file key.err_name
&& (not Config.filtering || String.is_empty (censored_reason key.err_name source_file)) && (not Config.filtering || String.is_empty (censored_reason key.err_name source_file))
then then
Exceptions.pp_err ~node_key:err_data.node_id_key.node_key err_data.loc key.err_kind Exceptions.pp_err ~node_key:err_data.node_id_key.node_key err_data.loc key.severity
key.err_name key.err_desc None fmt () key.err_name key.err_desc None fmt ()
@ -473,7 +473,7 @@ module Stats = struct
let process_row (key: Errlog.err_key) (err_data: Errlog.err_data) = let process_row (key: Errlog.err_key) (err_data: Errlog.err_data) =
let type_str = key.err_name.IssueType.unique_id in let type_str = key.err_name.IssueType.unique_id in
if key.in_footprint && error_filter key.err_name then if key.in_footprint && error_filter key.err_name then
match key.err_kind with match key.severity with
| Exceptions.Kerror -> | Exceptions.Kerror ->
found_errors := true ; found_errors := true ;
stats.nerrors <- stats.nerrors + 1 ; stats.nerrors <- stats.nerrors + 1 ;

@ -15,7 +15,7 @@ type log_t =
type log_issue_from_errlog = Errlog.t -> log_t type log_issue_from_errlog = Errlog.t -> log_t
let log_issue_from_errlog procname ?clang_method_kind err_kind err_log ?loc ?node_id ?session ?ltr let log_issue_from_errlog procname ?clang_method_kind severity err_log ?loc ?node_id ?session ?ltr
?linters_def_file ?doc_url ?access ?extras exn = ?linters_def_file ?doc_url ?access ?extras exn =
let clang_method_kind = let clang_method_kind =
Option.map clang_method_kind ~f:ProcAttributes.string_of_clang_method_kind Option.map clang_method_kind ~f:ProcAttributes.string_of_clang_method_kind
@ -34,11 +34,11 @@ let log_issue_from_errlog procname ?clang_method_kind err_kind err_log ?loc ?nod
match session with None -> (State.get_session () :> int) | Some session -> session match session with None -> (State.get_session () :> int) | Some session -> session
in in
let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in
Errlog.log_issue procname ?clang_method_kind err_kind err_log loc node_id session ltr Errlog.log_issue procname ?clang_method_kind severity err_log loc node_id session ltr
?linters_def_file ?doc_url ?access ?extras exn ?linters_def_file ?doc_url ?access ?extras exn
let log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters_def_file ?doc_url let log_issue_from_summary severity summary ?loc ?node_id ?session ?ltr ?linters_def_file ?doc_url
?access ?extras exn = ?access ?extras exn =
let attrs = Summary.get_attributes summary in let attrs = Summary.get_attributes summary in
let procname = attrs.proc_name in let procname = attrs.proc_name in
@ -58,15 +58,15 @@ let log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters
if should_suppress_lint || is_java_generated_method then () (* Skip the reporting *) if should_suppress_lint || is_java_generated_method then () (* Skip the reporting *)
else else
let err_log = Summary.get_err_log summary in let err_log = Summary.get_err_log summary in
log_issue_from_errlog procname ~clang_method_kind err_kind err_log ?loc ?node_id ?session ?ltr log_issue_from_errlog procname ~clang_method_kind severity err_log ?loc ?node_id ?session ?ltr
?linters_def_file ?doc_url ?access ?extras exn ?linters_def_file ?doc_url ?access ?extras exn
let log_issue_deprecated ?(store_summary= false) err_kind proc_name ?loc ?node_id ?session ?ltr let log_issue_deprecated ?(store_summary= false) severity proc_name ?loc ?node_id ?session ?ltr
?linters_def_file ?doc_url ?access ?extras:_ exn = ?linters_def_file ?doc_url ?access ?extras:_ exn =
match Summary.get proc_name with match Summary.get proc_name with
| Some summary -> | Some summary ->
log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters_def_file log_issue_from_summary severity summary ?loc ?node_id ?session ?ltr ?linters_def_file
?doc_url ?access exn ; ?doc_url ?access exn ;
if store_summary then if store_summary then
(* TODO (#16348004): This is currently needed as ThreadSafety works as a cluster checker *) (* TODO (#16348004): This is currently needed as ThreadSafety works as a cluster checker *)
@ -94,10 +94,10 @@ let log_info_deprecated ?(store_summary= false) =
log_issue_deprecated ~store_summary Exceptions.Kinfo log_issue_deprecated ~store_summary Exceptions.Kinfo
let log_issue_external procname ?clang_method_kind err_kind ?loc ?node_id ?session ?ltr let log_issue_external procname ?clang_method_kind severity ?loc ?node_id ?session ?ltr
?linters_def_file ?doc_url ?access ?extras exn = ?linters_def_file ?doc_url ?access ?extras exn =
let errlog = IssueLog.get_errlog procname in let errlog = IssueLog.get_errlog procname in
log_issue_from_errlog procname ?clang_method_kind err_kind errlog ?loc ?node_id ?session ?ltr log_issue_from_errlog procname ?clang_method_kind severity errlog ?loc ?node_id ?session ?ltr
?linters_def_file ?doc_url ?access ?extras exn ?linters_def_file ?doc_url ?access ?extras exn

@ -32,7 +32,7 @@ val log_info_deprecated : ?store_summary:bool -> Typ.Procname.t -> log_t
Use log_info instead *) Use log_info instead *)
val log_issue_from_errlog : val log_issue_from_errlog :
Typ.Procname.t -> ?clang_method_kind:ProcAttributes.clang_method_kind -> Exceptions.err_kind Typ.Procname.t -> ?clang_method_kind:ProcAttributes.clang_method_kind -> Exceptions.severity
-> log_issue_from_errlog -> log_issue_from_errlog
(** Report an issue of a given kind in the given error log. *) (** Report an issue of a given kind in the given error log. *)
@ -43,7 +43,7 @@ val log_warning : Summary.t -> log_t
(** Add an warning to the given summary. *) (** Add an warning to the given summary. *)
val log_issue_external : val log_issue_external :
Typ.Procname.t -> ?clang_method_kind:ProcAttributes.clang_method_kind -> Exceptions.err_kind Typ.Procname.t -> ?clang_method_kind:ProcAttributes.clang_method_kind -> Exceptions.severity
-> log_t -> log_t
(** Log an issue to the error log in [IssueLog] associated with the given procname. *) (** Log an issue to the error log in [IssueLog] associated with the given procname. *)

@ -158,7 +158,7 @@ let remove_new_lines_and_whitespace message =
String.concat words ~sep:" " String.concat words ~sep:" "
let string_to_err_kind = function let string_to_severity = function
| "WARNING" -> | "WARNING" ->
Exceptions.Kwarning Exceptions.Kwarning
| "ERROR" -> | "ERROR" ->
@ -221,7 +221,7 @@ let create_parsed_linters linters_def_file checkers : linter list =
| CDesc (av, sugg) when ALVar.is_suggestion_keyword av -> | CDesc (av, sugg) when ALVar.is_suggestion_keyword av ->
({issue with suggestion= Some sugg}, cond, wl_paths, bl_paths) ({issue with suggestion= Some sugg}, cond, wl_paths, bl_paths)
| CDesc (av, sev) when ALVar.is_severity_keyword av -> | CDesc (av, sev) when ALVar.is_severity_keyword av ->
({issue with severity= string_to_err_kind sev}, cond, wl_paths, bl_paths) ({issue with severity= string_to_severity sev}, cond, wl_paths, bl_paths)
| CDesc (av, m) when ALVar.is_mode_keyword av -> | CDesc (av, m) when ALVar.is_mode_keyword av ->
({issue with mode= string_to_issue_mode m}, cond, wl_paths, bl_paths) ({issue with mode= string_to_issue_mode m}, cond, wl_paths, bl_paths)
| CDesc (av, doc) when ALVar.is_doc_url_keyword av -> | CDesc (av, doc) when ALVar.is_doc_url_keyword av ->
@ -449,7 +449,6 @@ let log_frontend_issue method_decl_opt (node: Ctl_parser_types.ast_node)
in in
let exn = Exceptions.Frontend_warning ((issue_desc.id, issue_desc.name), err_desc, __POS__) in let exn = Exceptions.Frontend_warning ((issue_desc.id, issue_desc.name), err_desc, __POS__) in
let trace = [Errlog.make_trace_element 0 issue_desc.loc "" []] in let trace = [Errlog.make_trace_element 0 issue_desc.loc "" []] in
let err_kind = issue_desc.severity in
let key_str = let key_str =
match node with match node with
| Decl dec -> | Decl dec ->
@ -458,8 +457,8 @@ let log_frontend_issue method_decl_opt (node: Ctl_parser_types.ast_node)
CAst_utils.generate_key_stmt st CAst_utils.generate_key_stmt st
in in
let key = Utils.better_hash key_str in let key = Utils.better_hash key_str in
Reporting.log_issue_from_errlog procname err_kind errlog exn ~loc:issue_desc.loc ~ltr:trace Reporting.log_issue_from_errlog procname issue_desc.severity errlog exn ~loc:issue_desc.loc
~node_id:(0, key) ?linters_def_file ?doc_url:issue_desc.doc_url ~ltr:trace ~node_id:(0, key) ?linters_def_file ?doc_url:issue_desc.doc_url
let fill_issue_desc_info_and_log context ~witness ~current_node (issue_desc: CIssue.issue_desc) let fill_issue_desc_info_and_log context ~witness ~current_node (issue_desc: CIssue.issue_desc)

@ -21,7 +21,7 @@ type issue_desc =
by removing underscores and capitalizing first letters of words *) by removing underscores and capitalizing first letters of words *)
loc: Location.t loc: Location.t
; (* location in the code *) ; (* location in the code *)
severity: Exceptions.err_kind severity: Exceptions.severity
; suggestion: string option ; suggestion: string option
(* an optional suggestion or correction *) } (* an optional suggestion or correction *) }
@ -30,7 +30,7 @@ let string_of_mode m = match m with On -> "On" | Off -> "Off"
let pp_issue fmt issue = let pp_issue fmt issue =
Format.fprintf fmt "{@\n Id = %s@\n" issue.id ; Format.fprintf fmt "{@\n Id = %s@\n" issue.id ;
Format.fprintf fmt "{ Name = %s@\n" (Option.value ~default:"" issue.name) ; Format.fprintf fmt "{ Name = %s@\n" (Option.value ~default:"" issue.name) ;
Format.fprintf fmt " Severity = %s@\n" (Exceptions.err_kind_string issue.severity) ; Format.fprintf fmt " Severity = %s@\n" (Exceptions.severity_string issue.severity) ;
Format.fprintf fmt " Mode = %s@\n" (string_of_mode issue.mode) ; Format.fprintf fmt " Mode = %s@\n" (string_of_mode issue.mode) ;
Format.fprintf fmt " Description = %s@\n" issue.description ; Format.fprintf fmt " Description = %s@\n" issue.description ;
Format.fprintf fmt " Suggestion = %s@\n" (Option.value ~default:"" issue.suggestion) ; Format.fprintf fmt " Suggestion = %s@\n" (Option.value ~default:"" issue.suggestion) ;

@ -21,7 +21,7 @@ type issue_desc =
by removing underscores and capitalizing first letters of words *) by removing underscores and capitalizing first letters of words *)
loc: Location.t loc: Location.t
; (* location in the code *) ; (* location in the code *)
severity: Exceptions.err_kind severity: Exceptions.severity
; suggestion: string option ; suggestion: string option
(* an optional suggestion or correction *) } (* an optional suggestion or correction *) }

@ -233,7 +233,7 @@ module Severity = struct
None None
let err_instance_get_severity tenv err_instance : Exceptions.err_kind option = let err_instance_get_severity tenv err_instance : Exceptions.severity option =
match err_instance with match err_instance with
| Call_receiver_annotation_inconsistent (AnnotatedSignature.Nullable, _, _, origin_descr) | Call_receiver_annotation_inconsistent (AnnotatedSignature.Nullable, _, _, origin_descr)
| Null_field_access (_, _, origin_descr, _) -> | Null_field_access (_, _, origin_descr, _) ->
@ -247,7 +247,7 @@ end
type st_report_error = type st_report_error =
Typ.Procname.t -> Procdesc.t -> IssueType.t -> Location.t -> ?field_name:Typ.Fieldname.t option Typ.Procname.t -> Procdesc.t -> IssueType.t -> Location.t -> ?field_name:Typ.Fieldname.t option
-> ?origin_loc:Location.t option -> ?exception_kind:(IssueType.t -> Localise.error_desc -> exn) -> ?origin_loc:Location.t option -> ?exception_kind:(IssueType.t -> Localise.error_desc -> exn)
-> ?severity:Exceptions.err_kind -> string -> unit -> ?severity:Exceptions.severity -> string -> unit
(** Report an error right now. *) (** Report an error right now. *)
let report_error_now tenv (st_report_error: st_report_error) err_instance loc pdesc : unit = let report_error_now tenv (st_report_error: st_report_error) err_instance loc pdesc : unit =

@ -67,7 +67,7 @@ val node_reset_forall : Procdesc.Node.t -> unit
type st_report_error = type st_report_error =
Typ.Procname.t -> Procdesc.t -> IssueType.t -> Location.t -> ?field_name:Typ.Fieldname.t option Typ.Procname.t -> Procdesc.t -> IssueType.t -> Location.t -> ?field_name:Typ.Fieldname.t option
-> ?origin_loc:Location.t option -> ?exception_kind:(IssueType.t -> Localise.error_desc -> exn) -> ?origin_loc:Location.t option -> ?exception_kind:(IssueType.t -> Localise.error_desc -> exn)
-> ?severity:Exceptions.err_kind -> string -> unit -> ?severity:Exceptions.severity -> string -> unit
val report_error : val report_error :
Tenv.t -> st_report_error -> (Procdesc.Node.t -> Procdesc.Node.t) -> err_instance Tenv.t -> st_report_error -> (Procdesc.Node.t -> Procdesc.Node.t) -> err_instance

Loading…
Cancel
Save