diff --git a/CHANGELOG.md b/CHANGELOG.md index 46254b1fb36..4a0743aeea4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * [#8627](https://github.com/rubocop-hq/rubocop/issues/8627): Fix a false positive for `Lint/DuplicateRequire` when same feature argument but different require method. ([@koic][]) * [#8572](https://github.com/rubocop-hq/rubocop/issues/8572): Fix a false positive for `Style/RedundantParentheses` when parentheses are used like method argument parentheses. ([@koic][]) * [#8653](https://github.com/rubocop-hq/rubocop/pull/8653): Fix a false positive for `Layout/DefEndAlignment` when using refinements and `private def`. ([@koic][]) +* [#8655](https://github.com/rubocop-hq/rubocop/pull/8655): Fix a false positive for `Style/ClassAndModuleChildren` when using cbase class name. ([@koic][]) ### Changes diff --git a/lib/rubocop/cop/style/class_and_module_children.rb b/lib/rubocop/cop/style/class_and_module_children.rb index 9bc5d1ca638..294eb011ad1 100644 --- a/lib/rubocop/cop/style/class_and_module_children.rb +++ b/lib/rubocop/cop/style/class_and_module_children.rb @@ -32,6 +32,7 @@ class ClassAndModuleChildren < Base 'nested style.' def on_class(node) + return if node.identifier.children[0]&.cbase_type? return if node.parent_class && style != :nested check_style(node, node.body) diff --git a/spec/rubocop/cop/style/class_and_module_children_spec.rb b/spec/rubocop/cop/style/class_and_module_children_spec.rb index a78a9a438bf..a8a5527996d 100644 --- a/spec/rubocop/cop/style/class_and_module_children_spec.rb +++ b/spec/rubocop/cop/style/class_and_module_children_spec.rb @@ -60,6 +60,13 @@ module BarModule RUBY end + it 'accepts cbase class name' do + expect_no_offenses(<<~RUBY) + class ::Foo + end + RUBY + end + it 'accepts :: in parent class on inheritance' do expect_no_offenses(<<~RUBY) class FooClass