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/SingleArgumentDig confuses serverspec for a dig method #8423

Closed
tas50 opened this issue Jul 31, 2020 · 0 comments · Fixed by #8426
Closed

Style/SingleArgumentDig confuses serverspec for a dig method #8423

tas50 opened this issue Jul 31, 2020 · 0 comments · Fixed by #8426
Labels

Comments

@tas50
Copy link
Contributor

tas50 commented Jul 31, 2020

Expected behavior

Cop should not trigger for a spec checking to see if the "dig" command was run.

Actual behavior

Cop fails while scanning ServerSpecs testing for dig command.

Steps to reproduce the problem

Scan this:

describe host('test-cname.chef.kitchen') do
  it { should be_resolvable.by('dns') }
  cmd = "#{dig('test-cname.chef.kitchen')} | grep 'CNAME'"
  expected =
    "test-cname.chef.kitchen. 86400 IN CNAME client-ddns.chef.kitchen.\n"
  it "should have only one entry: #{ip_eth0}" do
    expect(command(cmd).stdout).to eq(expected)
  end
end

Throws this error:

undefined method `source' for nil:NilClass
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/style/single_argument_dig.rb:39:in `on_send'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:91:in `block (2 levels) in trigger_responding_cops'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:112:in `with_cop_error_handling'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:90:in `block in trigger_responding_cops'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:89:in `each'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:89:in `trigger_responding_cops'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:61:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `block in on_begin'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `on_begin'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `block in on_dstr'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `on_dstr'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:70:in `on_lvasgn'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `block in on_begin'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `on_begin'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:173:in `on_block'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `block in on_begin'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `each'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:59:in `on_begin'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:62:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.2.0/lib/rubocop/ast/traversal.rb:14:in `walk'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/commissioner.rb:74:in `investigate'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/team.rb:151:in `investigate_partial'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cop/team.rb:83:in `investigate'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:295:in `inspect_file'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:245:in `block in do_inspection_loop'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:277:in `block in iterate_until_no_changes'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:270:in `loop'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:270:in `iterate_until_no_changes'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:241:in `do_inspection_loop'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:121:in `block in file_offenses'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:146:in `file_offense_cache'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:120:in `file_offenses'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:111:in `process_file'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:90:in `block in each_inspected_file'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:89:in `each'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:89:in `reduce'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:89:in `each_inspected_file'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:78:in `inspect_files'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/runner.rb:39:in `run'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli/command.rb:10:in `run'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli/environment.rb:17:in `run'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli.rb:65:in `run_command'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli.rb:72:in `execute_runners'
/Users/tsmith/dev/oss/rubocop/lib/rubocop/cli.rb:41:in `run'
/Users/tsmith/dev/oss/rubocop/exe/rubocop:13:in `block in <top (required)>'
/usr/local/Cellar/ruby/2.7.1_2/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/Users/tsmith/dev/oss/rubocop/exe/rubocop:12:in `<top (required)>'
/usr/local/lib/ruby/gems/2.7.0/bin/rubocop:23:in `load'
/usr/local/lib/ruby/gems/2.7.0/bin/rubocop:23:in `<top (required)>'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/opt/ruby/bin/bundle:23:in `load'
/usr/local/opt/ruby/bin/bundle:23:in `<main>'

RuboCop version

master
@koic koic added the bug label Jul 31, 2020
koic added a commit to koic/rubocop that referenced this issue Jul 31, 2020
Fixes rubocop#8423.

This PR fixes an error for `Style/SingleArgumentDig`
when without a receiver.
This cop wouldn't have to offense when `dig` method without a receiver.
koic added a commit that referenced this issue Jul 31, 2020
…t_dig

[Fix #8423] Fix an error for `Style/SingleArgumentDig`
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.

2 participants