robotidy can produce invalid syntax with pipe separator?

29 views
Skip to first unread message

Geist Eng

unread,
Jul 29, 2022, 5:06:55 PM7/29/22
to robotframework-users
I did the test below to try and find a way to run only the transformers I want.  Specifically not run the Replace* transformers.  So first setup robotidy config file with just one transformer listed.

Robotidy configure file:

[tool.robotidy]
spacecount = 2
transform = [
     "AddMissingEnd"
]


Orig robot code:

Foo And Bar
| | FOR | ${index} | IN RANGE | 0 | 2
| |     | ${result} | ${error message}= | Run Keyword And Ignore Error | Verify All
| |     | Return From Keyword If | '${result}'=='PASS'
| | END
| | FAIL | "SNAFU"


After robotidy transform with config file above:

Foo And Bar
| | FOR | ${index} | IN RANGE | 0 | 2
| |     | ${result} | ${error message}= | Run Keyword And Ignore Error | Verify All
| |     | Return From Keyword If | '${result}'=='PASS'
| END
| | FAIL | "SNAFU"

The END was not missing to start with.  After transformation it just ended up removing the original second pipe.

My rig versions:

        Tool |      Version      
-------------+-------------------
  Linux Dist | Ubuntu 20.04.4 LTS
Linux Kernel | 5.15.0-41-generic
      Python | 3.8.10
          RF | 5.0
 RF Selenium | 6.0.0
 RF Requests | 0.9.2
    Selenium | 4.1.5
    Requests | 2.27.1


Geist Eng

unread,
Jul 29, 2022, 5:27:12 PM7/29/22
to robotframework-users
Interestingly if I removed the transform from the config file and only have the spacecount param robotidy removes all the pipe separators.  Not sure why it did not do this before

[tool.robotidy]
spacecount = 2

Output

Foo And Bar
  FOR  ${index}  IN RANGE  0  2
    ${result}  ${error message}=  Run Keyword And Ignore Error  Verify All
    IF  '${result}'=='PASS'  RETURN
  END
  FAIL  "SNAFU"


Bartłomiej Hirsz

unread,
Aug 1, 2022, 5:01:31 AM8/1/22
to robotframework-users
Yes - there is "NormalizeSeparator" default transformer that change all separator types to configured --separator (space by default) and apply fixed indentation (4 spaces per level by default). In your first configuration --transform option only selected "AddMissingEnd" (so "NormalizeSeparator" didn't run). In your second configuration you did run all default transformers - including "NormalizeSeparator".

You can quickly check what transformer is default one with robotidy --list :
robotgidy_dd.png

Geist Eng

unread,
Aug 1, 2022, 11:12:01 AM8/1/22
to robotframework-users
Yea, I found the robotidy github repo and addressed some of the issues I was seeing there with new bugs.  Including this one as not removing the pipe separators was throwing off other transforms but in strange ways once I realized it had to be done first.

I now do the NormalizeSeparator first before others.  And as noted in bug I opened, it must be done by itself and written back to disk before others.

For others I address this in detail in this conversation.
Reply all
Reply to author
Forward
0 new messages