Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] robocop-robotidy file level disabler strangeness #1044

Closed
levlist opened this issue Jan 9, 2024 · 4 comments · Fixed by #1079
Closed

[Bug] robocop-robotidy file level disabler strangeness #1044

levlist opened this issue Jan 9, 2024 · 4 comments · Fixed by #1079
Labels
bug Something isn't working

Comments

@levlist
Copy link

levlist commented Jan 9, 2024

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

@levlist levlist added the bug Something isn't working label Jan 9, 2024
@levlist
Copy link
Author

levlist commented Jan 9, 2024

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.

@bhirsz
Copy link
Member

bhirsz commented Jan 15, 2024

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.

@bhirsz
Copy link
Member

bhirsz commented Mar 1, 2024

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)

@bhirsz
Copy link
Member

bhirsz commented May 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants