summaryrefslogtreecommitdiff
path: root/rubocop
diff options
context:
space:
mode:
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/active_record_association_reload.rb21
-rw-r--r--rubocop/rubocop.rb1
2 files changed, 22 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
diff --git a/rubocop/rubocop.rb b/rubocop/rubocop.rb
index 3e33419eb2e..50eab6f9270 100644
--- a/rubocop/rubocop.rb
+++ b/rubocop/rubocop.rb
@@ -6,6 +6,7 @@ require_relative 'cop/gitlab/finder_with_find_by'
require_relative 'cop/gitlab/union'
require_relative 'cop/include_sidekiq_worker'
require_relative 'cop/safe_params'
+require_relative 'cop/active_record_association_reload'
require_relative 'cop/avoid_return_from_blocks'
require_relative 'cop/avoid_break_from_strong_memoize'
require_relative 'cop/avoid_route_redirect_leading_slash'