remove dynamic severity: Reporting.log_{error,warning} -> log_issue

Summary:
See previous diff: issues are always reported with the same severity so
recognise that and just use their default severity in "modern" checkers.

Reviewed By: ngorogiannis

Differential Revision: D21904591

fbshipit-source-id: fb5387e35
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 682f932150
commit 8a1c10f8a1

@ -65,14 +65,8 @@ let log_issue_from_summary_simplified ?severity_override attrs err_log ~loc ?(lt
~ltr ?extras checker exn
let log_error attrs err_log ~loc ?ltr ?extras checker issue_type error_message =
log_issue_from_summary_simplified ~severity_override:Error attrs err_log ~loc ?ltr ?extras checker
issue_type error_message
let log_warning attrs err_log ~loc ?ltr ?extras checker issue_type error_message =
log_issue_from_summary_simplified ~severity_override:Warning attrs err_log ~loc ?ltr ?extras
checker issue_type error_message
let log_issue attrs err_log ~loc ?ltr ?extras checker issue_type error_message =
log_issue_from_summary_simplified attrs err_log ~loc ?ltr ?extras checker issue_type error_message
let log_issue_external procname ~issue_log ?severity_override ~loc ~ltr ?access ?extras checker

@ -29,11 +29,8 @@ val log_frontend_issue :
Errlog.t -> loc:Location.t -> node_key:Procdesc.NodeKey.t -> ltr:Errlog.loc_trace -> exn -> unit
(** Report a frontend issue of a given kind in the given error log. *)
val log_error : Procdesc.t -> Errlog.t -> loc:Location.t -> log_t
(** Add an error to the given error log. *)
val log_warning : Procdesc.t -> Errlog.t -> loc:Location.t -> log_t
(** Add a warning to the given error log. *)
val log_issue : Procdesc.t -> Errlog.t -> loc:Location.t -> log_t
(** Add an issue to the given error log. *)
val log_issue_external :
Procname.t

@ -37,7 +37,7 @@ module UnusedBranch = struct
if true_branch then IssueType.condition_always_false else IssueType.condition_always_true
in
let ltr = [Errlog.make_trace_element 0 location "Here" []] in
Reporting.log_warning proc_desc err_log ~loc:location ~ltr BufferOverrunChecker issue_type desc
Reporting.log_issue proc_desc err_log ~loc:location ~ltr BufferOverrunChecker issue_type desc
end
module UnusedBranches = struct
@ -54,7 +54,7 @@ module UnreachableStatement = struct
let report {InterproceduralAnalysis.proc_desc; err_log} {location} =
let ltr = [Errlog.make_trace_element 0 location "Here" []] in
Reporting.log_error proc_desc err_log ~loc:location ~ltr BufferOverrunChecker
Reporting.log_issue proc_desc err_log ~loc:location ~ltr BufferOverrunChecker
IssueType.unreachable_code_after "Unreachable code after statement"
end
@ -417,7 +417,7 @@ let report_errors ({InterproceduralAnalysis.proc_desc; err_log} as analysis_data
Trace.Issue.make_err_trace ~description (PO.ConditionTrace.get_val_traces trace)
|> Errlog.concat_traces
in
Reporting.log_error proc_desc err_log ~loc:location ~ltr:trace BufferOverrunChecker issue_type
Reporting.log_issue proc_desc err_log ~loc:location ~ltr:trace BufferOverrunChecker issue_type
(description ~markup:true)
in
PO.ConditionSet.report_errors ~report cond_set

@ -82,7 +82,7 @@ let report_missing_required_prop proc_desc err_log prop parent_typename ~create_
in
Errlog.make_trace_element 0 location call_msg [] )
in
Reporting.log_error proc_desc err_log ~loc:create_loc ~ltr LithoRequiredProps
Reporting.log_issue proc_desc err_log ~loc:create_loc ~ltr LithoRequiredProps
IssueType.missing_required_prop message

@ -240,7 +240,7 @@ module TransferFunctions = struct
(Pvar.pp Pp.text) pvar var_use Location.pp loc
in
let ltr = make_trace_unchecked_strongself domain in
Reporting.log_error proc_desc err_log ~ltr ~loc SelfInBlock
Reporting.log_issue proc_desc err_log ~ltr ~loc SelfInBlock
IssueType.strong_self_not_checked message ;
let strongVars =
StrongEqualToWeakCapturedVars.add pvar
@ -437,7 +437,7 @@ let report_mix_self_weakself_issues proc_desc err_log domain (weakSelf : DomainD
Location.pp self.loc
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error proc_desc err_log ~ltr ~loc:self.loc SelfInBlock IssueType.mixed_self_weakself
Reporting.log_issue proc_desc err_log ~ltr ~loc:self.loc SelfInBlock IssueType.mixed_self_weakself
message
@ -455,7 +455,7 @@ let report_weakself_in_no_escape_block_issues proc_desc err_log domain (weakSelf
(Procname.to_simplified_string procname)
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error proc_desc err_log ~ltr ~loc:weakSelf.loc SelfInBlock
Reporting.log_issue proc_desc err_log ~ltr ~loc:weakSelf.loc SelfInBlock
IssueType.weak_self_in_noescape_block message ;
reported_weak_self_in_noescape_block )
else reported_weak_self_in_noescape_block
@ -473,7 +473,7 @@ let report_weakself_multiple_issue proc_desc err_log domain (weakSelf1 : DomainD
(Pvar.pp Pp.text) weakSelf1.pvar (Pvar.pp Pp.text) weakSelf1.pvar
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error proc_desc err_log ~ltr ~loc:weakSelf1.loc SelfInBlock
Reporting.log_issue proc_desc err_log ~ltr ~loc:weakSelf1.loc SelfInBlock
IssueType.multiple_weakself message
@ -495,7 +495,7 @@ let report_captured_strongself_issue proc_desc err_log domain (capturedStrongSel
(Pvar.pp Pp.text) capturedStrongSelf.pvar Location.pp capturedStrongSelf.loc
in
let ltr = make_trace_captured_strong_self domain in
Reporting.log_error proc_desc err_log ~ltr ~loc:capturedStrongSelf.loc SelfInBlock
Reporting.log_issue proc_desc err_log ~ltr ~loc:capturedStrongSelf.loc SelfInBlock
IssueType.captured_strong_self message ;
report_captured_strongself )
else report_captured_strongself

@ -231,7 +231,7 @@ let report_siof {InterproceduralAnalysis.proc_desc; err_log; analyze_dependency;
GlobalVar.pp (SiofTrace.Sink.kind final_sink)
in
let ltr = SiofTrace.trace_of_error loc gname trace in
Reporting.log_error proc_desc err_log ~loc ~ltr SIOF
Reporting.log_issue proc_desc err_log ~loc ~ltr SIOF
IssueType.static_initialization_order_fiasco description
in
let reportable_paths = SiofTrace.get_reportable_sink_paths trace ~trace_of_pname in

@ -85,7 +85,7 @@ let report_allocation_stack {InterproceduralAnalysis.proc_desc; err_log} src_ann
MF.pp_monospaced ("@" ^ src_annot) MF.pp_monospaced constr_str MF.pp_monospaced
("new " ^ constr_str)
in
Reporting.log_error proc_desc err_log ~loc:fst_call_loc ~ltr:final_trace AnnotationReachability
Reporting.log_issue proc_desc err_log ~loc:fst_call_loc ~ltr:final_trace AnnotationReachability
IssueType.checkers_allocates_memory description
@ -109,7 +109,7 @@ let report_annotation_stack ({InterproceduralAnalysis.proc_desc; err_log} as ana
IssueType.checkers_calls_expensive_method
else IssueType.checkers_annotation_reachability_error
in
Reporting.log_error proc_desc err_log ~loc ~ltr:final_trace AnnotationReachability issue_type
Reporting.log_issue proc_desc err_log ~loc ~ltr:final_trace AnnotationReachability issue_type
description
@ -334,7 +334,7 @@ module CxxAnnotationSpecs = struct
IssueType.register_from_string ~id:spec_name ~doc_url ~linters_def_file Error
AnnotationReachability
in
Reporting.log_error proc_desc err_log ~loc ~ltr:final_trace AnnotationReachability issue_type
Reporting.log_issue proc_desc err_log ~loc ~ltr:final_trace AnnotationReachability issue_type
description
in
let snk_annot = annotation_of_str snk_name in
@ -413,7 +413,7 @@ module ExpensiveAnnotationSpec = struct
(Procname.to_string overridden_pname)
MF.pp_monospaced ("@" ^ Annotations.expensive)
in
Reporting.log_error proc_desc err_log ~loc AnnotationReachability
Reporting.log_issue proc_desc err_log ~loc AnnotationReachability
IssueType.checkers_expensive_overrides_unexpensive description

@ -112,7 +112,7 @@ let report_loads {InterproceduralAnalysis.proc_desc; err_log} astate =
else
let ltr = ClassLoadsDomain.Event.make_loc_trace event in
let msg = Format.asprintf "Class %s loaded" elem in
Reporting.log_warning proc_desc err_log ~loc ~ltr ClassLoads IssueType.class_load msg
Reporting.log_issue proc_desc err_log ~loc ~ltr ClassLoads IssueType.class_load msg
in
let pname = Procdesc.get_proc_name proc_desc in
Procname.get_class_name pname

@ -43,7 +43,7 @@ let report_warning proc_desc err_log class_name fld fld_typ =
(format_method (Procdesc.get_proc_name proc_desc))
pp_m on_create_view pp_m on_destroy_view
in
Reporting.log_warning proc_desc err_log ~loc:(Procdesc.get_loc proc_desc) FragmentRetainsView
Reporting.log_issue proc_desc err_log ~loc:(Procdesc.get_loc proc_desc) FragmentRetainsView
IssueType.checkers_fragment_retain_view description

@ -170,14 +170,14 @@ let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} pulse_summary_opt
F.asprintf "Impure function %a with no pulse summary" Procname.pp proc_name
in
let impure_fun_ltr = Errlog.make_trace_element 0 pname_loc impure_fun_desc [] in
Reporting.log_error proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr] Impurity
Reporting.log_issue proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr] Impurity
IssueType.impure_function impure_fun_desc
| Some [] ->
let impure_fun_desc =
F.asprintf "Impure function %a with empty pulse summary" Procname.pp proc_name
in
let impure_fun_ltr = Errlog.make_trace_element 0 pname_loc impure_fun_desc [] in
Reporting.log_error proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr] Impurity
Reporting.log_issue proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr] Impurity
IssueType.impure_function impure_fun_desc
| Some pre_posts ->
let (ImpurityDomain.{modified_globals; modified_params; skipped_calls} as impurity_astate) =
@ -207,5 +207,5 @@ let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} pulse_summary_opt
:: modified_ltr Formal modified_params
(modified_ltr Global modified_globals skipped_functions)
in
Reporting.log_error proc_desc err_log ~loc:pname_loc ~ltr Impurity IssueType.impure_function
Reporting.log_issue proc_desc err_log ~loc:pname_loc ~ltr Impurity IssueType.impure_function
impure_fun_desc

