Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-10 15:08:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-10 15:08:58 +0300
commit0211553b0cd32ddcd49fbe61fdb318984d15af18 (patch)
treef95d5876dfee2d1ff158f38a676167501e6519db /rubocop
parent23ff717a29540bb1d4b0068f164b5f9df99386bf (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/default_scope.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/rubocop/cop/default_scope.rb b/rubocop/cop/default_scope.rb
new file mode 100644
index 00000000000..39f8c8e9ed0
--- /dev/null
+++ b/rubocop/cop/default_scope.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+module RuboCop
+ module Cop
+ # Cop that blacklists the use of `default_scope`.
+ class DefaultScope < RuboCop::Cop::Cop
+ MSG = <<~EOF
+ Do not use `default_scope`, as it does not follow the principle of
+ least surprise. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/33847
+ for more details.
+ EOF
+
+ def_node_matcher :default_scope?, <<~PATTERN
+ (send {nil? (const nil? ...)} :default_scope ...)
+ PATTERN
+
+ def on_send(node)
+ return unless default_scope?(node)
+
+ add_offense(node, location: :expression)
+ end
+ end
+ end
+end