[linters] Remove new lines from linters messages

Reviewed By: martinoluca

Differential Revision: D4634836

fbshipit-source-id: 4b21e48
master
Dulma Churchill 8 years ago committed by Facebook Github Bot
parent 3eecb243e6
commit 01c1d9f112

@ -73,6 +73,9 @@ let rec expand_message_string message an =
expand_message_string message' an
with Not_found -> message
let remove_new_lines message =
String.substr_replace_all ~pattern:"\n" ~with_:" " message
let string_to_err_kind = function
| "WARNING" -> Exceptions.Kwarning
| "ERROR" -> Exceptions.Kerror
@ -206,7 +209,8 @@ let get_current_method context (an : Ctl_parser_types.ast_node) =
| _ -> context.CLintersContext.current_method
let fill_issue_desc_info_and_log context an key issue_desc loc =
let desc = expand_message_string issue_desc.CIssue.description an in
let desc = remove_new_lines
(expand_message_string issue_desc.CIssue.description an) in
let issue_desc' =
{issue_desc with CIssue.description = desc; CIssue.loc = loc } in
log_frontend_issue context.CLintersContext.translation_unit_context

@ -19,3 +19,5 @@ val expand_checkers : CTL.ctl_checker list -> CTL.ctl_checker list
val make_condition_issue_desc_pair :
CTL.ctl_checker list -> unit
val remove_new_lines : string -> string

@ -0,0 +1,31 @@
(*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*)
open! IStd
open OUnit2
let test_correct_removing_new_lines =
let pp_diff_of_desc fmt (expected, actual) =
Format.fprintf fmt "Expected: [%s] Found: [%s]" expected actual in
let create_test (desc : string) (expected_desc : string) _ =
let output = CFrontend_errors.remove_new_lines desc in
let cmp = fun s1 s2 -> String.equal s1 s2 in
assert_equal ~pp_diff:pp_diff_of_desc ~cmp expected_desc output in
[
(
"test_correct_removing_new_lines",
"The selector m is not available in the required iOS SDK version\n8.0",
"The selector m is not available in the required iOS SDK version 8.0"
);
]
|> List.map
~f:(fun (name, test_input, expected_output) ->
name >:: create_test test_input expected_output)
let tests = "cfrontend_errors_suite" >::: test_correct_removing_new_lines

@ -11,4 +11,5 @@ open! IStd
let tests = [
CiOSVersionNumbersTests.tests;
QualifiedCppNameTests.tests;
CFrontend_errorsTests.tests;
]

Loading…
Cancel
Save