fix: zero wildcard matches for --required-files is not an error; literal non-matches emit SLNX020#68
Draft
fix: zero wildcard matches for --required-files is not an error; literal non-matches emit SLNX020#68
--required-files is not an error; literal non-matches emit SLNX020#68Conversation
Agent-Logs-Url: https://github.com/304NotModified/SLNX-validator/sessions/df57f4d4-bd94-489f-94d0-3f0476a70eee Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix SLNX020 error for wildcard patterns with zero matches
fix: zero wildcard matches for Apr 7, 2026
--required-files is not an error
304NotModified
requested changes
Apr 7, 2026
Owner
304NotModified
left a comment
There was a problem hiding this comment.
This is wrong. If we have unknownfile.md, we should an error. But not is *.unknown.file. So if it has a wildcard, then it's not required
… matches emit SLNX020 Agent-Logs-Url: https://github.com/304NotModified/SLNX-validator/sessions/deabf102-3e90-4a06-a252-62362daaa419 Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Contributor
Author
Fixed in 22f975c. The logic now distinguishes between literal and wildcard patterns:
Added |
Copilot
AI
changed the title
fix: zero wildcard matches for
fix: zero wildcard matches for Apr 7, 2026
--required-files is not an error--required-files is not an error; literal non-matches emit SLNX020
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.
Changes the behaviour of
--required-fileswhen a pattern matches zero files, distinguishing between wildcard and literal patterns:*or?) with zero matches → silently skipped, no errorunknownfile.md) with zero matches →SLNX020(RequiredFileDoesntExistOnSystem) errorChanges
SlnxCollector.cs: Restore thematched.Count == 0branch but guard theSLNX020error behind!HasWildcard— wildcard patterns with zero matches are skipped silentlyRequiredFilesOptions.cs: AddHasWildcardcomputed property (checks for*or?inPattern); updateMatchedPathsdoc comment to describe the new distinctionREADME.md: Restore the "Disk check" bullet andSLNX020row in the error codes table, both updated to describe the wildcard vs. literal distinction; update exit codes tableSLNX020); added matchingValidatorRunnerTestsfor both casesCore logic:
Original prompt
Problem
In
src/SLNX-validator/SlnxCollector.csat line 64, when--required-filesis used with a wildcard pattern that matches zero files, the code currently emits aSLNX020(RequiredFileDoesntExistOnSystem) error:The desired behaviour: when a wildcard pattern matches 0 files, this should be considered valid (no error). Zero matches with a wildcard simply means there's nothing to check — treat it the same as if
--required-fileswas not used for that solution. Only a non-wildcard (literal) pattern that matches nothing should produce theSLNX020error.Wait — re-reading the request: the user actually wants 0 items to always be OK for wildcards. Specifically the change is: remove the
matched.Count == 0branch (or change it so 0 matches is not an error at all). If the glob pattern yields 0 matches, just skip the check entirely (noSLNX020error, no reference check either).Required changes
1.
src/SLNX-validator/SlnxCollector.cs(line 61–78)Change the logic so that 0 matched files is not an error. Instead of:
It should become:
2.
src/SLNX-validator/RequiredFilesOptions.csUpdate the XML doc comment for
MatchedPathsto reflect that an empty list is now valid (no error):3.
README.mdUpdate the
--required-filessection. The "Disk check" bullet currently says:This should be removed or updated to reflect that 0 matches is now OK and no error is emitted. Also update the
SLNX020row in the error codes table to clarify this code is no longer triggered by wildcard zero-matches (or simply remove it if it's entirely unused — but keep it if there are still scenarios where it fires; verify this in the code).Also update the Exit codes table under
--required-files:014. Tests
tests/SLNX-validator.Tests/SlnxCollectorTests.cs: the testCollectAsync_RequiredFilesPatternNoMatch_AddsRequiredFileDoesntExistOnSystemErrorshould be changed to assert no error (notSLNX020) when 0 files are matched, e.g. rename it toCollectAsync_RequiredFilesPatternNoMatch_NoErrorand assertHasErrors == false.SLNX020error being emitted for zero-match glob patterns.SLNX020/RequiredFileDoesntExistOnSystembecomes entirely dead code (never emitted), consider removing it or keeping it with a note; be conservative and keep it unless it's clearly unused everywhere.Check if
SLNX020is still used elsewhere before removing it. If it's only used in this one place (line 66 ofSlnxCollector.cs), it becomes dead code and can be cleaned up, but only if you are confident it is not used anywhere else.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Bij wildcards is 0 items prima. Dus dit aanpassen inclusief docs
SLNX-validator/src/SLNX-validator/SlnxCollector.cs
Line 64 in 8fb9fa8
This pull request was created from Copilot chat.