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

Replace Cop with Base in tests to prepare for deprecating Cop #10127

Merged
merged 1 commit into from Sep 28, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions spec/rubocop/cli/options_spec.rb
Expand Up @@ -238,7 +238,7 @@
module RuboCop
module Cop
module Style
class SomeCop < Cop
class SomeCop < Base
end
end
end
Expand Down Expand Up @@ -330,7 +330,7 @@ class SomeCop < Cop
module RuboCop
module Cop
module Style
class SomeCop < Cop
class SomeCop < Base
end
end
end
Expand Down Expand Up @@ -378,7 +378,7 @@ class SomeCop < Cop
module RuboCop
module Cop
module Style
class SomeCop < Cop
class SomeCop < Base
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/config_loader_spec.rb
Expand Up @@ -736,7 +736,7 @@ def enabled?(cop)
module RuboCop
module Cop
module Custom
class Loop < Cop
class Loop < Base
end
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/rubocop/cop/internal_affairs/undefined_config_spec.rb
Expand Up @@ -192,6 +192,7 @@ def configured?
RUBY
end

# TODO: Remove this test when the `Cop` base class is removed
it 'works when the base class is `Cop` instead of `Base`' do
expect_offense(<<~RUBY)
module RuboCop
Expand Down
12 changes: 6 additions & 6 deletions spec/support/cops/class_must_be_a_module_cop.rb
Expand Up @@ -3,13 +3,13 @@
module RuboCop
module Cop
module Test
class ClassMustBeAModuleCop < RuboCop::Cop::Cop # rubocop:disable InternalAffairs/InheritDeprecatedCopClass
def on_class(node)
add_offense(node, message: 'Class must be a Module')
end
class ClassMustBeAModuleCop < RuboCop::Cop::Base
extend AutoCorrector

def autocorrect(node)
->(corrector) { corrector.replace(node.loc.keyword, 'module') }
def on_class(node)
add_offense(node, message: 'Class must be a Module') do |corrector|
corrector.replace(node.loc.keyword, 'module')
end
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/support/cops/module_must_be_a_class_cop.rb
Expand Up @@ -3,13 +3,13 @@
module RuboCop
module Cop
module Test
class ModuleMustBeAClassCop < RuboCop::Cop::Cop # rubocop:disable InternalAffairs/InheritDeprecatedCopClass
def on_module(node)
add_offense(node, message: 'Module must be a Class')
end
class ModuleMustBeAClassCop < RuboCop::Cop::Base
extend AutoCorrector

def autocorrect(node)
->(corrector) { corrector.replace(node.loc.keyword, 'class') }
def on_module(node)
add_offense(node, message: 'Module must be a Class') do |corrector|
corrector.replace(node.loc.keyword, 'class')
end
end
end
end
Expand Down