MarketSquare / robotframework-robocop

Tool for static code analysis of Robot Framework language
Apache License 2.0
190 stars 38 forks source link

[Rule] Suggest using inline evaluation instead of Evaluate #503

Open bhirsz opened 3 years ago

bhirsz commented 3 years ago

If the Evaluate keyword does not import any external modules it can be replaced with ${{ }} syntax.

# cannot be replaced
${items} =    Evaluate    [json.loads(item) for item in ('1', '"b"')]    modules=json

# can be replaced (and later shortened to one line)
${condition} =    Evaluate    '${VAR}' == '123'
Should Be True    ${condition}
bhirsz commented 3 years ago

But that's need to be further analysed based on https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#evaluating-expressions (if it's feasible and when replacing Evaluate is possible and when not).