skeleton new `infer help` command

Summary:
`infer help` will be used to display information about issue types and
checkers, and to generate the corresponding website documentation. We
can add more things in it over time. The goal is to avoid having to go
read the source code of infer to figure things out that are user-facing.

Reviewed By: ezgicicek

Differential Revision: D21934376

fbshipit-source-id: 2788c5af1
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 7310726155
commit 7ba6e015a8

@ -55,6 +55,7 @@ INFER_COMMANDS = \
infer-capture \ infer-capture \
infer-compile \ infer-compile \
infer-explore \ infer-explore \
infer-help \
infer-report \ infer-report \
infer-reportdiff \ infer-reportdiff \
infer-run \ infer-run \

@ -5,6 +5,8 @@ SYNOPSIS
infer analyze [options] infer analyze [options]
infer capture [options] infer capture [options]
infer compile [options] infer compile [options]
infer help [options]
infer explore [options]
infer report [options] infer report [options]
infer reportdiff [options] infer reportdiff [options]
infer run [options] infer run [options]
@ -608,21 +610,30 @@ OPTIONS
--help --help
Show this manual See also infer-analyze(1), infer-capture(1), infer-compile(1), Show this manual See also infer-analyze(1), infer-capture(1), infer-compile(1),
infer-explore(1), infer-report(1), infer-reportdiff(1), and infer-explore(1), infer-help(1), infer-report(1),
infer-run(1). infer-reportdiff(1), and infer-run(1).
--help-checker +checker-id
Show information about a checker, for example biabduction. To see
the list of all checkers, see --list-checkers. See also infer-help(1).
--help-format { auto | groff | pager | plain } --help-format { auto | groff | pager | plain }
Show this help in the specified format. auto sets the format to Show this help in the specified format. auto sets the format to
plain if the environment variable TERM is "dumb" or undefined, and plain if the environment variable TERM is "dumb" or undefined, and
to pager otherwise. See also infer-analyze(1), infer-capture(1), infer-compile(1), to pager otherwise. See also infer-analyze(1), infer-capture(1), infer-compile(1),
infer-explore(1), infer-report(1), infer-reportdiff(1), and infer-explore(1), infer-help(1), infer-report(1),
infer-run(1). infer-reportdiff(1), and infer-run(1).
--help-full --help-full
Show this manual with all internal options in the INTERNAL OPTIONS Show this manual with all internal options in the INTERNAL OPTIONS
section See also infer-analyze(1), infer-capture(1), infer-compile(1), section See also infer-analyze(1), infer-capture(1), infer-compile(1),
infer-explore(1), infer-report(1), infer-reportdiff(1), and infer-explore(1), infer-help(1), infer-report(1),
infer-run(1). infer-reportdiff(1), and infer-run(1).
--help-issue-type +UNIQUE_ID
Show information about an issue type, for example
NULL_DEREFERENCE. To see the list of all issue types, see
--list-issue-types. See also infer-help(1).
--no-hoisting-report-only-expensive --no-hoisting-report-only-expensive
Deactivates: [Hoisting] Report loop-invariant calls only when the Deactivates: [Hoisting] Report loop-invariant calls only when the
@ -737,6 +748,14 @@ OPTIONS
in JSON format to stdout (Conversely: in JSON format to stdout (Conversely:
--no-linters-validate-syntax-only) See also infer-capture(1). --no-linters-validate-syntax-only) See also infer-capture(1).
--list-checkers
Activates: Show the list of all available checkers. (Conversely:
--no-list-checkers) See also infer-help(1).
--list-issue-types
Activates: Show the list of all issue types that infer might
report. (Conversely: --no-list-issue-types) See also infer-help(1).
--litho-required-props --litho-required-props
Activates: [EXPERIMENTAL] Required Prop check for Litho Activates: [EXPERIMENTAL] Required Prop check for Litho
(Conversely: --no-litho-required-props) See also infer-analyze(1). (Conversely: --no-litho-required-props) See also infer-analyze(1).
@ -1115,6 +1134,12 @@ OPTIONS
--version-json --version-json
Print version information in json format and exit See also infer-run(1). Print version information in json format and exit See also infer-run(1).
--write-website path_to_website_dir
Use to write website files documenting issue types and checkers
under path_to_website_dir/. Meant to be used within the Infer
directory to generate its website at fbinfer.com at website/.
See also infer-help(1).
--Xbuck +string --Xbuck +string
Pass values as command-line arguments to invocations of `buck Pass values as command-line arguments to invocations of `buck
build`. Only valid for --buck-clang. See also infer-capture(1). build`. Only valid for --buck-clang. See also infer-capture(1).
@ -1410,6 +1435,12 @@ INTERNAL OPTIONS
Activates: Enable the genrule compatibility mode used for the Buck Activates: Enable the genrule compatibility mode used for the Buck
integration (Conversely: --no-genrule-mode) integration (Conversely: --no-genrule-mode)
--help-checker-reset
Set --help-checker to the empty list.
--help-issue-type-reset
Set --help-issue-type to the empty list.
--help-scrubbed --help-scrubbed
Show this manual without specifying default values induced by the Show this manual without specifying default values induced by the
current build configuration current build configuration
@ -1876,6 +1907,9 @@ INTERNAL OPTIONS
--write-html-whitelist-regex-reset --write-html-whitelist-regex-reset
Set --write-html-whitelist-regex to the empty list. Set --write-html-whitelist-regex to the empty list.
--write-website-reset
Cancel the effect of --write-website.
--Xbuck-no-inline-reset --Xbuck-no-inline-reset
Set --Xbuck-no-inline to the empty list. Set --Xbuck-no-inline to the empty list.
@ -1933,7 +1967,8 @@ FILES
SEE ALSO SEE ALSO
infer-analyze(1), infer-capture(1), infer-compile(1), infer-analyze(1), infer-capture(1), infer-compile(1),
infer-explore(1), infer-report(1), infer-reportdiff(1), infer-run(1) infer-explore(1), infer-help(1), infer-report(1), infer-reportdiff(1),
infer-run(1)

