blob: 0f517473982bb254756367b7e8fa1e92c23f8f4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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.children.first)
end
end
end
end
end
|