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 spaces as EnforcedStyle to SpaceInsideParens. #5672

Merged
merged 12 commits into from
Apr 16, 2018

Conversation

joshuapinter
Copy link
Contributor

@joshuapinter joshuapinter commented Mar 13, 2018

Fixes #5666.

Add config option for Style/SpaceInsideParens Cop to enforce spaces.

Simply supply EnforcedStyle: space in your rubocop.yml configuration and instead of enforcing no spaces inside parens, it will enforce spaces.

Even supports auto-correct!

Stylistic choice, to be sure, but one that can help alleviate cluttered code and parentheses hell.

Add documentation for EnforcedStyle: space option.

Add Layout/SpaceInsideParens to default.yml.

This defaults the EnforcedStyle to no_space and then lists the supported styles, including space.

Code formatting to match rubocop style.


Before submitting the PR make sure the following are checked:

  • 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.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run rake default or rake parallel. It executes all tests and RuboCop for itself, and generates the documentation.

Simply supply `EnforcedStyle: space` in your rubocop.yml configuration and instead of enforcing no spaces inside parens, it will enforce spaces.

Even supports auto-correct!

Stylistic choice, to be sure, but one that can help alleviate cluttered code and parentheses hell.
This defaults the EnforcedStyle to `no_space` and then lists the supported styles, including `space`.
@bbatsov
Copy link
Collaborator

bbatsov commented Mar 16, 2018

Ping us when the build is green and this is ready for review.

@Drenmi
Copy link
Collaborator

Drenmi commented Mar 16, 2018

You need to finish the checklist (add CHANGELOG entry and regenerate documentation) before I can review. 🙂

@joshuapinter
Copy link
Contributor Author

Will do! Sorry, we started using it in our codebase and it's working great so this got pushed down the to-do pile. :)

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 13, 2018

@joshuapinter Fair enough. Let us know when you decide to pick up it up again.

@joshuapinter
Copy link
Contributor Author

@bbatsov Will do. Should be next week after we catch up on a few things.

@joshuapinter
Copy link
Contributor Author

joshuapinter commented Apr 14, 2018

Hey Guys,

I've added an entry to CHANGELOG and fixed a few issues but when I try and re-generate the docs, I'm hitting this error:

$ bundle exec rake generate_cops_documentation
rake aborted!
NoMethodError: undefined method `type' for 68576:Fixnum
/Users/joshuapinter/.rbenv/versions/2.2.0/bin/bundle:23:in `load'
/Users/joshuapinter/.rbenv/versions/2.2.0/bin/bundle:23:in `<main>'
Tasks: TOP => generate_cops_documentation => yard_for_generate_documentation
(See full trace by running task with --trace)

Any ideas?

Thanks.

With `rake generate_cops_documentation`.

* Note: I was running Ruby 2.2.0 in my rbenv and was running into the following error:

```bash
NoMethodError: undefined method `type' for 68576:Fixnum
/Users/joshuapinter/.rbenv/versions/2.2.0/bin/bundle:23:in `load'
```

Changing my local rbenv to use Ruby 2.5.0 fixed the issue.
@joshuapinter
Copy link
Contributor Author

Figured out what the issue was.

I was running Ruby 2.2.0 in my rbenv.

Changing my local rbenv to use Ruby 2.5.0 fixed the issue.

I regenerated the docs, resolved conflicts and pushed.

Just waiting on tests to pass now.

Btw, I don't think I can squash my commits now that I've created this PR but I think you can do that on your side when you merge this in. Correct me if I'm wrong, though, and let me know how to do it.

Thanks!

@joshuapinter
Copy link
Contributor Author

Boom! Checks passing. We should be good to go!

@bbatsov bbatsov merged commit c6efac6 into rubocop:master Apr 16, 2018
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 16, 2018

LGMT! 👍

@joshuapinter
Copy link
Contributor Author

👍

@joshuapinter joshuapinter deleted the add_spaces_to_space_inside_parens branch April 16, 2018 15:54
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.

Enforce spaces in parentheses.
3 participants