| description | Reference for the codeql query format command |
|---|
The codeql query format command is used to automatically format CodeQL source code files.
The following is an example use of the command for formatting a query file:
# Format the ExampleQuery.ql file in the current working directory.
codeql query format -i -- ExampleQuery.qlThe codeql query format command can also format multiple files and directories:
# Format all files .ql and/or .qll files in-place (i.e. `-i`) in the
# `relative/path-to/some/queries/` directory.
codeql query format -i -- relative/path-to/some/queries/*.ql*# Format all queries found in the `queries/` directory. The `--in-place` flag
# is the long version of the `-i` flag.
codeql query format --in-place -- queries/*.ql# Only check formatting for all queries found in the `queries/` directory.
codeql query format --check-only -- queries/*.qlUsage: codeql query format [OPTIONS] -- [<file>...]
Autoformat QL source code.
[<file>...] One or more .ql or .qll source files to autoformat. A dash can be specified to read from standard input.
-o, --output=<file> Write the formatted QL code to this file instead of the standard output stream. Must not be given if there is more than one input.
-i, --[no-]in-place Overwrite each input file with a formatted version of its content.
--[no-]check-only Instead of writing output, exit with status 1 if any input files differ from their correct formatting. A message telling which files differed will be printed
to standard error unless you also give -qq.
-b, --backup=<ext> When writing a file that already exists, rename the existing file to a backup by appending this extension to its name. If the backup file already exists, it
will be silently deleted.
--no-syntax-errors If an input file is not syntactically correct QL, pretend that it is already correctly formatted. (Usually such a file causes the command to terminate with
an error message).
Common options:
-h, --help Show this help text.
-v, --verbose Incrementally increase the number of progress messages printed.
-q, --quiet Incrementally decrease the number of progress messages printed.
Some advanced options have been hidden; try --help -v for a fuller view.
- Edit or create CodeQL query (
.ql) and/or library (.qll) files.
codeql query compile- Compile the query once formatting has been validated / enforced.codeql query run- Run the formatted query against an existing, local CodeQL database.codeql test run- Run unit tests for the formatted query.