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

Extraneous space characters inserted with alignment of equal signs turned on, with an if-block #6934

Closed
ribose-jeffreylau opened this issue Apr 15, 2019 · 5 comments
Assignees
Labels

Comments

@ribose-jeffreylau
Copy link

Extra space characters are inserted when force-aligning equal signs, with if-unless-modifier disabled. Example input:

a = if b?
      c.d = :e
    end

The above code block showcases an assignment of an if-block, inside which there's another assignment.

Possibly related issues:


Expected behavior

Remains unchanged.

a = if b?
      c.d = :e
    end

Actual behavior

Scroll to the right and see that it inserted an absurd amount of space characters in between:

a                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 = if b?
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      c.d = :e
    end

Steps to reproduce the problem

When given the following Ruby source,

a = if b?
      c.d = :e
    end

and the following .rubocop.yml,

Layout/ExtraSpacing:
  ForceEqualSignAlignment: true

Style/IfUnlessModifier:
  Enabled: false

run Rubocop with autofix.

RuboCop version

$ rubocop -V
0.65.0 (using Parser 2.6.0.0, running on ruby 2.5.3 x86_64-darwin18)
@Drenmi Drenmi added the bug label Apr 15, 2019
@Drenmi
Copy link
Collaborator

Drenmi commented Apr 15, 2019

Thanks for the report! The reproduction steps helped a lot. 🙇

This is reproducible on latest master. The corruption happens because an infinite correction loop between Layout/ExtraSpacing and Layout/SpaceAroundOperators, and subsequently Layout/ExtraSpacing and Layout/IndentationWidth. The loop eventually terminates after a configured number of iterations, leaving the code far off to the right.

@stale
Copy link

stale bot commented Jul 14, 2019

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 Jul 14, 2019
@ribose-jeffreylau
Copy link
Author

Stale bot, this problem still exists as of:

$ rubocop -V
0.72.0 (using Parser 2.6.3.0, running on ruby 2.6.3 x86_64-darwin18)

@stale stale bot removed the stale Issues that haven't been active in a while label Jul 15, 2019
@Drenmi Drenmi self-assigned this Jul 15, 2019
@jfelchner
Copy link
Contributor

This should be fixed in #7211

@jfelchner
Copy link
Contributor

@Drenmi this can be closed.

@Drenmi Drenmi closed this as completed Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants