robocop
RoboCop is a linter and code formatter for the Robot Framework. It helps maintain clean, consistent, and high-quality automation test code.
Key Features:
- Static code analysis detecting common issues, code smells, and potential errors in Robot Framework test suites.
- Customizable rules (checks) with a large set of built-in rules (e.g., naming conventions, spacing, structure) that can be enabled, disabled, or configured to fit team standards.
- Code formatting can automatically format Robot Framework files to follow consistent style guidelines.
- Error, warning, and info levels each message is categorized, making it easy to distinguish between critical issues and style suggestions.
- Extensibility supports custom rules, so teams can enforce project-specific conventions.
- Configuration flexibility rules can be configured via pyproject.toml, robocop.toml, or CLI options, making integration smooth in different environments.
- Integration with CI/CD easy to run in pipelines to ensure code quality before merging changes.
- Pre-commit hook support can be added to Git pre-commit hooks to lint and format files automatically before committing.
- Output options supports multiple output formats (text, JSON, SARIF), useful for different reporting tools.
- Performance optimized for speed and can handle large Robot Framework projects.
robocop documentation
- Version in MegaLinter: 6.7.0
- Visit Official Web Site
- See How to configure robocop rules
- See How to disable robocop rules in files
- See Index of problems detected by robocop
Configuration in MegaLinter
- Enable robocop by adding
ROBOTFRAMEWORK_ROBOCOP
in ENABLE_LINTERS variable - Disable robocop by adding
ROBOTFRAMEWORK_ROBOCOP
in DISABLE_LINTERS variable
- Enable autofixes by adding
ROBOTFRAMEWORK_ROBOCOP
in APPLY_FIXES variable
Variable | Description | Default value |
---|---|---|
ROBOTFRAMEWORK_ROBOCOP_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
ROBOTFRAMEWORK_ROBOCOP_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
ROBOTFRAMEWORK_ROBOCOP_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Include every file |
ROBOTFRAMEWORK_ROBOCOP_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
ROBOTFRAMEWORK_ROBOCOP_CLI_LINT_MODE | Override default CLI lint mode - file : Calls the linter for each file- list_of_files : Call the linter with the list of files as argument- project : Call the linter from the root of the project |
list_of_files |
ROBOTFRAMEWORK_ROBOCOP_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
[".robot", ".resource"] |
ROBOTFRAMEWORK_ROBOCOP_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] |
Include every file |
ROBOTFRAMEWORK_ROBOCOP_PRE_COMMANDS | List of bash commands to run before the linter | None |
ROBOTFRAMEWORK_ROBOCOP_POST_COMMANDS | List of bash commands to run after the linter | None |
ROBOTFRAMEWORK_ROBOCOP_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling ROBOTFRAMEWORK_ROBOCOP and its pre/post commands | None |
ROBOTFRAMEWORK_ROBOCOP_CONFIG_FILE | robocop configuration file name Use LINTER_DEFAULT to let the linter find it |
robocop.toml |
ROBOTFRAMEWORK_ROBOCOP_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
ROBOTFRAMEWORK_ROBOCOP_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
ROBOTFRAMEWORK_ROBOCOP_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
ROBOTFRAMEWORK_ROBOCOP_CLI_EXECUTABLE | Override CLI executable | ['robocop'] |
IDE Integration
Use robocop in your favorite IDE to catch errors before MegaLinter !
IDE | Extension Name | Install | |
---|---|---|---|
Visual Studio Code | RobotCode | ![]() |
MegaLinter Flavors
This linter is available in the following flavors
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
![]() |
all | Default MegaLinter Flavor | 127 | |
cupcake | MegaLinter for the most commonly used languages | 87 |
Behind the scenes
How are identified applicable files
- File extensions:
.robot
,.resource
How the linting is performed
- robocop is called once with the list of files as arguments (
list_of_files
CLI lint mode)
Example calls
robocop check myfile.robot
Help content
Usage: robocop [OPTIONS] COMMAND [ARGS]...
Static code analysis tool (linter) and code formatter for Robot Framework.
Full documentation available at https://robocop.readthedocs.io .
â•─ Options ────────────────────────────────────────────────────────────────────╮
│ --version Show the version and │
│ exit. │
│ --install-completion [bash|zsh|fish|powers Install completion for │
│ hell|pwsh] the specified shell. │
│ --show-completion [bash|zsh|fish|powers Show completion for the │
│ hell|pwsh] specified shell, to │
│ copy it or customize │
│ the installation. │
│ --help -h Show this message and │
│ exit. │
╰──────────────────────────────────────────────────────────────────────────────╯
â•─ Commands ───────────────────────────────────────────────────────────────────╮
│ check Lint Robot Framework files. │
│ format Format Robot Framework files. │
│ list List available rules, reports or formatters. │
│ docs Print formatter, rule or report documentation. │
│ migrate Migrate Robocop and Robotidy old configuration files to the new │
│ format supported by the Robocop 6.0. │
╰──────────────────────────────────────────────────────────────────────────────╯
Installation on mega-linter Docker image
- Dockerfile commands :
# renovate: datasource=pypi depName=robotframework-robocop
ARG PIP_ROBOT_FRAMEWORK_ROBOCOP_VERSION=6.7.0
- PIP packages (Python):