@ -75,7 +75,7 @@ let report_matching_get proc_desc err_log tenv pvar loop_nodes : unit =
in
let loc = Procdesc.Node.get_loc node in
let ltr = [Errlog.make_trace_element 0 loc exp_desc []] in
Reporting.log_error proc_desc err_log ~loc ~ltr InefficientKeysetIterator
Reporting.log_issue proc_desc err_log ~loc ~ltr InefficientKeysetIterator
IssueType.inefficient_keyset_iterator exp_desc ) ) )
loop_nodes

@ -256,7 +256,7 @@ let checker {IntraproceduralAnalysis.proc_desc; err_log} =
(Typ.pp_full Pp.text) typ
in
let ltr = [Errlog.make_trace_element 0 loc "Write of unused value" []] in
Reporting.log_error proc_desc err_log ~loc ~ltr Liveness IssueType.dead_store message
Reporting.log_issue proc_desc err_log ~loc ~ltr Liveness IssueType.dead_store message
in
let report_dead_store live_vars captured_by_ref_vars = function
| Sil.Store {e1= Lvar pvar; typ; e2= rhs_exp; loc}

@ -111,7 +111,7 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
"%s at line %s: parameter %d is expected to be of type %s but %s was given."
instr_name instr_line n_arg (default_format_type_name ft) gt
in
Reporting.log_error proc_desc err_log ~loc:instr_loc PrintfArgs
Reporting.log_issue proc_desc err_log ~loc:instr_loc PrintfArgs
IssueType.checkers_printf_args description
else check_type_names instr_loc (n_arg + 1) instr_proc_name fs gs
| [], [] ->
@ -121,7 +121,7 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
Printf.sprintf "format string arguments don't mach provided arguments in %s at line %s"
instr_name instr_line
in
Reporting.log_error proc_desc err_log ~loc:instr_loc PrintfArgs
Reporting.log_issue proc_desc err_log ~loc:instr_loc PrintfArgs
IssueType.checkers_printf_args description
in
(* Get the array ivar for a given nvar *)
@ -158,7 +158,7 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
vararg_ivar_type_names
| None ->
if not (Reporting.is_suppressed tenv proc_desc IssueType.checkers_printf_args) then
Reporting.log_warning proc_desc err_log ~loc:cl PrintfArgs
Reporting.log_issue proc_desc err_log ~loc:cl PrintfArgs
IssueType.checkers_printf_args "Format string must be string literal"
with e ->
L.internal_error "%s Exception when analyzing %s: %s@."

