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

ForceEqualSignAlignment + SpaceAroundOperators causes infinite loop #7422

Closed
alebruck opened this issue Oct 12, 2019 · 3 comments · Fixed by #10001
Closed

ForceEqualSignAlignment + SpaceAroundOperators causes infinite loop #7422

alebruck opened this issue Oct 12, 2019 · 3 comments · Fixed by #10001
Labels

Comments

@alebruck
Copy link

alebruck commented Oct 12, 2019

Expected behavior

Layout/SpaceAroundOperators:
  Enabled: true

It should not report an error if more than a single space is around the operator when ForceEqualSignAlignment is in place.

Actual behavior

The cop forces a single space around the operator even when ForceEqualSignAlignment is in place, generating an infinite loop.

Layout/SpaceAroundOperators: Operator = should be surrounded by a single space.

Steps to reproduce the problem

.rubocop.yml

Layout/ExtraSpacing:
  ForceEqualSignAlignment: true

Layout/SpaceAroundOperators:
  Enabled: true

sample.rb

module Foo
  class Bar
    FIRST_GLOBAL  = {
      '.' => :dot
    }.freeze
    SECOND_GLOBAL = 1
  end
end

RuboCop version

$ [bundle exec] rubocop -V
0.75.0 (using Parser 2.6.5.0, running on ruby 2.4.1 x86_64-darwin16)

ps: I may tackle this issue when expected behavior is confirmed :)

@noraj
Copy link

noraj commented Mar 2, 2020

Similar problem:

Equals signs are aligned (operator aligned on the right), no complain from rubocop.

  s.files         = Dir['bin/*'] + Dir['docs/**/*'] + Dir['lib/**/*.rb']
  s.files        += ['LICENSE.txt', '.yardopts-dev', '.yardopts']

Plus sign and equal sign are aligned (operator aligned on the left), rubocop complaining (Operator += should be surrounded by a single space. (convention:Layout/SpaceAroundOperators))

  s.files         = Dir['bin/*'] + Dir['docs/**/*'] + Dir['lib/**/*.rb']
  s.files         += ['LICENSE.txt', '.yardopts-dev', '.yardopts']

Config

Which is the default:

Layout/ExtraSpacing:
  ForceEqualSignAlignment: false

Layout/SpaceAroundOperators:
  Enabled: true

@stale
Copy link

stale bot commented Aug 29, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added the stale Issues that haven't been active in a while label Aug 29, 2020
@noraj
Copy link

noraj commented Aug 29, 2020

unstale

@stale stale bot removed the stale Issues that haven't been active in a while label Aug 29, 2020
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Aug 10, 2021
koic added a commit that referenced this issue Aug 11, 2021
[Fix #7422] Treat `casgn` nodes like other assignment nodes in `Layout/SpaceAroundOperators`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants