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

Bump to latest rubocop 1.16.0 #102

Merged
merged 8 commits into from
Jun 9, 2021
Merged

Bump to latest rubocop 1.16.0 #102

merged 8 commits into from
Jun 9, 2021

Conversation

sagotsky
Copy link
Contributor

@sagotsky sagotsky commented Jun 4, 2021

Fixes #101

What did we change?

  • Bumped rubocop to most recent version.
  • Bumped rubocop-{rails,rspec} as well
  • Disabled a large number of new cops 872b163
  • Marked this as a new major version

Why are we doing this?

  1. Application fitness 🏋️
  2. After 1.0, new cops will be introduced in a default state. This will make future version bumps much easier.
  3. Disabling many of those cops is likely going to be my spicy take of the day. Bluntly speaking, we should have been doing more minor version bumps along the way. That would have introduced those cops in pending states and then phased them in to an enabled state. I suppose we could retroactively step through all the rubocop version bumps, but I'd rather just fast forward past that step.
  4. We've upgraded rubocop major versions. They had breaking changes. Therefore we inherited their breaking changes.

How was it tested?

  • Specs
  • Locally

@sagotsky sagotsky requested a review from a team as a code owner June 4, 2021 13:18
@sagotsky
Copy link
Contributor Author

sagotsky commented Jun 4, 2021

Looks like there's no CI for this repo. I get failures on the following specs locally.

