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

Add new Style/SingleLineDoEndBlock cop #12227

Merged
merged 1 commit into from
Sep 29, 2023

Commits on Sep 29, 2023

  1. Add new Style/SingleLineDoEndBlock cop

    This PR adds new `Style/SingleLineDoEndBlock` cop
    that checks for single-line `do`...`end` blocks.
    
    ```ruby
    # bad
    foo do |arg| bar(arg) end
    
    # good
    foo do |arg|
      bar(arg)
    end
    
    # bad
    ->(arg) do bar(arg) end
    
    # good
    ->(arg) { bar(arg) }
    ```
    
    In practice a single line `do`...`end` is autocorrected when `EnforcedStyle: semantic` in `Style/BlockDelimiters`.
    It can also be detected by this cop if it is written by handcraft.
    So I decided to introduce this new cop instead of an autocorrect extension of `Style/BlockDelimiters`.
    koic committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    8ad7335 View commit details
    Browse the repository at this point in the history