You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
I expect block-level disabling of the entire Rails department should be valid.
Actual behavior
Invalid reporting of an offense from Rails/HelperInstanceVariable cop.
rubocop -d rubocop.rb
For /Users/paul/dev/minesweeper_alliance: configuration from /Users/paul/dev/minesweeper_alliance/.rubocop.yml
configuration from /Users/paul/.gem/ruby/3.3.4/gems/rubocop-rails-2.26.1/config/default.yml
configuration from /Users/paul/.gem/ruby/3.3.4/gems/rubocop-rails-2.26.1/config/default.yml
Default configuration from /Users/paul/.gem/ruby/3.3.4/gems/rubocop-1.66.1/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /Users/paul/dev/minesweeper_alliance/rubocop.rb
W
Offenses:
rubocop.rb:3:1: C: Rails/HelperInstanceVariable: Do not use instance variables in helpers.
@ivar = 1
^^^^^
rubocop.rb:5:1: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Rails department.
# rubocop:disable Rails
^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 2 offenses detected, 1 offense autocorrectable
Finished in 0.2639049999997951 seconds
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.
The text was updated successfully, but these errors were encountered:
pdobb
changed the title
Block-level disabling of Rails department causes Rails/HelperInstanceVariable offense on ivars
False positive for Rails/HelperInstanceVariable when using block-level disabling of Rails department
Sep 18, 2024
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:
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.
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
The text was updated successfully, but these errors were encountered: