diff --git a/changelog/fix_space_around_singleton_class_operator.md b/changelog/fix_space_around_singleton_class_operator.md new file mode 100644 index 00000000000..a07d33720e3 --- /dev/null +++ b/changelog/fix_space_around_singleton_class_operator.md @@ -0,0 +1 @@ +* [#8469](https://github.com/rubocop/rubocop/issues/8469): Add inspection of `class <<` to `Layout/SpaceAroundOperators`. ([@jonas054][]) diff --git a/lib/rubocop/cop/layout/space_around_operators.rb b/lib/rubocop/cop/layout/space_around_operators.rb index 3e72bb23bfa..e03d57b9116 100644 --- a/lib/rubocop/cop/layout/space_around_operators.rb +++ b/lib/rubocop/cop/layout/space_around_operators.rb @@ -63,6 +63,10 @@ def self.autocorrect_incompatible_with [Style::SelfAssignment] end + def on_sclass(node) + check_operator(:sclass, node.loc.operator, node.source_range) + end + def on_pair(node) return unless node.hash_rocket? diff --git a/spec/rubocop/cop/layout/space_around_operators_spec.rb b/spec/rubocop/cop/layout/space_around_operators_spec.rb index 8cbe15701fe..a2fa14295d1 100644 --- a/spec/rubocop/cop/layout/space_around_operators_spec.rb +++ b/spec/rubocop/cop/layout/space_around_operators_spec.rb @@ -278,9 +278,15 @@ def init(name=nil) RUBY end - it 'accepts the construct class <