Metadata-Version: 2.4
Name: robotframework-robocop
Version: 8.2.9
Summary: Static code analysis tool (linter) and code formatter for Robot Framework
Project-URL: Bug tracker, https://github.com/MarketSquare/robotframework-robocop/issues
Project-URL: Source code, https://github.com/MarketSquare/robotframework-robocop
Project-URL: Documentation, https://robocop.dev/
Project-URL: Homepage, https://robocop.dev/
Author-email: Bartlomiej Hirsz <bartek.hirsz@gmail.com>, Mateusz Nojek <matnojek@gmail.com>
Maintainer-email: Bartlomiej Hirsz <bartek.hirsz@gmail.com>
License-File: LICENSE
Keywords: automation,formatter,formatting,linter,qa,robotframework,testautomation,testing
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Robot Framework
Classifier: Framework :: Robot Framework :: Tool
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: click>=8.0.0
Requires-Dist: jinja2>=3.1.4
Requires-Dist: msgpack>=1.0.0
Requires-Dist: pathspec>=0.12
Requires-Dist: platformdirs>=4.3
Requires-Dist: pytz>=2022.7
Requires-Dist: rich>=10.11.0
Requires-Dist: robotframework<7.5,>=5.0
Requires-Dist: tomli-w>=1.0
Requires-Dist: tomli==2.2.1; python_version < '3.11'
Requires-Dist: typer>=0.12.5
Requires-Dist: typing-extensions>=4.15.0
Provides-Extra: mcp
Requires-Dist: fastmcp>=3.0.0; extra == 'mcp'
Description-Content-Type: text/markdown

# Robocop

