[infer] better error messages for the nullable checker

Summary: Better error message for the direct dereference of nullable method without intermediate variable.

Reviewed By: sblackshear

Differential Revision: D6244494

fbshipit-source-id: 2ca2d22
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent ebea2a6ba1
commit b2a3f3b8e4

@ -40,10 +40,21 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
Typ.Procname.pp pname Typ.Procname.pp pname
in in
let message = let message =
match ap with
| (Var.LogicalVar _, _), _ ->
(* direct dereference without intermediate variable *)
Format.asprintf Format.asprintf
"Variable %a is indirectly annotated with %a (source %a) and is dereferenced without being checked for null" "The return value of %s is annotated with %a and is dereferenced without being checked for null at %a"
(MF.monospaced_to_string
(Typ.Procname.to_simplified_string ~withclass:true (CallSite.pname call_site)))
MF.pp_monospaced annotation Location.pp loc
| _ ->
(* dereference with intermediate variable *)
Format.asprintf
"Variable %a is indirectly annotated with %a (source %a) and is dereferenced without being checked for null at %a"
(MF.wrap_monospaced AccessPath.pp) (MF.wrap_monospaced AccessPath.pp)
ap MF.pp_monospaced annotation (MF.wrap_monospaced CallSite.pp) call_site ap MF.pp_monospaced annotation (MF.wrap_monospaced CallSite.pp) call_site Location.pp
loc
in in
let exn = Exceptions.Checkers (issue_kind, Localise.verbatim_desc message) in let exn = Exceptions.Checkers (issue_kind, Localise.verbatim_desc message) in
let summary = extras in let summary = extras in

Loading…
Cancel
Save