Skip to content

Commit

Permalink
Rename cops to reflect new behaviours
Browse files Browse the repository at this point in the history
Now that these cops are for method / class defnitions in rake
namespaces, the cop names should be updated too.
  • Loading branch information
Thong Kuah committed Nov 10, 2023
1 parent 19cca32 commit e116f67
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Rake:
- 'Rakefile'
- '**/*.rake'

Rake/ClassDefinitionInTask:
Description: 'Do not define a class or module in rake task, because it will be defined to the top level.'
Rake/ClassDefinitionInNamespace:
Description: 'Do not define a class or module in a rake namespace, because it will be defined to the top level.'
Enabled: true
VersionAdded: '0.3.0'

Expand All @@ -24,7 +24,7 @@ Rake/DuplicateTask:
Enabled: true
VersionAdded: '0.4.0'

Rake/MethodDefinitionInTask:
Description: 'Do not define a method in rake task, because it will be defined to the top level.'
Rake/MethodDefinitionInNamespace:
Description: 'Do not define a method in a rake namespace, because it will be defined to the top level.'
Enabled: true
VersionAdded: '0.2.0'
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Rake
# task :foo do
# end
#
class ClassDefinitionInTask < Base
class ClassDefinitionInNamespace < Base
MSG = 'Do not define a %<type>s in a rake namespace, because it will be defined to the top level.'

def on_class(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Rake
# task :foo do
# end
#
class MethodDefinitionInTask < Base
class MethodDefinitionInNamespace < Base
MSG = 'Do not define a method in a rake namespace, because it will be defined to the top level.'

def on_def(node)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rake_cops.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative 'rake/class_definition_in_task'
require_relative 'rake/class_definition_in_namespace'
require_relative 'rake/desc'
require_relative 'rake/duplicate_task'
require_relative 'rake/duplicate_namespace'
require_relative 'rake/method_definition_in_task'
require_relative 'rake/method_definition_in_namespace'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::Rake::ClassDefinitionInTask, :config do
RSpec.describe RuboCop::Cop::Rake::ClassDefinitionInNamespace, :config do
it 'allows class definition in task' do
expect_no_offenses(<<~RUBY)
task :foo do
Expand Down Expand Up @@ -50,7 +50,7 @@ class C
RUBY
end

it 'allows class definition outside task' do
it 'allows class definition at the top level' do
expect_no_offenses(<<~RUBY)
class C
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::Rake::MethodDefinitionInTask, :config do
RSpec.describe RuboCop::Cop::Rake::MethodDefinitionInNamespace, :config do
it 'does not register an offense to `def` in a task' do
expect_no_offenses(<<~RUBY)
task :foo do
Expand Down

0 comments on commit e116f67

Please sign in to comment.