Skip to content

[Infra] Fix code analysis warnings - #4979

Open
martincostello wants to merge 3 commits into
open-telemetry:mainfrom
martincostello:dotnet-11-preparation
Open

[Infra] Fix code analysis warnings#4979
martincostello wants to merge 3 commits into
open-telemetry:mainfrom
martincostello:dotnet-11-preparation

Conversation

@martincostello

Copy link
Copy Markdown
Member

Changes

Cherry-pick fixes for new code analysis warnings in .NET 11 from #3867.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

Cherry-pick fixes for new code analysis warnings in .NET 11 from open-telemetry#3867.
@github-actions github-actions Bot added comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva comp:extensions Things related to OpenTelemetry.Extensions labels Aug 13, 2026
@martincostello
martincostello marked this pull request as ready for review August 13, 2026 16:27
@martincostello
martincostello requested a review from a team as a code owner August 13, 2026 16:27
Copilot AI lite review requested due to automatic review settings August 13, 2026 16:27
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 28.57143% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.86%. Comparing base (4843598) to head (1861e0e).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...rter.Geneva/Internal/Tld/UncheckedASCIIEncoding.cs 16.66% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests-Exporter.Geneva 56.74% <16.66%> (+0.33%) ⬆️
unittests-Extensions 95.74% <ø> (ø)
unittests-Instrumentation.ConfluentKafka 83.42% <100.00%> (-0.12%) ⬇️

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

Files with missing lines Coverage Δ
...rumentation.ConfluentKafka/ConfluentKafkaCommon.cs 71.42% <100.00%> (-1.30%) ⬇️
...rter.Geneva/Internal/Tld/UncheckedASCIIEncoding.cs 17.30% <16.66%> (ø)

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 UncheckedASCIIEncoding to 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.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 13, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-08-14 16:20 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Remove redundant `!` when targeting .NET 8+.
@github-actions
github-actions Bot requested a review from g7ed6e August 14, 2026 09:57
@github-actions github-actions Bot added the comp:instrumentation.confluentkafka Things related to OpenTelemetry.Instrumentation.ConfluentKafka label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva comp:extensions Things related to OpenTelemetry.Extensions comp:instrumentation.confluentkafka Things related to OpenTelemetry.Instrumentation.ConfluentKafka

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants