Skip to content

Commit 15edf74

Browse files
committed
Explain how to disable it in the doc
1 parent 0b6d01e commit 15edf74

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

doc/development/module_with_instance_variables.md

+29
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,35 @@ rather than whatever includes the module, and those modules which were also
178178
included, making it much easier to track down any issues,
179179
and reducing the chance of having name conflicts.
180180

181+
### How to disable this cop
182+
183+
Put the disabling comment right after your code in the same line:
184+
185+
``` ruby
186+
module M
187+
def violating_method
188+
@f + @g # rubocop:disable Cop/ModuleWithInstanceVariables
189+
end
190+
end
191+
```
192+
193+
If there are multiple lines, you could also enable and disable for a section:
194+
195+
``` ruby
196+
module M
197+
# rubocop:disable Cop/ModuleWithInstanceVariables
198+
def violating_method
199+
@f = 0
200+
@g = 1
201+
@h = 2
202+
end
203+
# rubocop:enable Cop/ModuleWithInstanceVariables
204+
end
205+
```
206+
207+
Note that you need to enable it at some point, otherwise everything below
208+
won't be checked.
209+
181210
### Things we might need to ignore right now
182211

183212
Because of the way Rails helpers and mailers work, we might not be able to

rubocop/cop/module_with_instance_variables.rb

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ class ModuleWithInstanceVariables < RuboCop::Cop::Cop
66
for the rationale behind it:
77
88
https://docs.gitlab.com/ee/development/module_with_instance_variables.html
9-
10-
If you think the use for this is fine, please just add:
11-
# rubocop:disable Cop/ModuleWithInstanceVariables
129
EOL
1310

1411
def on_module(node)

0 commit comments

Comments
 (0)