rspec ./spec/rubocop/cop/ezcater/graphql_fields_naming_spec.rb ~~ ~~rspec ./spec/rubocop/cop/ezcater/style_dig_spec.rb`

All green!

sagotsky added 2 commits June 4, 2021 09:58
It looks like `check_name` now knows how to call `.loc.expression` on an
arugment.  We were doing that on our own as well.  Cleaned that up.
This gem requires 2.6+.  The 2.3 in this spec is no longer supported and
so it would not run.
Copy link

@jaeger401 jaeger401 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotta love a +3/-3 that adds this much value. Thanks for taking this on!

@jaeger401
Copy link

Probably worth updating the PR description to "Fixes #101" so merging this closes the issue automagically?

@sagotsky
Copy link
Contributor Author

sagotsky commented Jun 4, 2021

Good call! I forgot how much I miss that kind of github magic.

Copy link
Contributor

@jmpage jmpage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on testing this a prerelease of this version against a repo to get an idea of what might break with this upgrade?

Thoughts on updating CHANGELOG.md and the VERSION, as appropriate?

@sagotsky
Copy link
Contributor Author

sagotsky commented Jun 4, 2021

@jmpage Yes, to all.

@sagotsky
Copy link
Contributor Author

sagotsky commented Jun 4, 2021

The prerelease testing is what blocked a new version number. I'm not sure just how breaking this is yet.

sagotsky added 3 commits June 7, 2021 09:23
Rails specific cops migrated out of rubocop and into rubocop-rails.  Our
rubocop-rails gem was behind and so it was missing those cops.
Our old code was reaching into private APIs.  Lo and behold, the private
APIs gated off access with `private_constant` and then renamed their
methods.

Found the new way to access this method by including the rspec langauge
module.
Copy link
Contributor

@jmpage jmpage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on testing this on a non-ez-rails app as well, just to see how disruptive it might be?

conf/rubocop.yml Outdated
Comment on lines 156 to 332
Enabled: false

Rails/ArelStar:
Enabled: false

Rails/Pick:
Enabled: false

Rails/RedundantForeignKey:
Enabled: false

RSpec/Capybara/CurrentPathExpectation:
Enabled: false

RSpec/Capybara/FeatureMethods:
Enabled: false

RSpec/Capybara/VisibilityMatcher:
Enabled: false

RSpec/EmptyHook:
Enabled: false

RSpec/FactoryBot/AttributeDefinedStatically:
Enabled: false

RSpec/FactoryBot/CreateList:
Enabled: false

RSpec/FactoryBot/FactoryClassName:
Enabled: false

RSpec/MultipleMemoizedHelpers:
Enabled: false

RSpec/NotToNot:
Enabled: false

RSpec/Rails/HttpStatus:
Enabled: false

RSpec/RepeatedIncludeExample:
Enabled: false

RSpec/StubbedMock:
Enabled: false

RSpec/VariableDefinition:
Enabled: false

RSpec/VariableName:
Enabled: false

Style/AccessorGrouping:
Enabled: false

Style/BisectedAttrAccessor:
Enabled: false

Style/CaseLikeIf:
Enabled: false

Style/CombinableLoops:
Enabled: false

Style/GlobalStdStream:
Enabled: false

Style/HashAsLastArrayItem:
Enabled: false

Style/HashLikeCase:
Enabled: false

Style/KeywordParametersOrder:
Enabled: false

Style/OptionalBooleanParameter:
Enabled: false

Style/RedundantAssignment:
Enabled: false

Style/RedundantRegexpCharacterClass:
Enabled: false

Style/RedundantRegexpEscape:
Enabled: false

Style/RedundantSelfAssignment:
Enabled: false

Style/SingleArgumentDig:
Enabled: false

Style/SlicingWithRange:
Enabled: false

Style/SoleNestedConditional:
Enabled: false
Copy link
Contributor

@jmpage jmpage Jun 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on opening an issue on this project for evaluating these for inclusion and include a checkbox TODO list in the description containing the name of each disabled cop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely want to go through each of these and talk about the interesting ones. GH issues seems like a perfectly fine place to do so.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figure that GH issues let's us punt the issue of figuring out what to turn on from this PR while leaving us with a reminder to get back to it (which probably requires some deliberation for each cop).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#104

I think it's a good home for repos that don't have jira projects.

@@ -4,7 +4,7 @@
RSpec.describe RuboCop::Cop::Ezcater::StyleDig, :config do
subject(:cop) { described_class.new(config) }

let(:ruby_version) { 2.3 }
let(:ruby_version) { 2.6 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What prompted this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not gonna lie, I couldn't completely figure this one out. At least not without spending more time on it.

What I think is going on is that this cop had a minimum ruby version that it applied to. The test was making assertions about the style given a particular version. ruby_version isn't mentioned anywhere else in the file, so I assume it's provided by rubocop, but that's where I stopped digging in.

I figured that since the gem required 2.6 or higher, we'd never be looking at a ruby lower than that. Bumping the version here fixed the spec.

CHANGELOG.md Outdated
- Upgrade rubocop: 1.16.0
- Upgrade rubocop-rails: 2.10.1
- Upgrade rubocop-rspec: 2.3.0
- This is a major upgrade because a large number of cops have been introduced, tweaked, or renamed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on including (or linking to) a list of renamed cops so that people can easily update their rubocop:disable statements?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Is the changelog the appropriate home for that?

Copy link
Contributor

@jmpage jmpage Jun 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the thing that dependabot will excerpt in a bump PR and the first place someone should look when determining changes. If the list is short, it's probably fine to include it. If it's longer, it may make sense to create a separate file in a docs/migration_guides/ folder and link to that, or link to an external resource that lives in the rubocop repos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rolled up the breaking changes from the three dependencies into our changelog.

CHANGELOG.md Show resolved Hide resolved
@sagotsky
Copy link
Contributor Author

sagotsky commented Jun 8, 2021

@jmpage I'd be game for testing on other repos. Do you have any in mind? If not I'll just run this against whatever is checked out locally.

@sagotsky sagotsky force-pushed the js/rubocop-1.16.0 branch 2 times, most recently from 05dcb5f to ada7d38 Compare June 8, 2021 20:16
@jmpage
Copy link
Contributor

jmpage commented Jun 8, 2021

@sagotsky authentication-rails, identity-rails or ezcater-email-service are reasonably "simple" repos that you could test it against.

@sagotsky
Copy link
Contributor Author

sagotsky commented Jun 8, 2021

Tested against a handful of repos. All had single digit offenses. RequiredRubyVersion needed to be fixed everywhere (it was the only offense for coupons-rails, ezcater-identity, and authentication-rails`. club-soda-rails was the biggest repo and that weight in at 8 offenses, all of which were redundant. I'm comfortable releasing like this.

@jmpage
Copy link
Contributor

jmpage commented Jun 8, 2021

🎉 :shipit:

Thank you @sagotsky!

@sagotsky sagotsky merged commit cea1508 into master Jun 9, 2021
@sagotsky sagotsky deleted the js/rubocop-1.16.0 branch June 9, 2021 14:50
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.

Upgrade to newer rubocop
3 participants