Skip to content
代码片段 群组 项目
未验证 提交 ec8d4ee4 编辑于 作者: Sean McGivern's avatar Sean McGivern
浏览文件

Do not suggest match_array / contains_exactly for empty arrays

These suggestions are useful in general, but for an empty array it
doesn't really make sense: `eq([])` is both shorter and clearer.
Ordering cannot possibly be an issue with an empty array.
上级 61335b6b
No related branches found
No related tags found
无相关合并请求
...@@ -118,7 +118,8 @@ ...@@ -118,7 +118,8 @@
"- expect(foo).to match(['bar'])", "- expect(foo).to match(['bar'])",
"- expect(foo).to match ['bar']", "- expect(foo).to match ['bar']",
"- expect(foo).to eq(['bar'])", "- expect(foo).to eq(['bar'])",
"- expect(foo).to eq ['bar']" "- expect(foo).to eq ['bar']",
"+ expect(foo).to eq([])"
] + matching_lines ] + matching_lines
end end
...@@ -126,7 +127,7 @@ ...@@ -126,7 +127,7 @@
allow(specs.helper).to receive(:changed_lines).with(filename).and_return(changed_lines) allow(specs.helper).to receive(:changed_lines).with(filename).and_return(changed_lines)
end end
it 'returns added, modified, and renamed_after files by default' do it 'returns all lines using an array equality matcher' do
expect(specs.added_line_matching_match_with_array(filename)).to match_array(matching_lines) expect(specs.added_line_matching_match_with_array(filename)).to match_array(matching_lines)
end end
end end
......
...@@ -5,7 +5,7 @@ module Danger ...@@ -5,7 +5,7 @@ module Danger
module Specs module Specs
SPEC_FILES_REGEX = 'spec/' SPEC_FILES_REGEX = 'spec/'
EE_PREFIX = 'ee/' EE_PREFIX = 'ee/'
MATCH_WITH_ARRAY_REGEX = /(?<to>to\(?\s*)(?<matcher>match|eq)(?<expectation>[( ]?\[)/.freeze MATCH_WITH_ARRAY_REGEX = /(?<to>to\(?\s*)(?<matcher>match|eq)(?<expectation>[( ]?\[[^\]]+)/.freeze
SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT SUGGEST_MR_COMMENT = <<~SUGGEST_COMMENT
```suggestion ```suggestion
%<suggested_line>s %<suggested_line>s
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册