Class: Shirobai::Cop::Layout::LineContinuationSpacing

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

Overview

Drop-in Rust reimplementation of Layout/LineContinuationSpacing.

Stock only inspects files that contain a backslash, and its detection (find_offensive_spacing regex per line) and its ignored-range set (ignored_literal_ranges over processed_source.ast + comment_ranges over processed_source.comments) never touch the token stream. The one token access is last_line (processed_source.tokens.last.line), which materializes the parser-gem token stream on EVERY file — the "toucher" cost. Rust supplies last_line (stock's identical definition, shared with Layout/EndOfLine) from the shared parse, and the wrapper runs stock's own on_new_investigation body with that value injected, so detection, the offense range, and the autocorrect bytes are stock's code by construction.

last_line is line-based (identical whether computed from raw_source or the CR-stripped buffer.source) and the offense range comes from stock's own source_range, so no SourceOffsets conversion is needed.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.badgeObject



30
# File 'lib/shirobai/cop/layout/line_continuation_spacing.rb', line 30

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

.bundle_args(_config) ⇒ Object

Config-less on the Rust side (last_line needs no config; the wrapper reads EnforcedStyle from cop_config). Kept for the 4+1 convention.



34
35
36
# File 'lib/shirobai/cop/layout/line_continuation_spacing.rb', line 34

def self.bundle_args(_config)
  []
end

.cop_nameObject



29
# File 'lib/shirobai/cop/layout/line_continuation_spacing.rb', line 29

def self.cop_name = "Layout/LineContinuationSpacing"

Instance Method Details

#on_new_investigationObject

--- stock's on_new_investigation, with last_line from Rust ---



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/shirobai/cop/layout/line_continuation_spacing.rb', line 40

def on_new_investigation
  return unless processed_source.raw_source.include?("\\")

  last_line = resolved_last_line

  processed_source.raw_source.lines.each_with_index do |line, index|
    break if index >= last_line

    line_number = index + 1
    investigate(line, line_number)
  end
end