Fix false-positive superfluous ignore warnings for assign-only properties#1095
Merged
Fix false-positive superfluous ignore warnings for assign-only properties#1095
Conversation
…ties. Use the same assign-only property analysis for both normal detection and superfluous ignore checks so ignored write-only properties are not reported as unnecessarily ignored. Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
This PR fixes a false positive where // periphery:ignore on assign-only properties could be reported as “superfluous” by ensuring the superfluous-ignore detection reuses the same assign-only property analysis as the main scan pipeline.
Changes:
- Extract assign-only property detection into a reusable analyzer and use it in the assign-only mutator.
- Update superfluous-ignore detection to exclude assign-only properties (treating their ignore comments as non-superfluous).
- Add fixture + regression test coverage for ignored assign-only properties.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Tests/PeripheryTests/RetentionTest.swift | Adds a regression assertion that ignored assign-only properties are not flagged as superfluous. |
| Tests/Fixtures/Sources/RetentionFixtures/testSuperfluousIgnoreCommand.swift | Introduces an assign-only property fixture with an ignore comment and a usage pattern that triggers assign-only analysis. |
| Sources/SourceGraph/Mutators/AssignOnlyPropertyReferenceEliminator.swift | Extracts assign-only detection into AssignOnlyPropertyAnalyzer and reuses it in the mutator. |
| Sources/PeripheryKit/ScanResultBuilder.swift | Excludes assign-only properties from superfluous-ignore detection by calling the analyzer with retained bypass. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sources/SourceGraph/Mutators/AssignOnlyPropertyReferenceEliminator.swift
Outdated
Show resolved
Hide resolved
Sources/SourceGraph/Mutators/AssignOnlyPropertyReferenceEliminator.swift
Show resolved
Hide resolved
Store retained assign-only analysis results on the graph so superfluous ignore comment detection can reuse the recorded analysis instead of recomputing the rule. Made-with: Cursor
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.
Summary
Prevent
// periphery:ignorecomments on assign-only properties from being reported as superfluous by reusing the assign-only analysis when evaluating ignored declarations.Resolves #1081