diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-20 15:08:53 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-20 15:08:53 +0000 |
commit | 709948b7a69597b1efe24df9b0f388cc0b493dd9 (patch) | |
tree | a6cbb0b7a1243c5308f8d5afb703d1980edb4595 /rubocop | |
parent | 50ea04b6c6823aa1bd8d64cd9a77dcbd03b19053 (diff) | |
download | gitlab-ce-709948b7a69597b1efe24df9b0f388cc0b493dd9.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r-- | rubocop/cop/rspec/missing_feature_category.rb | 44 |
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 |