Expand description
Fixes: a replacement a rule offers for what it reported.
A fix is a byte range and the text to put there. Template-based replacement of a capture is the whole model — not a general edit script, not a patch format. A rule that matched a node knows that node’s extent, and replacing it is the operation that covers almost every automatic fix worth having.
§Safe and suggested
A fix is either safe — applying it preserves what the code does — or a suggestion,
which is a good idea a human should look at. --fix applies only the safe ones.
The distinction is the rule author’s to make and it is not checkable, which is exactly why the default is the cautious one: a rule that forgets to say gets a suggestion, and a suggestion that should have been safe costs a manual edit. The other default would let a forgotten flag silently rewrite someone’s code.
§Overlaps
Two fixes that touch the same bytes cannot both be applied — the second would be editing
text the first replaced, and the result is whatever the ordering happened to be. Applying
one and skipping the other is the only sound choice; see apply.
Structs§
- Fix
- A replacement for a range of a file’s bytes.
- FixOutcome
- What applying a set of fixes to one file produced.
Functions§
- apply
- Apply fixes to a file’s source.