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

Rubocop #460

Merged
merged 90 commits into from
Mar 21, 2018
Merged

Rubocop #460

merged 90 commits into from
Mar 21, 2018

Conversation

pushcx
Copy link
Member

@pushcx pushcx commented Mar 2, 2018

I'm adding rubocop to enforce style issues to save human attention (and patience) in code reviews. The default config found 4,849 offenses and this branch will be merged when there are zero.

Like everybody I have opinions on style issues, but my preferred style for any codebase is whatever the codebase is already doing. With that in mind, I'm configuring cops to enforce the common usage and then tweaking outliers to match, eg. 988aa22 and fda61bb.

If you have opinions on how best to paint this bikeshed, this PR is the place to speak up. Once this is merged I'd like to change style config as rarely as possible because it's distracting churn when reading through history during bughunts. Speak now or forever hold your peace or, in the future, make a compelling, metrics-driven argument that a style change will materially improve code quality.

The current 3,382 offenses may seem like a lot, but if you sort by offense count you'll of course see a pareto-like distribution of 135 cops, so this PR hopefully won't linger for months. rubocop | grep -o '[A-Z][^/]*/[A-Z][^ ]*' | sort | uniq -c | sort -rn | head -n 20

TODO: run rubocop as part of the test suite so humans see it easily and Travis fails the build.

@talklittle
Copy link
Contributor

👍 makes sense

On a related note, given the automated checks being added to the repo, maybe maintainers could refrain from committing non-critical changes directly to master in the future, so they'll be subject to automated checks on their pull requests as well? 😉

@hmadison
Copy link
Member

hmadison commented Mar 2, 2018

This looks good to me.

pushcx added 2 commits March 2, 2018 23:33
Codebase doesn't use these often and definitely doesn't prefer them.
@jcs
Copy link
Contributor

jcs commented Mar 14, 2018

I don't really care about this code anymore so do whatever you want, but:

Like everybody I have opinions on style issues, but my preferred style for any codebase is whatever the codebase is already doing.

I think I was/am pretty consistent in my code style but most of this diff changes the style, not the code to conform to the existing style as you said.

-    new_tags.keep_if {|t| t.valid_for? @user }
+    new_tags.keep_if { |t| t.valid_for? @user }

All of the existing code uses {|, so how is { | considered the existing style?

$ fgrep -r -- '{|' app | wc -l 
      51
$ fgrep -r -- '{ |' app | wc -l
       0

Similarly for spaces around brackets in array declarations.

@pushcx
Copy link
Member Author

pushcx commented Mar 14, 2018

I didn't notice the codebase was consistent. I haven't seen another do it so it looks odd to me. I put no thought into that one, I autocorrected it and moved on.

Edit: Spaces around brackets was pretty evenly split: 130 arrays without space, 142 with spaces. I considered disabling it, but I think it's come up in a PR so I went with the rubocop default.

Double edit: As long as someone's reading these... the existing style Layout/MultilineOperationIndentation was pretty consistent as 'the thing vim indenting does", but that doesn't match any cop options. Same with Layout/AlignParameters, but also indenting was more consistent with the cops around aligning hashes, arrays, parameters, and Layout/DotPosition.

As a warning to anyone paying attention to this PR: I will probably do a rebase fixup and push --force to revert Layout/SpaceInsideBlockBraces in 1ea897a to have less churn in the history of the main branch. I've been thinking merge rather than squash because there's some commit messages, but maybe no one will ever care about those on style and one big commit is less awful? Thoughts?

@pushcx
Copy link
Member Author

pushcx commented Mar 16, 2018

As described, I've edited 1ea897a into b1f83f5 to remove the space between block curly braces and arguments.

pushcx added 10 commits March 17, 2018 14:02
Rubocop doesn't have an option for our style, which is semantic (braces when
mapping) except for DSL usage.
Disabling. The codebase almost always uses an explicit self receiver.
We're pretty evenly split on this.
I'm endlessly amused that we had 666 offenses against the default style.
It's a transitional thing, let future me suffer with Ruby 3.0.
Turned off everything but LineLength, which I bumped to 100 and manually
tidied.
Seriously considered renaming vote_thusly_on_story_or_comment_for_user_because
just becaues of how many weird linewraps it causes.
@pushcx
Copy link
Member Author

pushcx commented Mar 19, 2018

OK, no cops complaining and the merge conflicts are trivial. I'll merge Wednesday morning, if anyone wants to express an opinion before then.

@sean-public
Copy link
Contributor

sean-public commented Mar 19, 2018

Since this touches so many files, I imagine anyone working in a branch will need to rebase (perhaps even painfully). Is there any such work going on and should anyone be notified in particular to make sure they see this mega-merge incoming?

image

@talklittle
Copy link
Contributor

Good point, @sean-public -- would be nice to get outstanding PRs merged first, so the authors won't be forced to conform to style checks that didn't exist when they initially created the PRs.

@pushcx
Copy link
Member Author

pushcx commented Mar 21, 2018

I merged the open PRs that were ready to go.

@pushcx pushcx merged commit 7b5bfdd into master Mar 21, 2018
@pushcx pushcx deleted the rubocop branch March 21, 2018 20:20
@pushcx
Copy link
Member Author

pushcx commented Mar 21, 2018

OK, and merged this branch down, too. (I'm adding it to the test suite + travis in a separate commit because of hassles around the bumped deps.)

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.

5 participants