autofac / Autofac

An addictive .NET IoC container
https://autofac.org
MIT License
4.44k stars 836 forks source link

Enable analyzers on test assemblies #1418

Closed tillig closed 1 month ago

tillig commented 1 month ago

I noticed that, while we have a set of test analysis rules, we didn't actually have static analysis running on the test assemblies.

This pull request fixes that:

The vast majority of the issues were around things being created in tests and not disposed - var x instead of using var x. It looks a little messy but it was easy enough to fix.

The second largest number was around nested public types in test fixtures. I think this is something that was hit while cleaning up tests in Autofac.Extensions.DependencyInjection or similar - I remember a bit of churn on one of those. This fixes that. I tried to just mark things private as much as possible, though there were a couple I simply suppressed the issue on rather than try to move things around too much.

There are a few suppressions, mostly around:

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 50.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 78.57%. Comparing base (4547d16) to head (4e0ad9f).

Files Patch % Lines
...tration/ExternalRegistryServiceMiddlewareSource.cs 0.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1418 +/- ## =========================================== + Coverage 78.52% 78.57% +0.05% =========================================== Files 200 200 Lines 5713 5713 Branches 1168 1168 =========================================== + Hits 4486 4489 +3 + Misses 714 712 -2 + Partials 513 512 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.