Skip to content

Fix an incorrect autocorrect for Layout/EmptyLineBetweenDefs #13092

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

Conversation

koic
Copy link
Member

@koic koic commented Aug 6, 2024

This PR fixes the following incorrect autocorrect for Layout/EmptyLineBetweenDefs when two method definitions are on the same line separated by a semicolon:

$ cat example.rb
def a
end;def b
end

$ bundle exec rubocop --only Layout/EmptyLineBetweenDefs -a

Before

It results in an autocorrection of the syntax error:

def a
end;d
ef b
end

After

No syntax errors:

def a
end;

def b
end

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.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • 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.

This PR fixes the following incorrect autocorrect for `Layout/EmptyLineBetweenDefs`
when two method definitions are on the same line separated by a semicolon:

```console
$ cat example.rb
def a
end;def b
end

$ bundle exec rubocop --only Layout/EmptyLineBetweenDefs -a
```

## Before

It results in an autcorrection of the syntax error:

```ruby
def a
end;d
ef b
end
```

## After

No syntax errors:

```ruby
def a
end;

def b
end
```
@koic koic force-pushed the fix_an_incorrect_autocorrect_for_style_empty_line_between_defs branch from 0c70c47 to e74f981 Compare August 7, 2024 03:56
@koic koic merged commit 97bd667 into rubocop:master Aug 7, 2024
22 checks passed
@koic koic deleted the fix_an_incorrect_autocorrect_for_style_empty_line_between_defs branch August 7, 2024 15:05
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.

1 participant