Class: Shirobai::Cop::Style::ColonMethodCall
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Shirobai::Cop::Style::ColonMethodCall
- Extended by:
- RuboCop::Cop::AutoCorrector
- Defined in:
- lib/shirobai/cop/style/colon_method_call.rb
Overview
Drop-in Rust reimplementation of ‘Style/ColonMethodCall`.
Detection and autocorrect both happen in Rust; Ruby turns the byte offsets of the ‘::` token into an offense range plus a `corrector.replace(range, ’.‘)` call (matching stock’s ‘add_offense(node.loc.dot) { |c| c.replace(node.loc.dot, ’.‘) }`).
The cop carries no config (stock has neither ‘EnforcedStyle` nor an allowed-methods list), so `bundle_args` returns an empty vector and the bundle path is always taken.
Constant Summary collapse
- MSG =
"Do not use `::` for method calls."
Class Method Summary collapse
-
.autocorrect_incompatible_with ⇒ Object
Stock declares ‘autocorrect_incompatible_with [RedundantSelf]`.
- .badge ⇒ Object
-
.bundle_args(_config) ⇒ Object
Config-less cop.
- .cop_name ⇒ Object
Instance Method Summary collapse
Class Method Details
.autocorrect_incompatible_with ⇒ Object
Stock declares ‘autocorrect_incompatible_with [RedundantSelf]`. We mirror that so the corrector dispatcher serialises us against `Style/RedundantSelf` in the same pass, matching stock’s behaviour when both cops fire in one autocorrect cycle.
24 25 26 |
# File 'lib/shirobai/cop/style/colon_method_call.rb', line 24 def self.autocorrect_incompatible_with [Shirobai::Cop::Style::RedundantSelf] end |
.badge ⇒ Object
29 |
# File 'lib/shirobai/cop/style/colon_method_call.rb', line 29 def self.badge = RuboCop::Cop::Badge.parse("Style/ColonMethodCall") |
.bundle_args(_config) ⇒ Object
Config-less cop. Returns an empty array so ‘Dispatch.packed_config` can splat it without touching `nums` or `lists`.
33 34 35 |
# File 'lib/shirobai/cop/style/colon_method_call.rb', line 33 def self.bundle_args(_config) [] end |
.cop_name ⇒ Object
28 |
# File 'lib/shirobai/cop/style/colon_method_call.rb', line 28 def self.cop_name = "Style/ColonMethodCall" |
Instance Method Details
#bundle_eligible? ⇒ Boolean
37 38 39 |
# File 'lib/shirobai/cop/style/colon_method_call.rb', line 37 def bundle_eligible? true end |
#on_new_investigation ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/shirobai/cop/style/colon_method_call.rb', line 41 def on_new_investigation buffer = processed_source.buffer off = SourceOffsets.for(processed_source.raw_source) fetch_offenses.each do |dot_start, dot_end| range = Parser::Source::Range.new(buffer, off[dot_start], off[dot_end]) add_offense(range) do |corrector| corrector.replace(range, ".") end end end |