Class: Shirobai::Cop::Layout::EmptyLinesAroundArguments
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Shirobai::Cop::Layout::EmptyLinesAroundArguments
- Extended by:
- RuboCop::Cop::AutoCorrector
- Includes:
- RuboCop::Cop::RangeHelp
- Defined in:
- lib/shirobai/cop/layout/empty_lines_around_arguments.rb
Overview
Drop-in Rust reimplementation of ‘Layout/EmptyLinesAroundArguments`.
Rust walks the AST, reproduces the stock cop’s ‘on_send` / `on_csend` over every multi-line call (with at least one argument whose receiver and selector share a line), scans each argument’s ‘source_range.begin` and the closing `)`/`]` for a preceding run of whitespace spanning a full empty line, and returns, per offense, the offense line range. Ruby reports the range and removes it, exactly like stock’s ‘corrector.remove(range)`.
The cop has no configuration, so it is always bundle eligible; the offenses come from the per-file bundled run (‘Shirobai::Dispatch`). The autocorrect re-passes re-investigate a fresh `ProcessedSource`, which recomputes the bundle from scratch, so this cop keeps no cross-pass state.
Constant Summary collapse
- MSG =
"Empty line detected around arguments."
Class Method Summary collapse
- .badge ⇒ Object
-
.bundle_args(_config) ⇒ Object
No packed configuration: the cop contributes nothing to the bundle’s ‘(nums, lists)` wire format.
- .cop_name ⇒ Object
Instance Method Summary collapse
Class Method Details
.badge ⇒ Object
27 |
# File 'lib/shirobai/cop/layout/empty_lines_around_arguments.rb', line 27 def self.badge = RuboCop::Cop::Badge.parse(cop_name) |
.bundle_args(_config) ⇒ Object
No packed configuration: the cop contributes nothing to the bundle’s ‘(nums, lists)` wire format. Kept for symmetry with the other wrappers.
31 32 33 |
# File 'lib/shirobai/cop/layout/empty_lines_around_arguments.rb', line 31 def self.bundle_args(_config) [] end |
.cop_name ⇒ Object
26 |
# File 'lib/shirobai/cop/layout/empty_lines_around_arguments.rb', line 26 def self.cop_name = "Layout/EmptyLinesAroundArguments" |
Instance Method Details
#on_new_investigation ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/shirobai/cop/layout/empty_lines_around_arguments.rb', line 35 def on_new_investigation buffer = processed_source.buffer off = SourceOffsets.for(processed_source.raw_source) offenses_for_source.each do |start, fin| range = Parser::Source::Range.new(buffer, off[start], off[fin]) add_offense(range) do |corrector| corrector.remove(range) end end end |