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

Fix warning CA1062#ContextualTtl #2217

Conversation

Zombach
Copy link
Contributor

@Zombach Zombach commented Jul 20, 2024

Pull Request

The issue or feature being addressed

#2215

Details on the issue fix or feature implementation

  • Suppress CA1062 in src/Polly/Caching/ContextualTtl.cs or fix the warning

Confirm the following

  • I started this PR by branching from the head of the default branch
  • I have targeted the PR to merge into the default branch
  • I have included unit tests for the issue/feature

@@ -28,6 +27,11 @@ public class ContextualTtl : ITtlStrategy
/// <returns>TimeSpan.</returns>
public Ttl GetTtl(Context context, object? result)
{
if (context is null)
Copy link
Contributor Author

@Zombach Zombach Jul 20, 2024

Choose a reason for hiding this comment

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

@martincostello
Which is better to use? == or the pattern is
The is mapping pattern, but mostly the code uses ==

Copy link
Member

Choose a reason for hiding this comment

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

I would use is for new code where it is equivalent to == null. Don't worry about updating existing code to match - it was written before is was a thing.

Copy link

codecov bot commented Jul 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.90%. Comparing base (e4ffcd4) to head (ccfc752).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2217   +/-   ##
=======================================
  Coverage   83.89%   83.90%           
=======================================
  Files         313      313           
  Lines        7179     7181    +2     
  Branches     1060     1061    +1     
=======================================
+ Hits         6023     6025    +2     
  Misses        785      785           
  Partials      371      371           
Flag Coverage Δ
linux 83.90% <100.00%> (+<0.01%) ⬆️
macos 83.90% <100.00%> (+<0.01%) ⬆️
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@martincostello martincostello enabled auto-merge (squash) July 20, 2024 08:02
@martincostello martincostello added this to the v8.4.2 milestone Jul 20, 2024
@martincostello martincostello merged commit c75b43b into App-vNext:main Jul 20, 2024
15 checks passed
@Zombach Zombach deleted the zombach/remove-warning-ca1062#contextual-ttl branch July 24, 2024 18:14
@martincostello martincostello removed this from the v8.4.2 milestone Sep 26, 2024
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