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

undefined method `map' for nil:NilClass #2218

Closed
ghost opened this issue Sep 6, 2015 · 5 comments · Fixed by #2219
Closed

undefined method `map' for nil:NilClass #2218

ghost opened this issue Sep 6, 2015 · 5 comments · Fixed by #2219

Comments

@ghost
Copy link

ghost commented Sep 6, 2015

Hello. In running rubocop today, I received an error message where my code had previously passed a few days before (presumably with the .33 version). I admit I am relatively new to the Ruby eco-system and do not have enough knowledge to be able to troubleshoot so I figured I would submit an issue.

Thank you ever so much and thanks for a wonderful product!

$ bundle exec rake style
Running RuboCop...
undefined method `map' for nil:NilClass
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/psych.rb:287:in `safe_load'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/config_loader.rb:151:in `yaml_safe_load'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/config_loader.rb:138:in `load_yaml_configuration'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/config_loader.rb:27:in `load_file'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/config_loader.rb:85:in `configuration_from_file'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/config_store.rb:40:in `for'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/target_finder.rb:112:in `excluded_dirs'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/target_finder.rb:90:in `find_files'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/target_finder.rb:60:in `target_files_in_dir'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/target_finder.rb:31:in `find'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/runner.rb:45:in `find_target_files'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/runner.rb:29:in `run'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/cli.rb:26:in `run'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/rake_task.rb:50:in `run_cli'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/rake_task.rb:38:in `run_main_task'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/rake_task.rb:30:in `block (2 levels) in initialize'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/file_utils_ext.rb:58:in `verbose'
/home/travis/.rvm/gems/ruby-2.2.2/gems/rubocop-0.34.0/lib/rubocop/rake_task.rb:26:in `block in initialize'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:199:in `each'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/travis/.rvm/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/home/travis/.rvm/gems/ruby-2.2.2/bin/rake:23:in `load'
/home/travis/.rvm/gems/ruby-2.2.2/bin/rake:23:in `<main>'
/home/travis/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
/home/travis/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'
RuboCop failed!
@ghost
Copy link
Author

ghost commented Sep 6, 2015

I have determined that rolling back to version 0.33.0 in my Gemfile via gem 'rubocop', '~> 0.33.0', require: false does not throw the error.

@brint
Copy link

brint commented Sep 6, 2015

We've seen this as well with tests since 0.34.0 was released. We have pinned back to 0.33.0 for now. In our Rakefile, we have a line like this to run our Ruby style checks which generates the same error that @st-isidore-de-seville is seeing:

RuboCop::RakeTask.new(:ruby)

Example Rakefile (from a Chef cookbook):

require 'bundler/setup'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'foodcritic'
require 'kitchen'

# Style tests. Rubocop and Foodcritic
namespace :style do
  desc 'Run Chef style checks'
  FoodCritic::Rake::LintTask.new(:chef) do |t|
    t.options = {
      search_gems: true,
      fail_tags: %w(any),
      # FC015: Consider converting definition to a LWRP (allow definitions without complaining)
      tags: %w(~FC015 ~FC041),
      chef_version: '12.3.0' # 12.2 was not valid - https://github.com/acrmp/foodcritic/issues/221
    }
  end

  desc 'Run Ruby style checks'
  RuboCop::RakeTask.new(:ruby)
end

desc 'Run all style checks'
task style: ['style:chef', 'style:ruby']

# Integration tests. Kitchen.ci
task :integration do
  desc 'Run Test Kitchen'
  Kitchen.logger = Kitchen.default_file_logger
  @loader = Kitchen::Loader::YAML.new(
    local_config: ENV['KITCHEN_LOCAL_YAML']
  )
  if ENV['KITCHEN_CONCURRENCY_DISABLE']
    Kitchen::Config.new(loader: @loader).instances.each do |instance|
      instance.test(:always)
    end
  else
    config = Kitchen::Config.new(loader: @loader)
    concurrency = config.instances.size
    queue = Queue.new
    config.instances.each { |i| queue << i }
    concurrency.times { queue << nil }
    threads = []
    concurrency.times do
      threads << Thread.new do
        while instance = queue.pop
          instance.send('test')
        end
      end
    end
    threads.map(&:join)
  end
end

# Default
task default: ['style', 'integration']

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 7, 2015

The fix is merged. Play with it and if everything looks good I'll cut a bugfix release tomorrow.

@ghost
Copy link
Author

ghost commented Sep 7, 2015

Thanks @bbatsov and @maxjacobson!

@martinb3
Copy link

martinb3 commented Sep 8, 2015

👍 I'd love to see this released as well. It's breaking CI on many of our Chef cookbooks.

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 a pull request may close this issue.

3 participants