KEMBAR78
Fix `Style/ItBlockParameter` cop error on `Always` style and missing block body by viralpraxis · Pull Request #14356 · rubocop/rubocop · GitHub
Skip to content

Conversation

@viralpraxis
Copy link
Contributor

For ->(_) {}:

Failures:

  1) RuboCop::Cop::Style::ItBlockParameter >= Ruby 3.4 EnforcedStyle: always does not register an offense for block with parameter and missing body
     Failure/Error:
       node.body.each_descendant(:lvar).select do |descendant|
         descendant.source == block_argument_name
       end

     NoMethodError:
       undefined method 'each_descendant' for nil

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

…block body

For `->(_) {}`:

```shell
Failures:

  1) RuboCop::Cop::Style::ItBlockParameter >= Ruby 3.4 EnforcedStyle: always does not register an offense for block with parameter and missing body
     Failure/Error:
       node.body.each_descendant(:lvar).select do |descendant|
         descendant.source == block_argument_name
       end

     NoMethodError:
       undefined method 'each_descendant' for nil
```
@koic koic merged commit 371018c into rubocop:master Jul 11, 2025
24 checks passed
@koic
Copy link
Member

koic commented Jul 11, 2025

Nice 👍

@viralpraxis viralpraxis deleted the fix-style-it-block-parameter-cop-error-on-always-style-and-empty-block branch July 11, 2025 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants