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
Add mixins folder #942
Conversation
There was a problem hiding this 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!
lib/rubocop-rspec.rb
Outdated
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' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Hmm, is this failure related to something on master? |
There was a problem hiding this 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.
lib/rubocop-rspec.rb
Outdated
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' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
lib/rubocop-rspec.rb
Outdated
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' |
There was a problem hiding this comment.
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 👍
9544e42
to
be285e9
Compare
Not sure why the build is failing on this. It works for me locally. |
I think you’re blocked by #955. |
#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' |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
Adjusted module namespace and rebased. |
There was a problem hiding this 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
?
That's an option. Depends on how essential this is to move #863 forward. |
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. |
No rush, take your time and make any additions you see fit in #863. |
I'll take care of rebasing this. |
@pirj thank you for rebasing! |
This moves several files to a new
mixins/
folder. I was going to addsome 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 sourceinstead.
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).Added tests.Updated documentation.Added an entry to theCHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).