Class: Shirobai::Cop::Layout::ClosingParenthesisIndentation
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Shirobai::Cop::Layout::ClosingParenthesisIndentation
- Extended by:
- RuboCop::Cop::AutoCorrector
- Includes:
- RuboCop::Cop::Alignment
- Defined in:
- lib/shirobai/cop/layout/closing_parenthesis_indentation.rb
Overview
Drop-in Rust reimplementation of ‘Layout/ClosingParenthesisIndentation`.
Rust parses the source, walks every parenthesized method call, method definition and grouped expression, and returns each hanging ‘)` that is misindented as an offense range plus its `column_delta` and message. Ruby supplies the flattened config and applies the realignment via `AlignmentCorrector` over the same `)` range, exactly like stock (whose `autocorrect` passes `right_paren` itself). Offenses come from the per-file bundled run (`Shirobai::Dispatch`); the config is a single number, so this cop is always bundle-eligible.
Class Method Summary collapse
- .badge ⇒ Object
-
.bundle_args(config) ⇒ Object
Packed args for the bundled run: ‘[indentation_width]` (`configured_indentation_width` from the `Alignment` mixin).
- .cop_name ⇒ Object
Instance Method Summary collapse
Class Method Details
.badge ⇒ Object
21 |
# File 'lib/shirobai/cop/layout/closing_parenthesis_indentation.rb', line 21 def self.badge = RuboCop::Cop::Badge.parse("Layout/ClosingParenthesisIndentation") |
.bundle_args(config) ⇒ Object
Packed args for the bundled run: ‘[indentation_width]` (`configured_indentation_width` from the `Alignment` mixin).
25 26 27 28 |
# File 'lib/shirobai/cop/layout/closing_parenthesis_indentation.rb', line 25 def self.bundle_args(config) cop_config = config.for_badge(badge) [cop_config["IndentationWidth"] || config.for_cop("Layout/IndentationWidth")["Width"] || 2] end |
.cop_name ⇒ Object
20 |
# File 'lib/shirobai/cop/layout/closing_parenthesis_indentation.rb', line 20 def self.cop_name = "Layout/ClosingParenthesisIndentation" |
Instance Method Details
#on_new_investigation ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/shirobai/cop/layout/closing_parenthesis_indentation.rb', line 30 def on_new_investigation buffer = processed_source.buffer offenses = Dispatch.offenses_for(processed_source, config, :closing_parenthesis_indentation) off = SourceOffsets.for(processed_source.raw_source) offenses.each do |start, fin, column_delta, | range = Parser::Source::Range.new(buffer, off[start], off[fin]) # Stock yields the corrector block for every offense (no per-offense # gating); `AlignmentCorrector` itself decides whether the corrector # stays empty (tabs / block comments), which keeps the lint-mode # `correctable?` status identical to stock. add_offense(range, message: ) do |corrector| RuboCop::Cop::AlignmentCorrector.correct( corrector, processed_source, range, column_delta ) end end end |