Skip to content
代码片段 群组 项目
提交 d7ce7098 编辑于 作者: Malcolm Locke's avatar Malcolm Locke 提交者: Michael Kozono
浏览文件

Increase number of lines used in Danger feature_category scan

Danger currently reports feature_category as missing on the top
level `RSpec.describe` if the describe declaration spans more than
2 lines.

OK:
```
RSpec.describe SomeClass, :js,
  feature_category: 'category' do
```

'Fetaure category missing':
```
RSpec.describe SomeClass,
  :js,
  feature_category: 'category' do
```

This change allows this check to support top level `RSpec.describe`
declarations that span up to 5 lines.
上级 5a8c3cac
No related branches found
No related tags found
无相关合并请求
......@@ -259,6 +259,10 @@
" ee: true do",
"\n",
"RSpec.describe Issues :aggregate_failures,",
" feature_category: :team_planning do",
"\n",
"RSpec.describe MergeRequest :aggregate_failures,",
" :js,",
" feature_category: :team_planning do"
]
end
......@@ -275,7 +279,11 @@
"+ feature_category: planning_analytics do",
"+RSpec.describe Epics :aggregate_failures,",
"+ ee: true do",
"+RSpec.describe Issues :aggregate_failures,"
"+RSpec.describe Issues :aggregate_failures,",
"+RSpec.describe MergeRequest :aggregate_failures,",
"+ :js,",
"+ feature_category: :team_planning do",
"+RSpec.describe 'line in commit diff but no longer in working copy' do"
]
end
......
......@@ -90,15 +90,17 @@ def add_suggestions_for_feature_category(filename)
changed_lines.each_with_index do |changed_line, i|
next unless changed_line =~ RSPEC_TOP_LEVEL_DESCRIBE_REGEX
next_line_in_file = file_lines[file_lines.find_index(changed_line.delete_prefix('+')) + 1]
if changed_line.include?(FEATURE_CATEGORY_KEYWORD) || next_line_in_file.to_s.include?(FEATURE_CATEGORY_KEYWORD)
next
end
line_number = file_lines.find_index(changed_line.delete_prefix('+'))
next unless line_number
# Get the top level RSpec.describe line and the next 5 lines
lines_to_check = file_lines[line_number, 5]
# Remove all the lines after the first one that ends in `do`
last_line_number_of_describe_declaration = lines_to_check.index { |line| line.end_with?(' do') }
lines_to_check = lines_to_check[0..last_line_number_of_describe_declaration]
next if lines_to_check.any? { |line| line.include?(FEATURE_CATEGORY_KEYWORD) }
suggested_line = file_lines[line_number]
markdown(comment(FEATURE_CATEGORY_SUGGESTION, suggested_line), file: filename, line: line_number.succ)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册