Skip to content

Fix rules #1631

Description

@bhirsz

Meta ticket for rules that can have fixes.

The tables below contain a brief overview of every rule: whether an automatic fix is possible, how difficult and how
safe it would be, whether an existing formatter already covers the rewrite, and the current implementation status.

Legend

Column Values
Fix ✅ possible / ❌ not possible (needs manual intervention, usually a bigger refactor)
Difficulty easy / mid / hard
Safety safe / unsafe (fix may change the behaviour, would need UNSAFE applicability)
Status ✅ implemented / 🔄 in progress / ⬜ to do / ➖ not planned

Scope of check --fix vs robocop format

robocop format focuses on whitespace, alignment and optional one-time housekeeping. It should not replace
deprecated syntax or solve single issues that are already fully covered by a rule - such formatters are being
deprecated (NormalizeComments in #1845, RemoveEmptySettings in #1849, ReplaceEmptyValues in #1853,
ReplaceRunKeywordIf in #1899, NormalizeAssignments in #1904, DiscardEmptySections in #1905) in favour
of a rule fix.
Whitespace/alignment formatters (NormalizeSeparators, NormalizeNewLines, Align*, SplitTooLongLine) stay,
and corresponding rules should document when robocop format fixes them. A rule fix is still appropriate when malformed
syntax prevents Robot Framework from producing an AST that formatters can process.
Rules with an existing formatter counterpart are marked in the Notes column - implementing the fix may allow us to
deprecate the formatter (as it happened with RemoveEmptySettings).

ANN

Rule Name Fix Difficulty Safety Status Notes
ANN01 missing-section-variable-type - unsafe could be derived from the value, but unsafe
ANN02 missing-argument-type - -
ANN03 missing-for-loop-variable-type - -

ARG

Rule Name Fix Difficulty Safety Status Notes
ARG01 unused-argument easy unsafe extremely unsafe
ARG02 argument-overwritten-before-usage - unsafe unclear what the fix should be
ARG03 undefined-argument-default easy safe #1852, adds ${EMPTY}
ARG04 undefined-argument-value easy unsafe
ARG05 invalid-argument - -
ARG06 duplicated-argument-name - -
ARG07 arguments-per-line mid safe split into multiple lines
ARG09 missing-argument-name - safe #1837

COM

Rule Name Fix Difficulty Safety Status Notes
COM01 todo-in-comment - -
COM02 missing-space-after-comment easy safe #1844, SOMETIMES (##comment not fixed); replaces NormalizeComments (removed in #1845)
COM03 invalid-comment - -
COM04 ignored-data easy safe #1844, SOMETIMES (data with the language: header not fixed)
COM05 bom-encoding-in-file - - not worth the effort
COM06 commented-out-code - -

DEPR

Rule Name Fix Difficulty Safety Status Notes
DEPR01 if-can-be-used mid safe superseded by deprecated-run-keyword-if (DEPR08); ReplaceRunKeywordIf formatter removed in #1899
DEPR02 deprecated-statement mid safe rule needs to be split first
DEPR03 deprecated-with-name easy safe #1843
DEPR04 deprecated-singular-header easy safe #1843
DEPR05 replace-set-variable-with-var mid safe ReplaceWithVAR
DEPR06 replace-create-with-var mid safe ReplaceWithVAR
DEPR07 deprecated-force-tags mid safe
DEPR08 deprecated-run-keyword-if mid safe #1898, SOMETIMES (only body keyword calls are fixed); replaces ReplaceRunKeywordIf (removed in #1899)
DEPR10 deprecated-return-keyword mid safe
DEPR11 deprecated-return-setting mid safe

DOC

Rule Name Fix Difficulty Safety Status Notes
DOC01 missing-doc-keyword - -
DOC02 missing-doc-test-case - -
DOC03 missing-doc-suite - -
DOC04 missing-doc-resource-file - -
DOC05 variable-in-documentation - unsafe escaping changes intentional interpolation; intentionally non-fixable (#1866)

DUP

Rule Name Fix Difficulty Safety Status Notes
DUP01 duplicated-test-case - -
DUP02 duplicated-keyword - -
DUP03 duplicated-variable easy safe #1857, removes the ignored (second) value
DUP04 duplicated-resource easy safe #1848
DUP05 duplicated-library easy safe #1848
DUP06 duplicated-metadata mid unsafe hard to decide which one to keep
DUP07 duplicated-variables-import easy safe #1848
DUP08 section-already-defined hard safe merging whole sections, MergeAndOrderSections
DUP09 both-tests-and-tasks - -
DUP10 duplicated-setting easy unsafe

ERR

All ERR* rules report parsing/syntax errors and cannot be fixed automatically: ERR01, ERR03, ERR04, ERR05, ERR08,
ERR09, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17.

IMP

Rule Name Fix Difficulty Safety Status Notes
IMP01 wrong-import-order easy safe #1856
IMP02 builtin-imports-not-sorted easy safe #1856
IMP03 non-builtin-imports-not-sorted mid unsafe import order may matter
IMP04 resources-imports-not-sorted mid unsafe import order may matter

KW

Rule Name Fix Difficulty Safety Status Notes
KW01 sleep-keyword-used - -
KW02 not-allowed-keyword - -
KW03 no-embedded-keyword-arguments - -
KW07 missing-keyword-prefix - safe #1838

LEN

Rule Name Fix Difficulty Safety Status Notes
LEN01 too-long-keyword - -
LEN02 too-few-calls-in-keyword - -
LEN03 too-many-calls-in-keyword - -
LEN04 too-long-test-case - -
LEN05 too-few-calls-in-test-case - -
LEN06 too-many-calls-in-test-case - -
LEN07 too-many-arguments - -
LEN08 line-too-long - - handled by robocop format (SplitTooLongLine)
LEN09 empty-section easy safe #1841, SOMETIMES (sections with comments are not fixed); replaces DiscardEmptySections, removed in #1905 (its allow_only_comments=False option is dropped)
LEN10 number-of-returned-values - -
LEN11-LEN26 empty-* settings easy safe #1840, RemoveEmptySettings removed in #1849
LEN27 too-many-test-cases - -
LEN28 file-too-long - -
LEN29 empty-test-template easy safe #1840
LEN30 empty-template easy safe #1840
LEN31 empty-keyword-tags easy safe #1840
LEN32 too-long-variable-name - -

Note on the empty settings: the empty test case settings that can overwrite a suite setting ([Setup], [Teardown],
[Timeout], [Template]) are not removed but replaced with an explicit NONE, since the suite setting can also
come from the parent __init__.robot.

MISC

Rule Name Fix Difficulty Safety Status Notes
MISC01 keyword-after-return hard unsafe reordering statements may change the behaviour
MISC02 empty-return easy safe #1846
MISC03 nested-for-loop hard unsafe
MISC04 inconsistent-assignment mid safe #1901, ALWAYS; extended to the VAR syntax in #1902; NormalizeAssignments removed in #1904
MISC05 inconsistent-assignment-in-variables easy safe #1859; together with MISC04 (#1901, #1902) it replaces NormalizeAssignments, removed in #1904
MISC06 can-be-resource-file mid unsafe requires renaming the file
MISC07 if-can-be-merged mid safe
MISC08 statement-outside-loop hard unsafe
MISC09 inline-if-can-be-used easy safe #1900, SOMETIMES (inline IF over the line limit is not fixed); InlineIf stays (does more: bidirectional, ELSE/ELSE IF and assignments)
MISC10 unreachable-code mid safe mechanical removal
MISC11 multiline-inline-if - - handled by robocop format (InlineIf), documented in #1859
MISC13 expression-can-be-simplified mid safe
MISC14 misplaced-negative-condition easy safe #1859, SOMETIMES (double negation is not fixed)
MISC15 unused-disabler easy safe #1855, SOMETIMES (only standalone directives are removed)

NAME

Rule Name Fix Difficulty Safety Status Notes
NAME01 not-allowed-char-in-name hard unsafe renaming needs human judgement
NAME02 wrong-case-in-keyword-name easy safe #1860, SOMETIMES (configured pattern is not fixed)
NAME03 keyword-name-is-reserved-word hard unsafe
NAME04 underscore-in-keyword-name easy safe RenameKeywords
NAME05 setting-name-not-in-title-case easy safe #1858, NormalizeSettingName stays (does more than the rule)
NAME06 section-name-invalid easy safe #1858, NormalizeSectionHeaderName stays (does more than the rule)
NAME07 not-capitalized-test-case-title mid unsafe RenameTestCases, test names are identifiers
NAME08 section-variable-not-uppercase easy safe RenameVariables
NAME09 else-not-upper-case easy safe #1854
NAME10 keyword-name-is-empty - -
NAME11 test-case-name-is-empty - -
NAME12 empty-library-alias easy safe #1847, SOMETIMES (multiline imports are not fixed)
NAME13 duplicated-library-alias easy safe #1847, SOMETIMES (multiline imports are not fixed)
NAME14 bdd-without-keyword-call mid unsafe
NAME15 not-allowed-char-in-filename hard unsafe requires renaming the file
NAME16 invalid-section mid unsafe
NAME17 mixed-task-test-settings mid unsafe
NAME18 wrong-case-in-keyword-call easy safe #1860, SOMETIMES (configured pattern is not fixed)

ORD

Rule Name Fix Difficulty Safety Status Notes
ORD01 test-case-section-out-of-order easy safe OrderSettings
ORD02 keyword-section-out-of-order easy safe OrderSettings
ORD03 section-out-of-order mid safe MergeAndOrderSections

SPC

Whitespace and alignment stay the responsibility of robocop format when Robot Framework can parse the statement.
Rules for malformed merged cells remain fixable because AST formatters cannot see those statements.

Rule Name Fix Difficulty Safety Status Notes
SPC01 trailing-whitespace easy safe already implemented
SPC02 missing-trailing-blank-line - - handled by robocop format (NormalizeNewLines)
SPC03 empty-lines-between-sections - - handled by robocop format (NormalizeNewLines)
SPC04 empty-lines-between-test-cases - - handled by robocop format (NormalizeNewLines)
SPC05 empty-lines-between-keywords - - handled by robocop format (NormalizeNewLines)
SPC06 mixed-tabs-and-spaces - - handled by robocop format (NormalizeSeparators)
SPC08 bad-indent - - handled by robocop format (NormalizeSeparators)
SPC09 empty-line-after-section - - handled by robocop format (NormalizeNewLines)
SPC10 too-many-trailing-blank-lines - - handled by robocop format (NormalizeNewLines)
SPC11 misaligned-continuation - - handled by robocop format (NormalizeSeparators)
SPC12 consecutive-empty-lines - - handled by robocop format (NormalizeNewLines)
SPC13 empty-lines-in-statement - - handled by robocop format (NormalizeNewLines)
SPC14 variable-not-left-aligned - - handled by robocop format (AlignVariablesSection)
SPC15 misaligned-continuation-row - - handled by robocop format (NormalizeSeparators)
SPC16 suite-setting-not-left-aligned - - no formatter fix; malformed input has no usable AST
SPC17 bad-block-indent - - handled by robocop format (NormalizeSeparators)
SPC18 first-argument-in-new-line - - no formatter fix; malformed input has no usable AST
SPC19 not-enough-whitespace-after-setting easy safe #1862; formatter cannot parse merged cells
SPC20 not-enough-whitespace-after-newline-marker easy safe #1862; formatter cannot parse merged cells
SPC21 not-enough-whitespace-after-variable easy safe #1862; formatter cannot parse merged cells
SPC22 not-enough-whitespace-after-suite-setting easy safe #1862; formatter cannot parse merged cells
SPC23 empty-line-in-test-template easy safe #1865; removes ignored empty template data rows

TAG

Rule Name Fix Difficulty Safety Status Notes
TAG01 tag-with-space mid unsafe changing the tag text can break tag selection
TAG02 tag-with-or-and easy safe NormalizeTags (case normalization)
TAG03 tag-with-reserved-word hard unsafe
TAG05 could-be-test-tags hard unsafe multi-location refactor
TAG06 tag-already-set-in-test-tags easy safe #1851
TAG07 unnecessary-default-tags easy safe #1850
TAG08 empty-tags easy safe #1842
TAG09 duplicated-tags easy safe #1851, NormalizeTags stays (case normalization)
TAG10 could-be-keyword-tags hard unsafe multi-location refactor
TAG11 tag-already-set-in-keyword-tags easy safe #1851
TAG12 redundant-continue-on-failure easy safe #1868; unwraps redundant BuiltIn wrapper when effective tags preserve behavior

VAR

Rule Name Fix Difficulty Safety Status Notes
VAR01 empty-variable easy safe #1852, ReplaceEmptyValues removed in #1853
VAR02 unused-variable hard unsafe
VAR03 variable-overwritten-before-usage mid safe replace the unused assignment with ${_}
VAR04 no-global-variable hard unsafe ReplaceWithVAR partially covers it
VAR05 no-suite-variable hard unsafe ReplaceWithVAR partially covers it
VAR06 no-test-variable hard unsafe ReplaceWithVAR partially covers it
VAR07 non-local-variables-should-be-uppercase easy safe RenameVariables
VAR08 possible-variable-overwriting mid unsafe RenameVariables
VAR09 hyphen-in-variable-name easy unsafe renaming changes the variable name
VAR10 inconsistent-variable-name mid unsafe RenameVariables
VAR11 overwriting-reserved-variable hard unsafe
VAR12 duplicated-assigned-var-name easy safe
VAR13 automatic-variable-not-available - - requires choosing a replacement or moving code based on intent; no safe automatic fix (#1867)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions