Skip to content

Commit

Permalink
[Fix #7688] Support MethodCallWithArgsParentheses.new without config
Browse files Browse the repository at this point in the history
  • Loading branch information
buehmann authored and bbatsov committed Feb 10, 2020
1 parent 956b401 commit e672f90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -20,6 +20,7 @@
* [#7655](https://github.com/rubocop-hq/rubocop/issues/7655): Fix an error when processing a regexp with a line break at the start of capture parenthesis. ([@koic][])
* [#7647](https://github.com/rubocop-hq/rubocop/issues/7647): Fix an `undefined method on_numblock` error when using Ruby 2.7's numbered parameters. ([@hanachin][])
* [#7675](https://github.com/rubocop-hq/rubocop/issues/7675): Fix a false negative for `Layout/SpaceBeforeFirstArg` when a vertical argument positions are aligned. ([@koic][])
* [#7688](https://github.com/rubocop-hq/rubocop/issues/7688): Fix a bug in `Style/MethodCallWithArgsParentheses` that made `--auto-gen-config` crash. ([@buehmann][])

### Changes

Expand Down
4 changes: 4 additions & 0 deletions lib/rubocop/cop/mixin/configurable_enforced_style.rb
Expand Up @@ -60,6 +60,10 @@ def detected_style=(style)
alias conflicting_styles_detected no_acceptable_style!
alias unrecognized_style_detected no_acceptable_style!

def style_configured?
cop_config.key?(style_parameter_name)
end

def style
@style ||= begin
s = cop_config[style_parameter_name].to_sym
Expand Down
5 changes: 5 additions & 0 deletions lib/rubocop/cop/style/method_call_with_args_parentheses.rb
Expand Up @@ -150,6 +150,8 @@ class MethodCallWithArgsParentheses < Cop

def initialize(*)
super
return unless style_configured?

case style
when :require_parentheses
extend RequireParentheses
Expand All @@ -158,6 +160,9 @@ def initialize(*)
end
end

# @abstract Overridden in style modules
def autocorrect(_node); end

private

def args_begin(node)
Expand Down

0 comments on commit e672f90

Please sign in to comment.