@ -201,7 +201,7 @@ let report_errors {InterproceduralAnalysis.proc_desc; err_log} astate_opt =
let loc = Procdesc.get_loc proc_desc in
let exp_desc = F.asprintf "Side-effect free function %a" Procname.pp proc_name in
let ltr = [Errlog.make_trace_element 0 loc exp_desc []] in
Reporting.log_error proc_desc err_log ~loc ~ltr Purity IssueType.pure_function exp_desc
Reporting.log_issue proc_desc err_log ~loc ~ltr Purity IssueType.pure_function exp_desc
| None ->
L.internal_error "Analyzer failed to compute purity information for %a@." Procname.pp
proc_name

@ -78,7 +78,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
access_expr
in
let ltr = [Errlog.make_trace_element 0 loc "" []] in
Reporting.log_error proc_desc err_log ~loc ~ltr Uninit IssueType.uninitialized_value message
Reporting.log_issue proc_desc err_log ~loc ~ltr Uninit IssueType.uninitialized_value message
let is_struct t = match t.Typ.desc with Typ.Tstruct _ -> true | _ -> false

@ -186,7 +186,7 @@ module Check = struct
{CostIssues.unreachable_issue; infinite_issue} =
let report issue suffix =
let message = F.asprintf "%s of the function %a %s" name Procname.pp pname suffix in
Reporting.log_error proc_desc err_log ~loc
Reporting.log_issue proc_desc err_log ~loc
~ltr:(BasicCost.polynomial_traces cost)
~extras:(compute_errlog_extras cost) Cost issue message
in

