Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not emit CA1854/CA1864 for nested conditionals #7228

Merged
merged 6 commits into from
Apr 12, 2024

Conversation

CollinAlpert
Copy link
Contributor

Affected analyzer: PreferDictionaryTryMethodsOverContainsKeyGuardAnalyzer
Affected diagnostic IDs: CA1854 and CA1864

Both diagnostics were emitted for dictionary access guarded by a ContainsKey() check, even if the dictionary access was in a nested conditional, thus resulting in the fixer changing the semantics of the code.

Fixes #7217

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.48%. Comparing base (4af0601) to head (20f5e66).
Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7228      +/-   ##
==========================================
+ Coverage   96.47%   96.48%   +0.01%     
==========================================
  Files        1432     1443      +11     
  Lines      342185   345394    +3209     
  Branches    11280    11364      +84     
==========================================
+ Hits       330107   333244    +3137     
- Misses       9227     9271      +44     
- Partials     2851     2879      +28     

Copy link
Contributor

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @CollinAlpert!

@buyaa-n buyaa-n enabled auto-merge (squash) April 12, 2024 22:34
@buyaa-n buyaa-n merged commit 4d72fc1 into dotnet:main Apr 12, 2024
11 checks passed
@CollinAlpert CollinAlpert deleted the issue-7217 branch April 29, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CA1864: false positive / incorrect refactoring
2 participants