-
Notifications
You must be signed in to change notification settings - Fork 447
Fix call-seq deduplicate for name overlap in aliases #1491
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
Conversation
lib/rdoc/code_object/any_method.rb
Outdated
| if ignore.any? | ||
| ignore_union = Regexp.union(ignore) | ||
| entries.reject! do |entry| | ||
| entry =~ /^(\w*\.)?#{ignore_union}([\(\s]|$)/ or |
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.
Main change
/^\w*\.?#{ignore_union}[$\(\s]/
↓
/^(\w*\.)?#{ignore_union}([\(\s]|$)/
^\w*\.?value?[$\(\s] matches to has_value?, but we only want to ignore value? and receiver.value?
Fix is: \w*\.? → (\w*\.)?
The latter part [$\(\s], $ seems like a mistake of $ (end-of-line), not "$" (dollar character)
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.
Unfortunately, with this change, receiver[arg] won't be handled here.
So I added bracket_method remove logic in line 375-379.
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 $\(\s] pattern was added by #897 .
The latter part
[$\(\s],$seems like a mistake of$(end-of-line), not"$"(dollar character)
I think that the assumption is correct.
|
🚀 Preview deployment available at: https://d1d6844d.rdoc-6cd.pages.dev (commit: 35d3352) |
kou
left a comment
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.
+1
It may be better that we extract method names from "call_seq" and compare method names instead of creating (complex) regular expressions to match raw "call_seq"...
lib/rdoc/code_object/any_method.rb
Outdated
| ignore_union = Regexp.union(ignore) | ||
| entries.reject! do |entry| | ||
| entry =~ /^(\w*\.)?#{ignore_union}([\(\s]|$)/ or | ||
| entry =~ /\s#{ignore_union}\s/ |
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.
| entry =~ /\s#{ignore_union}\s/ | |
| /^(\w*\.)?#{ignore_union}([\(\s]|$)/.match?(entry) or | |
| \s#{ignore_union}\s/.match?(entry) |
BTW:
- Can we use
\A/\znot^/$here? - Can we remove needless
\escape from[\(]? - How about using
(?:...)not(...)not referred groups?
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.
done!
lib/rdoc/code_object/any_method.rb
Outdated
| if ignore.any? | ||
| ignore_union = Regexp.union(ignore) | ||
| entries.reject! do |entry| | ||
| entry =~ /^(\w*\.)?#{ignore_union}([\(\s]|$)/ or |
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 $\(\s] pattern was added by #897 .
The latter part
[$\(\s],$seems like a mistake of$(end-of-line), not"$"(dollar character)
I think that the assumption is correct.
36d5137 to
14e858e
Compare
14e858e to
30e4865
Compare
I agree. I think call-seq's name part and params part extraction needs refactor.
def name
return @name if @name
@name =
@call_seq[/^.*?\.(\w+)/, 1] ||
@call_seq[/^.*?(\w+)/, 1] ||
@call_seq if @call_seq
endMaybe we can have a call-seq common format parser and use it in |
Fix call-seq deduplicate of `Hash#value?` and `Hash#has_value?`. When alias names have overlap, deduplicate didn't work correctly.
30e4865 to
35d3352
Compare
Backend fix of #1335
Fix call-seq deduplicate of
Hash#value?andHash#has_value?.When alias names have overlap, deduplicate didn't work correctly.