Simplify linters_doc_url

Reviewed By: ddino

Differential Revision: D9634702

fbshipit-source-id: 8d46b2af5
master
Mehdi Bouaziz 6 years ago committed by Facebook Github Bot
parent 365ebd8873
commit 882285a44e

@ -2419,20 +2419,19 @@ let process_iphoneos_target_sdk_version_path_regex args =
List.map ~f:process_iphoneos_target_sdk_version_path_regex args List.map ~f:process_iphoneos_target_sdk_version_path_regex args
type linter_doc_url = {linter: string; doc_url: string}
let process_linters_doc_url args = let process_linters_doc_url args =
let linters_doc_url arg = let linters_doc_url arg =
match String.lsplit2 ~on:':' arg with match String.lsplit2 ~on:':' arg with
| Some (linter, doc_url) -> | Some linter_doc_url_assoc ->
{linter; doc_url} linter_doc_url_assoc
| None -> | None ->
L.(die UserError) L.(die UserError)
"Incorrect format for the option linters-doc-url. The correct format is linter:doc_url \ "Incorrect format for the option linters-doc-url. The correct format is linter:doc_url \
but got %s" but got %s"
arg arg
in in
List.map ~f:linters_doc_url args let linter_doc_url_assocs = List.rev_map ~f:linters_doc_url args in
fun ~linter_id -> List.Assoc.find ~equal:String.equal linter_doc_url_assocs linter_id
(** Freeze initialized configuration values *) (** Freeze initialized configuration values *)
@ -2637,6 +2636,8 @@ and gen_previous_build_command_script = !gen_previous_build_command_script
and generated_classes = !generated_classes and generated_classes = !generated_classes
and get_linter_doc_url = process_linters_doc_url !linters_doc_url
and html = !html and html = !html
and icfg_dotty_outfile = !icfg_dotty_outfile and icfg_dotty_outfile = !icfg_dotty_outfile
@ -2686,8 +2687,6 @@ and linters_def_file = !linters_def_file
and linters_def_folder = !linters_def_folder and linters_def_folder = !linters_def_folder
and linters_doc_url = process_linters_doc_url !linters_doc_url
and linters_developer_mode = !linters_developer_mode and linters_developer_mode = !linters_developer_mode
and linters_ignore_clang_failures = !linters_ignore_clang_failures and linters_ignore_clang_failures = !linters_ignore_clang_failures

@ -375,6 +375,8 @@ val gen_previous_build_command_script : string option
val generated_classes : string option val generated_classes : string option
val get_linter_doc_url : linter_id:string -> string option
val html : bool val html : bool
val icfg_dotty_outfile : string option val icfg_dotty_outfile : string option
@ -440,10 +442,6 @@ val linters_def_file : string list
val linters_def_folder : string list val linters_def_folder : string list
type linter_doc_url = {linter: string; doc_url: string}
val linters_doc_url : linter_doc_url list
val linters_developer_mode : bool val linters_developer_mode : bool
val linters_ignore_clang_failures : bool val linters_ignore_clang_failures : bool

@ -184,12 +184,9 @@ let string_to_issue_mode m =
let post_process_linter_definition (linter : linter) = let post_process_linter_definition (linter : linter) =
match match Config.get_linter_doc_url ~linter_id:linter.issue_desc.id with
List.find Config.linters_doc_url ~f:(fun (linter_doc_url : Config.linter_doc_url) -> | Some doc_url ->
String.equal linter.issue_desc.id linter_doc_url.linter ) let issue_desc = {linter.issue_desc with doc_url= Some doc_url} in
with
| Some linter_doc_url ->
let issue_desc = {linter.issue_desc with doc_url= Some linter_doc_url.doc_url} in
{linter with issue_desc} {linter with issue_desc}
| None -> | None ->
linter linter

Loading…
Cancel
Save