Fix CodeQL warnings#189
Merged
martincostello merged 1 commit intomainfrom Jul 24, 2025
Merged
Conversation
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.
There was a problem hiding this comment.
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
readonlyand reordered override modifiers. - Replaced explicit
== falsechecks with!and method-group delegates. - Updated test code to use
using varfor activities and added a sample log invocation. - In the example ASP.NET app, switched from
Path.CombinetoPath.Joinand 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.");
matt-hensley
approved these changes
Jul 24, 2025
This was referenced Aug 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
CHANGELOG.mdupdatedChanges in public API reviewed (if applicable)