Class: Audition::Autofix

Inherits:
Data
  • Object
show all
Defined in:
lib/audition/finding.rb

Overview

A machine-applicable correction: replace source bytes start_offset...end_offset with replacement. Safety follows the RuboCop convention: :safe edits preserve semantics exactly; :unsafe edits trade a small semantic change for Ractor-readiness and only apply under --fix-unsafe.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(safety: :safe, **rest) ⇒ Autofix

Returns a new instance of Autofix.



33
34
35
# File 'lib/audition/finding.rb', line 33

def initialize(safety: :safe, **rest)
  super
end

Instance Attribute Details

#end_offsetInteger (readonly)

Returns byte offset where the edit ends (exclusive).

Returns:

  • (Integer)

    byte offset where the edit ends (exclusive)



30
31
32
33
34
35
36
37
38
39
# File 'lib/audition/finding.rb', line 30

Autofix = Data.define(
  :start_offset, :end_offset, :replacement, :safety
) do
  def initialize(safety: :safe, **rest)
    super
  end

  # @return [Boolean] whether this edit needs `--fix-unsafe`
  def unsafe? = safety == :unsafe
end

#replacementString (readonly)

Returns text spliced over the range.

Returns:

  • (String)

    text spliced over the range



30
31
32
33
34
35
36
37
38
39
# File 'lib/audition/finding.rb', line 30

Autofix = Data.define(
  :start_offset, :end_offset, :replacement, :safety
) do
  def initialize(safety: :safe, **rest)
    super
  end

  # @return [Boolean] whether this edit needs `--fix-unsafe`
  def unsafe? = safety == :unsafe
end

#safetySymbol (readonly)

Returns :safe or :unsafe.

Returns:

  • (Symbol)

    :safe or :unsafe



30
31
32
33
34
35
36
37
38
39
# File 'lib/audition/finding.rb', line 30

Autofix = Data.define(
  :start_offset, :end_offset, :replacement, :safety
) do
  def initialize(safety: :safe, **rest)
    super
  end

  # @return [Boolean] whether this edit needs `--fix-unsafe`
  def unsafe? = safety == :unsafe
end

#start_offsetInteger (readonly)

Returns byte offset where the edit begins.

Returns:

  • (Integer)

    byte offset where the edit begins



30
31
32
33
34
35
36
37
38
39
# File 'lib/audition/finding.rb', line 30

Autofix = Data.define(
  :start_offset, :end_offset, :replacement, :safety
) do
  def initialize(safety: :safe, **rest)
    super
  end

  # @return [Boolean] whether this edit needs `--fix-unsafe`
  def unsafe? = safety == :unsafe
end

Instance Method Details

#unsafe?Boolean

Returns whether this edit needs --fix-unsafe.

Returns:

  • (Boolean)

    whether this edit needs --fix-unsafe



38
# File 'lib/audition/finding.rb', line 38

def unsafe? = safety == :unsafe