Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance/RedundantBlockCall produces invalid code #448

Closed
TastyPi opened this issue Mar 22, 2024 · 0 comments · Fixed by #449
Closed

Performance/RedundantBlockCall produces invalid code #448

TastyPi opened this issue Mar 22, 2024 · 0 comments · Fixed by #449
Labels
bug Something isn't working

Comments

@TastyPi
Copy link

TastyPi commented Mar 22, 2024

class RubocopIssue
  def self.around(&around_block)
    define_method(:around) do |&test_block|
      around_block.call { super(&test_block) }
    end
  end
end

gets turned into

class RubocopIssue
  def self.around(&around_block)
    define_method(:around) do |&test_block|
      yield { super(&test_block) }
    end
  end
end

which is a syntax error:

syntax error, unexpected '{' (SyntaxError)
      yield { super(&test_block) }
            ^

Expected behavior

rubocop-performance should only produce valid code

Actual behavior

rubocop-performance produced a syntax error

Steps to reproduce the problem

Run rubocop-performance on the example above

RuboCop version

1.62.1 (using Parser 3.3.0.5, rubocop-ast 1.31.2, running on ruby 3.2.2) +server [x86_64-linux]

  • rubocop-capybara 2.20.0
  • rubocop-i18n 1.14.4
  • rubocop-minitest 0.35.0
  • rubocop-performance 1.20.2
  • rubocop-rails 2.24.0
  • rubocop-rake 0.6.0
  • rubocop-thread_safety 0.5.1
@koic koic added the bug Something isn't working label Mar 22, 2024
koic added a commit to koic/rubocop-performance that referenced this issue Mar 22, 2024
…kCall`

Fixes rubocop#448.

This PR fixes a false positive for `Performance/RedundantBlockCall`
when using `block.call` with block argument.
koic added a commit to koic/rubocop-performance that referenced this issue Mar 25, 2024
…kCall`

Fixes rubocop#448.

This PR fixes a false positive for `Performance/RedundantBlockCall`
when using `block.call` with block argument.
@koic koic closed this as completed in #449 Mar 29, 2024
koic added a commit that referenced this issue Mar 29, 2024
…redundant_block_call

[Fix #448] Fix a false positive for `Performance/RedundantBlockCall`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants