-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 handling of escaped octals in duplicate regexp cop #11562
Fix handling of escaped octals in duplicate regexp cop #11562
Conversation
if seen.include?(current_child_source) | ||
next if start_with_escaped_zero_number?(current_child_source, next_child.to_s) | ||
def group_expressions(node, expressions) | ||
expressions = expressions.to_a |
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 code seems unnecessary, right?
expressions = expressions.to_a |
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 was using the array as a "enum" so i can just remove items until it's empty.
it required less state tracking than the original enumerator.
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.
part of why i ended up here was because the original method was triggering several linters about method length and complexity, but i couldn't update the counter from a separate method, so in breaking it into smaller methods using a mutable array seemed simplest.
|
||
private | ||
def pop_octal_digits(current_child, expressions) | ||
2.times do |
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.
It looks better when named with 2
as a constant
lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb
Outdated
Show resolved
Hide resolved
te is the same as ts + length plus te is angering the spell checker
As I'm not familiar with the nuances of |
@koic Are we good to merge this PR? |
Yep! Let's take this change! |
Thanks! |
This improves the handling of escaped octals (as long as we allow regexp_parser < 2.7)
for the duplicate regexp character class element cop.
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 runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.