Repository navigation
fix: leave a sentence an allow entry quotes alone in fix - #225
Merged
Merged
Conversation
An allow entry drops only its own lint's findings, so fix still edited the sentence for the other lints. With an entry that exempts "in order to" in a sentence that also holds an em dash, fix replaced the dash, the quote stopped matching, the entry failed and the phrase finding came back. The report then told the agent that only a human may touch the entry, and the agent could neither fix the file nor repair the entry. Fix now makes no edit inside a sentence that any entry for the file quotes, for any lint, and reports each such place as unfixed with a reason that names the entry. Check is unchanged.
The reason told the agent to fix the other findings, which fix had already done, and said the entry exempts the sentence, which is not so when the entry has failed. It now names the config and the entry, says the quote would stop matching, and says not to edit the sentence by hand either. The unit test drops an assert on the text of a value it built, and checks the held reason on the second run too.
3 tasks done
webern
marked this pull request as ready for review
October 31, 2026 08:19
webern
added a commit
that referenced
this pull request
Oct 31, 2026
… name a line once (#230) ## AI Summary This is stacked on #225, the fix that leaves quoted sentences alone, which edits the same code in `src/fix/mod.rs`. It fixes two reports that said more than they should. First, `deslag fix` printed "deslag did not fix bin.md: it is not valid UTF-8, ..." about every file that is not valid UTF-8, on every run, even a file like `hello \xff world` with nothing in it to fix. `deslag check` reads such a file with each bad byte replaced by one `$` (`src/lint/mod.rs`, `decode`), lints it like any other file, and says nothing about its encoding. Now `fix` reads the file the same way and works out its edits without writing any. It reports the file as not UTF-8 only when it would make an edit there. Otherwise it skips the file, the way it skips a UTF-8 file with nothing to fix, and the `check` that `fix` runs afterwards reports what the lints find, as it does today. A finding that no edit exists for, such as a banned phrase, does not make `fix` report the file. Second, an `allow` entry whose quote matched two sentences on the same line reported "holds the quote as 2 sentences, on lines 1, 1", and `deslag explain` listed the entry at "lines 1, 1". The fix is in `on_lines` (`src/lint/mod.rs`), which every report uses to name lines: it now names a line once, however often it is given. The report now says "2 sentences, on line 1"; the count still comes from the sentences. `banned_chars` and `fix` deduplicated their lines before calling it, and no longer do. The fix sits there rather than only in `src/lint/allow.rs` so that `explain` gets it too. Two new cases under `tests/cases/banned_chars/`: - `fix_not_utf8`: a file with a bad byte and a banned phrase. `fix` says it fixed nothing, and `check` reports the phrase. - `allow_two_sentences_one_line`: an entry whose quote is twice on one line. Each case fails with its source change reverted. The existing tests where a non-UTF-8 file holds a dash `fix` would replace still pass unchanged, so that report stays. ## Testing - [x] `make ci-fast`: exit 0 - [x] `make test`: exit 0 - [x] Both reports reproduced by hand in a scratch repo before the change, and gone after it ## References - Stacked on #225
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI Summary
An
allowentry (#199) exempts one sentence from one lint, and it drops only that lint's findings.deslag fixtakes its edits from the findings left over, so it still edited the quoted sentence for every other lint. Take a config that bans dashes and the phrase "in order to", with this entry:On main,
deslag fixreplaces the dash with-. The quote no longer matches, the entry fails asno_such_sentence, the phrase finding comes back, and the run exits 1 with a report saying only a human may write or change an entry. The agent cannot fix the file and cannot repair the entry.Now
fixmakes no edit inside a sentence that anyallowentry for the file quotes, whatever the entry's lint. Each such place is listed under "deslag cannot fix these" with a reason that names the entry:The rest of the file is fixed as before.
checkis unchanged, so the dash stays abanned_charsfinding for the human to decide on. The change is infix(src/fix/mod.rs), not in how an entry applies, so an entry is what #199 built. A quote that two sentences equal holds both, since an edit to either changes how the entry comes out. A held place is any edit whose bytes reach into the sentence. Places a lint names no edit for keep the lint's own reason.No changelog entry: this is a bug fix.
Testing
make ci-fast: exit 0make test: exit 0. No existing case output or golden file moved.tests/cases/banned_chars/allow_fix_held: the config and file above plus a second dash outside the quote.fixreplaces that dash, leaves the quoted one with the reason above, the entry still applies, and the run exits 1 on the dash left.src/fix/mod.rs: the held sentence is left and reported as held bymd.allow[0], the other dash is fixed, and a second run edits nothing. It fails when the held check is taken out.Question for the owner
Today
checkreports the dash in the held sentence as an ordinarybanned_charsfinding, with the advice "Write it as listed, or reword", and the run exits 1 on it. The JSON and SARIF outputs carry nothing about the hold; only the text offixsays the sentence is held. Shouldcheckmark an occurrence inside a sentence that another lint's entry quotes as held, and should the JSON and SARIF outputs carry the hold?References