Class: Shirobai::Cop::Layout::SpaceAfterSemicolon

Inherits:
RuboCop::Cop::Base
  • Object
show all
Extended by:
RuboCop::Cop::AutoCorrector
Includes:
BundleEligible
Defined in:
lib/shirobai/cop/layout/space_after_semicolon.rb

Overview

Drop-in Rust reimplementation of Layout/SpaceAfterSemicolon.

Same byte-side reconstruction as SpaceAfterComma (they share stock's SpaceAfterPunctuation), with the semicolon-specific guards: a ;; sequence is skipped (semicolon_sequence?) and the tRCURLY allowance reads Layout/SpaceInsideBlockBraces instead of the hash-brace cop.

Each offense is the [start, end) range of the semicolon itself; the corrector replaces it with "; ".

Constant Summary collapse

MSG =
"Space missing after semicolon."

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.badgeObject



23
# File 'lib/shirobai/cop/layout/space_after_semicolon.rb', line 23

def self.badge = RuboCop::Cop::Badge.parse(cop_name)

.bundle_args(config) ⇒ Object

Packed args for the bundled run: [Layout/SpaceInsideBlockBraces EnforcedStyle == 'no_space'].



27
28
29
30
# File 'lib/shirobai/cop/layout/space_after_semicolon.rb', line 27

def self.bundle_args(config)
  style = config.for_cop("Layout/SpaceInsideBlockBraces")["EnforcedStyle"] || "space"
  [[style == "no_space" ? 1 : 0], []]
end

.cop_nameObject



22
# File 'lib/shirobai/cop/layout/space_after_semicolon.rb', line 22

def self.cop_name = "Layout/SpaceAfterSemicolon"

Instance Method Details

#on_new_investigationObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/shirobai/cop/layout/space_after_semicolon.rb', line 32

def on_new_investigation
  buffer = processed_source.buffer
  source = bundle_eligible? ? processed_source.raw_source : buffer.source
  off = SourceOffsets.for(source)
  resolved_offenses.each do |start, fin|
    range = Parser::Source::Range.new(buffer, off[start], off[fin])
    add_offense(range, message: MSG) do |corrector|
      corrector.replace(range, "#{range.source} ")
    end
  end
end