Configuration reference¶
This page contains all available configuration options for Robocop.
Common¶
include¶
Use --include option to include additional files. By default, Robocop checks only files with
.robot and .resource extension. Glob patterns are supported.
The following example will include all files ending with .task extension or named "special.file":
default include¶
Use --default-include option to override default include patterns. By default, Robocop checks only files with
.robot and .resource extension. Glob patterns are supported.
The following example will include all files ending with .robot extension (.resource will be ignored since
we have overridden default include).
exclude¶
Use --exclude option to exclude additional files.
By default, Robocop ignores .direnv, .eggs, .git, .svn, .hg, .nox, .tox, .venv, venv, dist directories.
Glob patterns are supported.
default exclude¶
Use --default-exclude option to override default exclude patterns.
By default, Robocop ignores .direnv, .eggs, .git, .svn, .hg, .nox, .tox, .venv, venv, dist directories.
Glob patterns are supported.
force exclude¶
Use --force-exclude flag to force Robocop to process files even if they are passed from the cli.
Files specified directly on the command line are always included regardless of exclusion rules. By using this flag, Robocop will respect the exclusion rules.
skip gitignore¶
Use --skip-gitignore flag to disable loading of .gitignore files.
Robocop will ignore all files listed in .gitignore files unless --skip-gitignore is used.
language¶
--language / --lang option allows configuring language used for parsing source files.
Custom language files are currently not supported.
verbose¶
Enable more verbose output with --verbose flag.
silent¶
Disable logging with --silent flag.
Configuration options¶
config¶
Use --config to specify a configuration file. It disables automatic loading of configuration files found in the
directory tree.
extends¶
Inherit configuration from another configuration file using extends option:
extends accept both relative and absolute paths. Configuration is loaded in the order they are specified.
List-like options (select, ignore etc.) are merged. String and boolean options are overwritten by the most recent
value.
configure¶
--configure / -c option allows configuring rules, formatters and linter reports. Exact parameters and their
types are described in their documentation. All parameters follow --configure name.param=value pattern for
providing values.
Typically, you can repeat it multiple times to configure multiple parameters.
ignore git dir¶
Use --ignore-git-dir flag to continue searching for configuration files even when encountering a .git directory.
By default, Robocop will stop searching for configuration files when encountering a .git directory.
ignore file config¶
Ignore configuration files (pyproject.toml, .robocop.toml and robot.toml) found in the directory tree
with --ignore-file-config flag.
target version¶
Use --target-version option to configure which Robot Framework version you want to target.
When configured, it will automatically disable all rules and formatters that require a more recent version of
Robot Framework.
It is useful if you have a legacy codebase you don't want to migrate yet, but the environment where you run Robocop
uses a more recent version of Robot Framework.
For example:
- if your codebase supports only Robot Framework 4.0, and your environment has 4.0, there is no need to configure anything
- if your codebase supports Robot Framework 4.0, and your environment has 5.0 or more recent, you need to configure a target version to 4
This option accepts a major version of Robot Framework (4, 5, .. ):
variables¶
Use --variable option to define variables used when resolving dynamic import paths. It is an equivalent of the
Robot Framework --variable option and uses the same NAME:VALUE syntax.
Project level rules resolve Resource, Library and Variables import paths to files on the disk. If the
path contains a variable that is not defined in the *** Variables *** section of the importing file, it can be
provided using this option:
Variables provided in the command line take precedence over variables from the configuration file, which take
precedence over variables defined in the *** Variables *** section of the file itself.
Built-in variables ${CURDIR}, ${EXECDIR} and ${TEMPDIR} are resolved automatically. Environment
variables are supported using the %{NAME} and %{NAME=default} syntax.
If a variable used in the import path cannot be resolved, the import is ignored instead of being reported, so dynamically built paths do not cause false positives.
variable-files¶
Use --variablefile option to load variables from a Python or YAML file. It is an equivalent of the Robot Framework
--variablefile option and supports the same path:arg1:arg2 syntax for variable files taking arguments.
Paths in the configuration file are relative to the configuration file. Only scalar variables are loaded, since only
those can be used to build an import path. Variables from the command line (--variable) take precedence over
variables from variable files, which take precedence over variables defined in the *** Variables *** section.
Warning
Loading a Python variable file imports it, which executes its code. Robocop never fails because of a variable file - if the file is missing or raises an error, it is silently skipped.
python-path¶
Use --pythonpath option to add locations searched for Resource, Library and Variables imports.
It is an equivalent of the Robot Framework --pythonpath option.
Robot Framework first searches for the import next to the importing file, and then in the locations from the
--pythonpath option. Robocop resolves imports the same way, so a project relying on this option needs to pass it
to Robocop as well:
Glob patterns are supported. Relative paths in the command line are resolved against the project root, and relative paths in the configuration file are resolved against the configuration file.
project¶
Project level rules require parsing the whole project. Robocop does it automatically whenever at least one project level rule is enabled, so this option is only needed to override that decision:
--projectalways runs project level rules (does nothing if none of them is enabled),--no-projectnever runs them, even if they are selected in the configuration file.
--no-project is useful when the same configuration file is shared between a fast run (for example a pre-commit
hook) and a full run in the CI:
The project context is always built from the project root, even if only selected paths are linted.
analyze-libraries¶
robocop check imports Robot Framework libraries to find out what keywords they provide and what
arguments those keywords accept. Importing a library executes its code, which is why it only happens when
project level rules are enabled. Every library is imported once and any failure is silently ignored - a library
that cannot be imported simply provides no keywords.
Use --no-analyze-libraries to disable it completely:
library-workers¶
By default libraries are imported synchronously, directly in the Robocop process. It is the fastest option, but Robocop cannot stop a library that never finishes importing.
Use --library-workers to import every library in a separate process instead. Several libraries are then
imported at the same time and every import is stopped after
load-library-timeout seconds. It is useful for projects with libraries that hang or
crash the interpreter on import.
load-library-timeout¶
Maximum time in seconds for importing a single library. Default is 10. Only used together with
library-workers, since a library imported in the Robocop process cannot be interrupted.
ignored-libraries¶
Libraries that should not be imported, for example because importing them is slow or has side effects. Glob patterns are supported.
Linter¶
Selecting rules¶
select¶
Use --select option to select rules to run. You can use rule id or rule name. Glob patterns are supported.
When this option is used, all other rules are disabled.
To only select and run missing-doc-keyword rule:
You can select multiple rules:
To only select and run rules with doc in their name:
Use ALL keyword to select all rules (including rules disabled by default, but excluding
project level rules). You can combine it with --ignore
option to select all rules except those you want to ignore:
Use PROJECT keyword to select all project level rules. It works with
--select, --extend-select and --ignore. Project level rules are not selected by ALL, so use
PROJECT to run them together with every other rule:
extend select¶
Use --extend-select option to select additional rules to run on top of the --select. If --select is not
used, all default rules plus --extend-select rules are run.
You can use rule id or rule name. Glob patterns are supported.
To run all default rules plus not-allowed-keyword (non-default rule):
To run selected spacing rules plus custom rule:
ignore¶
Use --ignore option to ignore rules. You can use rule id or rule name. Glob patterns are supported.
To run all default rules except missing-doc-keyword rule:
To ignore multiple rules:
To ignore all rules with doc in their name:
threshold¶
Use --threshold / -t option to filter out rules that have lower severity than the threshold. Each rule has
assigned severity level (info, warning, error) which can be used to filter out rules. Shorthands can be
used:
IforinfoWforwarningEforerror
To filter our rules with severity info:
per_file_ignores¶
A mapping of file patterns and rule ids or names to exclude from the results.
[tool.robocop.lint.per_file_ignores]
"test.robot" = ["VAR02"]
"ignore_subdir/*" = ["empty-line-after-section", "DOC01"]
"ignore_file_in_subpath/test2.robot" = ["SPC10"]
custom rules¶
Read more about custom rules on the Custom rules page.
--custom-rules option allows including custom rules.
Fix rules¶
fix¶
Apply automatic fixes to detected issues.
unsafe_fixes¶
Apply potentially unsafe fixes in addition to safe fixes. Requires fix = true to take effect.
Warning
Unsafe fixes may alter code behaviour. Always review changes before committing.
diff¶
Show the difference after applying the fixes without modifying files.
--diff is only supported in the cli.
fixable¶
Use --fixable option to select which rules should be fixed with --fix. By default, all applicable fixable rules
are fixed.
unfixable¶
Use --unfixable option to select which rules should not be fixed with --fix.
Reports¶
reports¶
Read more about reports on the Reports page.
Use --reports / -r option to configure which reports to generate.
List all available reports with list reports command:
persistent¶
Use --persistent option to save Robocop reports in cache directory for later comparison.
Use it with a combination with --compare option to compare reports.
compare¶
Use --compare option to compare Robocop reports with previous run. Requires --persistent option to be set
in previous run (to have results to compare with) with at least one report enabled.
For example, to compare reports, you can run:
You can combine both options and compare reports with previous run and save them in the cache directory:
roboocp check --reports rules_by_id --persistent --compare # will save report and compare with previous run (if any)
robocop check --reports rules_by_id --persistent --compare # will save report and compare with previous run
gitlab¶
--gitlab option is shorthand for --reports gitlab option. It will generate a GitLab compatible report.
See the GitLab page for more information.
Other¶
issue format¶
--issue-format option allows configuring output format of issues.
It only affects simple output type. See print issues reporter to see all
possible output types and their configuration.
Available placeholders:
{source}- source file name{source_abs}- absolute path to a source file{line}- line number{end_line}- end line number{col}- column number{end_col}- end column number{severity}- severity level (info,warning,error){rule_id}- rule id{desc}- rule description{name}- rule name
Extended output configuration:
exit zero¶
Use --exit-zero option to exit with code 0 even if there are issues found.
root¶
Use --root to point to the project root directory. By default, Robocop finds it automatically based on existence of the .git
directory. Root is used to find a default configuration file.
Formatter¶
Selecting formatters¶
select¶
Use --select option to select formatters to run. When this option is used, all other formatters are disabled.
Note
If you want to only enable additional formatters and do not disable default ones, use
--extend-select option instead.
To only select and run NormalizeSeparators formatter:
You can select multiple formatters:
extend select¶
--extend-select option allows including formatters in addition to the --select ones. Since --select option
by default enables all default formatters, this option is useful to run all default and selected non-default or custom
formatters.
Read more about custom formatters on the Custom formatters page.
force order¶
Use --force-order option to force order of the formatters (by order provided in the cli).
By default, all formatters run in the same order. Whether called with:
or:
or:
It will format files according to internal order (in this example NormalizeSettingName is before
SplitTooLongLine). External formatters are used last. To see order of the formatters run
robocop list formatters.
If you want to format files using a different order, you need to run formatters separately:
This behaviour can be changed by using --force-order flag:
Work modes¶
overwrite¶
By default, Robocop overwrites the file with formatted code. You can enable/disable this behaviour with --overwrite
/ --no-overwrite flag.
diff¶
Show difference after formatting the file with the --diff option.
color¶
Use --color / --no-color option to enable/disable color output. By default, Robocop uses color output.
check¶
Check is a special mode used to check if the file is formatted correctly. If the file is not formatted correctly,
Robocop will return exit code 1. The files are not overwritten (turn back overwriting with --overwrite flag).
reruns¶
Rerun formatter with the given number of times using --reruns option. Default value is 0 (do not rerun).
If the file was modified during the last run, the formatter will be rerun until the file is not modified.
This option is useful when you have a formatter that changes the formatting of the previous formatter. For example, if you align the code first, and then you add new code in another formatter, you may want to rerun the formatter so the new code is aligned.
Note that if you enable it, it can double the execution time of Robocop.
Formatting settings¶
space count¶
Use --space-count to configure number of spaces between cells (default 4). Most of the formatters use this value
to align code.
Spacing attributes names
- Indent
- Continuation indent
- Space count
indent¶
Use --indent to configure indentation of code. Default value is the same as space count option (4).
Spacing attributes names
- Indent
- Continuation indent
- Space count
continuation indent¶
Use --continuation-indent to configure indentation of continuation lines. Default value is the same as
space count option (4).
Spacing attributes names
- Indent
- Continuation indent
- Space count
line length¶
Number of characters per line. This value is used by formatters that split long lines into multiple lines to determine
where to split the line. Use --line-length option to configure line length (default 120).
separator¶
Use --separator option to configure separator between cells. Default value is space:
space: use--space-countspaces to separate tokenstab: use single tabulation to separate tokens
line ending¶
When working on multiple platforms, the file can contain different line endings (CRLF, LF). By default,
Robocop will replace all line endings with system native line ending. It may be problematic if you're using
different platforms. You can force specific line ending or autodetect line ending used in the file and use it by
configuring --line-ending option:
- native: use operating system's native line endings (default)
- windows: use Windows line endings (CRLF)
- unix: use Unix line endings (LF)
- auto: maintain existing line endings (uses what's used in the first line of the file)
start line¶
Use --start-line option to configure line number where formatter should start. If --end-line is not provided,
format text only at `--start-line.
This option is useful when you want to format only a part of the file, it is typically useful with the automatic tooling. We don't recommend using this option with the manual execution.
end line¶
Use --end-line option to configure line number where formatter should end. Use it only with a combination with
--start-line.
This option is useful when you want to format only a part of the file, it is typically useful with the automatic tooling. We don't recommend using this option with the manual execution.
Skip formatting¶
skip¶
Use --skip option to skip formatting code of a given type.
See skip option for more details.
skip sections¶
Use --skip-sections option to skip formatting code of a given section.
See skip sections for more details.
skip keyword call¶
Use --skip-keyword-call option to skip formatting code of a given keyword call.
See skip keyword call for more details.
skip keyword call pattern¶
Use --skip-keyword-call-pattern option to skip formatting code of a given keyword call that matches a configured
pattern.
See skip keyword call pattern for more details.
Caching¶
cache¶
Use --cache / --no-cache option to enable/disable caching of the files. By default, Robocop caches the results of
linting and formatting. Read more about caching one the ... page.
cache-dir¶
Change the cache directory (default .robocop_cache) using --cache-dir option.
clear-cache¶
Clear cache directory with --clear-cache option. It will force reprocessing of all the files.