Skip to content

Commit 4211159

Browse files
committed
disable CA1508
1 parent 7a836ae commit 4211159

File tree

5 files changed

+4
-10
lines changed

5 files changed

+4
-10
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,10 @@ dotnet_diagnostic.CA1305.severity = none
683683
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1309
684684
dotnet_diagnostic.CA1309.severity = none
685685

686+
# CA1508: Avoid dead conditional code
687+
# Too many false positives.
688+
dotnet_diagnostic.CA1508.severity = none
689+
686690
# CA1510: Use ArgumentNullException throw helper
687691
#
688692
# This is only available in .NET 6.0 and higher. We'd need to use conditional compilation to only

src/Renci.SshNet/Channels/ChannelDirectTcpip.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,10 @@ private void CloseSocket()
124124

125125
lock (_socketLock)
126126
{
127-
#pragma warning disable CA1508 // Avoid dead conditional code
128127
if (_socket is null)
129128
{
130129
return;
131130
}
132-
#pragma warning restore CA1508 // Avoid dead conditional code
133131

134132
// closing a socket actually disposes the socket, so we can safely dereference
135133
// the field to avoid entering the lock again later
@@ -295,13 +293,11 @@ protected override void Dispose(bool disposing)
295293
lock (_socketLock)
296294
{
297295
var socket = _socket;
298-
#pragma warning disable CA1508 // Avoid dead conditional code
299296
if (socket != null)
300297
{
301298
_socket = null;
302299
socket.Dispose();
303300
}
304-
#pragma warning restore CA1508 // Avoid dead conditional code
305301
}
306302
}
307303

src/Renci.SshNet/Channels/ChannelForwardedTcpip.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,11 @@ private void CloseSocket()
164164
lock (_socketShutdownAndCloseLock)
165165
{
166166
var socket = _socket;
167-
#pragma warning disable CA1508 // Avoid dead conditional code
168167
if (socket != null)
169168
{
170169
_socket = null;
171170
socket.Dispose();
172171
}
173-
#pragma warning restore CA1508 // Avoid dead conditional code
174172
}
175173
}
176174

src/Renci.SshNet/Session.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,9 +1964,7 @@ private void SocketDisconnectAndDispose()
19641964

19651965
try
19661966
{
1967-
#pragma warning disable CA1508 // Avoid dead conditional code; Value could have been changed by another thread.
19681967
if (_socket != null)
1969-
#pragma warning restore CA1508 // Avoid dead conditional code
19701968
{
19711969
if (_socket.Connected)
19721970
{

src/Renci.SshNet/Sftp/SftpFileStream.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,6 @@ protected override void Dispose(bool disposing)
10671067
{
10681068
lock (_lock)
10691069
{
1070-
#pragma warning disable CA1508 // Avoid dead conditional code
10711070
if (_session != null)
10721071
{
10731072
_canRead = false;
@@ -1091,7 +1090,6 @@ protected override void Dispose(bool disposing)
10911090

10921091
_session = null;
10931092
}
1094-
#pragma warning restore CA1508 // Avoid dead conditional code
10951093
}
10961094
}
10971095
}

0 commit comments

Comments
 (0)