summaryrefslogtreecommitdiff
path: root/rubocop/cop
diff options
context:
space:
mode:
Diffstat (limited to 'rubocop/cop')
-rw-r--r--rubocop/cop/active_record_association_reload.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/rubocop/cop/active_record_association_reload.rb b/rubocop/cop/active_record_association_reload.rb
new file mode 100644
index 00000000000..dc241cab7d0
--- /dev/null
+++ b/rubocop/cop/active_record_association_reload.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+module RuboCop
+ module Cop
+ # Cop that blacklists the use of `reload`.
+ class ActiveRecordAssociationReload < RuboCop::Cop::Cop
+ MSG = 'Use reset instead of reload. ' \
+ 'For more details check the https://gitlab.com/gitlab-org/gitlab-ce/issues/60218.'
+
+ def_node_matcher :reload?, <<~PATTERN
+ (send _ :reload ...)
+ PATTERN
+
+ def on_send(node)
+ return unless reload?(node)
+
+ add_offense(node, location: :selector)
+ end
+ end
+ end
+end