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

Created on 15 Apr 2019  路  5Comments  路  Source: rubocop-hq/rubocop

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)
bug

All 5 comments

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.

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 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)

This should be fixed in #7211

@Drenmi this can be closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bquorning picture bquorning  路  3Comments

lepieru picture lepieru  路  3Comments

mlammers picture mlammers  路  3Comments

bbugh picture bbugh  路  3Comments

mikegee picture mikegee  路  3Comments