From 35eba4045238e086d3ee41bf2aac25e31ea7b7a6 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Thu, 6 Sep 2018 15:02:09 -0700 Subject: [PATCH] [infer] remove the "kind" field from the analysis report Summary: This field was now redundant with the "severity" field Reviewed By: mbouaziz Differential Revision: D9553101 fbshipit-source-id: 69b7c9d1c --- infer/lib/python/inferlib/issues.py | 35 ++++++++++++------------ infer/src/atd/jsonbug.atd | 1 - infer/src/backend/InferPrint.ml | 7 ++--- infer/src/base/Config.ml | 5 ++-- infer/src/base/Config.mli | 3 +- infer/src/unit/DifferentialTestsUtils.ml | 7 ++--- 6 files changed, 25 insertions(+), 33 deletions(-) diff --git a/infer/lib/python/inferlib/issues.py b/infer/lib/python/inferlib/issues.py index f2092fff7..e0d7e9cbd 100644 --- a/infer/lib/python/inferlib/issues.py +++ b/infer/lib/python/inferlib/issues.py @@ -24,11 +24,11 @@ except ImportError: from . import colorize, config, source, utils -ISSUE_KIND_ERROR = 'ERROR' -ISSUE_KIND_WARNING = 'WARNING' -ISSUE_KIND_INFO = 'INFO' -ISSUE_KIND_ADVICE = 'ADVICE' -ISSUE_KIND_LIKE = 'LIKE' +ISSUE_SEVERITY_ERROR = 'ERROR' +ISSUE_SEVERITY_WARNING = 'WARNING' +ISSUE_SEVERITY_INFO = 'INFO' +ISSUE_SEVERITY_ADVICE = 'ADVICE' +ISSUE_SEVERITY_LIKE = 'LIKE' # field names in rows of json reports JSON_INDEX_DOTTY = 'dotty' @@ -39,7 +39,7 @@ JSON_INDEX_ISL_FILE = 'file' JSON_INDEX_ISL_LNUM = 'lnum' JSON_INDEX_ISL_CNUM = 'cnum' JSON_INDEX_ISL_ENUM = 'enum' -JSON_INDEX_KIND = 'kind' +JSON_INDEX_SEVERITY = 'severity' JSON_INDEX_LINE = 'line' JSON_INDEX_PROCEDURE = 'procedure' JSON_INDEX_QUALIFIER = 'qualifier' @@ -69,7 +69,7 @@ def text_of_infer_loc(loc): def text_of_report(report): filename = report[JSON_INDEX_FILENAME] - kind = report[JSON_INDEX_KIND] + severity = report[JSON_INDEX_SEVERITY] line = report[JSON_INDEX_LINE] error_type = report[JSON_INDEX_TYPE] msg = report[JSON_INDEX_QUALIFIER] @@ -79,7 +79,7 @@ def text_of_report(report): return '%s:%d: %s: %s%s\n %s' % ( filename, line, - kind.lower(), + severity.lower(), error_type, infer_loc, msg, @@ -118,13 +118,13 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None, source_context = '\n' + unicode(indenter) msg = text_of_report(report) - if report[JSON_INDEX_KIND] == ISSUE_KIND_ERROR: + if report[JSON_INDEX_SEVERITY] == ISSUE_SEVERITY_ERROR: msg = colorize.color(msg, colorize.ERROR, formatter) - elif report[JSON_INDEX_KIND] == ISSUE_KIND_WARNING: + elif report[JSON_INDEX_SEVERITY] == ISSUE_SEVERITY_WARNING: msg = colorize.color(msg, colorize.WARNING, formatter) - elif report[JSON_INDEX_KIND] == ISSUE_KIND_ADVICE: + elif report[JSON_INDEX_SEVERITY] == ISSUE_SEVERITY_ADVICE: msg = colorize.color(msg, colorize.ADVICE, formatter) - elif report[JSON_INDEX_KIND] == ISSUE_KIND_LIKE: + elif report[JSON_INDEX_SEVERITY] == ISSUE_SEVERITY_LIKE: msg = colorize.color(msg, colorize.LIKE, formatter) text = '%s%s' % (msg, source_context) text_errors_list.append(text) @@ -179,12 +179,11 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None, def _is_user_visible(report): - kind = report[JSON_INDEX_KIND] - return kind in [ - ISSUE_KIND_ERROR, - ISSUE_KIND_WARNING, - ISSUE_KIND_ADVICE, - ISSUE_KIND_LIKE] + return report[JSON_INDEX_SEVERITY] in [ + ISSUE_SEVERITY_ERROR, + ISSUE_SEVERITY_WARNING, + ISSUE_SEVERITY_ADVICE, + ISSUE_SEVERITY_LIKE] def print_and_save_errors(infer_out, project_root, json_report, bugs_out, diff --git a/infer/src/atd/jsonbug.atd b/infer/src/atd/jsonbug.atd index f57008e92..b10afecaa 100644 --- a/infer/src/atd/jsonbug.atd +++ b/infer/src/atd/jsonbug.atd @@ -19,7 +19,6 @@ type extra = { } type jsonbug = { - kind : string; bug_type : string; ?doc_url : string option; qualifier : string; diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index 3b7c5f66b..be769c408 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -302,8 +302,7 @@ module JsonIssuePrinter = MakeJsonListPrinter (struct Typ.Procname.to_string proc_name in let bug = - { Jsonbug_j.kind= severity - ; bug_type + { Jsonbug_j.bug_type ; qualifier ; severity ; visibility @@ -376,8 +375,6 @@ let pp_custom_of_report fmt report fields = in let pp_field index field = match field with - | `Issue_field_kind -> - Format.fprintf fmt "%s%s" (comma_separator index) issue.kind | `Issue_field_bug_type -> Format.fprintf fmt "%s%s" (comma_separator index) issue.bug_type | `Issue_field_bucket -> @@ -458,7 +455,7 @@ end let pp_text_of_report fmt report = let pp_row jsonbug = let open Jsonbug_t in - F.fprintf fmt "%s:%d: %s: %s %s@\n" jsonbug.file jsonbug.line jsonbug.kind jsonbug.bug_type + F.fprintf fmt "%s:%d: %s: %s %s@\n" jsonbug.file jsonbug.line jsonbug.severity jsonbug.bug_type jsonbug.qualifier in List.iter ~f:pp_row report ; F.fprintf fmt "@?" diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 83400feba..083746d84 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -48,8 +48,7 @@ let ml_bucket_symbols = let issues_fields_symbols = - [ ("kind", `Issue_field_kind) - ; ("bug_type", `Issue_field_bug_type) + [ ("bug_type", `Issue_field_bug_type) ; ("bucket", `Issue_field_bucket) ; ("qualifier", `Issue_field_qualifier) ; ("severity", `Issue_field_severity) @@ -1458,7 +1457,7 @@ and issues_fields = ; `Issue_field_line_offset ; `Issue_field_bug_type ; `Issue_field_bucket - ; `Issue_field_kind + ; `Issue_field_severity ; `Issue_field_bug_trace ] ~symbols:issues_fields_symbols ~eq:PolyVariantEqual.( = ) "Fields to emit with $(b,--issues-tests)" diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 4e0b57608..dd40518cb 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -400,8 +400,7 @@ 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_fields : - [ `Issue_field_kind - | `Issue_field_bug_type + [ `Issue_field_bug_type | `Issue_field_qualifier | `Issue_field_severity | `Issue_field_bucket diff --git a/infer/src/unit/DifferentialTestsUtils.ml b/infer/src/unit/DifferentialTestsUtils.ml index a0d45dc6c..619ba906e 100644 --- a/infer/src/unit/DifferentialTestsUtils.ml +++ b/infer/src/unit/DifferentialTestsUtils.ml @@ -7,14 +7,13 @@ open! IStd -let create_fake_jsonbug ?(kind = "kind") ?(bug_type = "bug_type") ?(qualifier = "qualifier") +let create_fake_jsonbug ?(bug_type = "bug_type") ?(qualifier = "qualifier") ?(severity = "severity") ?(visibility = "visibility") ?(line = 1) ?(column = 1) ?(procedure = "procedure") ?(procedure_start_line = 1) ?(file = "file/at/a/certain/path.java") ?(bug_trace = []) ?(key = "File|method|TYPE") ?(node_key = Some "1234") ?(hash = "1") ?(dotty = None) ?(infer_source_loc = None) ?(linters_def_file = Some "file/at/certain/path.al") ?doc_url () : Jsonbug_t.jsonbug = - { kind - ; bug_type + { bug_type ; qualifier ; severity ; visibility @@ -29,7 +28,7 @@ let create_fake_jsonbug ?(kind = "kind") ?(bug_type = "bug_type") ?(qualifier = ; hash ; dotty ; infer_source_loc - ; bug_type_hum= kind + ; bug_type_hum= bug_type ; linters_def_file ; doc_url ; traceview_id= None