Skip to content

Commit 6b497b5

Browse files
committed
fixing sonar issues
1 parent a4f00dc commit 6b497b5

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

libraries/src/AWS.Lambda.Powertools.Tracing/Internal/TracingAspect.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ public class TracingAspect
3333
/// <summary>
3434
/// The Powertools for AWS Lambda (.NET) configurations
3535
/// </summary>
36-
private IPowertoolsConfigurations _powertoolsConfigurations;
36+
private readonly IPowertoolsConfigurations _powertoolsConfigurations;
3737

3838
/// <summary>
3939
/// X-Ray Recorder
4040
/// </summary>
41-
private IXRayRecorder _xRayRecorder;
41+
private readonly IXRayRecorder _xRayRecorder;
4242

4343
/// <summary>
4444
/// If true, then is cold start
4545
/// </summary>
46-
private static bool _isColdStart;
46+
private static bool _isColdStart = true;
4747

4848
/// <summary>
4949
/// If true, capture annotations
@@ -70,7 +70,6 @@ public class TracingAspect
7070
/// </summary>
7171
public TracingAspect()
7272
{
73-
_isColdStart = true;
7473
_xRayRecorder = XRayRecorder.Instance;
7574
_powertoolsConfigurations = PowertoolsConfigurations.Instance;
7675
}
@@ -91,12 +90,8 @@ public TracingAspect()
9190
/// <returns></returns>
9291
[Advice(Kind.Around)]
9392
public object Around(
94-
[Argument(Source.Instance)] object instance,
9593
[Argument(Source.Name)] string name,
9694
[Argument(Source.Arguments)] object[] args,
97-
[Argument(Source.Type)] Type hostType,
98-
[Argument(Source.Metadata)] MethodBase method,
99-
[Argument(Source.ReturnType)] Type returnType,
10095
[Argument(Source.Target)] Func<object[], object> target,
10196
[Argument(Source.Triggers)] Attribute[] triggers)
10297
{

libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/Handlers/HandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public async Task Full_Example()
6868
Assert.True(handleSegment.IsSubsegmentsAdded);
6969

7070
Assert.Equal("POWERTOOLS", handleSegment.Annotations["Service"]);
71-
Assert.Equal(true, handleSegment.Annotations["ColdStart"]);
71+
Assert.True((bool)handleSegment.Annotations["ColdStart"]);
7272
Assert.Equal("value", handleSegment.Annotations["annotation"]);
7373
Assert.Equal("## Handle", handleSegment.Name);
7474

libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/TracingAttributeTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ public void OnEntry_WhenFirstCall_CapturesColdStart()
6161
Assert.Single(segmentCold.Subsegments);
6262
Assert.True(subSegmentCold.IsAnnotationsAdded);
6363
Assert.Equal(2, subSegmentCold.Annotations.Count());
64-
Assert.Equal(true, subSegmentCold.Annotations.Single(x => x.Key == "ColdStart").Value);
64+
Assert.True((bool)subSegmentCold.Annotations.Single(x => x.Key == "ColdStart").Value);
6565
Assert.Equal("POWERTOOLS", subSegmentCold.Annotations.Single(x => x.Key == "Service").Value);
6666

6767
// Warm
6868
Assert.True(segmentWarm.IsSubsegmentsAdded);
6969
Assert.Single(segmentWarm.Subsegments);
7070
Assert.True(subSegmentWarm.IsAnnotationsAdded);
7171
Assert.Equal(2, subSegmentWarm.Annotations.Count());
72-
Assert.Equal(false, subSegmentWarm.Annotations.Single(x => x.Key == "ColdStart").Value);
72+
Assert.False((bool)subSegmentWarm.Annotations.Single(x => x.Key == "ColdStart").Value);
7373
Assert.Equal("POWERTOOLS", subSegmentWarm.Annotations.Single(x => x.Key == "Service").Value);
7474
}
7575

@@ -98,14 +98,14 @@ public void OnEntry_WhenFirstCall_And_Service_Not_Set_CapturesColdStart()
9898
Assert.Single(segmentCold.Subsegments);
9999
Assert.True(subSegmentCold.IsAnnotationsAdded);
100100
Assert.Single(subSegmentCold.Annotations);
101-
Assert.Equal(true, subSegmentCold.Annotations.Single(x => x.Key == "ColdStart").Value);
101+
Assert.True((bool)subSegmentCold.Annotations.Single(x => x.Key == "ColdStart").Value);
102102

103103
// Warm
104104
Assert.True(segmentWarm.IsSubsegmentsAdded);
105105
Assert.Single(segmentWarm.Subsegments);
106106
Assert.True(subSegmentWarm.IsAnnotationsAdded);
107107
Assert.Single(subSegmentWarm.Annotations);
108-
Assert.Equal(false, subSegmentWarm.Annotations.Single(x => x.Key == "ColdStart").Value);
108+
Assert.False((bool)subSegmentWarm.Annotations.Single(x => x.Key == "ColdStart").Value);
109109
}
110110

111111
public void Dispose()

0 commit comments

Comments
 (0)