Class: RuboCop::Cop::Rake::Desc

Inherits:
RuboCop::Cop show all
Includes:
Helper::OnTask
Defined in:
lib/rubocop/cop/rake/desc.rb

Overview

Rake task definition should have a description with ‘desc` method. It is useful as a documentation of task. And Rake does not display task that does not have `desc` by `rake -T`.

Note: This cop does not require description for the default task,

because the default task is executed with `rake` without command.

Examples:

# bad
task :do_something

# bad
task :do_something do
end

# good
desc 'Do something'
task :do_something

# good
desc 'Do something'
task :do_something do
end

Constant Summary collapse

MSG =
'Describe the task with `desc` method.'

Instance Method Summary collapse

Methods included from Helper::OnTask

#on_send

Instance Method Details

#on_task(node) ⇒ Object



35
36
37
38
39
40
# File 'lib/rubocop/cop/rake/desc.rb', line 35

def on_task(node)
  return if task_with_desc?(node)
  return if Helper::TaskName.task_name(node) == :default

  add_offense(node)
end