fix(rules): finish the external rules file follow-ups - #97
Merged
Conversation
The flag no longer replaces the whole database: the embedded protected rules are prepended, so a supplied file cannot shadow them. --help still promised the old behaviour, and it was the only place left saying so after the README row was fixed.
An empty pattern list builds a GlobSet that matches nothing, so it fails exactly the way an invalid glob does — silently, and only for the rule whose author cared about it. validate() exists to stop a supplied file from reporting success for a rule that can never fire, and this was the other way to write one.
5 tasks
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.
What & why
Two leftovers from #78, raised in review and small enough that they'd
have cost another round trip on a first-time contributor's PR. #78 is
merged; this lands the remainder.
--helptold the old story.--rulesno longer replaces the wholedatabase —
with_embedded_protected_rulesprepends the embeddedprotectedrules so a supplied file can't shadow them. The flagdescription still said "instead of the embedded database", and after
the README row was corrected it was the only place left claiming it.
validate()missed the other way to write a rule that never fires.It rejects a pattern that isn't a valid glob, but an empty
"patterns": []builds aGlobSetthat matches nothing and passedvalidation. That fails exactly the way a bad glob does: silently, and
only for the rule whose author cared about it. Now rejected, with a
test.
Validation
cargo fmt --all -- --checkcargo clippy -p diskern-core -p diskern-cli --all-targets -- -D warningscargo test -p diskern-core -p diskern-cli— 66 pass, 0 failChecklist
cargo fmt --alland the required core/CLI clippy validation are clean