Skip to content
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

Improve performance by limiting on_send calls #1123

Merged
merged 1 commit into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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