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

Inconsistent indentation not detected #631

Closed
johnvh opened this issue Nov 13, 2013 · 2 comments
Closed

Inconsistent indentation not detected #631

johnvh opened this issue Nov 13, 2013 · 2 comments
Assignees

Comments

@johnvh
Copy link

johnvh commented Nov 13, 2013

As of dc7544f, using:

$ cat .rubocop.yml
IndentationWidth:
  Enabled: true

Then:

$ cat test_1.rb && rubocop test_1.rb
if foo
  do_bar
    do_baz
end
Inspecting 1 file
.

1 file inspected, no offences detected

$ cat test_2.rb && rubocop test_2.rb
if foo
    do_bar
  do_baz
end
Inspecting 1 file
C

Offences:

test_2.rb:2:1: C: Use 2 (not 4) spaces for indentation.
    do_bar
^^^^

1 file inspected, 1 offence detected

It looks to me like the IndentationWidth cop should catch this.

@johnvh
Copy link
Author

johnvh commented Nov 13, 2013

Actually, I'm not sure the intent of the IndentationWidth cop is to catch inconsistent indentation. Is there another cop that should catch this?

@jonas054
Copy link
Collaborator

It's a known limitation of the IndentationWidth cop that it can't catch inconsistent indentation in all cases (only in begin..end blocks). Here's an excerpt from the specs:

    it 'registers an offence for bad indentation of a def body' do
      inspect_source(cop,
                     ['def test',
                      '    func1',
                      '     func2', # No offence registered for this.
                      'end'])
      expect(cop.messages)
        .to eq(['Use 2 (not 4) spaces for indentation.'])
    end

But if we want to add more consistency checking, then I guess this cop is where it should go.

@ghost ghost assigned jonas054 Nov 19, 2013
bbatsov added a commit that referenced this issue Nov 19, 2013
[Fix #631] Check that consecutive lines have the same indentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants