[linters] Adding a new error type like

Reviewed By: martinoluca

Differential Revision: D5111078

fbshipit-source-id: 06e14b8
master
Dulma Churchill 8 years ago committed by Facebook Github Bot
parent 927b08346e
commit f5d3870485

@ -46,6 +46,7 @@ HEADER = BRIGHT
SUCCESS = BLUE_BG + WHITE + BRIGHT
WARNING = ''
ADVICE = ''
LIKE = ''
class Invalid_mode(Exception):

@ -30,6 +30,7 @@ ISSUE_KIND_ERROR = 'ERROR'
ISSUE_KIND_WARNING = 'WARNING'
ISSUE_KIND_INFO = 'INFO'
ISSUE_KIND_ADVICE = 'ADVICE'
ISSUE_KIND_LIKE = 'LIKE'
# field names in rows of json reports
JSON_INDEX_DOTTY = 'dotty'
@ -122,6 +123,8 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None,
msg = colorize.color(msg, colorize.WARNING, formatter)
elif report[JSON_INDEX_KIND] == ISSUE_KIND_ADVICE:
msg = colorize.color(msg, colorize.ADVICE, formatter)
elif report[JSON_INDEX_KIND] == ISSUE_KIND_LIKE:
msg = colorize.color(msg, colorize.LIKE, formatter)
text = '%s%s' % (msg, source_context)
text_errors_list.append(text)
@ -177,7 +180,11 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None,
def _is_user_visible(project_root, report):
kind = report[JSON_INDEX_KIND]
return kind in [ISSUE_KIND_ERROR, ISSUE_KIND_WARNING, ISSUE_KIND_ADVICE]
return kind in [
ISSUE_KIND_ERROR,
ISSUE_KIND_WARNING,
ISSUE_KIND_ADVICE,
ISSUE_KIND_LIKE]
def print_and_save_errors(infer_out, project_root, json_report, bugs_out,

@ -274,7 +274,9 @@ let log_issue err_kind err_log loc (node_id, node_key) session ltr ?linters_def_
let d = match err_kind with
| Exceptions.Kerror -> L.d_error
| Exceptions.Kwarning -> L.d_warning
| Exceptions.Kinfo | Exceptions.Kadvice -> L.d_info in
| Exceptions.Kinfo
| Exceptions.Kadvice
| Exceptions.Klike -> L.d_info in
d warn_str; L.d_ln();
end in
if should_print_now then print_now ()
@ -319,6 +321,7 @@ module Err_table = struct
let map_warn_re = ref LocMap.empty in
let map_info = ref LocMap.empty in
let map_advice = ref LocMap.empty in
let map_likes = ref LocMap.empty in
let add_err nslm key =
let map = match key.in_footprint, key.err_kind with
| true, Exceptions.Kerror -> map_err_fp
@ -326,7 +329,8 @@ module Err_table = struct
| true, Exceptions.Kwarning -> map_warn_fp
| false, Exceptions.Kwarning -> map_warn_re
| _, Exceptions.Kinfo -> map_info
| _, Exceptions.Kadvice -> map_advice in
| _, Exceptions.Kadvice -> map_advice
| _, Exceptions.Klike -> map_likes in
try
let err_list = LocMap.find nslm !map in
map := LocMap.add nslm ((key.err_name, key.err_desc) :: err_list) !map

@ -40,7 +40,7 @@ type err_class = Checker | Prover | Nocat | Linters [@@deriving compare]
let equal_err_class = [%compare.equal : err_class]
(** kind of error/warning *)
type err_kind = Kwarning | Kerror | Kinfo | Kadvice [@@deriving compare]
type err_kind = Kwarning | Kerror | Kinfo | Kadvice | Klike [@@deriving compare]
let equal_err_kind = [%compare.equal : err_kind]
@ -333,6 +333,7 @@ let err_kind_string = function
| Kerror -> "ERROR"
| Kinfo -> "INFO"
| Kadvice -> "ADVICE"
| Klike -> "LIKE"
(** string describing an error class *)
let err_class_string = function

@ -30,7 +30,7 @@ type severity =
| Low (** low severity bug *)
(** kind of error/warning *)
type err_kind = Kwarning | Kerror | Kinfo | Kadvice [@@deriving compare]
type err_kind = Kwarning | Kerror | Kinfo | Kadvice | Klike [@@deriving compare]
val equal_err_kind : err_kind -> err_kind -> bool

@ -281,7 +281,8 @@ let should_report (issue_kind: Exceptions.err_kind) issue_type error_desc eclass
| Kinfo => true
| Kerror
| Kwarning
| Kadvice => false
| Kadvice
| Klike => false
};
if issue_kind_is_blacklisted {
false
@ -642,6 +643,7 @@ module Stats = {
mutable nerrors: int,
mutable ninfos: int,
mutable nadvice: int,
mutable nlikes: int,
mutable nprocs: int,
mutable nspecs: int,
mutable ntimeouts: int,
@ -656,6 +658,7 @@ module Stats = {
nerrors: 0,
ninfos: 0,
nadvice: 0,
nlikes: 0,
nprocs: 0,
nspecs: 0,
ntimeouts: 0,
@ -723,6 +726,7 @@ module Stats = {
| Exceptions.Kwarning => stats.nwarnings = stats.nwarnings + 1
| Exceptions.Kinfo => stats.ninfos = stats.ninfos + 1
| Exceptions.Kadvice => stats.nadvice = stats.nadvice + 1
| Exceptions.Klike => stats.nlikes = stats.nlikes + 1
}
}
};

@ -114,6 +114,7 @@ let string_to_err_kind = function
| "ERROR" -> Exceptions.Kerror
| "INFO" -> Exceptions.Kinfo
| "ADVICE" -> Exceptions.Kadvice
| "LIKE" -> Exceptions.Klike
| s -> (Logging.out "\n[ERROR] Severity %s does not exist. Stop.\n" s;
assert false)

@ -202,7 +202,7 @@ DEFINE-CHECKER TEST_NTH_PARAM_TYPE_CHECK = {
HOLDS-IN-NODE ObjCMethodDecl;
SET message = "Found a method with nth parameter of type....";
SET severity = "LIKE";
};
DEFINE-CHECKER TEST_NAMESPACE_NAME = {

Loading…
Cancel
Save