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
Small Lint
cops perf tweaks
#8358
Conversation
debugger byebug remote_byebug pry remote_pry pry_remote console rescue | ||
save_and_open_page save_and_open_screenshot save_screenshot irb | ||
].to_set.freeze | ||
|
||
def_node_matcher :kernel?, <<~PATTERN |
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 want to make a release of rubocop-ast
soon so we can use #global_const?
:-)
Should we also add #kernel_call?
== {#global_const?(:Kernel) nil?}
or similar to rubocop-ast
?
Nicely done! 🙇♂️ |
@@ -30,10 +30,11 @@ class AmbiguousBlockAssociation < Cop | |||
'call.' | |||
|
|||
def on_send(node) | |||
return if !node.arguments? || node.parenthesized? || | |||
node.last_argument.lambda? || allowed_method?(node) | |||
return unless node.arguments? |
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 surprised to see that this line was still taking non-negligible time, so I investigated a bit and this led to a bunch of fixes and a bunch of optimizations in rubocop-ast
🎉
@@ -1,5 +1,7 @@ | |||
# frozen_string_literal: true | |||
|
|||
require 'set' |
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.
No need to require 'set'
here, it's required by parser
and (just to be explicit) by rubocop-ast
too.
@@ -1,5 +1,7 @@ | |||
# frozen_string_literal: true | |||
|
|||
require 'set' |
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.
No need
def on_send(node) | ||
return unless METHOD_DEF_METHODS.include?(node.method_name) | ||
|
||
if (name = alias_method?(node)) | ||
return unless name |
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 line is redundant. Apparently we don't have a cop for this 😅
@@ -21,11 +21,10 @@ class InterpolationCheck < Cop | |||
'Use double quoted strings if you need interpolation.' | |||
|
|||
def on_str(node) | |||
return if heredoc?(node) | |||
|
|||
parent = node.parent | |||
return if parent && (parent.dstr_type? || parent.regexp_type?) | |||
return unless /(?<!\\)#\{.*\}/.match?(node.source.scrub) |
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.
AFAIK, parser
only handles valid utf-8 sequences, so scrub
should not be needed at all here, or am I missing something?
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.
Good work 💪
A few minor comments for you
Oh, merged already 😅 |
|
Ran on larger
discourse
codebase (3.5k files).Before
After