@ -0,0 +1,77 @@
NAME
infer-help - Show and generate documentation.
SYNOPSIS
infer help
infer help --help-checker checker1 ... --help-checker checkerN
infer help --help-issue-type ISSUE_TYPE1 ... --help-issue-type ISSUE_TYPEN
infer help --list-checkers
infer help --list-issue-types
infer help --write-website website_root
DESCRIPTION
Without arguments, show the Infer manual as with infer --help
For each -help-checker or --help-issue-type option passed, display
information about the given checker or issue type.
If --list-checkers is passed, list all available checkers.
If --list-issue-types is passed, list all issue types.
Use --write-website to build some of the documentation for the
fbinfer.com website. (Used in scripts, not meant to be used except
when publishing content to fbinfer.com)
OPTIONS
--help
Show this manual
--help-checker +checker-id
Show information about a checker, for example biabduction. To see
the list of all checkers, see --list-checkers.
--help-format { auto | groff | pager | plain }
Show this help in the specified format. auto sets the format to
plain if the environment variable TERM is "dumb" or undefined, and
to pager otherwise.
--help-full
Show this manual with all internal options in the INTERNAL OPTIONS
section
--help-issue-type +UNIQUE_ID
Show information about an issue type, for example
NULL_DEREFERENCE. To see the list of all issue types, see
--list-issue-types.
--list-checkers
Activates: Show the list of all available checkers. (Conversely:
--no-list-checkers)
--list-issue-types
Activates: Show the list of all issue types that infer might
report. (Conversely: --no-list-issue-types)
--write-website path_to_website_dir
Use to write website files documenting issue types and checkers
under path_to_website_dir/. Meant to be used within the Infer
directory to generate its website at fbinfer.com at website/.
ENVIRONMENT
INFER_ARGS, INFERCONFIG, INFER_STRICT_MODE
See the ENVIRONMENT section in the manual of infer(1).
FILES
.inferconfig
See the FILES section in the manual of infer(1).

@ -5,6 +5,8 @@ SYNOPSIS
infer analyze [options] infer analyze [options]
infer capture [options] infer capture [options]
infer compile [options] infer compile [options]
infer help [options]
infer explore [options]
infer report [options] infer report [options]
infer reportdiff [options] infer reportdiff [options]
infer run [options] infer run [options]
@ -608,21 +610,30 @@ OPTIONS
--help --help
Show this manual See also infer-analyze(1), infer-capture(1), infer-compile(1), Show this manual See also infer-analyze(1), infer-capture(1), infer-compile(1),
infer-explore(1), infer-report(1), infer-reportdiff(1), and infer-explore(1), infer-help(1), infer-report(1),
infer-run(1). infer-reportdiff(1), and infer-run(1).
--help-checker +checker-id
Show information about a checker, for example biabduction. To see
the list of all checkers, see --list-checkers. See also infer-help(1).
--help-format { auto | groff | pager | plain } --help-format { auto | groff | pager | plain }
Show this help in the specified format. auto sets the format to Show this help in the specified format. auto sets the format to
plain if the environment variable TERM is "dumb" or undefined, and plain if the environment variable TERM is "dumb" or undefined, and
to pager otherwise. See also infer-analyze(1), infer-capture(1), infer-compile(1), to pager otherwise. See also infer-analyze(1), infer-capture(1), infer-compile(1),
infer-explore(1), infer-report(1), infer-reportdiff(1), and infer-explore(1), infer-help(1), infer-report(1),
infer-run(1). infer-reportdiff(1), and infer-run(1).
--help-full --help-full
Show this manual with all internal options in the INTERNAL OPTIONS Show this manual with all internal options in the INTERNAL OPTIONS
section See also infer-analyze(1), infer-capture(1), infer-compile(1), section See also infer-analyze(1), infer-capture(1), infer-compile(1),
infer-explore(1), infer-report(1), infer-reportdiff(1), and infer-explore(1), infer-help(1), infer-report(1),
infer-run(1). infer-reportdiff(1), and infer-run(1).
--help-issue-type +UNIQUE_ID
Show information about an issue type, for example
NULL_DEREFERENCE. To see the list of all issue types, see
--list-issue-types. See also infer-help(1).
--no-hoisting-report-only-expensive --no-hoisting-report-only-expensive
Deactivates: [Hoisting] Report loop-invariant calls only when the Deactivates: [Hoisting] Report loop-invariant calls only when the
@ -737,6 +748,14 @@ OPTIONS
in JSON format to stdout (Conversely: in JSON format to stdout (Conversely:
--no-linters-validate-syntax-only) See also infer-capture(1). --no-linters-validate-syntax-only) See also infer-capture(1).
--list-checkers
Activates: Show the list of all available checkers. (Conversely:
--no-list-checkers) See also infer-help(1).
--list-issue-types
Activates: Show the list of all issue types that infer might
report. (Conversely: --no-list-issue-types) See also infer-help(1).
--litho-required-props --litho-required-props
Activates: [EXPERIMENTAL] Required Prop check for Litho Activates: [EXPERIMENTAL] Required Prop check for Litho
(Conversely: --no-litho-required-props) See also infer-analyze(1). (Conversely: --no-litho-required-props) See also infer-analyze(1).
@ -1115,6 +1134,12 @@ OPTIONS
--version-json --version-json
Print version information in json format and exit See also infer-run(1). Print version information in json format and exit See also infer-run(1).
--write-website path_to_website_dir
Use to write website files documenting issue types and checkers
under path_to_website_dir/. Meant to be used within the Infer
directory to generate its website at fbinfer.com at website/.
See also infer-help(1).
--Xbuck +string --Xbuck +string
Pass values as command-line arguments to invocations of `buck Pass values as command-line arguments to invocations of `buck
build`. Only valid for --buck-clang. See also infer-capture(1). build`. Only valid for --buck-clang. See also infer-capture(1).
@ -1187,7 +1212,8 @@ FILES
SEE ALSO SEE ALSO
infer-analyze(1), infer-capture(1), infer-compile(1), infer-analyze(1), infer-capture(1), infer-compile(1),
infer-explore(1), infer-report(1), infer-reportdiff(1), infer-run(1) infer-explore(1), infer-help(1), infer-report(1), infer-reportdiff(1),
infer-run(1)