@ -96,7 +96,7 @@ let do_report extract_cost_if_expensive proc_desc err_log (Call.{pname; loc} as
F.asprintf "%s%s. It can be moved out of the loop at %a." exp_desc cost_msg Location.pp
loop_head_loc
in
Reporting.log_error proc_desc err_log ~loc ~ltr LoopHoisting issue message
Reporting.log_issue proc_desc err_log ~loc ~ltr LoopHoisting issue message
let get_cost_if_expensive tenv integer_type_widths get_callee_cost_summary_and_formals

@ -81,7 +81,7 @@ let report_if_leak {InterproceduralAnalysis.proc_desc; err_log; _} post =
if change_me then
let last_loc = Procdesc.Node.get_loc (Procdesc.get_exit_node proc_desc) in
let message = F.asprintf "Leaked %a resource(s)" ResourceLeakDomain.pp post in
Reporting.log_error proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
Reporting.log_issue proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
IssueType.lab_resource_leak message

@ -83,7 +83,7 @@ let report_if_leak {InterproceduralAnalysis.proc_desc; err_log; _} post =
if ResourceLeakDomain.has_leak post then
let last_loc = Procdesc.Node.get_loc (Procdesc.get_exit_node proc_desc) in
let message = F.asprintf "Leaked %a resource(s)" ResourceLeakDomain.pp post in
Reporting.log_error proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
Reporting.log_issue proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
IssueType.lab_resource_leak message

@ -83,7 +83,7 @@ let report_if_leak {InterproceduralAnalysis.proc_desc; err_log; _} post =
if ResourceLeakDomain.has_leak post then
let last_loc = Procdesc.Node.get_loc (Procdesc.get_exit_node proc_desc) in
let message = F.asprintf "Leaked %a resource(s)" ResourceLeakDomain.pp post in
Reporting.log_error proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
Reporting.log_issue proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
IssueType.lab_resource_leak message

@ -83,7 +83,7 @@ let report_if_leak {InterproceduralAnalysis.proc_desc; err_log; _} post =
if ResourceLeakDomain.has_leak post then
let last_loc = Procdesc.Node.get_loc (Procdesc.get_exit_node proc_desc) in
let message = F.asprintf "Leaked %a resource(s)" ResourceLeakDomain.pp post in
Reporting.log_error proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
Reporting.log_issue proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
IssueType.lab_resource_leak message

@ -96,7 +96,7 @@ let report_if_leak {InterproceduralAnalysis.proc_desc; err_log; _} post =
if ResourceLeakDomain.has_leak post then
let last_loc = Procdesc.Node.get_loc (Procdesc.get_exit_node proc_desc) in
let message = F.asprintf "Leaked %a resource(s)" ResourceLeakDomain.pp post in
Reporting.log_error proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
Reporting.log_issue proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
IssueType.lab_resource_leak message

@ -103,7 +103,7 @@ let report_if_leak {InterproceduralAnalysis.proc_desc; err_log; _} formal_map po
if ResourceLeakDomain.has_leak formal_map post then
let last_loc = Procdesc.Node.get_loc (Procdesc.get_exit_node proc_desc) in
let message = F.asprintf "Leaked %a resource(s)" ResourceLeakDomain.pp post in
Reporting.log_error proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
Reporting.log_issue proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
IssueType.lab_resource_leak message

@ -81,7 +81,7 @@ let report_if_leak {InterproceduralAnalysis.proc_desc; err_log; _} post =
if change_me then
let last_loc = Procdesc.Node.get_loc (Procdesc.get_exit_node proc_desc) in
let message = F.asprintf "Leaked %a resource(s)" ResourceLeakDomain.pp post in
Reporting.log_error proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
Reporting.log_issue proc_desc err_log ~loc:last_loc ResourceLeakLabExercise
IssueType.lab_resource_leak message

@ -14,7 +14,7 @@ open PulseDomainInterface
let report {InterproceduralAnalysis.proc_desc; err_log} diagnostic =
let open Diagnostic in
Reporting.log_error proc_desc err_log ~loc:(get_location diagnostic) ~ltr:(get_trace diagnostic)
Reporting.log_issue proc_desc err_log ~loc:(get_location diagnostic) ~ltr:(get_trace diagnostic)
Pulse (get_issue_type diagnostic) (get_message diagnostic)

@ -298,7 +298,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct
get_short_trace_string initial_source initial_source_caller final_sink final_sink_caller
in
let ltr = source_trace @ List.rev sink_trace in
Reporting.log_error proc_desc err_log ~loc:(CallSite.loc cur_site) ~ltr Quandary issue
Reporting.log_issue proc_desc err_log ~loc:(CallSite.loc cur_site) ~ltr Quandary issue
trace_str
in
List.iter ~f:report_one (TraceDomain.get_reports ~cur_site trace)

@ -282,7 +282,7 @@ let add_errors env proc_desc err_log biabduction_summary =
let property, _vname = ToplAutomaton.vname (Lazy.force automaton) error in
let message = Printf.sprintf "property %s reaches error" property in
tt "WARN@\n" ;
Reporting.log_error proc_desc err_log TOPL IssueType.topl_error ~loc message )
Reporting.log_issue proc_desc err_log TOPL IssueType.topl_error ~loc message )
in
(* Don't warn if [lookup_static_var] fails. *)
Option.iter ~f:handle_state_post_value (lookup_static_var env state_var post)

@ -3,7 +3,7 @@ codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.
codetoanalyze/java/checkers/FragmentRetainsViewExample.java, codetoanalyze.java.checkers.FragmentRetainsViewExample.onDestroyView():void, 0, CHECKERS_FRAGMENT_RETAINS_VIEW, no_bucket, WARNING, []
codetoanalyze/java/checkers/ImmutableCast.java, codetoanalyze.java.checkers.ImmutableCast.badCast(com.google.common.collect.ImmutableList):java.util.List, 0, CHECKERS_IMMUTABLE_CAST, no_bucket, WARNING, [Method badCast(...) returns class com.google.common.collect.ImmutableList but the return type is class java.util.List. Make sure that users of this method do not try to modify the collection.]
codetoanalyze/java/checkers/ImmutableCast.java, codetoanalyze.java.checkers.ImmutableCast.badCastFromField():java.util.List, 0, CHECKERS_IMMUTABLE_CAST, no_bucket, WARNING, [Method badCastFromField() returns class com.google.common.collect.ImmutableList but the return type is class java.util.List. Make sure that users of this method do not try to modify the collection.]
codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.PrintfArgsChecker.formatStringIsNotLiteral(java.io.PrintStream):void, 2, CHECKERS_PRINTF_ARGS, no_bucket, WARNING, []
codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.PrintfArgsChecker.formatStringIsNotLiteral(java.io.PrintStream):void, 2, CHECKERS_PRINTF_ARGS, no_bucket, ERROR, []
codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.PrintfArgsChecker.stringInsteadOfInteger(java.io.PrintStream):void, 1, CHECKERS_PRINTF_ARGS, no_bucket, ERROR, []
codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.PrintfArgsChecker.wrongNumberOfArguments(java.io.PrintStream):void, 1, CHECKERS_PRINTF_ARGS, no_bucket, ERROR, []
codetoanalyze/java/checkers/PrintfArgsChecker.java, codetoanalyze.java.checkers.SuppressedPrintfArgsChecker.classSuppressed(java.io.PrintStream):void, 1, CHECKERS_PRINTF_ARGS, no_bucket, ERROR, []

Loading…
Cancel
Save