Repository navigation
feat: name a line in an allow entry - #251
Merged
Merged
Conversation
banned_chars also reports characters in frontmatter, in HTML blocks and between sentences. No sentence holds those, so an entry could not name them, and fix refused them. An entry for banned_chars may now give `line`, the whole text of one line, in place of `quote`. Spaces and tabs fold and the ends are trimmed; any other character must match. The file must hold the line once. The entry drops only the occurrences on that line that no sentence holds, never one inside a sentence. New statuses: no_such_line and two_lines; no_finding is worded for a line. Loading refuses an entry with both or neither, an empty line, a control character other than a tab, and a line for any other lint. A failed entry lists, after the sentences, the three closest lines that hold a finding no sentence holds. A quote that equals such a line says so and points to `line`. Fix holds a named line whole. The notice, explain and the json output show `Line:` or `line` for a line entry; the output for a quote entry is unchanged. The allow page gains one sentence and stays within its budget. The freeze fill gains a line entry for each section.
Five cases under banned_chars: a frontmatter line and an HTML line exempted by `line`, the stale statuses, a quote that equals such a line, the reviewer notice under a base, and fix leaving a named line whole.
Load refusals, the json, sarif and github output, explain, a base and a diff, fix, and a line of a Rust comment.
The fill entries that name a line held against no file, so the next release freeze would have failed. The frozen repo now writes the line each entry names, a no-break space between two sentences of a comment for rust, cpp and toml, and an HTML line for md. A config with a line entry gets those lines; an older config would report them. The fill turns banned_chars on for rust, cpp and toml with a ban on the no-break space, since the freeze copies lint settings into md only. The freeze now lays each item of a list in the fill by position and appends an item that brings a key the list lacks, so an allow entry with a line sits beside one with a quote instead of being merged into it, which no config loads.
listing() takes what it lists and where as two values, not one string it splits again. compile() builds the entry's names in the match that reads quote and line. apply() chooses between a sentence and a line with an enum, not a boxed trait object. A comment over 100 columns is wrapped, and the doc comments of path, lint and reason now say sentence or line.
A failed entry that names a line ended with advice about a sentence. It now says a human exempts a line, leave the line as it is, and editing a line only to get past a lint is no fix. When a file has no sentence with a finding but has lines with one, the report says the findings are outside every sentence, not only that no sentence holds one.
Text added to a named line stales the entry. A prefix match passed every test before this one.
The freezer laid each item of a fill list onto the config item at the same position. If the config listed its `allow` entries in another order than the fill, a `quote` entry and a `line` entry merged into one entry that the loader refuses. `overlay` now matches by kind. The kind of an item is the set of keys that tell the items of the fill's list apart, the keys some carry and others lack. A fill item with no item of its kind left is appended when it brings a key the list lacks. A test lays a quote and a line entry onto a reordered list and onto two quote entries.
webern
marked this pull request as ready for review
November 2, 2026 16:18
Owner
Author
|
CI is green on 1e13c6f (run 41479129435). Decided on the maintainer's behalf: a |
5 tasks done
webern
added a commit
that referenced
this pull request
Nov 29, 2026
…erride (#273) ## Human Summary This gives the user the ability to exempt a single lint case. ## Summary Issue #68 asked for two things. The first is a way to exempt one violation, keyed to its place and not to the whole file. The second is a way for a narrower override to turn off a lint that a broader override turned on. Much of the first already exists. `[[<section>.allow]]` entries (#199, #251) exempt one sentence, they require a reason, a tally of them prints on every run, and a stale entry fails the check. `list_growth`, the lint behind #67, was removed in #207, so there was no list count to rebase. What was still missing: - `density` could not be exempted. An `allow` entry for `density` now quotes one whole paragraph or list item, folded the same way a sentence quote is. Any edit to that block makes the entry stale, and the block is judged again. So a paragraph that grows has to be re-exempted by a human, and an entry does not last forever. A failed entry reports `no_such_block`, `two_blocks` or `no_finding`. `deslag fix` leaves a quoted block as it is. A `line` on a `density` entry is refused. - An override can now say `off = ["<lint>", ...]`. This sets each named lint back to unset for the files the override matches. A later override that sets the lint's table turns it back on, with only the settings that table sets. Loading the config (exit 2) refuses an unknown lint, a lint named twice, a lint the same override both turns off and sets, and an `off` for a lint that no table in the section turns on. `deslag explain` shows `# <lint>: off, by override N`. The field is marked `since = "next"` with a default of `[]`, so it needs no schema version bump. Exemptions stay in the config, with no in-file marker. That keeps to the existing rule that there is one way to exempt a finding. `guide.md` and `lints/allow.md` no longer say that an override cannot turn a lint off, or that an entry only exempts a sentence. They keep the rule that an agent proposes an entry or an `off` and a human writes it. The summary line, the SARIF rule text and the docs for entries now say "text" rather than "sentence", since an entry can name a paragraph. `.agents/deslag.toml` is unchanged. The #67 workaround was already removed along with `list_growth`. ## Testing - [x] `make ci-fast`: exit 0, including `check-deslag` on the repo itself - [x] `make test-tools`: exit 0 - [x] New `density` cases: `override_off`, `allow_applied`, `allow_fails` (covering `no_such_block` and `no_finding`), `allow_rust` and `allow_fix_held` - [x] Unit tests for the `off` load errors, the merge order and `two_blocks`, plus a new `deslag explain` test - [x] Expected outputs regenerated with `make fix-test-output`, and the diff checked. Existing `density` cases changed only by the added advice sentence and the sentence-to-text wording. ## References - Closes #68 - Related: #67, #199, #207, #251
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 could only name a sentence. Butbanned_charsalso reports characters in frontmatter, in HTML blocks and in a no-break space between two sentences, and no sentence holds those. Such a finding could be neither fixed (fixrightly refuses to edit it) nor exempted. Worse, an entry that quoted the line failed with "does not hold a sentence equal to the quote", and the same report said "No sentence of a.md holds a finding", so the two messages together contradicted the finding the run had just printed.This adds the
lineform of anallowentry (issue #68).What a
lineentry exemptsA finding outside every sentence, matched by the whole text of its line, in any section. Only
banned_charstakes it, because it is the only lint that reports outside sentences. For another lint, loading refuses the entry and says to name the sentence withquote.linetakes the place ofquote. An entry with both, with neither, with an emptyline, or with alineholding a control character other than a tab is refused at load. The line is the whole line as findings count lines. Spaces and tabs fold and the ends are trimmed; any other character must match, so a character added anywhere on the line stales the entry. It is not a line number (an edit above would move it) and not a span (a short one would match anywhere).A
lineentry drops only the occurrences of its lint on that line that no sentence holds. A finding inside a sentence on the same line is still reported, so a finding has one way to be exempted.Stale entries
no_such_line: no line of the file equals the entry.two_lines: two or more lines equal it. Duplicates fail, as two equal sentences do, because exempting every copy would let a line be pasted elsewhere.no_finding: the line exists but holds no occurrence outside every sentence. The message is worded for a line and points atquotewhen the finding is in a sentence.no_such_line.line, and says to tell the human.L. The findings it has are outside every sentence.", so it no longer denies a finding the file has.fixholds a line that alineentry names, for every lint, as it holds a quoted sentence. The notice for an entry added since the base,explain, JSON, SARIF and GitHub annotations showLine: "..."for a line entry. In JSON a line entry haslineand noquote; a sentence entry's output is byte-identical to before, andFORMAT_VERSIONstays 1. A four-value JSON-array entry reads as before.Freezer and fill changes
Each release freezes a config that names every setting. A
lineentry is a new setting, so the freeze must produce one that holds.tests/configs/fill.tomlnames alineentry per section. The frozen fixture repo gains the lines the fill names:<td>✔️</td>indocs/note.md, and a comment holdingOne.<no-break space>Two.in the Rust, C++ and TOML files. A test ties the fill's lines to the fixture's, so changing one without the other fails.banned_charsfor the no-break space in the rust, cpp and toml sections. Without it the frozen config has no finding there, so the entry could not hold.overlayintools/release/src/freeze.rslaid each item of a fill list onto the config item at the same position. Reordered, aquoteentry and alineentry merged into one entry that the loader refuses. It now lays a fill item onto an item of the same kind. The kind of an item is the set of keys that tell the items of the fill's list apart (some items carry them, others lack them), so forallowit is which ofquoteorlinethe item carries. A fill item with no item of its kind left is appended when it brings a key the list lacks. A list whose items carry the same keys has one kind, which keeps the old behaviour.tests/frozen.rsreads a map-valued setting as one schema leaf, not as one path per map key.since = "next"and the pageAllowFile.linecarriessince = "next", with its doc comment.quotebecomes optional in the on-disk type, so the schema no longer marks it required and cannot say "quote or line, not both"; loading enforces that. No schema bump: no config already written changes meaning.src/instructions/lints/allow.mdgains the sentence "Abanned_charsfinding outside every sentence, as in frontmatter or HTML, is named byline, its whole line, in place ofquote." and stays within its 800-byte budget (787 bytes). The doc comments ofpathandlintnow say "sentence or line", which moves the schema description of those fields; one comment is rewrapped under 100 columns with its text unchanged.Decided on the maintainer's behalf
lineentry matches the whole line, not a prefix. With a prefix match an agent could grow a match by appending text to the line, and the entry would keep holding.HUMANS_ONLY("only a human writes or changes an exemption; leave the sentence as it is") keeps its "sentence" wording. It prints after every run that has a failed entry, sentence entries included, and changing it would move the output of existing cases. The per-entry advice for a line entry says "line".///markers. A finding in a comment sentence is the sentence's, so a line entry there endsno_finding; this is tested.explainwording is "Line:".Measurement
Every
banned_charsgroup on, release build, over the.mdfiles of the in-tree corpus (1,230) and of the big tier. Before:mainat 39b804f ondeslag-blobs:v6@sha256:d075cbb3(23,100 files). After: this branch at 1e13c6f ondeslag-blobs:v7@sha256:d9a3047c38e2f9e7845f15f4a4f8a66b715595879f818e4ad4cd0997077c85fb(23,100 files). "Outside" means a finding in frontmatter, in an HTML block, or a space character (U+00A0, U+202F, U+200A) between two sentences.The counts match but for two: v7 has 8,823 files with a finding, three more than v6, and 35 files with a space between two sentences where the earlier figure said 39. No count of findings moved. Besides these, 638 findings (60 files) in the big tier sit outside every sentence in a paragraph, such as box-drawing characters, check marks and em dashes; the
lineentry reaches them too, and the earlier figures did not count them.Tests
New cases under
tests/cases/banned_chars/:allow_line: frontmatter, HTML block and between-sentence lines named bylineentries: clean.allow_line_stale:no_such_line,two_linesandno_findingon a line whose finding is in a sentence.allow_line_quoted: a quote entry whose text equals a line with a finding outside every sentence.allow_line_base: the notice for an added line entry.allow_line_fix:fixleaves a between-sentence no-break space alone when a line entry names its line.During the review of the diff the outputs of two of these moved, and each move is intended:
allow_line_stale(stderr and JSON): a failed line entry now ends with the line advice ("only a human exempts a line ...") instead of the sentence advice.allow_line_quoted(stderr and JSON): the report gains the "No sentence of README.md holds a finding ofbanned_chars. The findings it has are outside every sentence." line. The entries are quote entries, so their advice is unchanged.tests/allow.rsgains tests for the load refusals, a Rust comment line, JSON, SARIF and GitHub output,explain,--diff, andfix. Unit tests cover matching, duplicates, the closest lines and the load checks.tools/release/tests/release.rsgainsa_fill_list_is_laid_by_kind_not_by_position, which lays [quote, line] onto a config holding [line, quote] and onto a config with two quote entries, and checks that no item carries both aquoteand aline. It fails on the previous head of this branch, where the quote and line merged.Mutations, each reverted after; the result is the tests that fail:
fixandlint::allow, two tests intests/allow.rs, and the casesallow_line_fixandallow_line_stale.allow_line_stale.fix's hold: thefixunit test,fix_leaves_the_whole_line_a_line_entry_namesand the caseallow_line_fix.lint::allowreport test,a_line_with_a_character_added_fails_its_entry_and_brings_the_finding_back, and the casesallow_line_quotedandallow_line_stale.starts_with):a_line_with_text_added_after_the_entry_does_not_match. This mutation passed every test before that test existed. Matching the other way round, bycontainsand byends_with, also fails tests.tools/release/tests/release.rs.fill.tomlor the matching constant in the frozen fixture: the test that ties them fails, and so does the frozen-config load test.A simulated
prepin a scratch clone wrote a config for the next release holding bothallowentries per section, andevery_frozen_config_loads_and_warns_only_for_redirectsandthe_newest_frozen_configs_name_every_settingpassed there.Testing
make ci-fast: exit 0make test: exit 0make test-tools: exit 0cargo test -p deslag-release: exit 0make check-release: exit 2, failing onlynothing_arrives_in_nextandthe_newest_frozen_configs_name_every_setting. Both are expected on a branch that addssince = "next"and name{md,rust,cpp,toml}.allow[].line(and thepossessive_ownsettings that are alreadynextonmain); the next release's freeze clears them.check --base origin/mainon this repo: exit 0References