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

[#2495, #1609] Add EnforcedStyle config parameter to IndentArray #2529

Merged
merged 3 commits into from
Dec 25, 2015
Merged

[#2495, #1609] Add EnforcedStyle config parameter to IndentArray #2529

merged 3 commits into from
Dec 25, 2015

Conversation

jawshooah
Copy link
Contributor

For parity with IndentHash, SupportedStyles include:

  • special_inside_parentheses(default)
  • consistent
  • align_brackets

Review on Reviewable

@alexdowad
Copy link
Contributor

Awesome!! Thanks!! 👍

@jawshooah
Copy link
Contributor Author

RuboCop's own code has quite a few offenses, due to following the consistent style (which was de-facto enforced before this PR). Should we:

  1. set EnforcedStyle to consistent in config/default.yml,
  2. set EnforcedStyle to consistent in .rubocop.yml, or
  3. fix the offenses?

@jawshooah
Copy link
Contributor Author

There's also a huge amount of duplication between IndentArray and IndentHash, since I basically just copy-pasted, removed logic that was applicable to hashes but not arrays, and tweaked some identifier names.

Is it worth extracting the common logic into a shared module?

@alexdowad
Copy link
Contributor

RuboCop's own code has quite a few offenses

I say it's better to fix all the offenses. The cleaner and more consistent the codebase is, the better.

@alexdowad
Copy link
Contributor

Is it worth extracting the common logic into a shared module?

Don't know what @bbatsov wants, but I would say, follow the "three strikes" rule. If the same code is needed in a 3rd place, then extract it.

It may be that there are other places in the codebase which could benefit from the extracted code right now... if so, it would be better to unify them.

@alexdowad
Copy link
Contributor

I say it's better to fix all the offenses.

...Wait a minute. Sorry.

Do we really want special_inside_parentheses to be the default style for IndentArray?
Is this the style which most Ruby developers will prefer?

@jawshooah
Copy link
Contributor Author

Is this the style which most Ruby developers will prefer?

Not sure. It could certainly make it a pain to keep lines within a reasonable length, although in most cases you'd just have to change something like this:

oh.wow.this.is.a.really.long.chain.of.methods([
                                                a.really.really.long.value,
                                                another.really.really.long.value
                                              ])

to this:

oh.wow.this.is.a.really.long.chain.of.methods(
  [
    a.really.really.long.value,
    another.really.really.long.value
  ])

In any case, I've pushed fixes for the various offenses. Check them out in e4f17a2, and if the changes look unreasonable, we can just switch the default back to consistent.

@alexdowad
Copy link
Contributor

Hmm. In some cases, the new style looks really good. In others, not so much.

@jawshooah
Copy link
Contributor Author

Yup. Unfortunately I'm not sure that any hard requirement will look good in all scenarios.

consistent has been the de-facto default for a while now, so maybe we should stick with that. Might cause confusion since the default for IndentHash is special_inside_parentheses, though.

@jawshooah
Copy link
Contributor Author

I'll ping @jfelchner and @zenspider here as well, since they opened the issues we aim to resolve.

@alexdowad
Copy link
Contributor

On the balance, I think special_inside_parentheses looks a little better...

@jfelchner
Copy link
Contributor

@jawshooah thanks so much! Defaults don't matter to me as long as I can switch it. 😉

@jawshooah
Copy link
Contributor Author

@bbatsov, care to weigh in on what the default should be?

@jfelchner
Copy link
Contributor

@jawshooah what does the current impl do? It should probably match that.

@jawshooah
Copy link
Contributor Author

@jfelchner I'd be fine with that, but as I said above:

consistent has been the de-facto default for a while now, so maybe we should stick with that. Might cause confusion since the default for IndentHash is special_inside_parentheses, though.

@jfelchner
Copy link
Contributor

@jawshooah ah thanks for pointing that out. I guess this is definitely a question for @bbatsov 😊

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 24, 2015

On the balance, I think special_inside_parentheses looks a little better...

Yeah (plus it's how Emacs's ruby-mode works :-) ).

A changelog entry has to be added and the PR has to be rebased.

For parity with IndentHash, SupportedStyles include:

  - special_inside_parentheses (default)
  - consistent
  - align_brackets
@jawshooah
Copy link
Contributor Author

@bbatsov I've addressed your comments and rebased.

bbatsov added a commit that referenced this pull request Dec 25, 2015
[#2495, #1609] Add EnforcedStyle config parameter to IndentArray
@bbatsov bbatsov merged commit 4c3e7ad into rubocop:master Dec 25, 2015
@bbatsov
Copy link
Collaborator

bbatsov commented Dec 25, 2015

👍 Thanks!

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

Successfully merging this pull request may close these issues.

4 participants