class

Krikri::Lint::Fixer

Inherits Reference < Object

Applies rule fixes to the files violations were reported on, then writes back the changed ones. Mirrors upstream's Transformer: matches whose rule is fixable and whose rule id/tags intersect the --fix write list get fixed; fixed matches are dropped from the report and do not affect the exit code.

Constants

BRACKETED_SUB_TAG = /\[[\w.]+\]/

The log renderer's tag pattern recognizes [\w.]+ groups as (unknown) markup tags; sub-tags with other characters (like yaml[trailing-spaces]) are printed verbatim without the stray closing-tag artifact.

Constructors

new(registry : Krikri::Lint::RuleRegistry, write_list : Array(String))
Source

Class methods

effective_write_set(write_list : Array(String)) : Set(String)

Mirrors upstream Transformer.effective_write_set: "none" resets, "all" enables everything.

Source
not_applied_id(v : Violation) : String

Upstream's match id for the transformer's not-applied log line: "{tag}/{match_type} {filename}:{lineno}". The tag's bracketed sub-tag is unknown markup to the log renderer, which prints the wrapper's closing [/] literally at the end of the line.

Source

Instance methods

apply(violations : Array(Violation)) : Array(String)

Applies rule fixes to violations' files and writes back the changed ones. Mirrors upstream's Transformer: matches whose rule is fixable and whose rule id/tags intersect the --fix write list get fixed. Returns the paths of files that changed, so the caller can re-run the checks instead of trusting the pre-fix report (upstream drops fixed matches; re-running is strictly more honest and also drops violations resolved incidentally by another rule's fix, e.g. an fqcn hit resolved by the shell-key rename).

Source
enabled?
Source
marked_fixed?(v : Violation) : Bool

Whether upstream's transform marks this violation fixed: such matches are dropped from the post-fix report even when krikri's own line edits differ from upstream's re-serialization.

Source
not_applied(violations : Array(Violation)) : Array(Violation)

The matches upstream's transformer would log "Rule specific fix not applied for:" for: ones whose rule is TransformMixin (transformable?), enabled under the --fix write set, and not marked fixed by the transform. Mirrors the transformer's per-file sorted(matches) order.

Source