Skip to content

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":

robocop check --include *.task --include special.file
robocop format --include *.task --include special.file
[tool.robocop]
include = [
    "*.task",
    "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).

robocop check --default-include *.robot
robocop format --default-include *.robot
[tool.robocop]
default-include = ["*.robot"]

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.

robocop check --exclude tmp_dir
robocop format --exclude tmp_dir
[tool.robocop]
exclude = ["tmp_dir"]

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.

robocop check --default-exclude .git
robocop format --default-exclude .git
[tool.robocop]
default-exclude = [".git"]

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.

robocop check --force-exclude test.txt
robocop format --force-exclude test.txt
[tool.robocop]
force-exclude = true

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.

robocop check --skip-gitignore
robocop format --skip-gitignore
[tool.robocop]
skip-gitignore = true

language

--language / --lang option allows configuring language used for parsing source files.

robocop check --language fi --language pl
robocop format --language fi --language pl
[tool.robocop]
language = [
    "fi",
    "pl"
]

Custom language files are currently not supported.


verbose

Enable more verbose output with --verbose flag.

robocop check --verbose
robocop format --verbose
[tool.robocop]
verbose = true

silent

Disable logging with --silent flag.

robocop check --silent
robocop format --silent
[tool.robocop]
silent = true

Configuration options

config

Use --config to specify a configuration file. It disables automatic loading of configuration files found in the directory tree.

robocop check --config robocop/config.toml
robocop format --config robocop/config.toml

extends

Inherit configuration from another configuration file using extends option:

[tool.robocop]
extends = ["../relative/path.toml", "C:/absolute/path.toml"]

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.

robocop check --configure line-too-long.line_length=80 --configure sonarqube.output_path=robocop.json
robocop format --configure NormalizeNewLines.section_lines=1 --configure NormalizeNewLines.keyword_lines=1
[tool.robocop.lint]
configure = [
    "line-too-long.line_length=80",
    "sonarqube.output_path=robocop.json"
]
[tool.robocop.format]
configure = [
    "NormalizeNewLines.section_lines=1",
    "NormalizeNewLines.keyword_lines=1"
]

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.

robocop check --ignore-git-dir
robocop format --ignore-git-dir
--ignore-git-dir is only supported in CLI.

ignore file config

Ignore configuration files (pyproject.toml, .robocop.toml and robot.toml) found in the directory tree with --ignore-file-config flag.

robocop check --ignore-file-config
robocop format --ignore-file-config
--ignore-file-config is only supported in CLI.

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, .. ):

robocop check --target-version 5
robocop format --target-version 5
[tool.robocop]
target-version = 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:

*** Settings ***
Resource    ${RESOURCE_DIR}/common.resource
robocop check --variable RESOURCE_DIR:resources
robocop check -v RESOURCE_DIR:resources -v ENV:qa
[tool.robocop.variables]
RESOURCE_DIR = "resources"
ENV = "qa"

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.

robocop check --variablefile config/variables.py
robocop check -V config/variables.py -V config/environments.yaml
[tool.robocop]
variable-files = ["config/variables.py", "config/environments.yaml"]

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:

