Skip to content
代码片段 群组 项目
未验证 提交 a035f4a7 编辑于 作者: Rémy Coutable's avatar Rémy Coutable
浏览文件

Don't allow 'rubocop:check:graceful' Rake task to take paths


Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
上级 abdeb126
No related branches found
No related tags found
无相关合并请求
...@@ -15,17 +15,14 @@ def run(args) ...@@ -15,17 +15,14 @@ def run(args)
--format RuboCop::Formatter::GracefulFormatter --format RuboCop::Formatter::GracefulFormatter
] ]
available_cops = RuboCop::Cop::Registry.global.to_h # Convert from Rake::TaskArguments into an Array to make `any?` work as expected.
cop_names = args.to_a
cop_names, paths = args.partition { available_cops.key?(_1) }
if cop_names.any? if cop_names.any?
list = cop_names.sort.join(',') list = cop_names.sort.join(',')
options.concat ['--only', list] options.concat ['--only', list]
end end
options.concat(paths)
puts <<~MSG puts <<~MSG
Running RuboCop in graceful mode: Running RuboCop in graceful mode:
rubocop #{options.join(' ')} rubocop #{options.join(' ')}
......
...@@ -119,9 +119,9 @@ ...@@ -119,9 +119,9 @@
end end
context 'with args' do context 'with args' do
let(:args) { %w[a.rb Lint/EmptyFile b.rb Lint/Syntax] } let(:args) { %w[Lint/EmptyFile Lint/Syntax] }
it_behaves_like 'rubocop scan', rubocop_args: %w[--only Lint/EmptyFile,Lint/Syntax a.rb b.rb] it_behaves_like 'rubocop scan', rubocop_args: %w[--only Lint/EmptyFile,Lint/Syntax]
it 'does not notify slack' do it 'does not notify slack' do
expect(Gitlab::Popen).not_to receive(:popen) expect(Gitlab::Popen).not_to receive(:popen)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册