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

Style/MethodCallWithArgsParentheses blows up when using --auto-gen-config #7688

Closed
sambostock opened this issue Feb 5, 2020 · 1 comment · Fixed by #7698
Closed

Style/MethodCallWithArgsParentheses blows up when using --auto-gen-config #7688

sambostock opened this issue Feb 5, 2020 · 1 comment · Fixed by #7698
Labels

Comments

@sambostock
Copy link
Contributor

sambostock commented Feb 5, 2020

Style/MethodCallWithArgsParentheses blows up when trying to use --auto-gen-config on a project which violates it.


Expected behavior

--auto-gen-config should generate the config without blowing up

Actual behavior

It blows up with undefined method 'to_sym' for nil:NilClass when trying to generate the config:

$ bundle exec rubocop --auto-gen-config
Phase 1 of 2: run Layout/LineLength cop
Inspecting 2 files
..

2 files inspected, no offenses detected
Created .rubocop_todo.yml.
Phase 2 of 2: run all cops
Inspecting 2 files
CC

2 files inspected, 8 offenses detected
undefined method `to_sym' for nil:NilClass
~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cop/mixin/configurable_enforced_style.rb:65:in `style'
~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cop/style/method_call_with_args_parentheses.rb:153:in `initialize'
~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/formatter/disabled_config_formatter.rb:124:in `new'
~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/formatter/disabled_config_formatter.rb:124:in `output_cop_comments'
...
Rest of stack trace~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/formatter/disabled_config_formatter.rb:99:in `output_cop' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/formatter/disabled_config_formatter.rb:86:in `block in output_offenses' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/formatter/disabled_config_formatter.rb:85:in `each' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/formatter/disabled_config_formatter.rb:85:in `output_offenses' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/formatter/disabled_config_formatter.rb:52:in `finished' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/formatter/formatter_set.rb:33:in `block (3 levels) in <class:FormatterSet>' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/formatter/formatter_set.rb:33:in `each' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/formatter/formatter_set.rb:33:in `block (2 levels) in <class:FormatterSet>' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/runner.rb:81:in `inspect_files' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/runner.rb:39:in `run' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli/command.rb:10:in `run' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli/environment.rb:17:in `run' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli/command/auto_genenerate_config.rb:100:in `execute_runner' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli/command/auto_genenerate_config.rb:78:in `run_all_cops' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli/command/auto_genenerate_config.rb:22:in `run' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli/command.rb:10:in `run' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli/environment.rb:17:in `run' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli.rb:65:in `run_command' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli.rb:70:in `execute_runners' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/lib/rubocop/cli.rb:41:in `run' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/exe/rubocop:13:in `block in <top (required)>' /opt/rubies/2.6.3/lib/ruby/2.6.0/benchmark.rb:308:in `realtime' ~/.gem/ruby/2.6.3/gems/rubocop-0.79.0/exe/rubocop:12:in `<top (required)>' ~/.gem/ruby/2.6.3/bin/rubocop:23:in `load' ~/.gem/ruby/2.6.3/bin/rubocop:23:in `<top (required)>' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `load' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `kernel_load' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:28:in `run' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/cli.rb:463:in `exec' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/cli.rb:27:in `dispatch' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/cli.rb:18:in `start' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/exe/bundle:30:in `block in <top (required)>' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors' ~/.gem/ruby/2.6.3/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>' ~/.gem/ruby/2.6.3/bin/bundle:23:in `load' ~/.gem/ruby/2.6.3/bin/bundle:23:in `<main>'

Steps to reproduce the problem

  1. Create a new directory

  2. Create the following Gemfile

# Gemfile.rb
source 'https://rubygems.org'
gem 'rubocop'

The calls to source and gem violate the Style/MethodCallWithArgsParentheses rule.

  1. Create the following Rubocop config
# .rubocop.yml
Style/MethodCallWithArgsParentheses:
  Enabled: true
  1. bundle install

  2. bundle exec rubocop --auto-gen-config 💥

RuboCop version

$ bundle exec rubocop -V
0.79.0 (using Parser 2.7.0.2, running on ruby 2.6.3 x86_64-darwin19)
@koic koic added the bug label Feb 6, 2020
@buehmann
Copy link
Contributor

buehmann commented Feb 6, 2020

This sounds like it could be related to some changes I did recently on this cop. I can take a look tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants