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

Support csend on Style/SymbolProc #10810

Merged
merged 1 commit into from Jul 13, 2022

Conversation

r7kamura
Copy link
Contributor

@r7kamura r7kamura commented Jul 13, 2022

I think the following bad side code should also be treated as an offense:

# bad
array&.map { |element| element.upcase }

# good
array&.map(&:upcase)

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
    • There doesn't seem to be an existing issue on this
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@bbatsov bbatsov merged commit 0217a37 into rubocop:master Jul 13, 2022
@bbatsov
Copy link
Collaborator

bbatsov commented Jul 13, 2022

Nice catch! Thanks!

@r7kamura r7kamura deleted the feautre/style-symbol-proc-csend branch July 13, 2022 05:29
@@ -0,0 +1 @@
* [#10810](https://github.com/rubocop/rubocop/pull/10810): Support `csend` on `Style/SymbolProc`. ([@r7kamura][])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* [#10810](https://github.com/rubocop/rubocop/pull/10810): Support `csend` on `Style/SymbolProc`. ([@r7kamura][])
* [#10810](https://github.com/rubocop/rubocop/pull/10810): Support safe navigation operator on `Style/SymbolProc`. ([@r7kamura][])

@@ -81,7 +81,7 @@ class SymbolProc < Base
def_node_matcher :proc_node?, '(send (const {nil? cbase} :Proc) :new)'

# @!method symbol_proc_receiver?(node)
def_node_matcher :symbol_proc_receiver?, '{(send ...) (super ...) zsuper}'
def_node_matcher :symbol_proc_receiver?, '{({csend | send} ...) (super ...) zsuper}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def_node_matcher :symbol_proc_receiver?, '{({csend | send} ...) (super ...) zsuper}'
def_node_matcher :symbol_proc_receiver?, '{(call ...) (super ...) zsuper}'

@@ -12,6 +12,17 @@
RUBY
end

it 'registers an offense for csend' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it 'registers an offense for csend' do
it 'registers an offense for safe navigation operator' do

@koic
Copy link
Member

koic commented Jul 13, 2022

The comments were delayed, please never mind.

koic pushed a commit that referenced this pull request Jul 14, 2022
koic added a commit that referenced this pull request Jul 14, 2022
Improve `Style/SymbolProc` about #10810 changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants