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

Add mixins folder #942

Closed
wants to merge 1 commit into from
Closed

Conversation

mockdeep
Copy link
Contributor

This moves several files to a new mixins/ folder. I was going to add
some new macros, per this comment, but thought it might clutter
things up a bit to put them in the root folder. I thought of adding a
macros/ folder, but decided to emulate the rubocop source
instead.


Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Updated documentation.
  • Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

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

Thanks for adding some structure!

require_relative 'rubocop/rspec/mixin/top_level_group'
require_relative 'rubocop/rspec/mixin/variable'
require_relative 'rubocop/rspec/mixin/final_end_location'
require_relative 'rubocop/rspec/mixin/blank_line_separation'
Copy link
Member

Choose a reason for hiding this comment

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

I guess maybe rubocop/rspec/cop/mixin/* if they are intended to be included in cops like RuboCop does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pirj yeah, I thought about that briefly. The weird thing in our case is that FinalEndLocation gets included in two places, one being lib/rubocop/rspec/corrector/move_node.rb. Should I put that in the cop/mixin/ directory anyway, or leave it in rubocop/rspec/? It also gets included in blank_line_separation.rb which is itself included in cops.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pirj I went ahead and moved them over to the cop/rspec/ folder. That one case is a little odd, but I think it's probably still better this way.

@mockdeep
Copy link
Contributor Author

Hmm, is this failure related to something on master?

@pirj pirj requested review from bquorning and Darhazer June 29, 2020 07:35
Copy link
Collaborator

@bquorning bquorning left a comment

Choose a reason for hiding this comment

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

Don’t worry about failures on edge rubocop; I think the latest master has some quite significant changes that we need to address separately.

require_relative 'rubocop/rspec/wording'
require_relative 'rubocop/rspec/language'
require_relative 'rubocop/rspec/language/node_pattern'
require_relative 'rubocop/rspec/top_level_group'

require_relative 'rubocop/cop/rspec/mixin/align_let_brace'
Copy link
Member

Choose a reason for hiding this comment

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

Technically, this is not a mixin. It's a helper class used by 2 cops.

Copy link
Member

Choose a reason for hiding this comment

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

Agree. Let's keep in rubocop/rspec.
Everything else is 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, sorry for the delay on this. I've moved align_let_brace back to where it came from.

Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

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

Thanks!

require_relative 'rubocop/rspec/wording'
require_relative 'rubocop/rspec/language'
require_relative 'rubocop/rspec/language/node_pattern'
require_relative 'rubocop/rspec/top_level_group'

require_relative 'rubocop/cop/rspec/mixin/align_let_brace'
Copy link
Member

Choose a reason for hiding this comment

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

Agree. Let's keep in rubocop/rspec.
Everything else is 👍

@mockdeep mockdeep force-pushed the rf-mixins branch 2 times, most recently from 9544e42 to be285e9 Compare July 7, 2020 21:45
@mockdeep
Copy link
Contributor Author

mockdeep commented Jul 7, 2020

Not sure why the build is failing on this. It works for me locally.

@bquorning
Copy link
Collaborator

Not sure why the build is failing on this. It works for me locally.

I think you’re blocked by #955.

@pirj
Copy link
Member

pirj commented Jul 10, 2020

#955 is merged. Please rebase. Sorry for the trouble.

require_relative 'rubocop/rspec/wording'
require_relative 'rubocop/rspec/language'
require_relative 'rubocop/rspec/language/node_pattern'
require_relative 'rubocop/rspec/top_level_group'

require_relative 'rubocop/cop/rspec/mixin/top_level_describe'
Copy link
Collaborator

Choose a reason for hiding this comment

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

When we change the folder like this, shouldn’t we also change the namespace? E.g. RuboCop::RSpec::TopLevelDescribe -> RuboCop::Cop::RSpec::TopLevelDescribe.

Copy link
Member

Choose a reason for hiding this comment

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

Agree.

@mockdeep We've just renamed RuboCop::Cop::RSpec::Cop to RuboCop::Cop::RSpec::Base following RuboCop core's naming.
If we happen to move classes/modules around namespaces, and if it happens those are used by custom cops, we'll break them with a minor version update.
So for Base, we've decided to keep the old class, Cop as well until 2.0.
I don't see how it would be possible to release this change with namespace before we release 2.0 without similar breakage risks.

AFAI understand #863 depends on this pull request. But if this is going to be released in 2.0, that means that #863 will only be released as enabled in 3.0, until then it will be pending.

So I propose two options for #863:

  • untangle it from this pull request, and release separately
  • keep it dependent on this pull request and release post-2.0

Please let me know what you think.

This moves several files to a new `mixins/` folder. I was going to add
some new macros, per [this comment][1], but thought it might clutter
things up a bit to put them in the root folder. I thought of adding a
`macros/` folder, but decided to emulate the [rubocop source][2]
instead.

[1]: rubocop#934 (comment)
[2]: https://github.com/rubocop-hq/rubocop/tree/master/lib/rubocop/cop/mixin
@pirj
Copy link
Member

pirj commented Jul 15, 2020

Adjusted module namespace and rebased.
Let's wait for Github to catch up.

@pirj pirj added this to the 2.0 milestone Jul 15, 2020
Copy link
Collaborator

@bquorning bquorning left a comment

Choose a reason for hiding this comment

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

Is this enough of a breaking change to wait for 2.0? Can we just alias the modules like we did for Cop?

@pirj
Copy link
Member

pirj commented Jul 15, 2020

That's an option. Depends on how essential this is to move #863 forward.

@mockdeep
Copy link
Contributor Author

Unfortunately, as you may have noticed, I haven't been able to be very consistent on following up with these PRs. I don't think #863 depends on this, since, if I remember correctly it was built on #934 instead. I was picturing adding some more macros and using those instead, but we could stick with #863 as is if you want to get that out sooner.

@pirj
Copy link
Member

pirj commented Jul 16, 2020

No rush, take your time and make any additions you see fit in #863.
We'll take care of this pull request later.
Even though RuboCop 1.0 and RuboCop RSpec 2.0 are around the corner, there's a fat list of leftovers there and something to work on here as well, so I guess it's not going to happen earlier than in 3-4 weeks.

@pirj
Copy link
Member

pirj commented Oct 22, 2020

I'll take care of rebasing this.
This is optional, but a nice cleanup nevertheless.

@pirj pirj changed the base branch from master to release-2.0 October 22, 2020 18:22
This was referenced Oct 22, 2020
@pirj
Copy link
Member

pirj commented Oct 22, 2020

Superseded by #1056
Thanks, @mockdeep, this will become part of the 2.0 release!

@pirj pirj closed this Oct 22, 2020
@mockdeep
Copy link
Contributor Author

@pirj thank you for rebasing!

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.

None yet

4 participants