Skip to content

Add --extend-select option for selecting rules/formatters #1546

@andre-morise

Description

@andre-morise

Problem

Currently, robocop format --select ... completely replaces the default ENABLED formatters. Users who want to depend on the default formatters and enable one or two extras must either manually list all default formatters, or use the somewhat verbose --configure option, which is not ideal.

A. Example (with select):

[tool.robocop.format]
# Must list all ~20 default formatters just to enable additional formatters
select = [
    "AddMissingEnd",
    "NormalizeSeparators",
    "DiscardEmptySections",
    # ... the rest ...
    # The only ones we actually want to enable
    "AlignKeywordsSection",
    "AlignTestCasesSection"
]

This breaks when robocop's default formatters change.

B. Example (with configure):

select = [
    # defaults
]
configure = [
    "AlignKeywordsSection.enabled=True",
    "AlignTestCasesSection.enabled=True"
]

This would not break when robocop's default formatters change, but is verbose nonetheless.

Proposed Feature

Add --extend-select / extend-select option that augments formatters instead of replacing them.

CLI:

robocop format --extend-select AlignKeywordsSection --extend-select AlignTestCasesSection

TOML:

[tool.robocop.format]
extend-select = [
    "AlignKeywordsSection",
    "AlignTestCasesSection"
]

Behavior

Configuration Result
extend-select = ["F1"] All defaults + F1
select = ["F1"] + extend-select = ["F2"] F1 + F2 (no defaults)
No select or extend-select All defaults (unchanged)

Benefits

  • Reduces configuration verbosity for common use case
  • Future-proof: automatically includes new default formatters
  • No breaking changes to existing --select behavior
  • Follows precedent from Ruff's linter configuration (See extend-select)

Notes

  • Custom formatters (via --custom-formatters) should continue to appear last
  • --force-order should affect --extend-select same as --select
  • When neither --select nor --extend-select is specified, behavior should remain unchanged (all defaults)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions