robotframework-robocop
robotframework-robocop copied to clipboard
[Bug] robocop-robotidy file level disabler strangeness
What happened?
File-level disabler should be the very first line of the given robot file without empty line before *** Settings *** in this case it is working fine. Working format:
# robocop: disable=0527,1004
*** Settings ***
Documentation asdfasdf
But if I add an empy line between the disabler line and the section header, although the defined rules are disabled, but I get an 'ignored-data' (0704) finding:
# robocop: disable=0527,1004
*** Settings ***
Documentation asdfasdf
If I run robotidy the file-level disabler will be added to a *** Comments *** section. And after I rerun the robocop, it will not be recognized as a file-level disabler.
*** Comments ***
# robocop: disable=0527,1004
*** Settings ***
Documentation asdfasdf
I tried only Robocop 5.0.0, the earlier version might affected as well.
What command/code did you try to run?
Regular command execution.
What is the full error message?
There is no error message, the regular finding messages will be printed.
What did you expect to happen instead?
Either the robotidy should jump over the file-level robocop disablers (not put it under a *** Comments *** section), or robocop should handle the disablers as file-level disablers when it can be found under the *** Comments *** section.
And should not be reported as ignore-data if there are empty lines between the file-level disabler and the first section.
Operating System
Linux
Robocop version
5.0.0
Update: Added the "And should not be reported as ignore-data if there are empty lines between the file-level disabler and the first section." line.
Actually the implementation of disablers is quite different for robocop and robotidy - but it can of course share some bugs. I already have some open issues for disablers (in robotidy mostly) and some questions from the users. I definietely want to take a look into it.
Another issue is that Robotidy does not recognize Robocop disablers - in your case it adds Comments section even if you section contains only disablers. I believe it shouldn't do it, and if there are other comments that disablers it should still keep robocop disablers in the first line and move comments to Comments section separately.
Returning to the subject. I see following items:
- recognize robocop file-level disablers from comments section (if it's first section in the file)
- do not raise ignored-data if comments section contains only robocop disablers
- optionally do not create *** Comments *** section if it only contains disablers / or create but keep disablers in their position (issue for robotidy)
I have fixed problems with ignored-data rule (now it ignores robocop and robotidy disablers). I have also opened PR that makes it possible to disable Robocop rule in the whole file if disabler is placed anywhere in the first comment section (instead of just first line of the file). Those changes will be part of the next release.