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>2023-01-20 18:08:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-20 18:08:53 +0300
commit709948b7a69597b1efe24df9b0f388cc0b493dd9 (patch)
treea6cbb0b7a1243c5308f8d5afb703d1980edb4595 /rubocop
parent50ea04b6c6823aa1bd8d64cd9a77dcbd03b19053 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/rspec/missing_feature_category.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/rubocop/cop/rspec/missing_feature_category.rb b/rubocop/cop/rspec/missing_feature_category.rb
new file mode 100644
index 00000000000..314250af5ee
--- /dev/null
+++ b/rubocop/cop/rspec/missing_feature_category.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'rubocop/cop/rspec/base'
+require 'rubocop/cop/rspec/mixin/top_level_group'
+
+module RuboCop
+ module Cop
+ module RSpec
+ # Ensures that top level example group contains a feature category.
+ #
+ # @example
+ #
+ # # bad
+ # RSpec.describe 'foo' do
+ # end
+ #
+ # # good
+ # RSpec.describe 'foo', feature_category: :wiki do
+ # end
+ class MissingFeatureCategory < RuboCop::Cop::RSpec::Base
+ include RuboCop::Cop::RSpec::TopLevelGroup
+
+ MSG = 'Please add missing feature category. ' \
+ 'See https://docs.gitlab.com/ee/development/feature_categorization/#rspec-examples.'
+
+ # @!method feature_category?(node)
+ def_node_matcher :feature_category?, <<~PATTERN
+ (block
+ (send ...
+ (hash <(pair (sym :feature_category) _) ...>)
+ )
+ ...
+ )
+ PATTERN
+
+ def on_top_level_example_group(node)
+ return if feature_category?(node)
+
+ add_offense(node)
+ end
+ end
+ end
+ end
+end