Class: Shirobai::Cop::Lint::Debugger

Inherits:
RuboCop::Cop::Base
  • Object
show all
Defined in:
lib/shirobai/cop/lint/debugger.rb

Overview

Drop-in Rust reimplementation of ‘Lint/Debugger`.

All detection (Prism parse, AST walk, offense location) happens in Rust. Ruby only flattens the configuration and turns the byte offsets Rust returns into offenses. Offenses come from the per-file bundled run (‘Shirobai::Dispatch`); the config derivation is purely config-driven, so this cop is always bundle-eligible.

Constant Summary collapse

MSG =
'Remove debugger entry point `%<source>s`.'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.badgeObject



17
# File 'lib/shirobai/cop/lint/debugger.rb', line 17

def self.badge = RuboCop::Cop::Badge.parse("Lint/Debugger")

.bundle_args(config) ⇒ Object

Packed args for the bundled run: ‘[debugger_methods, debugger_requires]`, the exact values `Shirobai.check_debugger` receives.



21
22
23
24
# File 'lib/shirobai/cop/lint/debugger.rb', line 21

def self.bundle_args(config)
  cop_config = config.for_badge(badge)
  [flatten_config(cop_config, "DebuggerMethods"), flatten_config(cop_config, "DebuggerRequires")]
end

.cop_nameObject



16
# File 'lib/shirobai/cop/lint/debugger.rb', line 16

def self.cop_name = "Lint/Debugger"

Instance Method Details

#on_new_investigationObject



33
34
35
36
37
38
39
40
# File 'lib/shirobai/cop/lint/debugger.rb', line 33

def on_new_investigation
  offenses = Dispatch.offenses_for(processed_source, config, :debugger)
  off = SourceOffsets.for(processed_source.raw_source)
  offenses.each do |start_offset, end_offset|
    range = Parser::Source::Range.new(processed_source.buffer, off[start_offset], off[end_offset])
    add_offense(range, message: format(MSG, source: range.source))
  end
end