Skip to content

Releases: MarketSquare/robotframework-tidy

2.4.0

01 Jun 05:44
358aa60
Compare
Choose a tag to compare

Extra --indent option

Robotidy normalizes all whitespaces using the same fixed amount of spaces (configurable via --spacecount).
It's then optionally modified by various transformers such as AlignSettingsSection.
This release adds additional option --indent that allows to configure indentation separately (#293).

It's now possible to have for example indentation of 4, but separator between the tokens (spacecount) equal to 2 spaces:

robotidy --indent 4 --spacecount 2
Keyword
    FOR  ${index}  ${item}  IN ENUMERATE  @{LIST}
        My Keyword  ${index}  ${item}
    END

skip_documentation for NormalizeSeparators

It is now possible to skip formatting suite, test case and keyword documentation with NormalizeSeparator transformer
by using skip_documentation parameter (#300):

robotidy --configure NormalizeSeparators:skip_documentation=True src

This option is useful if you have custom formatting of the documentation that you don't want to lose when running the Robotidy.

Other

  • Added --skip-gitignore flag to ignore .gitignore files and parse files listed there (#299).

2.3.0

19 May 05:47
6e0fa1d
Compare
Choose a tag to compare

Prettified Robotidy output in the console from the help, desc and list commands:

image

2.2.0

26 Apr 18:20
f5347c9
Compare
Choose a tag to compare

In this release we're adding feature allowing to disable robotidy from source code and option to run robotidy with target Robot Framework version. Read the below description for more information and list of other changes.

Disable formatting from source code

Previously the only option to disable formatting in part of the file was to use cumbersome
--startline and --endline markers. This release brings new feature - comment disablers.
You can disable formatting in Robot Framework statement or in span of lines using # robocop: off marker.

To skip the formatting for one statement:

Keyword That Is Longer Than Allowed Line Length  ${arg}  # robotidy: off

To skip multiple lines:

*** Test Cases ***
Test that will be formatted
    Step

# robotidy: off
Test that will not be formatted
    Step

# robotidy: on
Another test that will be formatted
    Step

# robotidy: on marker is used to enable the formatting again - but is not required. # robotidy: off will disable
the formatting to the end of the current block:

Keyword That Is Formatted
IF    $condition
    Formatted
ELSE
    Formatted
    # robotidy: off
    Not Formatted
    WHILE    $condition
        Not Formatted
    END
END
Formatted

It's possible to disable the formatting in whole file by putting # robotidy: off on first line:

# robotidy: off
*** Settings ***
Library    Collections

You can also disable the formatting in whole section if you put # robotidy: off in section header:

*** Test Cases ***
Formatted
    Step

*** Keywords ***  # robotidy: off
Not Formatted
    Step

Transformers

  • NormalizeNewLines now removes leading, trailing and consecutive empty lines in IF, FOR, WHILE, TRY EXCEPT blocks (#288)

Fixes

  • It's no longer possible to forcefully enable transformer not supported in installed Robot Framework version (#281, #283)

Other

  • You can now disable coloring the output with --no-color cli option or by setting $NO_COLOR environment variable (#268)
  • Added an option to set target version of Robot Framework when formatting the files:
    robotidy --target-version rf4 .
    
    It will disable all transformers that require Robot Framework greater than to run (even if you have Robot Framework greater than installed). (#253)

Acknowledgements

Thanks @DrVanScott, @Ga22be, @westadejl and @IlfirinPL for raising bug issues & feature requests!

2.1.1

12 Apr 13:27
03e142f
Compare
Choose a tag to compare

Fix release addressing a bug where *** Tasks *** were normalized to *** Test Cases *** by NormalizeSectionHeaderName (#279).

Acknowledgements

Thanks @fabioz for finding and fixing the issue!

2.1.0

24 Mar 21:54
69e407e
Compare
Choose a tag to compare

Minor update with major change - standarized the empty lines count between sections in Robotidy and Robocop tool.

Transformers

Updated NormalizeNewLines to separate sections by two empty lines (instead of one). It's effort of normalizing
Robocop output (which suggest to use 2 empty lines) and Robotidy (which previously transformed with 1 empty line) (#536).

Previously:

*** Settings ***
Force Tags    tag

*** Test Cases ***
Test
    No Operation

Now:

*** Settings ***
Force Tags    tag


*** Test Cases ***
Test
    No Operation

If you wish to retain previous behaviour you can configure it:

robotidy --configure NormalizeNewLines:section_lines=1 <src>

or from configuration file:

[tool.robotidy]
configure = [
    "NormalizeNewLines : section_lines = 1"
]

Other

Add missing packaging dependency (#275)

Acknowledgements

Big thanks to @bollwyvl for detecting and fixing missing packaging dependency (and improving our requirements in general)

2.0.0

24 Mar 12:07
8ff6520
Compare
Choose a tag to compare

Robotidy 2.0

Major release of Robotidy that brings new transformers and features. It focuses on bringing support for
Robot Framework 5.0 new syntax such as BREAK, CONTINUE, RETURN statements or TRY EXCEPT block.
Also Robotidy documentation got several improvements and extra examples.

New Transformers

ReplaceReturns

Replaces return statements (such as [Return] setting or Return From Keyword keyword) with RETURN statement (#231).

Following code:

*** Keywords ***
Keyword
    Return From Keyword If    $condition    2
    Sub Keyword
    [Return]    1

Keyword 2
    Return From Keyword    ${arg}

will be transformed to:

*** Keywords ***
Keyword
    IF    $condition
        RETURN    2
    END
    Sub Keyword
    RETURN    1

Keyword 2
    RETURN    ${arg}

See https://robotidy.readthedocs.io/en/latest/transformers/ReplaceReturns.html for more examples

ReplaceBreakContinue

Replaces Continue For Loop and Exit For Loop keyword variants with CONTINUE and BREAK statements (#241).

Following code:

*** Keywords ***
Keyword
    FOR    ${var}    IN  1  2
        Continue For Loop
        Continue For Loop If    $condition
        Exit For Loop
        Exit For Loop If    $condition
    END

will be transformed to:

*** Keywords ***
Keyword
    FOR    ${var}    IN  1  2
        CONTINUE
        IF    $condition
            CONTINUE
        END
        BREAK
        IF    $condition
            BREAK
        END
    END

See https://robotidy.readthedocs.io/en/latest/transformers/ReplaceBreakContinue.html for more examples.

InlineIf

Replaces IF blocks with inline IF (#230).

Following code::

*** Test Cases ***
Test
    IF    $condition1
        Keyword    argument
    END
    IF    $condition2
        ${var}  Keyword
    ELSE
        ${var}  Keyword 2
    END
    IF    $condition1
        Keyword    argument
        Keyword 2
    END

will be transformed to:

*** Test Cases ***
Test
    IF    $condition1    Keyword    argument
    ${var}    IF    $condition2    Keyword    ELSE    Keyword 2
    IF    $condition1
        Keyword    argument
        Keyword 2
    END

You can decide to not replace IF blocks containing ELSE or ELSE IF branches by setting skip_else to True.

See https://robotidy.readthedocs.io/en/latest/transformers/InlineIf.html for more examples.

Changes in transformers

min_width parameter

New min_width parameter was added to AlignSettingsSection, AlignVariablesSection and AlignTestCases (#242).
It allows to set minimal width of data column instead of using width of the widest argument in the column.

Following code:

*** Variables ***
${var}    a
${var2}  b

would be aligned to ${var2} length since it's the longest token. If you wish to have fixed width you can use
min_width parameter:

robotidy --configure AlignVariablesSection:min_width=15

With such configuration previous code will be transformed to:

*** Variables ***
${var}         a
${var2}        b

Sections only with comments

Previously, sections that contained only comments and empty lines were removed by default by DiscardEmptySections. It
could be changed by configuring allow_only_comments to True. Since it wasn't expected behaviour by most users, now it
works in an opposite way - only the sections with comments will be removed by configuring allow_only_comments to False (#235).

Do not align variables with given types

New skip_types parameter in AlignVariablesSection which allows to not align variables of particular type (#225)

With following configuration:

    robotidy --configure AlignVariablesSection:skip_types=dict

All variables except dictionaries will be aligned.

SplitTooLongLine transformer

Several updates to SplitTooLongLine transformer.


Basic behaviour changed and now every statement that's longer than
character limit will be split to multiple lines:

Keyword With Longer Name
...    ${arg1}
...    ${arg2}
...    ${arg3}

If you wish to use previous algorithm of feeding arguments into one line until limit set split_on_every_arg to False:

Keyword With Longer Name    ${arg1}  # let's asumme that ${arg} is right below character limit
...    ${arg2}    ${arg3}

Assignments are now split (if they don't fit in one line):

${first_assignment}
...    ${second_assignment}
...    ${third_assignment}
...    Some Lengthy Keyword So That This Line Is Too Long And Bit Over

RenameKeywords transformer

Library names are now by default ignored by RenameKeywords transformer. Previously, it could result in an unexpected behaviour (#269).
If you want to transform library names pass ignore_library=False to transformer.

    custom_library.Keyword  # custom_library will be renamed to Custom Library only if you set `ignore_library` to False
    Other Keyword

Other

Overwrite files with --check flag

It is now possible to force overwrite with --check and --overwrite flags (#239).
Going over possible options:

Transform the files and return 0 even if there were files transformed.

robotidy src

Don't transform the files and return 0 even if there would be files transformed

robotidy --no-overwrite src

Don't transform the files and return 1 if there would be files transformed

robotidy --check src

Transform the files and return 1 if there are files transformed

robotidy --check --overwrite src

User-friendly exceptions

Changed exceptions to be more user-friendly. Robotidy will try to recognize common mistakes.
For unknown issues there is an extra message with link to our bug board (#250)

Previously, typos or common mistakes resulted in an error stack being printed - often without clear information what went wrong.
Now Robotidy tries to output the reason of a failure:

> robotidy --transform InlineI:line_length=100 .
Error: Importing transformer 'InlineI' failed. Verify if correct name or configuration was provided. Did you mean:
    InlineIf

> robotidy --diff --transform InlineIf:line-len=100 .
Error: InlineIf: Failed to import. Verify if correct name or configuration was provided. This transformer accepts following arguments:
    line_length
    skip_else

> robotidy --diff --transform InlineIf:line_lengthn=abc .
Error: InlineIf: Failed to import. Verify if correct name or configuration was provided. 
Argument 'line_length' got value 'abc' that cannot be converted to integer or None.

Changes to acceptance tests

Refactored Robotidy acceptance tests (#248).

Fixes

  • Unmodified files are now not saved to the disk (#237)

Acknowledgements

Thanks @DetachHead and @ealap for reporting issues and ideas.

1.6.2

14 Nov 13:51
f8ba51d
Compare
Choose a tag to compare

Fixes

  • AddMissingEnd transformer now properly handles IFs without indented block of code (#226)
  • Paths passed from command line are now checked against excluded paths (previously it was only checked when iterating over directories) (#227)

Acknowledgements

Thanks @d-biehl for reporting issue and @DetachHead for reporting and implementing fix.

1.6.1

11 Oct 16:45
f80010c
Compare
Choose a tag to compare

Minor fixes.

Fixes

  • Extra trailing whitespace when aligning multiline statements with blank lines will no longer be added #220
  • Task header should no longer be converted to test cases header #221
  • Fix keword -> keyword typo #222

Acknowledgements

Thanks @admorgan, @adrszad for reporting issues.

1.6.0

01 Oct 07:30
b0ea7f6
Compare
Choose a tag to compare

This release brings a lot of new transformers & changes! New long awaited AlignTestCases transformer (which for now is non default and for templated test only). There are also two new transformers contributed by @adrszad - OrderTags and NormalizeTags.
We also introduced new method of running non default parameter. By configuring enabled parameter you can run all default transformers with addition of selected non default ones:

robotidy --configure RenameTestCases:enabled=True <src>

See below changelog to read about other new transformers, features and fixes. You can also use our discussion page for any questions regarding this release or robotidy in general.

Transformers

  • New non default transformer RenameTestCases. It capitalizes first letter of the test case name, removes trailing dot and can replace provided regex pattern with substitute string (#183)

  • New non default transformer RenameKeywords. It applies Title Case to keyword name and replace underscores by spaces and can replace provided regex pattern with substitute string (#183)

  • Added AlignTestCases transformer for aligning templated test cases in column. Because it's in experimental mode it will be non default for now (see docs for information how to run it) (#185)

  • Missing ENDs in for loop and if statements will be added by new AddMissingEnd transformer (#91)

  • NormalizeAssignments now recognizes assignments from *** Variables *** section separately. It allows you to configure different assignment sign type for keyword calls and for variables section (#159)

    With this change following command will change all assignments signs to = for keyword calls and remove them in *** Variables *** sections.

    robotidy -c NormalizeAssignments:equal_sign_type=equal_sign -c NormalizeAssignments:equal_sign_type_variables=remove <src>
    
  • New OrderTags (non default) transformer. It orders tags in lexicographic order (#205)

  • New NormalizeTags (non default) transformer. It normalizes tag name case and removes duplicates (#212)

Features

  • It is now possible to provide source paths in configuration file (#154)
  • Non default transformers can be enabled using enabled=True parameter (#182)
  • Semicolon in parameter value can now be escaped with \: (#190)
  • Default separator can be changed from space to tabular with new --separator option (#184)

Fixes

  • Robotidy will not print "Loaded configuration from ... " if the configuration is empty (#193)
  • no source path provided error now exits with code 1 instead of 0 (#208)

Other

  • ReplaceRunKeywordIf now removes ELSE branch if it is unnecessary (#192)

Acknowledgements

Thanks @DetachHead for reporting issues regarding aligning test cases nad reporing & fixing #208, @liambeguin for PR with --separator option that allows to use tab as separator, @adrszad for all issues and adding two new transformers (OrderTags and NormalizeTags)

1.5.1

16 Aug 08:29
d3006aa
Compare
Choose a tag to compare

Fix critical issue with pathspec dependency.

Fixes

  • Robotidy will now not crash on directory path #177

Acknowledgements

Thanks @sergii-tsymbal-exa for reporting the issue