Skip to content

Inconsistent spacing in AlignVariablesSection rule depending on variable name length #1511

@jannekSympa

Description

@jannekSympa

When using robocop’s AlignVariablesSection rule to format the *** Variables *** section, the number of spaces inserted between the variable name and its value is inconsistent depending on the length of the variable name.

Example cases

Case 1 – 4 spaces between name and value:

*** Variables ***
${VARXX_CONTEXT}    ${EMPTY}    # Set in Suite Setup
${ADD_REMOVE_T1}    ${EMPTY}    # Set in Test Setup
${ADD_REMOVE_2}     ${EMPTY}    # Set in Test Setup
${ADD_REMOVE_3}     ${EMPTY}    # Set in Test Setup
${ADD_REMOVE_4}     ${EMPTY}    # Set in Test Setup

Case 2 – 7 spaces:

*** Variables ***
${VARXX_CONTEXT}        ${EMPTY}    # Set in Suite Setup
${ADD_REMOVE_TE1}       ${EMPTY}    # Set in Test Setup
${ADD_REMOVE_2}         ${EMPTY}    # Set in Test Setup
${ADD_REMOVE_3}         ${EMPTY}    # Set in Test Setup
${ADD_REMOVE_4}         ${EMPTY}    # Set in Test Setup

Case 3 – 5 spaces:

*** Variables ***
${VARXX_CONTEXT}        ${EMPTY}    # Set in Suite Setup
${ADD_REMOVE_TEST1}     ${EMPTY}    # Set in Test Setup
${ADD_REMOVE_2}         ${EMPTY}    # Set in Test Setup
${ADD_REMOVE_3}         ${EMPTY}    # Set in Test Setup
${ADD_REMOVE_4}         ${EMPTY}    # Set in Test Setup

Expected behavior

The formatter should use consistent spacing regardless of variable name length. For example, if the configuration defines a fixed alignment rule (e.g., 4 spaces between name and value), it should apply uniformly across all variables.

Actual behavior

The number of spaces varies depending on the variable name length — seemingly trying to align the ${EMPTY} tokens to a shared column, but producing inconsistent spacing when variable names differ slightly in length.

robocop, version 6.10.0
Robot Framework 7.3.2 (Python 3.12.12 on linux)

[tool.robocop.format]
    line-ending = "unix"
    line-length = 150
    reruns = 3
    configure = [
        "InlineIf.enabled=True",
        "InlineIf.line_length=150",
        "NormalizeTags.preserve_format=True",
        "NormalizeAssignments.equal_sign_type=space_and_equal_sign",
        "OrderTags.enabled=False",
        "RenameKeywords.enabled=True",
        "RenameTestCases.enabled=True",
        "RenameTestCases.capitalize_each_word=True",
        "ReplaceWithVAR.enabled=True",
    ]

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