Skip to content

Fix false-positive superfluous ignore warnings for assign-only properties#1095

Merged
ileitch merged 2 commits intomasterfrom
issue-1081
Mar 21, 2026
Merged

Fix false-positive superfluous ignore warnings for assign-only properties#1095
ileitch merged 2 commits intomasterfrom
issue-1081

Conversation

@ileitch
Copy link
Contributor

@ileitch ileitch commented Mar 21, 2026

Summary

Prevent // periphery:ignore comments on assign-only properties from being reported as superfluous by reusing the assign-only analysis when evaluating ignored declarations.

Resolves #1081

…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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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
@ileitch ileitch marked this pull request as ready for review March 21, 2026 15:08
@ileitch ileitch merged commit dcaddc2 into master Mar 21, 2026
12 of 13 checks passed
@ileitch ileitch deleted the issue-1081 branch March 21, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore comments falsely flagged as superfluous

2 participants