Let RSpec/SpecFilePathFormat leverage ActiveSupport inflections when configured#2090
Conversation
RSpec/SpecFilePathFormat leverage ActiveSupport inflections, if…RSpec/SpecFilePathFormat leverage ActiveSupport inflections, if defined
6899764 to
b403e05
Compare
|
edit: I was missing the need to |
0d66eec to
11f3e2a
Compare
RSpec/SpecFilePathFormat leverage ActiveSupport inflections, if definedRSpec/SpecFilePathFormat leverage ActiveSupport inflections, if configured and defined
RSpec/SpecFilePathFormat leverage ActiveSupport inflections, if configured and definedRSpec/SpecFilePathFormat leverage ActiveSupport inflections when configured and defined
|
Alternatively: We could remove all the handling to cache the lookup by rescuing and warning on a load error when the user has configured to use Inflectors but they aren't available. The current approach fails gracefully when configured on, but unavailable. |
922fa1e to
49b0b1c
Compare
RSpec/SpecFilePathFormat leverage ActiveSupport inflections when configured and definedRSpec/SpecFilePathFormat leverage ActiveSupport inflections when configured
89d6175 to
b798556
Compare
b798556 to
2a70680
Compare
2a70680 to
eb47846
Compare
|
@bquorning I think I addressed all the comments on the original proposed fix PR. We tested this locally in one of our repos with good results. I made the path configurable, but I didn't think an array of possible integrations in config was warranted at this point. In the event that someone does come along and adds an adapter to a new Inflector library, they could add a new top level config key and use the same InflectorPath key. I guess I just think it's unlikely we'll reach more than 3 custom inflectors at which point we could always switch to making users pick a style instead of having a boolean option. |
bd33b0f to
84381d1
Compare
c987a4a to
82090d3
Compare
82090d3 to
0a308f6
Compare
|
@bquorning I'm not really sure where to take this. Should I remove the file path config? I added it because it was asked for in the previous PR. https://github.com/search?q=repo%3Arubocop%2Frubocop%20ActiveSupportExtensionsEnabled&type=code |
|
Hi @corsonknowles, I’m sorry for being unresponsive on this issue for (checks dates) a couple of months 😮
|
|
Regarding |
|
@corsonknowles If you want, I can take a stab at implementing those changes I suggested above? |
|
Oh that would be great! Thank you!!
…On Wed, Oct 8, 2025 at 4:14 AM Benjamin Quorning ***@***.***> wrote:
*bquorning* left a comment (rubocop/rubocop-rspec#2090)
<#2090 (comment)>
@corsonknowles <https://github.com/corsonknowles> If you want, I can take
a stab at implementing those changes I suggested above?
—
Reply to this email directly, view it on GitHub
<#2090 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANFDSY7FMD625HAZK2E2S33WTWZFAVCNFSM6AAAAAB6OHU36WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGOBRGAZDQNRYGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
bca2a89 to
eb1a6b4
Compare
|
@corsonknowles, I managed to push a commit to your branch. It’s not polished yet, but feel welcome to take a look already. |
|
@pirj Can you help with the failing RSpec 4 tests? |
|
We can remove that RSpec 4 job. It’s about to be released. |
|
All the more reason to get the tests passing 🙈 |
|
Fair enough. Seems that it’s failing because RSpec switched to having verified part doubles by default. It is puzzling howe build was passing as this has been in the build long enough. Anyway, we seem to be stubbing |
|
This looks good to me. I'm going to squash and force push, as I think that's required by the repo git standards |
eca02bb to
9fa48a5
Compare
…n defined and configured Fix rubocop#740 Co-Authored-By: Dave Corson-Knowles <david.corsonknowles@gusto.com> Co-Authored-By: Benjamin Quorning <benjamin@quorning.net>
9fa48a5 to
2777fa2
Compare
|
@bquorning Okay, I think it meets standards now. |
|
@pirj Would you have time to do the final review of this PR? |
| ActiveSupport::Inflector.underscore(string) | ||
| end | ||
|
|
||
| def self.prepare_availability(config) |
There was a problem hiding this comment.
Cop_config may differ across directories.
Does it make sense to cache the preparations?
There was a problem hiding this comment.
Corson and I talked about this a couple of times earlier. The main problem is that loaded inflections are stored globally, in ActiveSupport::Inflector::Inflections.instance. So it would be very hard to separate the configurations, even if we tried.
I think that for most use cases, people will only have one inflection configuration, so it’s not a problem. But perhaps we should document the issue for those who may run into the issue in the future?
There was a problem hiding this comment.
Totally reasonable. Even though the anxiety of having config race conditions never left me, we haven’t seen any real reports for … five tears?
| def inflector | ||
| case cop_config.fetch('EnforcedInflector') | ||
| when 'active_support' | ||
| ActiveSupportInflector.prepare_availability(cop_config) |
There was a problem hiding this comment.
In addition to the excessive caching across directories, there can be another problem - multiple threads. RuboCop can run in threads? Or are those processes?
In any case, can we init the inflector once per inspection?
Or this would be too expensive if the inflection file is large?
I can think of a monorepo with many engines each with its own set of inflections
|
Thank you! |
Fix #740
Credit to this PR, reviving with performance and configuration comments addressed:
Before submitting the PR make sure the following are checked:
master(if not - rebase it).CHANGELOG.mdif 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 created a new cop:
config/default.yml.Enabled: pendinginconfig/default.yml.Enabled: truein.rubocop.yml.VersionAdded: "<<next>>"indefault/config.yml.If you have modified an existing cop's configuration options:
VersionChanged: "<<next>>"inconfig/default.yml.