Commit 15edf741 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Explain how to disable it in the doc

parent 0b6d01ed
...@@ -178,6 +178,35 @@ rather than whatever includes the module, and those modules which were also ...@@ -178,6 +178,35 @@ rather than whatever includes the module, and those modules which were also
included, making it much easier to track down any issues, included, making it much easier to track down any issues,
and reducing the chance of having name conflicts. and reducing the chance of having name conflicts.
### How to disable this cop
Put the disabling comment right after your code in the same line:
``` ruby
module M
def violating_method
@f + @g # rubocop:disable Cop/ModuleWithInstanceVariables
end
end
```
If there are multiple lines, you could also enable and disable for a section:
``` ruby
module M
# rubocop:disable Cop/ModuleWithInstanceVariables
def violating_method
@f = 0
@g = 1
@h = 2
end
# rubocop:enable Cop/ModuleWithInstanceVariables
end
```
Note that you need to enable it at some point, otherwise everything below
won't be checked.
### Things we might need to ignore right now ### Things we might need to ignore right now
Because of the way Rails helpers and mailers work, we might not be able to Because of the way Rails helpers and mailers work, we might not be able to
......
...@@ -6,9 +6,6 @@ module RuboCop ...@@ -6,9 +6,6 @@ module RuboCop
for the rationale behind it: for the rationale behind it:
https://docs.gitlab.com/ee/development/module_with_instance_variables.html https://docs.gitlab.com/ee/development/module_with_instance_variables.html
If you think the use for this is fine, please just add:
# rubocop:disable Cop/ModuleWithInstanceVariables
EOL EOL
def on_module(node) def on_module(node)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment