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

Indentation consistency in arrays and hashes #797

Closed
bquorning opened this issue Feb 5, 2014 · 7 comments
Closed

Indentation consistency in arrays and hashes #797

bquorning opened this issue Feb 5, 2014 · 7 comments
Assignees

Comments

@bquorning
Copy link
Contributor

Consider the following example code:

a = {
  a: 4
}
puts a

b = {
    b: 5
}
puts b

c = [
  1, 2, 3,
  4
]
puts c

d = [
    5, 6, 7,
    8
]
puts d

Hash b and array d are clearly mis-indented, but Rubocop doesn’t see any offences.

@bbatsov
Copy link
Collaborator

bbatsov commented Feb 5, 2014

Indeed. @jonas054 would you take a look at this?

@jonas054 jonas054 self-assigned this Feb 5, 2014
@jonas054
Copy link
Collaborator

jonas054 commented Feb 6, 2014

Certainly. I think a couple of new cops are needed. We already have AlignArray and AlignHash to check that elements in multi-line literals have the same indentation. The new cops could be called IndentArray and IndentHash. The IndentHash cop would enforce style a in the example above. IndentArraywould enforce style c by default, since that's consistent with the style guide, but it would be configurable to allow another style

e = [
     1, 2, 3,
     4
    ]

This is the style I get from my emacs settings, and it's been used quite a lot in the RuboCop source code.

@bbatsov
Copy link
Collaborator

bbatsov commented Feb 7, 2014

@jonas054 I think that style e was actually caused by a bug in Emacs, that's fixed in 24.4. I'm OK with the idea for this being handled by new cops.

@jonas054
Copy link
Collaborator

jonas054 commented Feb 8, 2014

Oh. I feel I have been misled by Emacs for some time.

Alright, I guess we don't need to make it configurable, then.

jonas054 added a commit to jonas054/rubocop that referenced this issue Feb 12, 2014
jonas054 added a commit to jonas054/rubocop that referenced this issue Feb 13, 2014
@bquorning
Copy link
Contributor Author

Thank you.

Benjamin

On 15/02/2014, at 06.35, Jonas Arvidsson notifications@github.com wrote:

Closed #797 via b5651c1.


Reply to this email directly or view it on GitHub.

@bquorning
Copy link
Contributor Author

No pressure, but when will the be available in the gem? Do you have a patch/minor release planned?

@bbatsov
Copy link
Collaborator

bbatsov commented Feb 18, 2014

No specific date has been planned. I usually make a new feature release every 4-6 weeks. Expect a new version in the beginning of March. In the meantime you can build the gem from github manually.

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

3 participants