Closed pdobb closed 2 months ago
Similar to this old issue: https://github.com/rubocop/rubocop-rails/issues/1161
It seems like the department-level disable causes a cop to forget it's only supposed to look at a subset of files. This is reproducable with plain RuboCop and the following: ```yml # .rubocop.yml AllCops: DisabledByDefault: true Exclude: - test.rb Style/HashSyntax: Enabled: true ``` ```rb # test.rb { :a => :b } # rubocop:disable Style { :a => :b } # rubocop:enable Style ``` The same also applies to `rubocop:disable all` Where it then reports a offense for the first hash. I also notice the following warning which is unexpected: > An AutocorrectNotice must be defined in your RuboCop config (from file: /home/user/code/test/test.rb) From `Style/Copyright`.
Above I was running rubocop while passing in the filename which changes behaviour. I can still reproduce the original issue but the original message was nonsense.
I openend https://github.com/rubocop/rubocop/issues/13257 since this is more of a general problem and not specific to rubocop-rails. Can you close this issue?
Thanks @Earlopain 👍. Closing in favor of your ticket.
The presence of a block-level disabling of the entire
Rails
department causes any instance variables in same file to report:Rails/HelperInstanceVariable: Do not use instance variables in helpers
.Expected behavior
I expect block-level disabling of the entire Rails department should be valid.
Actual behavior
Invalid reporting of an offense from Rails/HelperInstanceVariable cop.
Steps to reproduce the problem
Simple example, though it is quite contrived. I put the following into a file and then disabled all but rubocop-rails and removed all of my config.
Here are a couple of ways that work to avoid the Rails/HelperInstanceVariable offense:
RuboCop version