Actions
Patch #32308
closedRubocop: Performance/RedundantBlockCall: Use yield instead of block.call.
Status:
Closed
Priority:
Normal
Assignee:
Toshi MARUYAMA
Category:
Code cleanup/refactoring
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Description
Offenses:
lib/redmine/scm/adapters/abstract_adapter.rb:252:17: C: [Corrected] Performance/RedundantBlockCall: Use yield instead of block.call.
block.call(io) if block_given?
^^^^^^^^^^^^^^
Fix:
root@df2fd1389bf4:/work# git diff
diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb
index 67a1f17a3..14f8f09c4 100644
--- a/lib/redmine/scm/adapters/abstract_adapter.rb
+++ b/lib/redmine/scm/adapters/abstract_adapter.rb
@@ -249,7 +249,7 @@ module Redmine
IO.popen(cmd, mode) do |io|
io.set_encoding("ASCII-8BIT") if io.respond_to?(:set_encoding)
io.close_write unless options[:write_stdin]
- block.call(io) if block_given?
+ yield(io) if block_given?
end
rescue => e
msg = strip_credential(e.message)
Files
Updated by Marius BĂLTEANU over 4 years ago
All tests pass: https://gitlab.com/redmine-org/redmine/pipelines/90121225
Updated by Pavel Rosický over 4 years ago
- File yield.patch yield.patch added
there are a few other cases
Updated by Pavel Rosický over 4 years ago
- File block_given.patch block_given.patch added
Updated by Toshi MARUYAMA over 4 years ago
def check(&block)
if block
puts "if block"
else
puts "else"
end
if block_given?
puts "Block is given."
else
puts "Block isn't given."
end
end
check{}
puts
check
$ ruby test.rb if block Block is given. else Block isn't given.
Updated by Toshi MARUYAMA over 4 years ago
- Status changed from New to Closed
- Target version deleted (
Candidate for next major release)
Fixed, thanks.
Actions