KEMBAR78
Offend missing whitespace between `return` and opening parens in `Layout/SpaceAroundKeyword` by lovro-bikic · Pull Request #14378 · rubocop/rubocop · GitHub
Skip to content

Conversation

lovro-bikic
Copy link
Contributor

@lovro-bikic lovro-bikic commented Jul 21, 2025

Currently, Layout/SpaceAroundKeyword will allow both of these examples:

return(foo + bar)
return (foo + bar)

This PR changes the cop to always require a space before the opening parenthesis.

Style with space is much more frequent than the style without space, so I'd like to make that explicit in the cop.

Arguments for this change:

  • will enforce a consistent style
  • is already a much more common style than the no-space style (shown above)
  • when closing parens isn't the end of the return expression, no-space style looks weird (e.g. return (foo + bar) * baz vs return(foo + bar) * baz)

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.

@bbatsov bbatsov merged commit d4809c1 into rubocop:master Jul 22, 2025
24 checks passed
@lovro-bikic lovro-bikic deleted the layout-space-around-keyword-return-space branch July 22, 2025 05:23
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