-
-
Notifications
You must be signed in to change notification settings - Fork 276
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 configuration option CustomTransformPatterns
to RSpec/SpecFilePathFormat
#1716
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.
Wr had this option in FilePath? How comes we’ve missed copying it over to this cop whennsplitting ?
What about yhe other cop, does it need the option?
There is no way to declare this in the obsoletion conf, is there?
Thank you!
@pirj We didn't have this option in FilePath and had the same issue 👍🏻
|
We probably had the same issue because ‘rspec’ was not in the defaults? |
This is occurring though It also occurs when explicitly specified as follows
|
That is weird. Wondering, why?
Is there a guarantee that specs from this PR won’t conceal the problem ? |
This test does not guarantee this case. # foofoo/some/class/bar_spec.rb
describe FooFoo::Some::Class, '#bar' do; end Note, however, that the following cases of # foofoo_bar/some/class/bar_spec.rb
describe FooFooBar::Some::Class, '#bar' do; end Because
|
A-ha! So this is an additional option. |
53cfeb7
to
bba30a7
Compare
I'm wondering if adding this feature as a separate additional option might be better in order to ensure backward compatibility when there are already custom settings in CustomTransform. What do you think? |
bba30a7
to
a6faf3c
Compare
|
||
context 'when configured with `CustomTransformPatterns: ' \ | ||
'{ "RSpec" => "rspec" }`' do | ||
let(:cop_config) { { 'CustomTransformPatterns' => { 'RSpec' => 'rspec' } } } |
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.
What i meant with reusing the option was to allow ‘“RSpec” => “rspec”’ config in CustomTransform.
That would still be backwards-compatible.
I’m not against the new option, but I experience some cognitive resistance due to the lack of real examples.
Would the following make good examples of partial trasgormations?
API -> api
DSL -> dsl
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’m still not convinced with RSpecClass.
6c70914
to
35c779b
Compare
Sorry for the delay. I have updated this PR. How do you like it? |
|
||
context 'when configured with `CustomTransformPatterns: ' \ | ||
'{ "RSpec" => "rspec" }`' do | ||
let(:cop_config) { { 'CustomTransformPatterns' => { 'RSpec' => 'rspec' } } } |
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’m still not convinced with RSpecClass.
35c779b
to
3f826e2
Compare
d550f3a
to
9937e8a
Compare
9937e8a
to
d22bf34
Compare
I updated this PR. |
it 'registers an offense when not an exact match to custom ' \ | ||
'module name transformation' do | ||
expect_offense(<<-RUBY, 'rspec_foo_spec.rb') | ||
RSpec.describe RSpecFoo do; end |
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.
The best way to demo the difference between those two option would be RSpec.describe CustomDSL
and DSL
=> dsl
mapping. One would insist on custom_d_s_l_*spec.rb
, the other on custom_dsl_*spec.rb
, right?
Namespaces and RSpecFoo
don't help understand it.
I keep losing grip about this option.
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.
This does not appear to be an offense when followed by only one uppercase letter, as in DSL, so this is not the case that can be resolved with this option. This option may not be a common use case.
Please pardon my continuous inability to understand what problem this PR solves. |
Yes For example, the following custom cup collection does not have separate divisions, so I'm not sure this is common, though. |
I’ll try to argue that |
That may indeed be true. Thank you. I will close this PR. |
Motivation
For example, if you have the following files:
Suppose you have the following .rubocop.yml:
But this would be offense:
So how about something that can be specified in a pattern?
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.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).If you have modified an existing cop's configuration options:
VersionChanged: "<<next>>"
inconfig/default.yml
.