Skip to content

Commit

Permalink
Improve performance by limiting on_send calls
Browse files Browse the repository at this point in the history
  • Loading branch information
bquorning committed Feb 2, 2021
1 parent 4c81f2d commit 98495dd
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Master (Unreleased)

* Fix `HooksBeforeExamples`, `LeadingSubject`, `LetBeforeExamples` and `ScatteredLet` autocorrection to take into account inline comments and comments immediately before the moved node. ([@Darhazer][])
* Improve rubocop-rspec performance. ([@Darhazer][])
* Improve rubocop-rspec performance. ([@Darhazer][], [@bquorning][])
* Include `Enabled: true` to prevent a mismatched configuration parameter warning when `RSpec` cops are explicitly enabled in the user configuration. ([@pirj][])

## 2.1.0 (2020-12-17)
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/rspec/expect_change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ExpectChange < Base

MSG_BLOCK = 'Prefer `change(%<obj>s, :%<attr>s)`.'
MSG_CALL = 'Prefer `change { %<obj>s.%<attr>s }`.'
RESTRICT_ON_SEND = %i[change].freeze

def_node_matcher :expect_change_with_arguments, <<-PATTERN
(send nil? :change ({const send} nil? $_) (sym $_))
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/rspec/factory_bot/create_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class CreateList < Base

MSG_CREATE_LIST = 'Prefer create_list.'
MSG_N_TIMES = 'Prefer %<number>s.times.'
RESTRICT_ON_SEND = %i[create_list].freeze

def_node_matcher :n_times_block_without_arg?, <<-PATTERN
(block
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/rspec/message_expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MessageExpectation < Base
MSG = 'Prefer `%<style>s` for setting message expectations.'

SUPPORTED_STYLES = %w[allow expect].freeze
RESTRICT_ON_SEND = %i[to].freeze

def_node_matcher :message_expectation, <<-PATTERN
(send $(send nil? {:expect :allow} ...) :to #receive_message?)
Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/cop/rspec/receive_counts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class ReceiveCounts < Base

MSG = 'Use `%<alternative>s` instead of `%<original>s`.'

RESTRICT_ON_SEND = %i[times].freeze

def_node_matcher :receive_counts, <<-PATTERN
(send $(send _ {:exactly :at_least :at_most} (int {1 2})) :times)
PATTERN
Expand Down

0 comments on commit 98495dd

Please sign in to comment.