summaryrefslogtreecommitdiff
path: root/rubocop
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-23 15:11:27 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-23 15:11:27 +0000
commit003d7f2a09668af85f94e48ed49d60862b96d8f8 (patch)
tree10f9baf4674416a5a7ca376bcc651973a56917b5 /rubocop
parente10ea43772b9a6be150a074be7e26bfd6fa0380e (diff)
downloadgitlab-ce-003d7f2a09668af85f94e48ed49d60862b96d8f8.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/rspec/misspelled_aggregate_failures.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/rubocop/cop/rspec/misspelled_aggregate_failures.rb b/rubocop/cop/rspec/misspelled_aggregate_failures.rb
new file mode 100644
index 00000000000..04eec515318
--- /dev/null
+++ b/rubocop/cop/rspec/misspelled_aggregate_failures.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+require 'rubocop/cop/rspec/base'
+
+module RuboCop
+ module Cop
+ module RSpec
+ class MisspelledAggregateFailures < RuboCop::Cop::RSpec::Base
+ extend RuboCop::Cop::AutoCorrector
+
+ CORRECT_SPELLING = :aggregate_failures
+ MSG = "Use `#{CORRECT_SPELLING.inspect}` to aggregate failures.".freeze
+
+ # @!method aggregate_tag(node)
+ def_node_matcher :aggregate_tag, <<~PATTERN
+ (block
+ (send #rspec? {#ExampleGroups.all #Examples.all}
+ <$(sym /^aggregate[a-z]*_[a-z]+$/) ...>
+ )
+ ...
+ )
+ PATTERN
+
+ def on_block(node)
+ tag_node = aggregate_tag(node)
+ return if tag_node.nil? || tag_node.value == CORRECT_SPELLING
+
+ add_offense(tag_node) do |corrector|
+ corrector.replace(tag_node, CORRECT_SPELLING.inspect)
+ end
+ end
+ end
+ end
+ end
+end