diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index ed06d7b92..8192b8063 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -2419,20 +2419,19 @@ let 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 linters_doc_url arg = match String.lsplit2 ~on:':' arg with - | Some (linter, doc_url) -> - {linter; doc_url} + | Some linter_doc_url_assoc -> + linter_doc_url_assoc | None -> L.(die UserError) "Incorrect format for the option linters-doc-url. The correct format is linter:doc_url \ but got %s" arg 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 *) @@ -2637,6 +2636,8 @@ and gen_previous_build_command_script = !gen_previous_build_command_script and generated_classes = !generated_classes +and get_linter_doc_url = process_linters_doc_url !linters_doc_url + and html = !html 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_doc_url = process_linters_doc_url !linters_doc_url - and linters_developer_mode = !linters_developer_mode and linters_ignore_clang_failures = !linters_ignore_clang_failures diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index e7ce6ae19..1a8410cc3 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -375,6 +375,8 @@ val gen_previous_build_command_script : string option val generated_classes : string option +val get_linter_doc_url : linter_id:string -> string option + val html : bool val icfg_dotty_outfile : string option @@ -440,10 +442,6 @@ val linters_def_file : 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_ignore_clang_failures : bool diff --git a/infer/src/clang/cFrontend_errors.ml b/infer/src/clang/cFrontend_errors.ml index 155fa3118..dbec42050 100644 --- a/infer/src/clang/cFrontend_errors.ml +++ b/infer/src/clang/cFrontend_errors.ml @@ -184,12 +184,9 @@ let string_to_issue_mode m = let post_process_linter_definition (linter : linter) = - match - List.find Config.linters_doc_url ~f:(fun (linter_doc_url : Config.linter_doc_url) -> - String.equal linter.issue_desc.id linter_doc_url.linter ) - with - | Some linter_doc_url -> - let issue_desc = {linter.issue_desc with doc_url= Some linter_doc_url.doc_url} in + match Config.get_linter_doc_url ~linter_id:linter.issue_desc.id with + | Some doc_url -> + let issue_desc = {linter.issue_desc with doc_url= Some doc_url} in {linter with issue_desc} | None -> linter