[![Unit tests](https://github.com/MarketSquare/robotframework-robocop/actions/workflows/tests.yml/badge.svg)](https://github.com/MarketSquare/robotframework-robocop/actions/workflows/unit-tests.yml "GitHub Workflow Unit Tests Status")
![Codecov](https://img.shields.io/codecov/c/github/MarketSquare/robotframework-robocop/master "Code coverage on master branch")
![PyPI](https://img.shields.io/pypi/v/robotframework-robocop?label=version "PyPI package version")
![Python versions](https://img.shields.io/pypi/pyversions/robotframework-robocop "Supported Python versions")
![License](https://img.shields.io/pypi/l/robotframework-robocop "PyPI - License")
[![Downloads](https://static.pepy.tech/personalized-badge/robotframework-robocop?period=total&units=international_system&left_color=grey&right_color=orange&left_text=downloads)](https://pepy.tech/project/robotframework-robocop)

---

<img style="float:right" src="https://raw.githubusercontent.com/MarketSquare/robotframework-robocop/main/docs/source/images/robocop_logo_small.png">


- [Introduction](#introduction)
- [Documentation](#documentation)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Example Output](#example-output)
- [MCP Server](#mcp-server)
- [Values](#values)
- [FAQ](#faq)

---

## Introduction

Robocop is a tool that performs static code analysis and formatting of [Robot Framework](https://github.com/robotframework/robotframework) code.

It uses official [Robot Framework parsing API](https://robot-framework.readthedocs.io/en/stable/) to parse files and
runs a number of checks, looking for potential errors or violations to code quality standards (commonly referred to as
*linting issues*).

> Hosted on [GitHub](https://github.com/MarketSquare/robotframework-robocop).

## Documentation

Full documentation is available at [https://robocop.dev](https://robocop.dev). :open_book:

The most common questions with answers can be found at the bottom ⬇ of this README file.

## Requirements

Python 3.10+ :snake: and Robot Framework 5.0+ :robot:.

## Installation

You can install the latest version of Robocop simply by running:

```commandline
pip install -U robotframework-robocop
```


## Usage

Robocop runs by default from the current directory, and it discovers supported files recursively.
To lint the files, you can run:

```
robocop check
```

To format the files, you can run:

```commandline
robocop format
```

All command line options can be displayed in a help message by executing:

```commandline
robocop -h
```

## Example Output

Executing command:

```commandline
robocop check --reports rules_by_error_type test.robot
```


Will result in the following output:

```text
test.robot:17:1 SPC22 Not enough whitespace after 'Test Teardown' setting
    |
 15 |
 16 | Test Setup Keyword
 17 | Test Teardown Keyword2
    | ^ SPC22
 18 | Testtimeout 1min
 19 | Documentation this is doc
    |

test.robot:28:1 SPC14 Variable in Variables section is not left aligned
   |
 1 | *** Variables ***
 2 | ${VAR} 1
 3 |  ${VAR}  1
   | ^ SPC14
 4 |   ${VAR}  1
 5 | VALUE  1

Found 2 issues: 2 ERRORs, 0 WARNINGs, 0 INFO.
```

## MCP Server

Robocop provides an [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server that allows AI assistants like Claude and GitHub Copilot to lint and format Robot Framework code directly.

Install with MCP support:

```bash
pip install robotframework-robocop[mcp]
```

Run the server:

```bash
robocop-mcp
```

Full documentation: [MCP Server](https://robocop.dev/stable/integrations/ai/)

## Values

Original *RoboCop* - a fictional cybernetic police officer - was the following three prime directives
which also drive the progress of Robocop linter:

First Directive: **Serve the public trust**

Which lies behind the creation of the project - to **serve** developers and testers as a tool to build applications they can **trust**.

Second Directive: **Protect the innocent**

**The innocent** testers and developers have no intention of producing ugly code, but sometimes, you know, it just happens,
so Robocop is there to **protect** them.

Third Directive: **Uphold the law**

Following the coding guidelines established in the project are something crucial to keep the code clean,
readable and understandable by others, and Robocop can help to **uphold the law**.

## FAQ

<details>
  <summary>Can I integrate Robocop with my code editor (IDE)?</summary>

  **Yes**, Robocop integrates nicely with popular IDEs like PyCharm or VSCode
  thanks to [the RobotCode](https://robotcode.io/) plugin.
  Read a simple manual (README) in that project to figure out how to install and use it.

</details>

<details>
  <summary>Can I load configuration from a file?</summary>

  **Yes**, you can use toml-based configuration files:

  **`pyproject.toml` file**
  **`robocop.toml` file**
  **`robot.toml` file**

  Example configuration file:

  ```toml
  [tool.robocop]
  exclude = ["deprecated.robot"]
  
  [tool.robocop.lint]
  select = [
    "rulename",
    "ruleid"
  ]
  configure = [
      "line-too-long.line_length=110"
  ]
  
  [tool.robocop.format]
  select = ["NormalizeNewLines"]
  configure = [
      "NormalizeNewLines.flatten_lines=True"
  ]
  ```

  Multiple configuration files are supported. However, global-like options such as ``--verbose`` or ``--reports`` are
  only loaded from a top configuration file. Read more in
  [configuration](https://robocop.dev/stable/configuration/).

</details>

<details>
  <summary>I use different coding standards. Can I configure rules so that they fit my needs?</summary>

  **Yes**, some rules and formatters are configurable. You can find the configuration details in the documentation or
  by running:

  ```commandline
  robocop docs rule_name_or_id
  robocop docs formatter_name
  ```

  Configuring is done by using `-c / --configure` command line option followed by pattern
  `<name>.<param_name>=<value>` where:
  - `<name>` can either be rule name or its id, or formatter name
  - `<param_name>` is a public name of the parameter
  - `<value>` is a desired value of the parameter

  For example:

  ```commandline
  robocop check --configure line-too-long.line_length=140
  ```

  ---
  Each rule's severity can also be overwritten. Possible values are
  `e/error`, `w/warning` or `i/info` and are case-insensitive. Example:

  ```commandline
  robocop check -c too-long-test-case.severity=e
  ```

  ---
  If there are special cases in your code that violate the rules,
  you can also exclude them in the source code.

  Example:

  ```robotframework
  Keyword with lowercased name  # robocop: off
  ```

  More about it in
  [our documentation](https://robocop.dev/stable/configuration/configuration_reference/#selecting-rules).

</details>

<details>
  <summary>Can I define custom rules?</summary>

  **Yes**, you can define and include custom rules using `--custom-rules` command line option
  by providing a path to a file containing your rule(s):

  ```commandline
  robocop --custom-rules my/own/rule.py --custom-rules external_rules.py
  ```

  If you feel that your rule is very helpful and should be included in Robocop permanently,
  you can always share your solution by
  [submitting a pull request](https://github.com/MarketSquare/robotframework-robocop/pulls).
  You can also share your idea by
  [creating an issue](https://github.com/MarketSquare/robotframework-robocop/issues/new/choose).

  More about custom rules with code examples in
  [our documentation](https://robocop.dev/stable/linter/custom_rules/).
</details>

<details>
  <summary>Can I use Robocop in continuous integration (CI) tools?</summary>

  **Yes**, Robocop is able to produce different kinds of reports that are supported by most popular platforms such as
  GitHub, Gitlab, Sonar Qube, etc. Read more in [integrations](https://robocop.dev/stable/integrations/precommit/).

</details>

---

> Excuse me, I have to go. Somewhere there is a crime happening. - Robocop
