Skip to content

Lint and format with Robocop

Chapter lab: Team toolingch25-team-tooling.zip · 15 KB

This chapter works in a prepared project. Download it before the first task; it unpacks into its own folder.

Download ch25-team-tooling.zip

Or fetch and unpack it from a terminal in VS Code:

Terminal window
curl -fsSLO https://manykarim.github.io/robotframework-essentials-web/labs/ch25-team-tooling.zip && unzip -q ch25-team-tooling.zip && rm ch25-team-tooling.zip

Open the folder in VS Code with code rfe-ch25-team-tooling (or File → Open Folder…) and accept the recommended RobotCode and Python extensions. Then set it up:

Terminal window
uv sync
Terminal window
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Keep the environment active in every terminal where you run lesson commands.

Terminal window
poetry install --no-root

Python 3.13 or newer is required; uv installs it when it is missing.

Open in browserNo setup? Try the lab right here: its files, an editor and a terminal, running in your browser.

What's inside
  • Directoryrfe-ch25-team-tooling/
    • Directory.vscode/
      • extensions.json
    • Directorychecks/
      • alpha.robot
      • beta.robot
      • unformatted.robot
    • .gitignore
    • .python-version
    • LAB.md
    • pyproject.toml
    • README.md
    • requirements.txt
    • uv.lock

Two tools keep a team’s suites healthy, and both ship in one package — Robocop.

  • robocop check lints: it flags style and correctness issues — unclear names, missing documentation, inconsistent spacing, suspicious patterns. Reading its findings is how you learn a team’s conventions.
  • robocop format formats: it rewrites files to a consistent layout — standard indentation, cell spacing, casing — so nobody argues about style in review.
Run

Run the linter over checks/:

Terminal window
uv run robocop check checks
Terminal window
robocop check checks
Terminal window
poetry run robocop check checks

Robocop prints each issue with a rule id you can look up:

uv run robocop check checksrobocop check checkspoetry run robocop check checks
checks/alpha.robot:1:1 DOC03 Missing documentation in suite
checks/alpha.robot:2:1 DOC02 Missing documentation in 'Order Is Created' test case
checks/beta.robot:1:1 DOC03 Missing documentation in suite

A real project tunes which rules apply; for now, just read what it surfaces.

Done when

you ran robocop check.

Run

The bundled checks/unformatted.robot is deliberately cramped — two-space indentation, single-spaced cells. Let Robocop fix it:

Terminal window
uv run robocop format checks/unformatted.robot
Terminal window
robocop format checks/unformatted.robot
Terminal window
poetry run robocop format checks/unformatted.robot
uv run robocop format checks/unformatted.robotrobocop format checks/unformatted.robotpoetry run robocop format checks/unformatted.robot
Reformatted checks/unformatted.robot
 
1 file reformatted, 0 files left unchanged.

Open the file: it is now standard four-space, cleanly separated — the same formatting the rest of the course uses.

Done when

checks/unformatted.robot is consistently formatted.

Check your understanding

Quick recall. Your first answer stays in this browser; the quiz never blocks your progress.

  1. robocop check does what?

    Show the answer

    Answer: lints — flags style and correctness issues — It is the linter; robocop format is the formatter. Both ship in the Robocop package.

  2. Why format with a tool?

    Show the answer

    Answer: so layout is consistent and not argued over in review — A formatter enforces one consistent style automatically.

Key terms

robocop checkcommand
Lint Robot Framework files for style and correctness issues.
robocop formatcommand
Rewrite files to a consistent standard format.

All terms in the glossary →