summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-11-22 00:59:16 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-11-22 17:06:57 +0800
commit15edf741a14a53443fb39ecb59888e75697b9c2b (patch)
tree8d9acc47f7c08bae32d13bda497ecd100a4e2319
parent0b6d01ed775e957161e1304de44d0bd5251f4098 (diff)
downloadgitlab-ce-15edf741a14a53443fb39ecb59888e75697b9c2b.tar.gz
Explain how to disable it in the doc
-rw-r--r--doc/development/module_with_instance_variables.md29
-rw-r--r--rubocop/cop/module_with_instance_variables.rb3
2 files changed, 29 insertions, 3 deletions
diff --git a/doc/development/module_with_instance_variables.md b/doc/development/module_with_instance_variables.md
index 43ec8911b81..1c64b35b782 100644
--- a/doc/development/module_with_instance_variables.md
+++ b/doc/development/module_with_instance_variables.md
@@ -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,
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
Because of the way Rails helpers and mailers work, we might not be able to
diff --git a/rubocop/cop/module_with_instance_variables.rb b/rubocop/cop/module_with_instance_variables.rb
index 9f9856e308b..f101ae09ad2 100644
--- a/rubocop/cop/module_with_instance_variables.rb
+++ b/rubocop/cop/module_with_instance_variables.rb
@@ -6,9 +6,6 @@ module RuboCop
for the rationale behind it:
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
def on_module(node)