Class: RuboCop::Cop::Sorbet::SingleLineRbiClassModuleDefinitions

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/sorbet/rbi/single_line_rbi_class_module_definitions.rb

Overview

Ensures empty class/module definitions in RBI files are done on a single line rather than being split across multiple lines.

Examples:


# bad
module SomeModule
end

# good
module SomeModule; end

Constant Summary collapse

MSG =
"Empty class/module definitions in RBI files should be on a single line."

Instance Method Summary collapse

Instance Method Details

#on_module(node) ⇒ Object Also known as: on_class



22
23
24
25
26
27
28
29
# File 'lib/rubocop/cop/sorbet/rbi/single_line_rbi_class_module_definitions.rb', line 22

def on_module(node)
  return if node.body
  return if node.single_line?

  add_offense(node) do |corrector|
    corrector.replace(node, convert_newlines_to_semicolons(node.source))
  end
end