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

IndentationConsistency & IndentationWidth auto-correct combined breaks code #1118

Closed
andreaseger opened this issue May 27, 2014 · 2 comments
Closed
Assignees
Labels

Comments

@andreaseger
Copy link
Contributor

another bug found in out huge and old codebase.

Before:

module Bar
class Goo
  def something
    first call
      do_other 'things'
      if other > 34
        more_work
      end
  end
end
end

After rubocop --only IndentationConsistency,IndentationWidth --auto-correct indentation_minimal_bug1.rb

module Bar
  class Goo
    def something
      first call
      do_other 'things'
      if other > 3  4
      more_wor  k
    end
    end
  end
end

If I run each of these cops separately one after the other it works as expected and generated the following:

module Bar
  class Goo
    def something
      first call
      do_other 'things'
      if other > 34
        more_work
      end
    end
  end
end
@bbatsov
Copy link
Collaborator

bbatsov commented May 27, 2014

Sounds like another task for @jonas054 :-)

@andreaseger
Copy link
Contributor Author

I found an other one which I think is related to this one. This time its AlignArray + IndentationWidth

before:

module Foo
class Bar

  stuff = [
            {
              some: 'hash',
            },
                 {
              another: 'hash',
              with: 'more'
            },
          ]
end
end

after rubocop --only AlignArray,IndentationWidth --auto-correct indentation_minimal_bug2.rb

module Foo
  class Bar

    stuff = [
              {
                some: 'hash',
              },
              {
       another: 'ha  sh',
       with: 'm  ore'
     },
            ]
  end
end

This example does not break ruby syntax but just look at the strings it changed. Also note that the overall indentation is worse than before and an other run with all default cops on auto-correct does not really help

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