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
[Fix #8708] Fix bad regexp recognition in Lint/OutOfRangeRegexpRef
when there are multiple regexps
#8844
Conversation
206a75e
to
657d7d8
Compare
Update: I started reviewing, love the message changes 👍 |
@marcandre thanks! Let me know if you want me to change something. |
|
I'm not sure what you mean? This PR is for that issue haha 😅 |
657d7d8
to
fbc4b7a
Compare
Updated to fix the changelog now that 0.93 is out. |
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.
fbc4b7a
to
8497895
Compare
So I checked about adding |
8497895
to
7ff174f
Compare
@marcandre fixed the conflict, happy to make other changes if you want, just let me know! |
15e88e3
to
243222b
Compare
…boCop, at around 8% of overall processing. This is because we currently build a new `Commissionner` for every file (could be optimized but not easy as config can change) and a commissioner must know which cops need responding to which node types. Previous method was thus `O(files * cops * types)` where `types` is the number of node types encountered in a typical file. Testing on `files == 200` typical RuboCop files, I calculated `types ~22.5`. Currently `cops == 422`. This new algorithm is the same `O` but `types` is instead the number of types that a cop responds to (on average). For the cops that we run that is ~1.8. The optimized cache building is almost 6x faster, for an *overall gain of ~6.6%* It also has the advantage that adding new callbacks has zero impact on the cache building. Note: I'd like to add `on_after_send` etc (see #8844). The only downside is that the list of callbacks is (by default) cached per Cop class. This means that any Cop that somehow relies on *adding* callbacks it responds to *at runtime* is incompatible. There's a single cop that does this (see #8881). Solutions include: not doing that (as in the PR), or only modifying the callbacks (in this case it could have been done by adding empty methods `on_send`, etc., even though they would be overriden by the extending modules), or overriding `Cop::Base#callbacks_needed` (although I marked the api as private for now). How I tested performance: ``` $ stackprof tmp/stackprof.dump --text --method 'RuboCop::Cop::Commissioner#cops_callbacks_for' samples: 1039 self (7.5%) / 1104 total (8.0%) $ stackprof tmp/stackprof.dump --text --method 'RuboCop::Cop::Commissioner#initialize_callbacks' samples: 25 self (0.2%) / 180 total (1.4%) ```
…boCop, at around 8% of overall processing. This is because we currently build a new `Commissionner` for every file (could be optimized but not easy as config can change) and a commissioner must know which cops need responding to which node types. Previous method was thus `O(files * cops * types)` where `types` is the number of node types encountered in a typical file. Testing on `files == 200` typical RuboCop files, I calculated `types ~22.5`. Currently `cops == 422`. This new algorithm is the same `O` but `types` is instead the number of types that a cop responds to (on average). For the cops that we run that is ~1.8. The optimized cache building is almost 6x faster, for an *overall gain of ~6.6%* It also has the advantage that adding new callbacks has zero impact on the cache building. Note: I'd like to add `on_after_send` etc (see #8844). The only downside is that the list of callbacks is (by default) cached per Cop class. This means that any Cop that somehow relies on *adding* callbacks it responds to *at runtime* is incompatible. There's a single cop that does this (see #8881). Solutions include: not doing that (as in the PR), or only modifying the callbacks (in this case it could have been done by adding empty methods `on_send`, etc., even though they would be overriden by the extending modules), or overriding `Cop::Base#callbacks_needed` (although I marked the api as private for now). How I tested performance: ``` $ stackprof tmp/stackprof.dump --text --method 'RuboCop::Cop::Commissioner#cops_callbacks_for' samples: 1039 self (7.5%) / 1104 total (8.0%) $ stackprof tmp/stackprof.dump --text --method 'RuboCop::Cop::Commissioner#initialize_callbacks' samples: 25 self (0.2%) / 180 total (1.4%) ```
Update: I opened #8889; I'm waiting a day or two to see if the latest bug fix release is stable and I'll merge that, which would give you the |
…boCop, at around 8% of overall processing. This is because we currently build a new `Commissionner` for every file (could be optimized but not easy as config can change) and a commissioner must know which cops need responding to which node types. Previous method was thus `O(files * cops * types)` where `types` is the number of node types encountered in a typical file. Testing on `files == 200` typical RuboCop files, I calculated `types ~22.5`. Currently `cops == 422`. This new algorithm is the same `O` but `types` is instead the number of types that a cop responds to (on average). For the cops that we run that is ~1.8. The optimized cache building is almost 6x faster, for an *overall gain of ~6.6%* It also has the advantage that adding new callbacks has zero impact on the cache building. Note: I'd like to add `on_after_send` etc (see #8844). The only downside is that the list of callbacks is (by default) cached per Cop class. This means that any Cop that somehow relies on *adding* callbacks it responds to *at runtime* is incompatible. There's a single cop that does this (see #8881). Solutions include: not doing that (as in the PR), or only modifying the callbacks (in this case it could have been done by adding empty methods `on_send`, etc., even though they would be overriden by the extending modules), or overriding `Cop::Base#callbacks_needed` (although I marked the api as private for now). How I tested performance: ``` $ stackprof tmp/stackprof.dump --text --method 'RuboCop::Cop::Commissioner#cops_callbacks_for' samples: 1039 self (7.5%) / 1104 total (8.0%) $ stackprof tmp/stackprof.dump --text --method 'RuboCop::Cop::Commissioner#initialize_callbacks' samples: 25 self (0.2%) / 180 total (1.4%) ```
…boCop, at around 8% of overall processing. This is because we currently build a new `Commissionner` for every file (could be optimized but not easy as config can change) and a commissioner must know which cops need responding to which node types. Previous method was thus `O(files * cops * types)` where `types` is the number of node types encountered in a typical file. Testing on `files == 200` typical RuboCop files, I calculated `types ~22.5`. Currently `cops == 422`. This new algorithm is the same `O` but `types` is instead the number of types that a cop responds to (on average). For the cops that we run that is ~1.8. The optimized cache building is almost 6x faster, for an *overall gain of ~6.6%* It also has the advantage that adding new callbacks has zero impact on the cache building. Note: I'd like to add `on_after_send` etc (see #8844). The only downside is that the list of callbacks is (by default) cached per Cop class. This means that any Cop that somehow relies on *adding* callbacks it responds to *at runtime* is incompatible. There's a single cop that does this (see #8881). Solutions include: not doing that (as in the PR), or only modifying the callbacks (in this case it could have been done by adding empty methods `on_send`, etc., even though they would be overriden by the extending modules), or overriding `Cop::Base#callbacks_needed` (although I marked the api as private for now). How I tested performance: ``` $ stackprof tmp/stackprof.dump --text --method 'RuboCop::Cop::Commissioner#cops_callbacks_for' samples: 1039 self (7.5%) / 1104 total (8.0%) $ stackprof tmp/stackprof.dump --text --method 'RuboCop::Cop::Commissioner#initialize_callbacks' samples: 25 self (0.2%) / 180 total (1.4%) ```
|
@marcandre cool thanks, I’ll probably Be able to update this tomorrow! |
I believe this or can be simplified without using an ignore list...
…On Thu, Oct 8, 2020, 11:04 Daniel Vandersluis ***@***.***> wrote:
@marcandre <https://github.com/marcandre> thanks! Let me know if you want
me to change something.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8844 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAIH2WQPHNZ3RGTPGDNXF3SJXII3ANCNFSM4SCNZDPA>
.
|
243222b
to
f380667
Compare
@marcandre updated to use |
f380667
to
58823be
Compare
@bbatsov made all the requested changes, thanks! |
58823be
to
28c8713
Compare
Can you also address the changelog conflict? |
You can use |
…xpRef` when there are multiple regexps.
28c8713
to
d202e85
Compare
@bbatsov @marcandre moved the changelog item in |
Outstanding work @dvandersluis 👍 |
Lint/OutOfRangeRegexpRef
was using the wrong regexp to determine how many capturing groups there are, in a few cases, that are now fixed. I also updated the error message to be a bit more straightforward because I found it hard to understand, but please let me know if you'd like me to reword or revert.Also I have no idea what the plural of
regexp
should be. 😅Fixes #8708.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.