[report] Print Cost/ConfigImpact json reports only for changed files

Summary: This diff prints cost and config impact checkers' json reports only for the changed files.

Reviewed By: ezgicicek

Differential Revision: D28707192

fbshipit-source-id: d949771f2
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent 11ea6f9ab1
commit 7211e4cfbc

@ -276,17 +276,21 @@ let changed_sources_from_changed_files changed_files =
with _exn -> changed_files_set )
let read_config_changed_files () =
match Config.changed_files_index with
| None ->
None
| Some index -> (
match Utils.read_file index with
| Ok lines ->
Some (changed_sources_from_changed_files lines)
| Error error ->
L.external_error "Error reading the changed files index '%s': %s@." index error ;
None )
let read_config_changed_files =
let result =
lazy
( match Config.changed_files_index with
| None ->
None
| Some index -> (
match Utils.read_file index with
| Ok lines ->
Some (changed_sources_from_changed_files lines)
| Error error ->
L.external_error "Error reading the changed files index '%s': %s@." index error ;
None ) )
in
fun () -> Lazy.force result
module SQLite = struct

@ -325,6 +325,15 @@ end
module JsonConfigImpactPrinter = MakeJsonListPrinter (JsonConfigImpactPrinterElt)
let is_in_changed_files {Location.file} =
match SourceFile.read_config_changed_files () with
| None ->
(* when Config.changed_files_index is not given *)
true
| Some changed_files ->
SourceFile.Set.mem file changed_files
let mk_error_filter filters proc_name file error_name =
(Config.write_html || not (IssueType.(equal skip_function) error_name))
&& filters.Inferconfig.path_filter file
@ -339,7 +348,7 @@ let collect_issues proc_name proc_location err_log issues_acc =
let write_costs proc_name loc cost_opt (outfile : Utils.outfile) =
if not (Cost.is_report_suppressed proc_name) then
if (not (Cost.is_report_suppressed proc_name)) && is_in_changed_files loc then
JsonCostsPrinter.pp outfile.fmt {loc; proc_name; cost_opt}
@ -357,7 +366,7 @@ let get_all_config_fields () =
let write_config_impact all_config_fields proc_name loc config_impact_opt (outfile : Utils.outfile)
=
if ExternalConfigImpactData.is_in_config_data_file proc_name then
if ExternalConfigImpactData.is_in_config_data_file proc_name && is_in_changed_files loc then
let config_impact_opt =
Option.map config_impact_opt
~f:

@ -1 +1 @@
{"top":{"current":0,"previous":0},"unreachable":{"current":0,"previous":0},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":10,"previous":10},{"degree":100,"current":4,"previous":1},{"degree":200,"current":0,"previous":1}]}
{"top":{"current":0,"previous":0},"unreachable":{"current":0,"previous":0},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":10,"previous":7},{"degree":100,"current":4,"previous":0},{"degree":200,"current":0,"previous":1}]}
Loading…
Cancel
Save