Skip to content

Commit

Permalink
Remove respond_to from default value of AllowedMethods for `Style…
Browse files Browse the repository at this point in the history
…/SymbolProc`

The commit below adds `respond_to` to the config, which looks like a Rails method.
rubocop@54ff86e

Ruby has method called `respond_to?`, not `respond_to`.
So `respond_to` is a Rails API and `respond_to?` doesn't take a block argument.

RuboCop core does not depend on Rails, so move the `respond_to` config from
RuboCop core to RuboCop Rails.

I noticed this by rubocop/rubocop-rails#779.

This removed setting was added in RuboCop Rails 2.17. Rails application developers
can get this change in the upgrade.
rubocop/rubocop-rails#806
  • Loading branch information
koic committed Dec 5, 2022
1 parent 6057535 commit 5bcdc93
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#11236](https://github.com/rubocop/rubocop/pull/11236): Remove `respond_to` from default value of `AllowedMethods` for `Style/SymbolProc`. ([@koic][])
3 changes: 1 addition & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5150,12 +5150,11 @@ Style/SymbolProc:
Enabled: true
Safe: false
VersionAdded: '0.26'
VersionChanged: '1.28'
VersionChanged: '<<next>>'
AllowMethodsWithArguments: false
# A list of method names to be always allowed by the check.
# The names should be fairly unique, otherwise you'll end up ignoring lots of code.
AllowedMethods:
- respond_to
- define_method
AllowedPatterns: []
IgnoredMethods: [] # deprecated
Expand Down
6 changes: 2 additions & 4 deletions lib/rubocop/cop/style/symbol_proc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Style
#
# If you prefer a style that allows block for method with arguments,
# please set `true` to `AllowMethodsWithArguments`.
# respond_to , and `define_method?` methods are allowed by default.
# `define_method?` methods are allowed by default.
# These are customizable with `AllowedMethods` option.
#
# @safety
Expand Down Expand Up @@ -72,12 +72,10 @@ module Style
# # some comment
# end
#
# @example AllowedMethods: [respond_to, define_method] (default)
# @example AllowedMethods: [define_method] (default)
# # good
# respond_to { |foo| foo.bar }
# define_method(:foo) { |foo| foo.bar }
#
#
# @example AllowedPatterns: [] (default)
# # bad
# something.map { |s| s.upcase }
Expand Down

0 comments on commit 5bcdc93

Please sign in to comment.