Skip to content

Reduce UNT0043 false positives for platform and version guards - #505

Merged
Sebastien Lebreton (sailro) merged 1 commit into
mainfrom
fix/unt0043-false-positives
Sep 24, 2026
Merged

Sebastien Lebreton (sailro) merged 1 commit into
mainfrom
fix/unt0043-false-positives

Conversation

@sailro

Copy link
Copy Markdown
Member

Checklist

  • I have read the Contribution Guide.
  • There is an approved issue describing the change when contributing a new analyzer or suppressor (not applicable: this fixes an existing analyzer).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation.

Short description of what this resolves

UNT0043 can mistake intentionally inactive platform and Unity-version symbols for typos because it only compares them with symbols enabled in the current build. Reported examples include UNITY_6000_4_OR_NEWER and UNITY_6000_5_OR_NEWER being suggested as UNITY_6000_0_OR_NEWER, and UNITY_PS4 being suggested as UNITY_64.

Make detection more conservative without maintaining a catalog of Unity platforms or versions. This remains a heuristic: valid optional symbols can still resemble enabled symbols, and typos for inactive platforms may go undetected.

Changes proposed in this pull request

  • Exempt well-formed UNITY_X, UNITY_X_Y, UNITY_X_Y_Z, and UNITY_X_Y_OR_NEWER version symbols independently of the installed Unity version.
  • Preserve numeric components, including their boundaries, when suggesting a correction.
  • Replace the length-dependent edit-distance threshold with a single insertion, deletion, substitution, or adjacent transposition; require a unique candidate instead of breaking ties alphabetically.
  • Use a realistic platform configuration in the compound-condition test, add regressions and code-fix coverage, and document the behavior and limitations.

Validation

  • Built the test project successfully and ran all 66 ConditionalCompilationSymbolTypoTests cases successfully.
  • Exercised the analyzer on the 11 affected Burst/Input System package files with both Editor and Player defines: all 22 file/configuration combinations produced no UNT0043 diagnostics, while a genuine typo control remained detected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sailro
Sebastien Lebreton (sailro) merged commit fd250c3 into main Sep 24, 2026
6 checks passed
@sailro
Sebastien Lebreton (sailro) deleted the fix/unt0043-false-positives branch September 24, 2026 14:50
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.

2 participants