Enforce the thread-safe collector rather than rely on remembering it - #51
Merged
Conversation
The concurrent-callback contract was documented and still broken in twenty test files. Documenting it again would be the same bet. HarnessInvariantTests reads the test sources and fails when a List's Add is handed to ScanDirectory or ConvertFiles, the two calls whose callbacks the engine documents as concurrent. Scoped to those: callbacks passed to a plain sequential enumeration are not this rule's business, and flagging them would make it noise people learn to ignore. The first version was not scoped and produced seven false positives, including a file whose EntrySink was condemned by an unrelated List of the same name elsewhere in it - so declarations are now resolved to the nearest one before the use. Two things the rule asserts about itself. That it found call sites to examine at all, because a search looking in the wrong place is indistinguishable from a clean result. And that EntrySink is still actually used, because a ban with nothing to point at is one people work around. Verified against a deliberately reintroduced violation: it names the file and line. 424 passing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Make the rule enforced, not remembered
The concurrent-callback contract was already documented, and was still broken in twenty test files. Documenting it again would be the same bet.
HarnessInvariantTestsreads the test sources and fails the build when aList'sAddis handed toScanDirectoryorConvertFiles— the two calls whose callbacks the engine documents as concurrent.Scoped deliberately
The first version was not, and produced seven false positives:
DirectoryTraversalWarningTestspassesonWarning: warnings.AddtoDirectoryTraversal.EnumerateFiles(...).ToList()— a plain sequential enumeration. Not this rule's business.ScanEngineValidationTestsalready usedEntrySink, but an unrelatedListnamedentrieselsewhere in the same file condemned it. Declarations now resolve to the nearest preceding one.A rule that flags correct code is a rule people learn to ignore.
It checks itself
Two assertions about the search, not just its result:
EntrySinkis still in use. A ban with nothing to point at is one people work around.Verified against a real violation
Reverting one file to the old pattern:
File and line, then reverted.
424 passing.
🤖 Generated with Claude Code