Skip to content

Commit c87abe8

Browse files
committed
refactor: fix misc analyzer warnings
1 parent b7e396e commit c87abe8

File tree

5 files changed

+20
-44
lines changed

5 files changed

+20
-44
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,3 +754,7 @@ dotnet_diagnostic.CA1854.severity = suggestion
754754

755755
# JSON002: Probable JSON string detected
756756
dotnet_diagnostic.JSON002.severity = suggestion
757+
758+
# Workaround for https://github.com/dotnet/roslyn-analyzers/issues/5628
759+
[Program.cs]
760+
dotnet_diagnostic.ca1812.severity = none

src/Microsoft.ComponentDetection.Common/Telemetry/TelemetryRelay.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ namespace Microsoft.ComponentDetection.Common.Telemetry;
1212
/// </summary>
1313
public sealed class TelemetryRelay
1414
{
15+
private IEnumerable<ITelemetryService> telemetryServices;
16+
1517
// For things not populating the telemetry services collection, let's not throw.
1618
private TelemetryRelay() =>
1719
this.telemetryServices = Enumerable.Empty<ITelemetryService>();
1820

19-
private IEnumerable<ITelemetryService> telemetryServices;
20-
2121
/// <summary>
2222
/// Gets a value indicating whether or not the telemetry relay has been shutdown.
2323
/// </summary>

src/Microsoft.ComponentDetection.Orchestrator/Exceptions/NoDetectorsFoundException.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

test/Microsoft.ComponentDetection.Orchestrator.Tests/Services/BcdeScanExecutionServiceTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ namespace Microsoft.ComponentDetection.Orchestrator.Tests.Services;
2323
[TestCategory("Governance/ComponentDetection")]
2424
public class BcdeScanExecutionServiceTests
2525
{
26-
private Mock<ILogger> loggerMock;
27-
private Mock<IDetectorProcessingService> detectorProcessingServiceMock;
28-
private Mock<IEnumerable<IComponentDetector>> detectorsMock;
29-
private Mock<IDetectorRestrictionService> detectorRestrictionServiceMock;
30-
private Mock<IComponentDetector> componentDetector2Mock;
31-
private Mock<IComponentDetector> componentDetector3Mock;
32-
private Mock<IComponentDetector> versionedComponentDetector1Mock;
33-
private IGraphTranslationService graphTranslationService;
26+
private readonly Mock<ILogger> loggerMock;
27+
private readonly Mock<IDetectorProcessingService> detectorProcessingServiceMock;
28+
private readonly Mock<IEnumerable<IComponentDetector>> detectorsMock;
29+
private readonly Mock<IDetectorRestrictionService> detectorRestrictionServiceMock;
30+
private readonly Mock<IComponentDetector> componentDetector2Mock;
31+
private readonly Mock<IComponentDetector> componentDetector3Mock;
32+
private readonly Mock<IComponentDetector> versionedComponentDetector1Mock;
33+
private readonly IGraphTranslationService graphTranslationService;
3434

35-
private DetectedComponent[] detectedComponents;
36-
private ContainerDetails sampleContainerDetails;
35+
private readonly DetectedComponent[] detectedComponents;
36+
private readonly ContainerDetails sampleContainerDetails;
3737

38-
private BcdeScanExecutionService serviceUnderTest;
38+
private readonly BcdeScanExecutionService serviceUnderTest;
3939

40-
private DirectoryInfo sourceDirectory;
40+
private readonly DirectoryInfo sourceDirectory;
4141

4242
public BcdeScanExecutionServiceTests()
4343
{

test/Microsoft.ComponentDetection.TestsUtilities/DetectorTestUtilityBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public DetectorTestUtilityBuilder()
4848
public DetectorTestUtilityBuilder<T> WithFile(string fileName, string fileContents, IEnumerable<string> searchPatterns = null, string fileLocation = null) =>
4949
this.WithFile(fileName, fileContents.ToStream(), searchPatterns, fileLocation);
5050

51-
public DetectorTestUtilityBuilder<T> AddServiceMock<U>(Mock<U> mock)
52-
where U : class
51+
public DetectorTestUtilityBuilder<T> AddServiceMock<TMock>(Mock<TMock> mock)
52+
where TMock : class
5353
{
5454
this.serviceCollection.AddSingleton(_ => mock.Object);
5555
return this;

0 commit comments

Comments
 (0)