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

Layout/SpaceAroundOperators should allow literal rationals without spaces #7537

Closed
eki opened this issue Nov 29, 2019 · 0 comments · Fixed by #7541
Closed

Layout/SpaceAroundOperators should allow literal rationals without spaces #7537

eki opened this issue Nov 29, 2019 · 0 comments · Fixed by #7541
Labels

Comments

@eki
Copy link

eki commented Nov 29, 2019

Example code:

1/2r + 3

Rubocop 0.77.0 says this:

lib/rational.rb:1:2: C: Layout/SpaceAroundOperators: Surrounding space missing for operator /.
1/2r + 3
 ^ 

Ruby style guide linked by Rubocop says it is preferred not to have spaces around the / in a rational literal: https://rubystyle.guide/#spaces-operators


Expected behavior

Rubocop should enforce the Ruby style guide with respect to rational literals. We should prefer 1/2r to 1 / 2r.

Actual behavior

Rubocop prefers 1 / 2r over the recommended 1/2r.

Steps to reproduce the problem

Add a rational literal without spaces around / to some code, run rubocop.

RuboCop version

0.77.0 (using Parser 2.6.5.0, running on ruby 2.6.3 x86_64-darwin18)
@koic koic added the bug label Nov 29, 2019
koic added a commit to koic/rubocop that referenced this issue Dec 4, 2019
…ors`

Fixes rubocop#7537.

This PR fixes a false positive for `Layout/SpaceAroundOperators` when
using a Rational literal with `/` (e.g. `2/3r`).
bbatsov pushed a commit that referenced this issue Dec 5, 2019
Fixes #7537.

This PR fixes a false positive for `Layout/SpaceAroundOperators` when
using a Rational literal with `/` (e.g. `2/3r`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants