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

Rake/Desc failure #28

Closed
tas50 opened this issue Dec 31, 2019 · 1 comment · Fixed by #32
Closed

Rake/Desc failure #28

tas50 opened this issue Dec 31, 2019 · 1 comment · Fixed by #32
Assignees

Comments

@tas50
Copy link

tas50 commented Dec 31, 2019

Hi there. Thanks for putting together this project. I wanted to let you know about an issue with the Rake/Desc cop.

An error occurred while Rake/Desc cop was inspecting /Users/tsmith/dev/work/chef-dk/Rakefile:36:47.
undefined method `send_type?' for :name:Symbol
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-rake-0.5.0/lib/rubocop/cop/rake/desc.rb:50:in `task_with_desc?'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-rake-0.5.0/lib/rubocop/cop/rake/desc.rb:36:in `on_task'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-rake-0.5.0/lib/rubocop/cop/rake/helper/on_task.rb:17:in `on_send'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:57:in `block (2 levels) in trigger_responding_cops'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:128:in `with_cop_error_handling'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:56:in `block in trigger_responding_cops'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:55:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:55:in `trigger_responding_cops'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:32:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:107:in `block in on_send'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `each_with_index'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `on_send'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `block in on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `block in on_dstr'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `on_dstr'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:107:in `block in on_send'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `each_with_index'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `on_send'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:141:in `on_if'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:169:in `block in on_case'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:168:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:168:in `on_case'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:169:in `block in on_case'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:168:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:168:in `on_case'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `block in on_kwbegin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `on_kwbegin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `block in on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:164:in `on_block'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `block in on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:13:in `walk'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:44:in `investigate'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/team.rb:119:in `investigate'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/team.rb:107:in `offenses'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/team.rb:44:in `inspect_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:283:in `inspect_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:231:in `block in do_inspection_loop'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:263:in `block in iterate_until_no_changes'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:256:in `loop'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:256:in `iterate_until_no_changes'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:227:in `do_inspection_loop'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:124:in `block in file_offenses'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:142:in `file_offense_cache'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:122:in `file_offenses'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:110:in `process_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:87:in `block in each_inspected_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:86:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:86:in `reduce'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:86:in `each_inspected_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:73:in `inspect_files'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:39:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cli.rb:210:in `execute_runner'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cli.rb:80:in `execute_runners'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cli.rb:51:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/exe/rubocop:13:in `block in <top (required)>'
/usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/exe/rubocop:12:in `<top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/chefstyle-0.14.0/bin/chefstyle:13:in `load'
/usr/local/lib/ruby/gems/2.6.0/gems/chefstyle-0.14.0/bin/chefstyle:13:in `<top (required)>'
/usr/local/lib/ruby/gems/2.6.0/bin/chefstyle:23:in `load'
/usr/local/lib/ruby/gems/2.6.0/bin/chefstyle:23:in `<main>'```

Here's the content of the Rakefile:

```ruby
#
# Copyright:: Copyright (c) 2016-2018 Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

begin
  require_relative "tasks/dependencies"
  require_relative "tasks/announce"
rescue LoadError
  puts "Additional rake tasks not found. If you require these rake tasks run Rake from the git repo not the installation files!"
end

namespace :style do
  begin
    require "rubocop/rake_task"

    desc "Run Cookbook Ruby style checks"
    RuboCop::RakeTask.new(:cookstyle) do |t|
      t.requires = ["cookstyle"]
      t.patterns = ["lib/chef-dk/skeletons/code_generator"]
      t.options = ["--display-cop-names"]
    end
  rescue LoadError => e
    puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"]
  end

  begin
    require "rubocop/rake_task"

    ignore_dirs = Regexp.union(%w{
      lib/chef-dk/skeletons/code_generator
      spec/unit/fixtures/chef-runner-cookbooks
      spec/unit/fixtures/cookbook_cache
      spec/unit/fixtures/example_cookbook
      spec/unit/fixtures/example_cookbook_metadata_json_only
      spec/unit/fixtures/example_cookbook_no_metadata
      spec/unit/fixtures/local_path_cookbooks
    })

    desc "Run Cookstyle style checks"
    RuboCop::RakeTask.new(:chefstyle) do |t|
      t.requires = ["chefstyle"]
      t.patterns = `rubocop --list-target-files`.split("\n").reject { |f| f =~ ignore_dirs }
      t.options = ["--display-cop-names"]
    end
  rescue LoadError => e
    puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"]
  end
end
@pocke pocke self-assigned this Feb 8, 2020
pocke added a commit to pocke/rubocop-rake that referenced this issue Feb 8, 2020
pocke added a commit to pocke/rubocop-rake that referenced this issue Feb 8, 2020
@pocke pocke closed this as completed in #32 Feb 14, 2020
pocke added a commit that referenced this issue Feb 14, 2020
[Fix #28] Fix `Rake/Desc` to avoid an error when `task` is not a task definition
@pocke
Copy link
Collaborator

pocke commented Feb 14, 2020

I fixed this problem in #32, and released v0.5.1. Thanks for your report, and sorry too late replay.

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.

2 participants