Class: Shirobai::Cop::Lint::UnreachableCode
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Shirobai::Cop::Lint::UnreachableCode
- Defined in:
- lib/shirobai/cop/lint/unreachable_code.rb
Overview
Drop-in Rust reimplementation of ‘Lint/UnreachableCode`.
Detection happens entirely in Rust (no autocorrect, mirroring stock). Ruby only turns byte offsets into offenses.
The cop carries no config so ‘bundle_args` returns an empty vector and the bundle path is always taken (the standalone entry point exists for the per-cop fallback to keep symmetry with the other config-less Lint cops, but is not exercised on the normal investigation path).
Constant Summary collapse
- MSG =
"Unreachable code detected."
Class Method Summary collapse
- .badge ⇒ Object
-
.bundle_args(_config) ⇒ Object
Config-less cop.
- .cop_name ⇒ Object
Instance Method Summary collapse
Class Method Details
.badge ⇒ Object
19 |
# File 'lib/shirobai/cop/lint/unreachable_code.rb', line 19 def self.badge = RuboCop::Cop::Badge.parse("Lint/UnreachableCode") |
.bundle_args(_config) ⇒ Object
Config-less cop. Returns an empty array so ‘Dispatch.packed_config` can splat it without touching `nums` or `lists`.
23 24 25 |
# File 'lib/shirobai/cop/lint/unreachable_code.rb', line 23 def self.bundle_args(_config) [] end |
.cop_name ⇒ Object
18 |
# File 'lib/shirobai/cop/lint/unreachable_code.rb', line 18 def self.cop_name = "Lint/UnreachableCode" |
Instance Method Details
#bundle_eligible? ⇒ Boolean
27 28 29 |
# File 'lib/shirobai/cop/lint/unreachable_code.rb', line 27 def bundle_eligible? true end |
#on_new_investigation ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/shirobai/cop/lint/unreachable_code.rb', line 31 def on_new_investigation buffer = processed_source.buffer off = SourceOffsets.for(processed_source.raw_source) fetch_offenses.each do |start_offset, end_offset| range = Parser::Source::Range.new(buffer, off[start_offset], off[end_offset]) add_offense(range) end end |