Class: Audition::Autofix
- Inherits:
-
Data
- Object
- Data
- Audition::Autofix
- 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
-
#end_offset ⇒ Integer
readonly
Byte offset where the edit ends (exclusive).
-
#replacement ⇒ String
readonly
Text spliced over the range.
-
#safety ⇒ Symbol
readonly
:safeor:unsafe. -
#start_offset ⇒ Integer
readonly
Byte offset where the edit begins.
Instance Method Summary collapse
-
#initialize(safety: :safe, **rest) ⇒ Autofix
constructor
A new instance of Autofix.
-
#unsafe? ⇒ Boolean
Whether this edit needs
--fix-unsafe.
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_offset ⇒ Integer (readonly)
Returns 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 |
#replacement ⇒ String (readonly)
Returns 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 |
#safety ⇒ Symbol (readonly)
Returns :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_offset ⇒ Integer (readonly)
Returns 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.
38 |
# File 'lib/audition/finding.rb', line 38 def unsafe? = safety == :unsafe |