*** Settings ***
Resource    common.resource  # stored in the shared/ directory, not next to this file
robocop check --pythonpath shared
robocop check -P shared -P libs/*
[tool.robocop]
python-path = ["shared", "libs/*"]

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:

  • --project always runs project level rules (does nothing if none of them is enabled),
  • --no-project never 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:

robocop check --no-project
[tool.robocop]
project = false

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:

robocop check --no-analyze-libraries
[tool.robocop]
analyze-libraries = false

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.

robocop check --library-workers
[tool.robocop]
library-workers = true

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.

robocop check --load-library-timeout 30
[tool.robocop]
load-library-timeout = 30

ignored-libraries

Libraries that should not be imported, for example because importing them is slow or has side effects. Glob patterns are supported.

robocop check --ignored-library SeleniumLibrary --ignored-library Custom*
[tool.robocop]
ignored-libraries = ["SeleniumLibrary", "Custom*"]

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:

robocop check --select missing-doc-keyword
[tool.robocop.lint]
select = [
    "missing-doc-keyword"
]

You can select multiple rules:

robocop check --select unused-argument --select DUP01
[tool.robocop.lint]
select = [
    "unused-argument",
    "DUP01"
]

To only select and run rules with doc in their name:

robocop check --select *doc*
[tool.robocop.lint]
select = [
    "*doc*"
]

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:

robocop check --select ALL
[tool.robocop.lint]
select = [
    "ALL"
]

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:

robocop check --extend-select PROJECT
robocop check --select ALL --extend-select PROJECT
[tool.robocop.lint]
extend-select = [
    "PROJECT"
]

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):

robocop check --extend-select not-allowed-keyword
[tool.robocop.lint]
extend-select = [
    "not-allowed-keyword"
]

To run selected spacing rules plus custom rule:

robocop check --select SPC* --extend-select custom-rule
[tool.robocop.lint]
select = [
    "SPC*",
]
extend-select = [
    "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:

robocop check --ignore missing-doc-keyword
[tool.robocop.lint]
ignore = [
    "missing-doc-keyword"
]

To ignore multiple rules:

robocop check --ignore missing-doc-keyword --ignore duplicated-test-case
[tool.robocop.lint]
ignore = [
    "missing-doc-keyword",
    "duplicated-test-case"
]

To ignore all rules with doc in their name:

robocop check --ignore *doc*
[tool.robocop.lint]
ignore = [
    "*doc*"
]

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:

  • I for info
  • W for warning
  • E for error

To filter our rules with severity info:

robocop check --threshold W
[tool.robocop.lint]
threshold = "W"

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.

robocop check --custom-rules my/own/rule.py --custom-rules custom_rules.py
[tool.robocop.lint]
custom_rules = [
    "my/own/rule.py",
    "custom_rules.py"
]

Fix rules

fix

Apply automatic fixes to detected issues.

robocop check --fix
[tool.robocop.lint]
fix = true

unsafe_fixes

Apply potentially unsafe fixes in addition to safe fixes. Requires fix = true to take effect.

robocop check --fix --unsafe-fixes
[tool.robocop.lint]
fix = true
unsafe_fixes = true

Warning

Unsafe fixes may alter code behaviour. Always review changes before committing.


diff

Show the difference after applying the fixes without modifying files.

robocop check --diff

--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.

robocop check --fix --fixable rule-name-or-id --fixable other-rule
[tool.robocop.lint]
fix = true
fixable = [
  "rule-name-or-id",
  "other-rule"
]

unfixable

Use --unfixable option to select which rules should not be fixed with --fix.

robocop check --fix --unfixable rule-name-or-id --unfixable other-rule
[tool.robocop.lint]
fix = true
unfixable = [
  "rule-name-or-id",
  "other-rule"
]

Reports

reports

Read more about reports on the Reports page.

Use --reports / -r option to configure which reports to generate.

robocop check --reports gitlab,file_stats
[tool.robocop.lint]
reports = [
    "gitlab",
    "file_stats"
]

List all available reports with list reports command:

robocop list reports

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.

robocop check --reports file_stats --persistent
[tool.robocop.lint]
persistent = true
reports = [
    "file_stats"
]

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.

robocop check --reports file_stats --compare
[tool.robocop.lint]
compare = true
reports = [
    "file_stats"
]

For example, to compare reports, you can run:

roboocp check --reports rules_by_id --persistent
robocop check --reports rules_by_id --compare

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.

robocop check --gitlab
--gitlab is only supported in CLI.

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
robocop check --issue-format "{source}:{line}:{col} [{severity}] {rule_id} {desc} ({name})"
[tool.robocop.lint]
issue-format = "{source}:{line}:{col} [{severity}] {rule_id} {desc} ({name})"

Extended output configuration:

robocop check --configure print_issues.issue_format="{source}"
[tool.robocop.lint]
configure = [
    "print_issues.issue_format={source}"
]

exit zero

Use --exit-zero option to exit with code 0 even if there are issues found.

robocop check --exit-zero
[tool.robocop.lint]
exit-zero = true

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.

robocop check --root path/to/project/root

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:

robocop format --select NormalizeSeparators
[tool.robocop.format]
select = [
    "NormalizeSeparators"
]

You can select multiple formatters:

robocop format --select AlignVariablesSection --select OrderTags
[tool.robocop.format]
select = [
    "AlignVariablesSection",
    "OrderTags"
]

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.

robocop format --extend-select my/own/Formatter.py --extend-select CustomFormatter.py
[tool.robocop.format]
extend-select = [
    "my/own/Formatter.py",
    "CustomFormatter.py"
]

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:

robocop format

or:

robocop format --select NormalizeSettingName --select SplitTooLongLine

or:

robocop format --select SplitTooLongLine --select NormalizeSettingName

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:

robocop format --select SplitTooLongLine
robocop format --select NormalizeSettingName

This behaviour can be changed by using --force-order flag:

robocop format --force-order --select SplitTooLongLine --select NormalizeSettingName
[tool.robocop.format]
force-order = true
select = [
    "SplitTooLongLine",
    "NormalizeSettingName"
]

Work modes


overwrite

By default, Robocop overwrites the file with formatted code. You can enable/disable this behaviour with --overwrite / --no-overwrite flag.

robocop format --no-overwrite
[tool.robocop.format]
overwrite = false

diff

Show difference after formatting the file with the --diff option.

robocop format --diff
[tool.robocop.format]
diff = true

color

Use --color / --no-color option to enable/disable color output. By default, Robocop uses color output.

robocop format --no-color
[tool.robocop.format]
color = false

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).

robocop format --check
[tool.robocop.format]
check = true

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.

robocop format --reruns 3
[tool.robocop.format]
reruns = 3

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
*** Keywords ***
Custom Keyword
    Keyword Call
    (1)...    (2)${arg}
    (1)...    (2)${arg2}
    (1)Log    (3)${value}
  1. Indent
  2. Continuation indent
  3. Space count
robocop format --space-count 2
[tool.robocop.format]
space-count = 2

indent

Use --indent to configure indentation of code. Default value is the same as space count option (4).

Spacing attributes names
*** Keywords ***
Custom Keyword
    Keyword Call
    (1)...    (2)${arg}
    (1)...    (2)${arg2}
    (1)Log    (3)${value}
  1. Indent
  2. Continuation indent
  3. Space count
robocop format --indent 2
[tool.robocop.format]
indent = 2

continuation indent

Use --continuation-indent to configure indentation of continuation lines. Default value is the same as space count option (4).

Spacing attributes names
*** Keywords ***
Custom Keyword
    Keyword Call
    (1)...    (2)${arg}
    (1)...    (2)${arg2}
    (1)Log    (3)${value}
  1. Indent
  2. Continuation indent
  3. Space count
robocop format --continuation-indent 2
[tool.robocop.format]
continuation-indent = 2

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).

robocop format --line-length 140
[tool.robocop.format]
line-length = 140

separator

Use --separator option to configure separator between cells. Default value is space:

  • space: use --space-count spaces to separate tokens
  • tab: use single tabulation to separate tokens
robocop format --separator space
[tool.robocop.format]
separator = "space"

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)
robocop format --line-ending unix
[tool.robocop.format]
line-ending = "unix"

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.

robocop format --start-line 10
[tool.robocop.format]
start-line = 10

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.

robocop format --start-line 10 --end-line 20
[tool.robocop.format]
start-line = 10
end-line = 20

Skip formatting

skip

Use --skip option to skip formatting code of a given type.

robocop format --skip documentation
[tool.robocop.format]
skip = ["documentation"]

See skip option for more details.


skip sections

Use --skip-sections option to skip formatting code of a given section.

robocop format --skip-sections=keywords,testcases
[tool.robocop.format]
skip-sections = [
    "keywords",
    "testcases"
]

See skip sections for more details.


skip keyword call

Use --skip-keyword-call option to skip formatting code of a given keyword call.

robocop format --skip-keyword-call Name --skip-keyword-call othername
[tool.robocop.format]
skip-keyword-call = [
    "Name",
    "othername"
]

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.

robocop format --skip-keyword-call-pattern ^Second --skip-keyword-call-pattern (i?)contains\s?words
[tool.robocop.format]
skip-keyword-call-pattern = [
    "^Second",
    "(i?)contains\\s?words"
]

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.

robocop lint --no-cache
robocop format --no-cache
[tool.robocop]
cache = false

cache-dir

Change the cache directory (default .robocop_cache) using --cache-dir option.

robocop lint --cache-dir cache_directory
robocop format --cache-dir cache_directory
[tool.robocop]
cache-dir = "cache_directory"

clear-cache

Clear cache directory with --clear-cache option. It will force reprocessing of all the files.

robocop lint --clear-cache
robocop format --clear-cache