Skip to content

Commit cfaad65

Browse files
committed
Added sonar analyzer
1 parent 049fed6 commit cfaad65

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

CodingInterview/CodingInterview/CodingInterview.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
<PackageReference Include="nunit" Version="3.12.0" />
1111
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
1212
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
13+
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.0.0.9566">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
</PackageReference>
1317
</ItemGroup>
1418

1519
</Project>

CodingInterview/CodingInterview/Tests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private static int[] MoveZeros(IReadOnlyList<int> arrayOfNumbers)
6969
private static int[] GetProductofArrayExceptSelf(IReadOnlyList<int> inputArray)
7070
{
7171
if (inputArray == null || inputArray.Count == 0)
72-
throw new ArgumentNullException("inputArray needs to have elements");
72+
throw new ArgumentNullException(nameof(inputArray), "inputArray needs to have elements");
7373

7474
return inputArray
7575
.Select(arrayElement => inputArray.Where(element => element != arrayElement)
@@ -108,7 +108,7 @@ private static int[] GetMinimumSizeSubarraySum(IReadOnlyList<int> inputArray, in
108108
private static string[] GetSummaryRanges(int[] inputArray)
109109
{
110110
if (inputArray == null || inputArray.Length == 0)
111-
throw new ArgumentNullException("inputArray needs to have elements");
111+
throw new ArgumentNullException(nameof(inputArray), "inputArray needs to have elements");
112112

113113
var listOfAnswers = new List<string>();
114114

@@ -148,7 +148,7 @@ private static string[] GetSummaryRanges(int[] inputArray)
148148
private static string[] GetMissingRanges(int lower, int upper, IReadOnlyCollection<int> inputArray)
149149
{
150150
if (inputArray == null || inputArray.Count == 0)
151-
throw new ArgumentNullException("InputArray needs to have elements");
151+
throw new ArgumentNullException(nameof(inputArray), "InputArray needs to have elements");
152152

153153
if (lower > upper && lower >= 0 && upper >= 0)
154154
throw new ArgumentException("Correct arguments");
@@ -290,13 +290,6 @@ public void MissingRanges_10()
290290
public void MergeIntervals_11()
291291
{
292292
//given
293-
var inputArray = new[]
294-
{
295-
new [] { 1, 3 },
296-
new [] { 2, 6 },
297-
new [] { 8, 10 },
298-
new [] { 15, 18 }
299-
};
300293
var expectedArray = new[]
301294
{
302295
new [] { 1, 6 },

0 commit comments

Comments
 (0)