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

Enable analysers #908

Closed
wants to merge 22 commits into from
Closed

Enable analysers #908

wants to merge 22 commits into from

Conversation

martincostello
Copy link
Contributor

Changes

Enable <AnalysisLevel>latest-All</AnalysisLevel> as suggested in #900 (comment).

Within the production shipping packages there are two changes that change the public API surface. As both packages are still pre-release on NuGet.org I assumed this was fine. These changes can be reverted and suppressed if preferred.

For the test projects I erred on the side of disabling rules rather than fixing them to reduce churn.

I'm leaving this as a draft for now as it touches a lot of files so might ping a lot of different reviewers. I can also split the commits up differently and/or create smaller more targeted PRs if that's preferred.

Let me know if any of these changes warrant a note in the CHANGELOG.

For significant contributions please make sure you have completed the following items:

  • Appropriate CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #

Set `AnalysisLevel` to `latest-All`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Contrib.Extensions.AWSXRay`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Contrib.Instrumentation.AWS`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Contrib.Shared`.
Fix tests broken by 65e7e03.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Exporter.Instana`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Exporter.Stackdriver`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Extensions.Docker`.
ix (or suppress) code analysis warnings for `OpenTelemetry.Extensions.PersistentStorage`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Instrumentation.AspNet`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Instrumentation.AWSLambda`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Instrumentation.ElasticsearchClient`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Instrumentation.EntityFrameworkCore`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Instrumentation.GrpcCore`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Contrib.Extensions.AWSXRay`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Instrumentation.MySqlData`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Contrib.Extensions.AWSXRay`.
Fix (or suppress) code analysis warnings for `OpenTelemetry.Instrumentation.Wcf`.
Use `Guard.ThrowIfNull()` where possible.
- Fix analysis warnings in non-production projects, such as tests and examples.
- Fix analysis warnings in production projects missed in the first pass.
Fix CA1725 warning by adjusting the public API.
Fix test broken by refactor to use `TryGetValue()`.
@codecov
Copy link

codecov bot commented Jan 19, 2023

Codecov Report

Merging #908 (1c7b54f) into main (b53b6b9) will decrease coverage by 0.26%.
The diff coverage is 82.06%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #908      +/-   ##
==========================================
- Coverage   68.48%   68.22%   -0.26%     
==========================================
  Files         183      183              
  Lines        7002     7018      +16     
==========================================
- Hits         4795     4788       -7     
- Misses       2207     2230      +23     
Impacted Files Coverage Δ
...y.Contrib.Extensions.AWSXRay/AWSXRayIdGenerator.cs 61.64% <ø> (ø)
...orter.Geneva/TLDExporter/UncheckedASCIIEncoding.cs 16.00% <0.00%> (+0.31%) ⬆️
...Implementation/Processors/ActivityProcessorBase.cs 92.85% <0.00%> (ø)
...metry.Exporter.Instana/Implementation/Transport.cs 0.00% <0.00%> (-18.30%) ⬇️
...xporter.Instana/TracerProviderBuilderExtensions.cs 0.00% <ø> (ø)
...y.Exporter.Stackdriver/Implementation/Constants.cs 0.00% <0.00%> (-100.00%) ⬇️
...ter.Stackdriver/TracerProviderBuilderExtensions.cs 100.00% <ø> (ø)
...elemetry.Exporter.Stackdriver/Utils/CommonUtils.cs 0.00% <0.00%> (ø)
...y.Extensions.PersistentStorage/FileBlobProvider.cs 77.41% <ø> (ø)
....AspNet.TelemetryHttpModule/TelemetryHttpModule.cs 5.26% <0.00%> (-0.15%) ⬇️
... and 54 more

@@ -7,6 +7,7 @@
<DefineConstants>$(DefineConstants);SIGNED</DefineConstants>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<NetFrameworkMinimumSupportedVersion>net462</NetFrameworkMinimumSupportedVersion>
<AnalysisLevel>latest-All</AnalysisLevel>
Copy link
Member

Choose a reason for hiding this comment

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

latest-All sound a bit too much, can we use a fixed version here?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is an agreement to use this approach on SDK repository. I think we could do the same here. See open-telemetry/opentelemetry-dotnet#3958

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense.

@@ -41,19 +41,19 @@ public class AWSEKSResourceDetector : IResourceDetector
public IEnumerable<KeyValuePair<string, object>> Detect()
{
var credentials = this.GetEKSCredentials(AWSEKSCredentialPath);
var httpClientHandler = Handler.Create(AWSEKSCertificatePath);
using var httpClientHandler = Handler.Create(AWSEKSCertificatePath);
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch

@Oberon00
Copy link
Member

All in all, this PR seems a bit too large. The nontrivial changes should probably go to separate PRs (separately dis/enabled before)

@Kielek
Copy link
Contributor

Kielek commented Jan 19, 2023

All in all, this PR seems a bit too large. The nontrivial changes should probably go to separate PRs (separately dis/enabled before)

I think that enabling this feature project by project (including tests) could be easier to review. If you agree, it will be great to create issue to link all changes, similar to #894.

@TimothyMothra, fyi as you working on similar issue in SDK repository.

@Oberon00
Copy link
Member

I was thinking of doing the trivial warnings (such as adding static) in one PR, and for the more involved changes, doing it per warning, or per project, however it clusters better.

@martincostello
Copy link
Contributor Author

As noted in the description, I'm happy to chunk this up into N commits/PRs (whatever works best for you), but doing all the changes and pushing up a draft as a starting point was the easiest way for me to do the majority of the work in the first instance. The easiest way to fix with it turned on was per-file, per-project.

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jan 27, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2023

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@martincostello
Copy link
Contributor Author

martincostello commented Feb 3, 2023

Have opened #950 to track doing these changes in a series of separate pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.