[Infra] Fix code analysis warnings - #4979
Conversation
Cherry-pick fixes for new code analysis warnings in .NET 11 from open-telemetry#3867.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4979 +/- ##
==========================================
+ Coverage 77.84% 77.86% +0.02%
==========================================
Files 473 471 -2
Lines 20205 20193 -12
==========================================
- Hits 15729 15724 -5
+ Misses 4476 4469 -7
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Cherry-picks small code adjustments to address new .NET 11 code analysis warnings, primarily by refactoring expression bodies / casts without changing behavior. This fits the repo’s ongoing effort to keep builds and analyzers clean across supported TFMs.
Changes:
- Converted a few expression-bodied local functions in unit tests to block-bodied functions.
- Removed redundant casts in fuzz tests when computing thresholds/randomness values.
- Simplified several trivial overrides in
UncheckedASCIIEncodingto expression-bodied members.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/OpenTelemetry.Extensions.Tests/Trace/ConsistentProbabilitySamplerTests.cs | Refactors local helper functions to block bodies to satisfy analyzers without changing test behavior. |
| test/OpenTelemetry.Extensions.FuzzTests/ConsistentProbabilityFuzzTests.cs | Removes redundant casts in modulo expressions while preserving the intended [0, 2^56) ranges. |
| src/OpenTelemetry.Exporter.Geneva/Internal/Tld/UncheckedASCIIEncoding.cs | Simplifies trivial Encoding overrides to expression-bodied members; behavior remains identical. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Pull request dashboard statusWaiting on reviewers · refreshed 2026-08-14 16:20 UTC Review the latest changes. Status above doesn't look right?
|
Remove redundant `!` when targeting .NET 8+.
Changes
Cherry-pick fixes for new code analysis warnings in .NET 11 from #3867.
Merge requirement checklist
AppropriateCHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)