Skip to content

Commit

Permalink
rubocop: disable Performance/RedundantBlockCall
Browse files Browse the repository at this point in the history
It suggests changes like this:

    diff --git a/lib/tasks/book2.rake b/lib/tasks/book2.rake
    index 046f35f3..f083f25a 100644
    --- a/lib/tasks/book2.rake
    +++ b/lib/tasks/book2.rake
    @@ -11,9 +11,9 @@ def expand(content, path, &get_content)
         else
           new_fname = (Pathname.new(path).dirname + Pathname.new($1)).cleanpath.to_s
         end
    -    new_content = get_content.call(new_fname)
    +    new_content = yield(new_fname)
         if new_content
    -      expand(new_content.gsub("\xEF\xBB\xBF".force_encoding("UTF-8"), ""), new_fname) { |c| get_content.call (c) }
    +      expand(new_content.gsub("\xEF\xBB\xBF".force_encoding("UTF-8"), ""), new_fname) { |c| yield (c) }
         else
           puts "#{new_fname} could not be resolved for expansion"
           ""

That's not wrong, but it seems weird to me to yield in a function that
takes a bunch of parameters. Yes, the get_content function passed in
_happens_ to be the final one, but it doesn't have to be.
  • Loading branch information
peff committed Oct 5, 2022
1 parent 9d0a145 commit b25202e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ AllCops:

Performance:
enabled: true
Performance/RedundantBlockCall:
Enabled: false

Style:
Exclude:
Expand Down

0 comments on commit b25202e

Please sign in to comment.