robotframework-robocop: Disable(/Enable) rules from code in keyword/test case block

It should be possible to disable/enable rules on Keyword and Test Suite level so that they are only applied inside that scope. (like in PyLint)

F.g. If I would add following line: # robocop: disable=too-many-calls-in-keyword Inside keyword (after the settings) it would be valid only for that keyword.

These lines inside Keywords/Test Cases should be applied to rules for:

  • Keyword/Test Case name
  • Keyword/Test Case settings
  • Keyword/Test Case code

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (13 by maintainers)

Most upvoted comments

Solved both issues in the branch https://github.com/MarketSquare/robotframework-robocop/compare/disablers_in_block?expand=1 I will raise PR later, which will be part of the upcoming 4.0.0 release.

I have rewritten disablers class completely from analysing the raw lines to visiting the Robot Framework file like a model (so it works the same as rules checkers). Thanks for this disablers are now scope-aware.

As for too-many-arguments and similar rules, surprisingly we already had the solution in place. It is possible to configure additional lines that should be checked when checking if the line is disabled (ext_disablers). When creating the rule that is reported for parent node it needs to be properly configured.

No, it will be reported for Keyword because disabler inside keyword is not detected. Then disabler is in use until its called off, thats why Keyword 2 will not be reported. The goal would be to have robocop disabler work only inside the scope they were defined (ie. if there is disabler inside for loop it should work there, not after the loop).

One of the reason why it works that way is to integrate disabler feature seamlessly with RawFileCheckers and external rules (so the users don’t need to configure anything extra to get disablers working).

Yes, it’s valid request and we should implement it.