@ -6,8 +6,9 @@
*) *)
open Core open Core
(* NOTE: All variants must be also added to `all_commands` below *) (* NOTE: All variants must be also added to [command_to_string] below *)
type t = Analyze | Capture | Compile | Explore | Report | ReportDiff | Run [@@deriving compare] type t = Analyze | Capture | Compile | Explore | Help | Report | ReportDiff | Run
[@@deriving compare]
let equal = [%compare.equal: t] let equal = [%compare.equal: t]
@ -16,6 +17,7 @@ let command_to_string =
; (Capture, "capture") ; (Capture, "capture")
; (Compile, "compile") ; (Compile, "compile")
; (Explore, "explore") ; (Explore, "explore")
; (Help, "help")
; (Report, "report") ; (Report, "report")
; (ReportDiff, "reportdiff") ; (ReportDiff, "reportdiff")
; (Run, "run") ] ; (Run, "run") ]

@ -14,6 +14,7 @@ type t =
(** set up the infer environment then run the compilation commands without capturing the (** set up the infer environment then run the compilation commands without capturing the
source files *) source files *)
| Explore (** explore infer reports *) | Explore (** explore infer reports *)
| Help (** documentation about various aspects of infer *)
| Report (** post-process infer results and reports *) | Report (** post-process infer results and reports *)
| ReportDiff (** compute the difference of two infer reports *) | ReportDiff (** compute the difference of two infer reports *)
| Run (** orchestrate the capture, analysis, and reporting of a compilation command *) | Run (** orchestrate the capture, analysis, and reporting of a compilation command *)

@ -289,3 +289,5 @@ let config c =
let get_id c = (config c).id let get_id c = (config c).id
let from_id id = List.find all ~f:(fun checker -> String.equal (get_id checker) id)

@ -67,3 +67,5 @@ val config : t -> config
val get_id : t -> string val get_id : t -> string
(** [get_id c] is [(config c).id] *) (** [get_id c] is [(config c).id] *)
val from_id : string -> t option

