-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add rubocop #1125
Add rubocop #1125
Conversation
- Add `.rubocop.yml` + `.rubocop_todo.yml` following instructions in https://rubocop.readthedocs.io/en/latest/configuration/#automatically-generated-configuration - Add rake task for rubocop
- Rubocop complained about invalid ruby; since the file is technically erb and _not_ ruby, the extension should reflect that anyway.
- Remove empty lines per `Layout/EmptyLines` Cop. - Remove empty lines per `Layout/EmptyLines` Cop from test-dummy rails app. - Remove `Layout/EmptyLines` Cop from todo list.
- Fix quotes in string literals per `Style/StringLiterals` Cop. - Fix quotes in string literals per rubocop for test-dummy rails app. - Remove `Style/StringLiterals` Cop from todo list.
- This Cop is for future Ruby. Skip it for now; it works with the `--auto-correct` option, making future application trivial.
- This Cop forces either nested or compact module declarations. While nested may be considered best practice, changing these up may lead to all kinds of merge conflicts on open PRs.
- Move `Style/HashSyntax` from todos to main config, and set enforced style to `ruby19`--i.e. `{foo: :bar}`. - Update hash syntax from hash-rockets to ruby 1.9 style. - Update hash syntax to ruby 1.9 style in test-dummy rails app.
- Move `Style/SymbolArray` from todos to main config: * Set enforced style to 'percent' -- i.e. `%i[]`. * Don't enforce on arrays with < 3 elements. - Use percent array literals for large arrays of symbols. - Use percent array literals for large arrays of symbols.
Hold off on review for the moment. |
5a48229
to
a3c6ea0
Compare
When `rubocop` was added, the `parser` gem was added as a dependency. Unfortunately, the version of parser specified in the `Gemfile.lock` was unpublished; must update to the newly released parser dependency.
This looks good! I saw that you split the work with @dks17, great because this doesn't have it done at once. I hope in the future, we can add it to travis. When this is ready, just remove the "on hold" label. I would squash the commits at the end because they are a lot, but we can do it at merge time. Thanks @Evan-M !! |
Yeah, 👍@dks17 for helping out with this! I tried local 'feature/cop' branches with merge commits for each cop, but it doesn't look like the ref hierarchy made it up to github. In any event, I think I'll try @dks17's approach with the rest of this PR, and have a single commit for each cop fix. Also, I know I've seen travis running the rubocop code, but it always feels like it blocks test from running. I know that codeclimate can utilize rubocop, so maybe that would work better? https://docs.codeclimate.com/docs/advanced-configuration And I agree that squashing these commits at the end makes sense, but lets get all the commits reviewed beforehand! |
I merged #1126, but then ran into all kinds of rebase and/or merge duplicates and other silliness. If an attempt to make sure that this PR ends up in a reviewable and mergeable state, I cherry-picked the commits that @dks17 made in #1126 back to this branch, squashed all my previous merge commits (such that there is one commit per set of cop violation fixes), and did some This of course required a force-push. So if anyone else has checked-out or forked this branch, I apologize in advance! To get back to valid state, rename your existing checkout/fork, re-checkout or re-fork a clean copy of the updated branch, and rebase your changes against the new copy. |
I have just pull master into rubocop branch. |
@dks17 Agreed, we don't have frequent PRs merged lately, but this could take a while to be finished. Rebase it, we make sure Travis passes and we will merge it (squashing) |
@Evan-M Warning: unrecognized parameter Metrics/BlockLength:inherit_mode found in .rubocop.yml
Warning: unrecognized parameter Metrics/LineLength:inherit_mode found in .rubocop.yml Do you thing these configuration parameters were set properly? Metrics/BlockLength:
inherit_mode:
merge:
- Exclude
- ExcludedMethod
Metrics/LineLength:
inherit_mode:
merge:
- Exclude It seems there is no effect if these properties are commented. |
That happens when there are no inherited settings to merge with from an If you comment out the |
b41294b
to
c19432b
Compare
I'm not a big fan of |
I did not use auto correction (manually only) then ran the tests. |
I've been using the I also frequently use
@krzysiek1507 To your point though, running |
#1157 added the frozen string literal comment to _most_ files; this cop fixes the remaining files and enforces the presence of the frozen string literal comment in future files.
I saw a lot of pull requests with In this case, it's better but it is still hard to review it because of 2.5k additions and 1.9 deletions. |
We can always split this PR into smaller by cherrypicking. |
You don't need to freeze strings if there is |
@Evan-M Is this still on hold? because we can merge after you fix @krzysiek1507 comment, and you continue it in another PR, so it doesn't keep growing |
@krzysiek1507 @Evan-M I reviewed the PR and it looks good, as I don't see more activity from the author and I don't want to lose this work, I will merge it. About |
Taking a stab at adding
rubocop
to the repo, as suggested in #1124I've already addressed some of the simpler Cops that can utilize the
--auto-correct
option.Each correction for a given cop was made in a separate commit, so to make reviewing easier (I hope).
The flow I've used was as follows:
.rubocop_todo.yml
.rubocop.yml
config.add_rubocop
branch with the--no-ff
option.This PR gets the offenses down to 652, but there is still more work to do!