Skip to content

Conversation

martincostello
Copy link
Member

Changes

Fix CodeQL suggestions, which mostly fall into the "minor code analysis warnings" category and a few style ones, plus one bug in the example app.

Merge requirement checklist

  • Unit tests added/updated
  • CHANGELOG.md updated
  • Changes in public API reviewed (if applicable)

Fix CodeQL suggestions, which mostly fall into the "minor code analysis warnings" category and a few style ones, plus one bug in the example app.
@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 17:06
@martincostello martincostello requested a review from a team as a code owner July 17, 2025 17:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses CodeQL warnings by applying minor style and immutability improvements, simplifying conditionals, and fixing a bug in the example app.

  • Marked static arrays and settings fields as readonly and reordered override modifiers.
  • Replaced explicit == false checks with ! and method-group delegates.
  • Updated test code to use using var for activities and added a sample log invocation.
  • In the example ASP.NET app, switched from Path.Combine to Path.Join and corrected the created-response ID usage.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/Grafana.OpenTelemetry.Tests/TracerProviderExtensionsTest.cs Switched to using var for activity spans
tests/Grafana.OpenTelemetry.Tests/OpenTelemetryLoggerOptionsExtensionsTest.cs Added a log invocation to the logger test
tests/Grafana.OpenTelemetry.Tests/Grafana.OpenTelemetry.Tests.csproj Set <LangVersion> to latest
src/Grafana.OpenTelemetry.Base/ResourceDetectors/ResourceDetectorInitializer.cs Made Initializers readonly and adjusted abstract member order
src/Grafana.OpenTelemetry.Base/ResourceBuilderExtension.cs Simplified boolean inversion
src/Grafana.OpenTelemetry.Base/Instrumentations/InstrumentationInitializer.cs Made Initializers readonly
src/Grafana.OpenTelemetry.Base/GrafanaOpenTelemetryResourceDetector.cs Marked _settings readonly
src/Grafana.OpenTelemetry.Base/ExporterSettings/OtlpExporter.cs Reordered override modifiers and simplified Enable* checks
src/Grafana.OpenTelemetry.Base/ExporterSettings/GrafanaCloudConfigurationHelper.cs Made configuration fields readonly
src/Grafana.OpenTelemetry.Base/ExporterSettings/CloudOtlpExporter.cs Reordered override modifiers and simplified Enable* checks
src/Grafana.OpenTelemetry.Base/ExporterSettings/AgentOtlpExporter.cs Used method-group delegates and removed redundant casts
examples/net8.0/aspnetcore/TodoAppEndpoints.cs Switched to Path.Join and fixed the Created response ID
Comments suppressed due to low confidence (1)

tests/Grafana.OpenTelemetry.Tests/OpenTelemetryLoggerOptionsExtensionsTest.cs:26

  • Add an assertion to verify that the test logger captured the expected log message to improve test coverage and ensure the logging extension behaves as intended.
            logger.LogInformation("This is a test log message.");

@martincostello martincostello enabled auto-merge (squash) July 17, 2025 17:10
@martincostello martincostello merged commit 09d8e0f into main Jul 24, 2025
18 checks passed
@martincostello martincostello deleted the codeql-fixes branch July 24, 2025 17:22
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