MarketSquare / MarketSquare/robotframework-tidy

Enhancement: RenameVariables transformer

Open
#440 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
RobotFramework
Stars
113
Forks
16
PR merge metrics
No merged PRs in 30d

Description

We have a requirement to bulk-replace variables, and wondered if we can leverage Robotidy for this.. Simplified test case shown below, our goal would be to replace the variables `OLD_SCALAR` by `NEW_SCALAR`, `OLD` by `NEW`, `OLD_DICT` by `NEW_DICT`, and also `OLD_DICT_2` by `NEW_DICT_2`, but also its keys `old_key1` by `new_key1`.. Obviously this example could also be achieved through regexp substitution, but we would like to explore if Robotidy could do it "better" and "more robust" than a potentially complex regexp.

Really appreciate you looking into this!

```

*** Test Cases ***
Test
Import Variables ${CURDIR}/vars.yaml
Log Variables
FOR ${var} IN @{OLD}
Log ${var}
END

Should Be True ${OLD_SCALAR}
Should Be True ${OLD}
Should be True ${OLD}[1]
Should be True ${OLD_DICT.a}
Should be True ${OLD_DICT}[a]
Should be True ${OLD_DICT_2.old_key1}
Should be True ${OLD_DICT_2}[old_key1]

Do something with ${OLD}
Do something with ${OLD}[1]
Do something with ${OLD_DICT.a}
Do something with ${OLD_DICT}[a]
Do something with ${OLD_DICT_2.old_key1}
Do something with ${OLD_DICT_2}[old_key1]

*** Keywords ***
Do something with ${var}
Log ${var}

```

vars.yaml content:
```
OLD_SCALAR: 1

OLD:
- 1
- 2
- 3

OLD_DICT:
a: 1
b: 1
c: 1

OLD_DICT_2:
old_key1: 1
old_key2: 2
```

Contributor guide

Open the contributing guide

Research direction

Start with the Robot Framework example in the issue and its vars.yaml content to understand the requested replacement scope. Done should cover the listed scalar, list, dictionary, indexed, dotted-key, bracket-key, and keyword-argument references more robustly than complex regexp substitution.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.