Class: Shirobai::Cop::Layout::SpaceBeforeSemicolon
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Shirobai::Cop::Layout::SpaceBeforeSemicolon
- Extended by:
- RuboCop::Cop::AutoCorrector
- Includes:
- BundleEligible
- Defined in:
- lib/shirobai/cop/layout/space_before_semicolon.rb
Overview
Drop-in Rust reimplementation of Layout/SpaceBeforeSemicolon.
Same byte-side reconstruction as SpaceBeforeComma (they share
stock's SpaceBeforePunctuation). The block-{ skip is live here:
loop { ; 1 } keeps its space when Layout/SpaceInsideBlockBraces
is space (a lambda's tLAMBEG and BEGIN/END braces count as
left curlies; a "#{ ;…}" tSTRING_DBEG does not).
Each offense is the [start, end) whitespace run before the
semicolon; the corrector removes it.
Constant Summary collapse
- MSG =
"Space found before semicolon."
Class Method Summary collapse
- .badge ⇒ Object
-
.bundle_args(config) ⇒ Object
Packed args for the bundled run:
[Layout/SpaceInsideBlockBraces EnforcedStyle == 'space']. - .cop_name ⇒ Object
Instance Method Summary collapse
Class Method Details
.badge ⇒ Object
23 |
# File 'lib/shirobai/cop/layout/space_before_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 == 'space'].
27 28 29 30 |
# File 'lib/shirobai/cop/layout/space_before_semicolon.rb', line 27 def self.bundle_args(config) style = config.for_cop("Layout/SpaceInsideBlockBraces")["EnforcedStyle"] || "space" [[style == "space" ? 1 : 0], []] end |
.cop_name ⇒ Object
22 |
# File 'lib/shirobai/cop/layout/space_before_semicolon.rb', line 22 def self.cop_name = "Layout/SpaceBeforeSemicolon" |
Instance Method Details
#on_new_investigation ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/shirobai/cop/layout/space_before_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.remove(range) end end end |