From 1a4316065a1de9cf629e274d1afa9961c803b8e5 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Tue, 21 Nov 2017 17:53:31 -0800 Subject: [PATCH] [infer] no longer create the CSV report Reviewed By: mbouaziz Differential Revision: D6356859 fbshipit-source-id: 2797c03 --- infer/lib/python/inferlib/analyze.py | 6 -- infer/lib/python/inferlib/colorize.py | 1 + infer/lib/python/inferlib/issues.py | 1 - infer/lib/python/inferlib/utils.py | 3 - infer/lib/python/report.py | 5 +- infer/src/backend/InferPrint.ml | 115 ++------------------------ infer/src/backend/InferPrint.mli | 2 +- infer/src/backend/infer.ml | 3 +- infer/src/base/Config.ml | 11 +-- infer/src/base/Config.mli | 2 - infer/src/integration/Driver.ml | 8 +- 11 files changed, 17 insertions(+), 140 deletions(-) diff --git a/infer/lib/python/inferlib/analyze.py b/infer/lib/python/inferlib/analyze.py index 19fccdaa1..3b2e941d5 100644 --- a/infer/lib/python/inferlib/analyze.py +++ b/infer/lib/python/inferlib/analyze.py @@ -11,17 +11,11 @@ from __future__ import print_function from __future__ import unicode_literals import argparse -import csv import multiprocessing -import sys from . import config, utils -# Increase the limit of the CSV parser to sys.maxlimit -csv.field_size_limit(sys.maxsize) - - base_parser = argparse.ArgumentParser(add_help=False) base_group = base_parser.add_argument_group('global arguments') base_group.add_argument('-o', '--out', metavar='', diff --git a/infer/lib/python/inferlib/colorize.py b/infer/lib/python/inferlib/colorize.py index 683e02eab..ecd1fa64a 100644 --- a/infer/lib/python/inferlib/colorize.py +++ b/infer/lib/python/inferlib/colorize.py @@ -29,6 +29,7 @@ def terminal_only(s): return '' return s + BLUE = terminal_only('\033[34m') BLUE_BG = terminal_only('\033[44m') MAGENTA = terminal_only('\033[35m') diff --git a/infer/lib/python/inferlib/issues.py b/infer/lib/python/inferlib/issues.py index 60a503839..0efb943e7 100644 --- a/infer/lib/python/inferlib/issues.py +++ b/infer/lib/python/inferlib/issues.py @@ -102,7 +102,6 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None, utils.stderr(msg) return msg - text_errors_list = [] for report in reports[:limit]: filename = report[JSON_INDEX_FILENAME] diff --git a/infer/lib/python/inferlib/utils.py b/infer/lib/python/inferlib/utils.py index c64858f8f..38b6e51c8 100644 --- a/infer/lib/python/inferlib/utils.py +++ b/infer/lib/python/inferlib/utils.py @@ -12,9 +12,6 @@ from __future__ import unicode_literals import argparse import codecs -import csv -import fnmatch -import gzip import json import logging import os diff --git a/infer/lib/python/report.py b/infer/lib/python/report.py index 9439642d6..ce878a185 100755 --- a/infer/lib/python/report.py +++ b/infer/lib/python/report.py @@ -13,14 +13,11 @@ from __future__ import print_function from __future__ import unicode_literals import argparse -import os import sys -from inferlib import config, issues, utils +from inferlib import issues, utils arg_parser = argparse.ArgumentParser(add_help=False) -arg_parser.add_argument('--issues-csv', metavar='', - help='Location of the csv report (ignored for now)') arg_parser.add_argument('--issues-json', metavar='', required=True, help='Location of the json report') arg_parser.add_argument('--issues-txt', metavar='', diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index 85436c1d5..d994dcb8d 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -32,16 +32,6 @@ let load_specfiles () = specs_files_in_dir result_specs_dir -let error_desc_to_csv_string error_desc = - let pp fmt = F.fprintf fmt "%a" Localise.pp_error_desc error_desc in - Escape.escape_csv (F.asprintf "%t" pp) - - -let error_advice_to_csv_string error_desc = - let pp fmt = F.fprintf fmt "%a" Localise.pp_error_advice error_desc in - Escape.escape_csv (F.asprintf "%t" pp) - - let error_desc_to_plain_string error_desc = let pp fmt = F.fprintf fmt "%a" Localise.pp_error_desc error_desc in let s = F.asprintf "%t" pp in @@ -55,12 +45,6 @@ let error_desc_to_plain_string error_desc = let error_desc_to_dotty_string error_desc = Localise.error_desc_get_dotty error_desc -let error_desc_to_xml_tags error_desc = - let tags = Localise.error_desc_get_tags error_desc in - let subtree label contents = Io_infer.Xml.create_tree label [] [Io_infer.Xml.String contents] in - List.map ~f:(fun (tag, value) -> subtree tag (Escape.escape_xml value)) tags - - let get_bug_hash (kind: string) (type_str: string) (procedure_id: string) (filename: string) (node_key: Digest.t) (error_desc: Localise.error_desc) = let qualifier_tag_call_procedure = Localise.error_desc_get_tag_call_procedure error_desc in @@ -241,86 +225,6 @@ let censored_reason (issue_type: IssueType.t) source_file = Option.value ~default:"" (List.find_map Config.filter_report ~f:rejected_by) -module IssuesCsv = struct - let csv_issues_id = ref 0 - - let pp_header fmt () = - Format.fprintf fmt "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s@\n" Io_infer.Xml.tag_class - Io_infer.Xml.tag_kind Io_infer.Xml.tag_type Io_infer.Xml.tag_qualifier - Io_infer.Xml.tag_severity Io_infer.Xml.tag_line Io_infer.Xml.tag_procedure - Io_infer.Xml.tag_procedure_id Io_infer.Xml.tag_file Io_infer.Xml.tag_trace - Io_infer.Xml.tag_key Io_infer.Xml.tag_qualifier_tags Io_infer.Xml.tag_hash "bug_id" - "always_report" "advice" - - - let pp_issue fmt error_filter procname proc_loc_opt (key: Errlog.err_key) - (err_data: Errlog.err_data) = - let pp x = F.fprintf fmt x in - let source_file = - match proc_loc_opt with - | Some proc_loc -> - proc_loc.Location.file - | None -> - err_data.loc.Location.file - in - if key.in_footprint && error_filter source_file key.err_desc key.err_name - && should_report key.err_kind key.err_name key.err_desc err_data.err_class - then - let err_desc_string = error_desc_to_csv_string key.err_desc in - let err_advice_string = error_advice_to_csv_string key.err_desc in - let qualifier_tag_xml = - let xml_node = - Io_infer.Xml.create_tree Io_infer.Xml.tag_qualifier_tags [] - (error_desc_to_xml_tags key.err_desc) - in - let p fmt = F.fprintf fmt "%a" (Io_infer.Xml.pp_document false) xml_node in - let s = F.asprintf "%t" p in - Escape.escape_csv s - in - let kind = Exceptions.err_kind_string key.err_kind in - let type_str = key.err_name.IssueType.unique_id in - let procedure_id = Typ.Procname.to_filename procname in - let filename = SourceFile.to_string source_file in - let always_report = - match Localise.error_desc_extract_tag_value key.err_desc "always_report" with - | "" -> - "false" - | v -> - v - in - let trace = - Jsonbug_j.string_of_json_trace - {trace= loc_trace_to_jsonbug_record err_data.loc_trace key.err_kind} - in - incr csv_issues_id ; - pp "%s," (Exceptions.err_class_string err_data.err_class) ; - pp "%s," kind ; - pp "%s," type_str ; - pp "\"%s\"," err_desc_string ; - pp "%s," key.severity ; - pp "%d," err_data.loc.Location.line ; - pp "\"%s\"," (Escape.escape_csv (Typ.Procname.to_string procname)) ; - pp "\"%s\"," (Escape.escape_csv procedure_id) ; - pp "%s," filename ; - pp "\"%s\"," (Escape.escape_csv trace) ; - pp "\"%s\"," (Digest.to_hex err_data.node_id_key.node_key) ; - pp "\"%s\"," qualifier_tag_xml ; - pp "\"%s\"," - ( get_bug_hash kind type_str procedure_id filename err_data.node_id_key.node_key - key.err_desc - |> Digest.to_hex ) ; - pp "\"%d\"," !csv_issues_id ; - (* bug id *) - pp "\"%s\"," always_report ; - pp "\"%s\"@\n" err_advice_string - - - (** Write bug report in csv format *) - let pp_issues_of_error_log fmt error_filter _ proc_loc_opt procname err_log = - Errlog.iter (pp_issue fmt error_filter procname proc_loc_opt) err_log - -end - let potential_exception_message = "potential exception at line" module IssuesJson = struct @@ -762,11 +666,11 @@ let pp_issue_in_format (format_kind, (outf: Utils.outfile)) error_filter {Issue.proc_name; proc_location; err_key; err_data} = match format_kind with | Csv -> - IssuesCsv.pp_issue outf.fmt error_filter proc_name (Some proc_location) err_key err_data + L.(die InternalError) "Printing issues in a CSV format is not implemented" | Json -> IssuesJson.pp_issue outf.fmt error_filter proc_name (Some proc_location) err_key err_data | Tests -> - L.(die InternalError) "Print issues as tests is not implemented" + L.(die InternalError) "Printing issues as tests is not implemented" | Text -> IssuesTxt.pp_issue outf.fmt error_filter (Some proc_location) err_key err_data @@ -776,9 +680,9 @@ let pp_issues_in_format (format_kind, (outf: Utils.outfile)) = | Json -> IssuesJson.pp_issues_of_error_log outf.fmt | Csv -> - IssuesCsv.pp_issues_of_error_log outf.fmt + L.(die InternalError) "Printing issues in a CSV format is not implemented" | Tests -> - L.(die InternalError) "Print issues as tests is not implemented" + L.(die InternalError) "Printing issues as tests is not implemented" | Text -> IssuesTxt.pp_issues_of_error_log outf.fmt @@ -1031,12 +935,11 @@ let mk_format format_kind fname = ~default:[] (Utils.create_outfile fname) -let init_issues_format_list report_csv report_json = - let csv_format = Option.value_map ~f:(mk_format Csv) ~default:[] report_csv in +let init_issues_format_list report_json = let json_format = Option.value_map ~f:(mk_format Json) ~default:[] report_json in let tests_format = Option.value_map ~f:(mk_format Tests) ~default:[] Config.issues_tests in let txt_format = Option.value_map ~f:(mk_format Text) ~default:[] Config.issues_txt in - csv_format @ json_format @ tests_format @ txt_format + json_format @ tests_format @ txt_format let init_procs_format_list () = Option.value_map ~f:(mk_format Csv) ~default:[] Config.procs_csv @@ -1056,7 +959,7 @@ let init_files format_list_by_kind = let init_files_of_format (format_kind, (outfile: Utils.outfile)) = match (format_kind, report_kind) with | Csv, Issues -> - IssuesCsv.pp_header outfile.fmt () + L.(die InternalError) "Printing issues in a CSV format is not implemented" | Csv, Procs -> ProcsCsv.pp_header outfile.fmt () | Csv, Stats -> @@ -1113,8 +1016,8 @@ let pp_summary_and_issues formats_by_report_kind issue_formats = finalize_and_close_files formats_by_report_kind stats -let main ~report_csv ~report_json = - let issue_formats = init_issues_format_list report_csv report_json in +let main ~report_json = + let issue_formats = init_issues_format_list report_json in let formats_by_report_kind = [ (Issues, issue_formats) ; (Procs, init_procs_format_list ()) diff --git a/infer/src/backend/InferPrint.mli b/infer/src/backend/InferPrint.mli index e13965c3f..b74981de6 100644 --- a/infer/src/backend/InferPrint.mli +++ b/infer/src/backend/InferPrint.mli @@ -11,4 +11,4 @@ open! IStd val exception_value : string -val main : report_csv:string option -> report_json:string option -> unit +val main : report_json:string option -> unit diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index 4989ff34a..86c2abc1e 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -96,7 +96,7 @@ let () = if Config.developer_mode then InferAnalyze.register_perf_stats_report () ; Driver.analyze_and_report Analyze ~changed_files:(Driver.read_config_changed_files ()) | Report -> - InferPrint.main ~report_csv:Config.issues_csv ~report_json:None + InferPrint.main ~report_json:None | ReportDiff -> (* at least one report must be passed in input to compute differential *) ( match (Config.report_current, Config.report_previous) with @@ -127,4 +127,3 @@ let () = L.external_error "** Error running the reporting script:@\n** %s %s@\n** See error above@." prog (String.concat ~sep:" " args) - diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 80956537a..c4effedb4 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -691,6 +691,7 @@ and analyzer = x) ~symbols:string_to_analyzer + and ( annotation_reachability , biabduction , bufferoverrun @@ -1370,12 +1371,6 @@ and iphoneos_target_sdk_version_path_regex = "To pass a specific target SDK version to use for iphoneos in a particular path, with the format path:version (can be specified multiple times)" -and issues_csv = - CLOpt.mk_path_opt ~deprecated:["bugs"] ~long:"issues-csv" - ~in_help:CLOpt.([(Report, manual_generic)]) - ~meta:"file" "Write a list of issues in CSV format to $(i,file)" - - and issues_fields = CLOpt.mk_symbol_seq ~long:"issues-fields" ~in_help:CLOpt.([(Report, manual_generic)]) @@ -1727,7 +1722,7 @@ and report_hook = ~in_help:CLOpt.([(Analyze, manual_generic); (Run, manual_generic)]) ~default:(lib_dir ^/ "python" ^/ "report.py") ~meta:"script" - "Specify a script to be executed after the analysis results are written. This script will be passed $(b,--issues-csv), $(b,--issues-json), $(b,--issues-txt), $(b,--issues-xml), $(b,--project-root), and $(b,--results-dir)." + "Specify a script to be executed after the analysis results are written. This script will be passed, $(b,--issues-json), $(b,--issues-txt), $(b,--issues-xml), $(b,--project-root), and $(b,--results-dir)." and report_previous = @@ -2447,8 +2442,6 @@ and iphoneos_target_sdk_version_path_regex = process_iphoneos_target_sdk_version_path_regex !iphoneos_target_sdk_version_path_regex -and issues_csv = !issues_csv - and issues_fields = !issues_fields and issues_tests = !issues_tests diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 388cc905c..0c67c52ce 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -456,8 +456,6 @@ type iphoneos_target_sdk_version_path_regex = {path: Str.regexp; version: string val iphoneos_target_sdk_version_path_regex : iphoneos_target_sdk_version_path_regex list -val issues_csv : string option - val issues_fields : [ `Issue_field_bug_class | `Issue_field_kind diff --git a/infer/src/integration/Driver.ml b/infer/src/integration/Driver.ml index 5c6abaa09..5f3e2af32 100644 --- a/infer/src/integration/Driver.ml +++ b/infer/src/integration/Driver.ml @@ -345,11 +345,8 @@ let execute_analyze ~changed_files = let report ?(suppress_console= false) () = - let report_csv = - if Config.buck_cache_mode then None else Some (Config.results_dir ^/ "report.csv") - in let report_json = Config.(results_dir ^/ report_json) in - InferPrint.main ~report_csv ~report_json:(Some report_json) ; + InferPrint.main ~report_json:(Some report_json) ; (* Post-process the report according to the user config. By default, calls report.py to create a human-readable report. @@ -358,11 +355,10 @@ let report ?(suppress_console= false) () = | true, _ | false, None -> () | false, Some prog -> - let if_some key opt args = match opt with None -> args | Some arg -> key :: arg :: args in let if_true key opt args = if not opt then args else key :: args in let bugs_txt = Option.value ~default:(Config.results_dir ^/ "bugs.txt") Config.issues_txt in let args = - if_some "--issues-csv" report_csv @@ if_true "--pmd-xml" Config.pmd_xml + if_true "--pmd-xml" Config.pmd_xml @@ if_true "--quiet" (Config.quiet || suppress_console) [ "--issues-json"