@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*) *)
open! IStd open! IStd
module CLOpt = CommandLineOption module CLOpt = CommandLineOption
module L = Die
type data = {name: string; command_doc: CLOpt.command_doc} type data = {name: string; command_doc: CLOpt.command_doc}
@ -18,12 +20,14 @@ let mk_command_doc ~see_also:see_also_commands ?environment:environment_opt ?fil
~synopsis = ~synopsis =
let section = 1 in let section = 1 in
let see_also = let see_also =
let exe_names = if List.is_empty see_also_commands then None
List.map see_also_commands ~f:(fun cmd -> else
let exe = InferCommand.to_exe_name cmd in let exe_names =
Printf.sprintf "$(b,%s)(%d)" (Cmdliner.Manpage.escape exe) section ) List.map see_also_commands ~f:(fun cmd ->
in let exe = InferCommand.to_exe_name cmd in
[`P (String.concat ~sep:", " exe_names)] Printf.sprintf "$(b,%s)(%d)" (Cmdliner.Manpage.escape exe) section )
in
Some [`P (String.concat ~sep:", " exe_names)]
in in
let environment = let environment =
Option.value environment_opt Option.value environment_opt
@ -43,7 +47,7 @@ let mk_command_doc ~see_also:see_also_commands ?environment:environment_opt ?fil
Cmdliner.Manpage.s_files section ) ] Cmdliner.Manpage.s_files section ) ]
in in
CLOpt.mk_command_doc ~section ~version:Version.versionString CLOpt.mk_command_doc ~section ~version:Version.versionString
~date:Version.man_pages_last_modify_date ~synopsis:[`Pre synopsis] ~environment ~files ~see_also ~date:Version.man_pages_last_modify_date ~synopsis:[`Pre synopsis] ~environment ~files ?see_also
let analyze = let analyze =
@ -131,6 +135,29 @@ $(b,infer) $(b,explore) $(b,--source-files) $(i,[options])|}
~see_also:InferCommand.[Report; Run] ~see_also:InferCommand.[Report; Run]
let help =
mk_command_doc ~title:"Infer Help" ~short_description:"Show and generate documentation."
~synopsis:
{|$(b,infer) $(b,help)
$(b,infer) $(b,help) $(b,--help-checker) $(i,checker1) $(i,...) $(b,--help-checker) $(i,checkerN)
$(b,infer) $(b,help) $(b,--help-issue-type) $(i,ISSUE_TYPE1) $(i,...) $(b,--help-issue-type) $(i,ISSUE_TYPEN)
$(b,infer) $(b,help) $(b,--list-checkers)
$(b,infer) $(b,help) $(b,--list-issue-types)
$(b,infer) $(b,help) $(b,--write-website) $(i,website_root)|}
~description:
[ `P "Without arguments, show the Infer manual as with $(b,infer) $(b,--help)"
; `P
"For each $(b,-help-checker) or $(b,--help-issue-type) option passed, display \
information about the given checker or issue type."
; `P "If $(b,--list-checkers) is passed, list all available checkers."
; `P "If $(b,--list-issue-types) is passed, list all issue types."
; `P
"Use $(b,--write-website) to build some of the documentation for the $(i,fbinfer.com) \
website. (Used in scripts, not meant to be used except when publishing content to \
$(i,fbinfer.com))" ]
~see_also:[]
let infer = let infer =
mk_command_doc ~title:"Infer Static Analyzer" mk_command_doc ~title:"Infer Static Analyzer"
~short_description:"static analysis for Java and C/C++/Objective-C/Objective-C++" ~short_description:"static analysis for Java and C/C++/Objective-C/Objective-C++"
@ -138,6 +165,8 @@ let infer =
{|$(b,infer) $(b,analyze) $(i,[options]) {|$(b,infer) $(b,analyze) $(i,[options])
$(b,infer) $(b,capture) $(i,[options]) $(b,infer) $(b,capture) $(i,[options])
$(b,infer) $(b,compile) $(i,[options]) $(b,infer) $(b,compile) $(i,[options])
$(b,infer) $(b,help) $(i,[options])
$(b,infer) $(b,explore) $(i,[options])
$(b,infer) $(b,report) $(i,[options]) $(b,infer) $(b,report) $(i,[options])
$(b,infer) $(b,reportdiff) $(i,[options]) $(b,infer) $(b,reportdiff) $(i,[options])
$(b,infer) $(b,run) $(i,[options]) $(b,infer) $(b,run) $(i,[options])
@ -298,9 +327,16 @@ let command_to_data =
; mk Capture capture ; mk Capture capture
; mk Compile compile ; mk Compile compile
; mk Explore explore ; mk Explore explore
; mk Help help
; mk Report report ; mk Report report
; mk ReportDiff reportdiff ; mk ReportDiff reportdiff
; mk Run run ] ; mk Run run ]
let data_of_command command = List.Assoc.find_exn ~equal:InferCommand.equal command_to_data command let data_of_command command =
match List.Assoc.find ~equal:InferCommand.equal command_to_data command with
| Some data ->
data
| None ->
L.die InternalError "No data found for command '%s'. Please add an entry in %s!"
(InferCommand.to_string command) __FILE__

@ -737,7 +737,7 @@ let normalize_desc_list speclist =
let mk_command_doc ~title ~section ~version ~date ~short_description ~synopsis ~description ?options let mk_command_doc ~title ~section ~version ~date ~short_description ~synopsis ~description ?options
?exit_status ?environment ?files ?notes ?bugs ?examples ~see_also command_str = ?exit_status ?environment ?files ?notes ?bugs ?examples ?see_also command_str =
let add_if section blocks = let add_if section blocks =
match blocks with None -> `Blocks [] | Some bs -> `Blocks (`S section :: bs) match blocks with None -> `Blocks [] | Some bs -> `Blocks (`S section :: bs)
in in
@ -758,8 +758,7 @@ let mk_command_doc ~title ~section ~version ~date ~short_description ~synopsis ~
; add_if manpage_s_notes notes ; add_if manpage_s_notes notes
; add_if Cmdliner.Manpage.s_bugs bugs ; add_if Cmdliner.Manpage.s_bugs bugs
; add_if Cmdliner.Manpage.s_examples examples ; add_if Cmdliner.Manpage.s_examples examples
; `S Cmdliner.Manpage.s_see_also ; add_if Cmdliner.Manpage.s_see_also see_also ]
; `Blocks see_also ]
in in
let command_doc = let command_doc =
{ title= (command_str, section, date, version, title) { title= (command_str, section, date, version, title)

@ -172,7 +172,7 @@ val mk_command_doc :
-> ?notes:Cmdliner.Manpage.block list -> ?notes:Cmdliner.Manpage.block list
-> ?bugs:Cmdliner.Manpage.block list -> ?bugs:Cmdliner.Manpage.block list
-> ?examples:Cmdliner.Manpage.block list -> ?examples:Cmdliner.Manpage.block list
-> see_also:Cmdliner.Manpage.block list -> ?see_also:Cmdliner.Manpage.block list
-> string -> string
-> command_doc -> command_doc
(** [mk_command_doc ~title ~section ~version ~short_description ~synopsis ~description ~see_also (** [mk_command_doc ~title ~section ~version ~short_description ~synopsis ~description ~see_also

@ -487,7 +487,7 @@ let () =
match cmd with match cmd with
| Report -> | Report ->
`Add `Add
| Analyze | Capture | Compile | Explore | ReportDiff | Run -> | Analyze | Capture | Compile | Explore | Help | ReportDiff | Run ->
`Reject `Reject
in in
(* make sure we generate doc for all the commands we know about *) (* make sure we generate doc for all the commands we know about *)
@ -1001,8 +1001,12 @@ and ( bo_debug
, write_html , write_html
, write_dotty ) = , write_dotty ) =
let all_generic_manuals = let all_generic_manuals =
List.filter_map InferCommand.all_commands ~f:(fun cmd -> List.filter_map InferCommand.all_commands ~f:(fun (command : InferCommand.t) ->
if InferCommand.equal Explore cmd then None else Some (cmd, manual_generic) ) match command with
| Explore | Help ->
None
| (Analyze | Capture | Compile | Report | ReportDiff | Run) as command ->
Some (command, manual_generic) )
in in
let bo_debug = let bo_debug =
CLOpt.mk_int ~default:0 ~long:"bo-debug" CLOpt.mk_int ~default:0 ~long:"bo-debug"
@ -1356,6 +1360,13 @@ and help =
var var
and help_checker =
CLOpt.mk_string_list ~long:"help-checker" ~meta:"checker-id"
~in_help:InferCommand.[(Help, manual_generic)]
"Show information about a checker, for example $(i,biabduction). To see the list of all \
checkers, see $(b,--list-checkers)."
and help_format = and help_format =
CLOpt.mk_symbol ~long:"help-format" CLOpt.mk_symbol ~long:"help-format"
~symbols:[("auto", `Auto); ("groff", `Groff); ("pager", `Pager); ("plain", `Plain)] ~symbols:[("auto", `Auto); ("groff", `Groff); ("pager", `Pager); ("plain", `Plain)]
@ -1365,6 +1376,13 @@ and help_format =
environment variable $(b,TERM) is \"dumb\" or undefined, and to $(b,pager) otherwise." environment variable $(b,TERM) is \"dumb\" or undefined, and to $(b,pager) otherwise."
and help_issue_type =
CLOpt.mk_string_list ~long:"help-issue-type" ~meta:"UNIQUE_ID"
~in_help:InferCommand.[(Help, manual_generic)]
"Show information about an issue type, for example $(i,NULL_DEREFERENCE). To see the list of \
all issue types, see $(b,--list-issue-types)."
and html = and html =
CLOpt.mk_bool ~long:"html" CLOpt.mk_bool ~long:"html"
~in_help:InferCommand.[(Explore, manual_explore_bugs)] ~in_help:InferCommand.[(Explore, manual_explore_bugs)]
@ -1531,6 +1549,18 @@ and linters_validate_syntax_only =
~default:false "Validate syntax of AL files, then emit possible errors in JSON format to stdout" ~default:false "Validate syntax of AL files, then emit possible errors in JSON format to stdout"
and list_checkers =
CLOpt.mk_bool ~long:"list-checkers"
~in_help:InferCommand.[(Help, manual_generic)]
"Show the list of all available checkers."
and list_issue_types =
CLOpt.mk_bool ~long:"list-issue-types"
~in_help:InferCommand.[(Help, manual_generic)]
"Show the list of all issue types that infer might report."
and load_average = and load_average =
CLOpt.mk_float_opt ~long:"load-average" ~short:'l' CLOpt.mk_float_opt ~long:"load-average" ~short:'l'
~in_help:InferCommand.[(Capture, manual_generic)] ~in_help:InferCommand.[(Capture, manual_generic)]
@ -2318,6 +2348,14 @@ and write_html_whitelist_regex =
"Whitelist files that will have their html debug output printed when $(b,--html) is true." "Whitelist files that will have their html debug output printed when $(b,--html) is true."
and write_website =
CLOpt.mk_path_opt ~long:"write-website" ~meta:"path_to_website_dir"
~in_help:InferCommand.[(Help, manual_generic)]
"Use to write website files documenting issue types and checkers under \
$(i,path_to_website_dir/). Meant to be used within the Infer directory to generate its \
website at $(i,fbinfer.com) at $(i,website/)."
and xcode_developer_dir = and xcode_developer_dir =
CLOpt.mk_path_opt ~long:"xcode-developer-dir" CLOpt.mk_path_opt ~long:"xcode-developer-dir"
~in_help:InferCommand.[(Capture, manual_buck)] ~in_help:InferCommand.[(Capture, manual_buck)]
@ -2758,6 +2796,31 @@ and genrule_mode = !genrule_mode
and get_linter_doc_url = process_linters_doc_url !linters_doc_url and get_linter_doc_url = process_linters_doc_url !linters_doc_url
and help_checker =
List.map !help_checker ~f:(fun checker_string ->
match Checker.from_id checker_string with
| Some checker ->
checker
| None ->
L.die UserError
"Wrong argument for --help-checker: '%s' is not a known checker identifier.@\n\
@\n\
See --list-checkers for the list of all checkers." checker_string )
and help_issue_type =
List.map !help_issue_type ~f:(fun id ->
match IssueType.find_from_string ~id with
| Some issue_type ->
issue_type
| None ->
L.die UserError
"Wrong argument for --help-issue-type: '%s' is not a known issue type identifier, or \
is defined in a linters file.@\n\
@\n\
See --list-issue-types for the list of all known issue types." id )
and html = !html and html = !html
and hoisting_report_only_expensive = !hoisting_report_only_expensive and hoisting_report_only_expensive = !hoisting_report_only_expensive
@ -2804,6 +2867,10 @@ and linters_ignore_clang_failures = !linters_ignore_clang_failures
and linters_validate_syntax_only = !linters_validate_syntax_only and linters_validate_syntax_only = !linters_validate_syntax_only
and list_checkers = !list_checkers
and list_issue_types = !list_issue_types
and liveness_dangerous_classes = !liveness_dangerous_classes and liveness_dangerous_classes = !liveness_dangerous_classes
and load_average = and load_average =
@ -3116,6 +3183,8 @@ and write_html = !write_html
and write_html_whitelist_regex = !write_html_whitelist_regex and write_html_whitelist_regex = !write_html_whitelist_regex
and write_website = !write_website
and xcode_developer_dir = !xcode_developer_dir and xcode_developer_dir = !xcode_developer_dir
and xcpretty = !xcpretty and xcpretty = !xcpretty

@ -314,6 +314,10 @@ val genrule_mode : bool
val get_linter_doc_url : linter_id:string -> string option val get_linter_doc_url : linter_id:string -> string option
val help_checker : Checker.t list
val help_issue_type : IssueType.t list
val hoisting_report_only_expensive : bool val hoisting_report_only_expensive : bool
val html : bool val html : bool
@ -372,6 +376,10 @@ val linters_ignore_clang_failures : bool
val linters_validate_syntax_only : bool val linters_validate_syntax_only : bool
val list_checkers : bool
val list_issue_types : bool
val liveness_dangerous_classes : Yojson.Basic.t val liveness_dangerous_classes : Yojson.Basic.t
val max_nesting : int option val max_nesting : int option
@ -611,6 +619,8 @@ val write_html : bool
val write_html_whitelist_regex : string list val write_html_whitelist_regex : string list
val write_website : string option
val xcode_developer_dir : string option val xcode_developer_dir : string option
val xcpretty : bool val xcpretty : bool

@ -60,10 +60,20 @@ let setup () =
db_start () ; db_start () ;
SourceFiles.mark_all_stale () ) SourceFiles.mark_all_stale () )
| Explore -> | Explore ->
ResultsDir.assert_results_dir "please run an infer analysis first" ) ; ResultsDir.assert_results_dir "please run an infer analysis first"
db_start () ; | Help ->
if CLOpt.is_originator then ResultsDir.RunState.add_run_to_sequence () ; () ) ;
() let has_result_dir =
match Config.command with
| Analyze | Capture | Compile | Explore | Report | ReportDiff | Run ->
true
| Help ->
false
in
if has_result_dir then (
db_start () ;
if CLOpt.is_originator then ResultsDir.RunState.add_run_to_sequence () ) ;
has_result_dir
let print_active_checkers () = let print_active_checkers () =
@ -136,9 +146,9 @@ let () =
| None -> | None ->
() ) ; () ) ;
if Config.print_builtins then Builtin.print_and_exit () ; if Config.print_builtins then Builtin.print_and_exit () ;
setup () ; let has_results_dir = setup () in
log_environment_info () ; if has_results_dir then log_environment_info () ;
if Config.debug_mode && CLOpt.is_originator then ( if has_results_dir && Config.debug_mode && CLOpt.is_originator then (
L.progress "Logs in %s@." (ResultsDir.get_path Logs) ; L.progress "Logs in %s@." (ResultsDir.get_path Logs) ;
L.progress "Execution ID %Ld@." Config.execution_id ) ; L.progress "Execution ID %Ld@." Config.execution_id ) ;
( match Config.command with ( match Config.command with
@ -150,6 +160,23 @@ let () =
run Driver.Analyze run Driver.Analyze
| Capture | Compile | Run -> | Capture | Compile | Run ->
run (Lazy.force Driver.mode_from_command_line) run (Lazy.force Driver.mode_from_command_line)
| Help ->
if
Config.(
list_checkers || list_issue_types || Option.is_some write_website
|| (not (List.is_empty help_checker))
|| not (List.is_empty help_issue_type))
then (
if Config.list_checkers then Help.list_checkers () ;
if Config.list_issue_types then Help.list_issue_types () ;
Help.show_checkers Config.help_checker ;
Help.show_issue_types Config.help_issue_type ;
Option.iter Config.write_website ~f:(fun website_root -> Help.write_website ~website_root) ;
() )
else
L.result
"To see Infer's manual, run `infer --help`.@\n\
To see help about the \"help\" command itself, run `infer help --help`.@\n"
| Report -> ( | Report -> (
let write_from_json out_path = let write_from_json out_path =
IssuesTest.write_from_json ~json_path:Config.from_json_report ~out_path IssuesTest.write_from_json ~json_path:Config.from_json_report ~out_path

@ -236,7 +236,7 @@ let analyze_and_report ?suppress_console_report ~changed_files mode =
| _ when Config.infer_is_clang || Config.infer_is_javac -> | _ when Config.infer_is_clang || Config.infer_is_javac ->
(* Called from another integration to do capture only. *) (* Called from another integration to do capture only. *)
(false, false) (false, false)
| (Capture | Compile | Explore | Report | ReportDiff), _ -> | (Capture | Compile | Explore | Help | Report | ReportDiff), _ ->
(false, false) (false, false)
| (Analyze | Run), _ -> | (Analyze | Run), _ ->
(true, true) (true, true)

@ -0,0 +1,18 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
let list_checkers () = assert false
let list_issue_types () = assert false
let show_checkers _ = assert false
let show_issue_types _ = assert false
let write_website ~website_root:_ = assert false

@ -0,0 +1,23 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
val list_checkers : unit -> unit
(** print the list of all checkers *)
val list_issue_types : unit -> unit
(** print the list of all known issue types *)
val show_checkers : Checker.t list -> unit
(** show information about the given checkers *)
val show_issue_types : IssueType.t list -> unit
(** show information about the given issue_types *)
val write_website : website_root:string -> unit
(** generate files for the fbinfer.com website *)
Loading…
Cancel
Save