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

Use Cop::Base API for Rake department #34

Merged
merged 1 commit into from
Dec 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changes

* [#33](https://github.com/rubocop-hq/rubocop-rake/pull/33): Drop support for Ruby 2.3. ([@koic][])
* [#34](https://github.com/rubocop-hq/rubocop-rake/pull/34): Require RuboCop 1.0 or higher. ([@koic][])

## 0.5.1 (2020-02-14)

Expand Down
8 changes: 2 additions & 6 deletions lib/rubocop/cop/rake/class_definition_in_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@ module Rake
# task :foo do
# end
#
class ClassDefinitionInTask < Cop
class ClassDefinitionInTask < Base
MSG = 'Do not define a %<type>s in rake task, because it will be defined to the top level.'

def on_class(node)
return if Helper::ClassDefinition.in_class_definition?(node)
return unless Helper::TaskDefinition.in_task_or_namespace?(node)

add_offense(node)
end

def message(node)
format(MSG, type: node.type)
add_offense(node, message: format(MSG, type: node.type))
end

alias on_module on_class
Expand Down
3 changes: 2 additions & 1 deletion lib/rubocop/cop/rake/desc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ module Rake
# task :do_something do
# end
#
class Desc < Cop
class Desc < Base
include Helper::OnTask
extend AutoCorrector

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

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rake/duplicate_namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Rake
# end
# end
#
class DuplicateNamespace < Cop
class DuplicateNamespace < Base
include Helper::OnNamespace

MSG = 'Namespace `%<namespace>s` is defined at both %<previous>s and %<current>s.'
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rake/duplicate_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Rake
# p 'foo 2'
# end
#
class DuplicateTask < Cop
class DuplicateTask < Base
include Helper::OnTask

MSG = 'Task `%<task>s` is defined at both %<previous>s and %<current>s.'
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rake/method_definition_in_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Rake
# task :foo do
# end
#
class MethodDefinitionInTask < Cop
class MethodDefinitionInTask < Base
MSG = 'Do not define a method in rake task, because it will be defined to the top level.'

def on_def(node)
Expand Down
2 changes: 1 addition & 1 deletion rubocop-rake.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rubocop', '~> 1.0'
end