Skip to content

Commit be67e32

Browse files
committed
chore: snoarqube smells
1 parent 2d05c7d commit be67e32

10 files changed

Lines changed: 12 additions & 18 deletions

src/System.Net.IPNetwork/BigIntegerExtensions.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,9 @@ public static string ToOctalString(this BigInteger bigint)
103103
string octal = Convert.ToString(int24, 8);
104104

105105
// Ensure leading zero exists if value is positive.
106-
if (octal[0] != '0')
106+
if (octal[0] != '0' && (bigint.Sign == 1))
107107
{
108-
if (bigint.Sign == 1)
109-
{
110-
base8.Append('0');
111-
}
108+
base8.Append('0');
112109
}
113110

114111
// Append first converted chunk to StringBuilder.

src/TestProject/IPAddressExtensionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ e XOR'd with the byte count so the two sequences will be different. */
9595
hashInput[0] ^= (byte)byteCount;
9696

9797
/* Loop many times. */
98-
foreach (int i in Enumerable.Range(1, 1000))
98+
foreach (int _ in Enumerable.Range(1, 1000))
9999
{
100100
/* Hash the current interation to get a new block of deterministic bytes. */
101101
hashInput = SHA256.HashData(hashInput);

src/TestProject/IPNetworkTest/IPNetworkCtorWithIpAndCidrTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void CtorWithIpAndCidr2()
3131
Assert.ThrowsExactly<ArgumentNullException>(() =>
3232
{
3333
IPAddress ip = null;
34-
var ipnetwork = new IPNetwork2(ip, 24);
34+
var _ = new IPNetwork2(ip, 24);
3535
});
3636
}
3737

@@ -45,7 +45,7 @@ public void CtorWithIpAndCidr3()
4545
{
4646
string ipaddress = "192.168.168.100";
4747
var ip = IPAddress.Parse(ipaddress);
48-
var ipnetwork = new IPNetwork2(ip, 33);
48+
var _ = new IPNetwork2(ip, 33);
4949
});
5050
}
5151
}

src/TestProject/IPNetworkTest/IPNetworkParseTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ public void TestParse(string ipnetwork, string guess, string expected)
672672
{
673673
cidrGuess = CidrGuess.ClassFull;
674674
}
675-
bool result = IPNetwork2.TryParse(ipnetwork, cidrGuess, out IPNetwork2 ipnetwork2);
675+
bool _ = IPNetwork2.TryParse(ipnetwork, cidrGuess, out IPNetwork2 ipnetwork2);
676676
var ipnetworkExpected = IPNetwork2.Parse(expected);
677677

678678
// This assert fails.

src/TestProject/IPNetworkTest/IPNetworkSubnetTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public void TestSubnet13()
225225
IPNetwork2 ipnetwork = IPNetwork2.IANA_CBLK_RESERVED1;
226226
byte cidr = 20;
227227
IPNetworkCollection subnets = ipnetwork.Subnet(cidr);
228-
IPNetwork2 error = subnets[1000];
228+
IPNetwork2 _ = subnets[1000];
229229
});
230230
}
231231
}

src/TestProject/IPNetworkTest/IPNetworkSupernetTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ public void TestSupernetInternal1()
2727
[TestMethod]
2828
public void TestSupernetInternal2()
2929
{
30-
IPNetwork2 result;
3130
Assert.ThrowsExactly<ArgumentNullException>(() =>
3231
{
33-
IPNetwork2.InternalSupernet(false, null, null, out result);
32+
IPNetwork2.InternalSupernet(false, null, null, out var _);
3433
});
3534
}
3635

src/TestProject/IPNetworkTest/IPNetworkTrySupernetTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ public void TestTrySupernet2()
3535
{
3636
IPNetwork2 network1 = null;
3737
var network2 = IPNetwork2.Parse("192.168.1.1/24");
38-
IPNetwork2 supernet;
3938

4039
#pragma warning disable 0618
41-
IPNetwork2.TrySupernet(network1, network2, out supernet);
40+
IPNetwork2.TrySupernet(network1, network2, out var _);
4241
#pragma warning restore 0618
4342
});
4443
}

src/TestProject/IPNetworkV6/IPNetworkV6CtorWithIpAndCidrTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void CtorWithIpAndCidr2()
3232
{
3333
string ipaddress = "2001:db8::";
3434
var ip = IPAddress.Parse(ipaddress);
35-
var ipn = new IPNetwork2(ip, 129);
35+
var _ = new IPNetwork2(ip, 129);
3636
});
3737
}
3838
}

src/TestProject/IPNetworkV6/IPNetworkV6SubnetTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public void TestSubnet13()
160160
var ipnetwork = IPNetwork2.Parse("2001:db08::/64");
161161
byte cidr = 70;
162162
IPNetworkCollection subnets = ipnetwork.Subnet(cidr);
163-
IPNetwork2 error = subnets[1000];
163+
IPNetwork2 _ = subnets[1000];
164164
});
165165
}
166166

src/TestProject/IPNetworkV6/IPNetworkV6TrySupernetTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ public void TestTrySupernet2()
3535
{
3636
IPNetwork2 network1 = null;
3737
var network2 = IPNetwork2.Parse("2001:db8::/64");
38-
IPNetwork2 supernet;
3938
#pragma warning disable 0618
40-
IPNetwork2.TrySupernet(network1, network2, out supernet);
39+
IPNetwork2.TrySupernet(network1, network2, out var _);
4140
#pragma warning restore 0618
4241
});
4342
}

0 commit comments

Comments
 (0)