Skip to content

Commit 934f1bc

Browse files
viralpraxispalkan
authored andcommitted
Improve AnyCable/PeriodicalTimers cop performance
Since we match any `periodically` method we can configure `RESTRICT_ON_SEND` to prevent unrelated `send` nodes from being dispatched.
1 parent 63bd98b commit 934f1bc

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

lib/anycable/rails/rubocop/cops/anycable/periodical_timers.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@ module AnyCable
1515
#
1616
class PeriodicalTimers < RuboCop::Cop::Base
1717
MSG = "Periodical Timers are not supported in AnyCable"
18+
RESTRICT_ON_SEND = %i[periodically].freeze
1819

19-
def_node_matcher :calls_periodically?, <<-PATTERN
20-
(send _ :periodically ...)
21-
PATTERN
22-
23-
def on_send(node)
24-
add_offense(node) if calls_periodically?(node)
25-
end
20+
alias_method :on_send, :add_offense
2621
end
2722
end
2823
end

0 commit comments

Comments
 (0)