From 9be67c0c991c0acd5f8e09b5ddb58417a6abf9ad Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Carle <29762210+jscarle@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:57:35 -0400 Subject: [PATCH] Cleanup and muting of analyzer warnings (#1357) * Fixed warnings in tests. * Fixed warnings in main project. * Fix public key. * Further warning cleanup. * Muted remaining warnings. * Final cleanup. * Fix warning. * Fix test classes. * Fix more internals. * Revert "internal" in test projects * Revert more internals. * Revert all non-analyzer changes. --------- Co-authored-by: Rob Hague --- Renci.SshNet.sln | 1 - src/Renci.SshNet/.editorconfig | 30 ++- .../Abstractions/CryptoAbstraction.cs | 12 - .../Abstractions/SocketExtensions.cs | 4 - src/Renci.SshNet/Common/BigInteger.cs | 6 - src/Renci.SshNet/Compression/ZlibStream.cs | 1 - src/Renci.SshNet/ForwardedPort.cs | 2 - src/Renci.SshNet/ISftpClient.cs | 2 - ...KeyboardInteractiveAuthenticationMethod.cs | 2 +- .../Messages/Authentication/FailureMessage.cs | 4 - .../PasswordAuthenticationMethod.cs | 2 +- .../PrivateKeyAuthenticationMethod.cs | 2 - .../Cryptography/EcdsaDigitalSignature.cs | 7 +- .../Security/Cryptography/EcdsaKey.cs | 9 +- .../Security/Cryptography/HMACMD5.cs | 6 - .../Security/Cryptography/HMACSHA1.cs | 6 - src/Renci.SshNet/Sftp/SftpFileStream.cs | 6 +- src/Renci.SshNet/Sftp/SftpSession.cs | 45 ---- src/Renci.SshNet/ShellStream.cs | 13 +- src/Renci.SshNet/SshClient.cs | 1 - src/Renci.SshNet/SshCommand.cs | 2 - test/Renci.SshNet.Benchmarks/.editorconfig | 50 +++-- .../Common/ExtensionsBenchmarks.cs | 2 +- .../.editorconfig | 4 + .../.editorconfig | 190 +++++++++------- .../.editorconfig | 24 +- test/Renci.SshNet.Tests/.editorconfig | 210 ++++++++++-------- .../Classes/Common/ExtensionsTest_Concat.cs | 2 - .../ExtensionsTest_IsEqualTo_ByteArray.cs | 2 - .../Classes/Common/ExtensionsTest_Pad.cs | 5 +- .../Classes/Common/ExtensionsTest_Reverse.cs | 2 - .../Common/ExtensionsTest_Take_Count.cs | 2 - .../ExtensionsTest_Take_OffsetAndCount.cs | 2 - .../Common/ExtensionsTest_TrimLeadingZeros.cs | 2 - .../Classes/PrivateKeyFileTest.cs | 6 +- .../Classes/ShellStreamTest_ReadExpect.cs | 2 + 36 files changed, 336 insertions(+), 332 deletions(-) diff --git a/Renci.SshNet.sln b/Renci.SshNet.sln index 2ccb88b37..5c6c417ae 100644 --- a/Renci.SshNet.sln +++ b/Renci.SshNet.sln @@ -29,7 +29,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{D21A4D03-0AC2-4613-BB6D-74D2D16A72CC}" ProjectSection(SolutionItems) = preProject - test\.editorconfig = test\.editorconfig test\Directory.Build.props = test\Directory.Build.props EndProjectSection EndProject diff --git a/src/Renci.SshNet/.editorconfig b/src/Renci.SshNet/.editorconfig index c5f4bdf61..f7f9047a4 100644 --- a/src/Renci.SshNet/.editorconfig +++ b/src/Renci.SshNet/.editorconfig @@ -108,10 +108,18 @@ MA0053.public_class_should_be_sealed = false # TODO: Remove exclusion when issues are fixed dotnet_diagnostic.MA0055.severity = none +# MA0089: Optimize string method usage +# https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0089.md +dotnet_diagnostic.MA0089.severity = none + # MA0110: Use the Regex source generator # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0110.md dotnet_diagnostic.MA0110.severity = none +# MA0026: Fix TODO comment +# https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0026.md +dotnet_diagnostic.MA0026.severity = none + #### .NET Compiler Platform analysers rules #### # CA1030: Use events where appropriate @@ -152,10 +160,30 @@ dotnet_diagnostic.CA3075.severity = none # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0004 dotnet_diagnostic.IDE0004.severity = none +# IDE0047: Remove unnecessary parentheses +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0047-ide0048 +dotnet_diagnostic.IDE0047.severity = none + # IDE0048: Add parentheses for clarity -# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0047 +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0047-ide0048 dotnet_diagnostic.IDE0048.severity = none # IDE0305: Collection initialization can be simplified # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0305 dotnet_diagnostic.IDE0305.severity = none + +# IDE0046: Use conditional expression for return +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/style-rules/ide0046 +dotnet_diagnostic.IDE0046.severity = none + +# IDE0032: Use auto-implemented property +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0032 +dotnet_diagnostic.IDE0032.severity = none + +# CA5350: Do Not Use Weak Cryptographic Algorithms +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/quality-rules/ca5350 +dotnet_diagnostic.CA5350.severity = none + +# CA5351: Do Not Use Broken Cryptographic Algorithms +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/quality-rules/ca5351 +dotnet_diagnostic.CA5351.severity = none diff --git a/src/Renci.SshNet/Abstractions/CryptoAbstraction.cs b/src/Renci.SshNet/Abstractions/CryptoAbstraction.cs index ac3d1915c..bc53905d8 100644 --- a/src/Renci.SshNet/Abstractions/CryptoAbstraction.cs +++ b/src/Renci.SshNet/Abstractions/CryptoAbstraction.cs @@ -39,16 +39,12 @@ public static System.Security.Cryptography.RandomNumberGenerator CreateRandomNum public static System.Security.Cryptography.MD5 CreateMD5() { -#pragma warning disable CA5351 // Do not use broken cryptographic algorithms return System.Security.Cryptography.MD5.Create(); -#pragma warning restore CA5351 // Do not use broken cryptographic algorithms } public static System.Security.Cryptography.SHA1 CreateSHA1() { -#pragma warning disable CA5350 // Do not use weak cryptographic algorithms return System.Security.Cryptography.SHA1.Create(); -#pragma warning restore CA5350 // Do not use weak cryptographic algorithms } public static System.Security.Cryptography.SHA256 CreateSHA256() @@ -68,30 +64,22 @@ public static System.Security.Cryptography.SHA512 CreateSHA512() public static System.Security.Cryptography.HMACMD5 CreateHMACMD5(byte[] key) { -#pragma warning disable CA5351 // Do not use broken cryptographic algorithms return new System.Security.Cryptography.HMACMD5(key); -#pragma warning restore CA5351 // Do not use broken cryptographic algorithms } public static HMACMD5 CreateHMACMD5(byte[] key, int hashSize) { -#pragma warning disable CA5351 // Do not use broken cryptographic algorithms return new HMACMD5(key, hashSize); -#pragma warning restore CA5351 // Do not use broken cryptographic algorithms } public static System.Security.Cryptography.HMACSHA1 CreateHMACSHA1(byte[] key) { -#pragma warning disable CA5350 // Do not use weak cryptographic algorithms return new System.Security.Cryptography.HMACSHA1(key); -#pragma warning restore CA5350 // Do not use weak cryptographic algorithms } public static HMACSHA1 CreateHMACSHA1(byte[] key, int hashSize) { -#pragma warning disable CA5350 // Do not use weak cryptographic algorithms return new HMACSHA1(key, hashSize); -#pragma warning restore CA5350 // Do not use weak cryptographic algorithms } public static System.Security.Cryptography.HMACSHA256 CreateHMACSHA256(byte[] key) diff --git a/src/Renci.SshNet/Abstractions/SocketExtensions.cs b/src/Renci.SshNet/Abstractions/SocketExtensions.cs index 2c34c899c..b0946c88b 100644 --- a/src/Renci.SshNet/Abstractions/SocketExtensions.cs +++ b/src/Renci.SshNet/Abstractions/SocketExtensions.cs @@ -50,9 +50,7 @@ public void SetCancelled() SetCompleted(); } -#pragma warning disable S1144 // Unused private types or members should be removed public AwaitableSocketAsyncEventArgs GetAwaiter() -#pragma warning restore S1144 // Unused private types or members should be removed { return this; } @@ -68,9 +66,7 @@ void INotifyCompletion.OnCompleted(Action continuation) } } -#pragma warning disable S1144 // Unused private types or members should be removed public void GetResult() -#pragma warning restore S1144 // Unused private types or members should be removed { if (_isCancelled) { diff --git a/src/Renci.SshNet/Common/BigInteger.cs b/src/Renci.SshNet/Common/BigInteger.cs index 53a659daf..c9c2ea565 100644 --- a/src/Renci.SshNet/Common/BigInteger.cs +++ b/src/Renci.SshNet/Common/BigInteger.cs @@ -1,5 +1,4 @@ #pragma warning disable SA1028 // Code should not contain trailing whitespace -#pragma warning disable SA1515 // Single-line comment should be preceded by blank line // // System.Numerics.BigInteger // @@ -46,7 +45,6 @@ * * * ***************************************************************************/ -#pragma warning restore SA1515 // Single-line comment should be preceded by blank line #pragma warning restore SA1028 // Code should not contain trailing whitespace using System; @@ -4578,9 +4576,7 @@ public readonly byte[] ToByteArray() if (needExtra) { -#pragma warning disable S1854 // Unused assignments should be removed res[j++] = 0xFF; -#pragma warning restore S1854 // Unused assignments should be removed } } else @@ -4590,9 +4586,7 @@ public readonly byte[] ToByteArray() res[j++] = (byte)(word >> 8); res[j++] = (byte)(word >> 16); res[j++] = (byte)(word >> 24); -#pragma warning disable S1854 // Unused assignments should be removed res[j++] = 0xFF; -#pragma warning restore S1854 // Unused assignments should be removed } } diff --git a/src/Renci.SshNet/Compression/ZlibStream.cs b/src/Renci.SshNet/Compression/ZlibStream.cs index e09244992..fb2e8089e 100644 --- a/src/Renci.SshNet/Compression/ZlibStream.cs +++ b/src/Renci.SshNet/Compression/ZlibStream.cs @@ -54,5 +54,4 @@ public void Write(byte[] buffer, int offset, int count) } } -#pragma warning restore SA1005 // Single line comments should begin with single space #pragma warning restore S125 // Sections of code should not be commented out diff --git a/src/Renci.SshNet/ForwardedPort.cs b/src/Renci.SshNet/ForwardedPort.cs index b0b5838c8..a0ae7fdb0 100644 --- a/src/Renci.SshNet/ForwardedPort.cs +++ b/src/Renci.SshNet/ForwardedPort.cs @@ -71,9 +71,7 @@ public virtual void Start() /// /// Stops port forwarding. /// -#pragma warning disable CA1716 // Identifiers should not match keywords public virtual void Stop() -#pragma warning restore CA1716 // Identifiers should not match keywords { if (IsStarted) { diff --git a/src/Renci.SshNet/ISftpClient.cs b/src/Renci.SshNet/ISftpClient.cs index efbce934a..48e9dce87 100644 --- a/src/Renci.SshNet/ISftpClient.cs +++ b/src/Renci.SshNet/ISftpClient.cs @@ -592,9 +592,7 @@ public interface ISftpClient : IBaseClient /// was not found on the remote host. /// is . /// The method was called after the client was disposed. -#pragma warning disable CA1716 // Identifiers should not match keywords ISftpFile Get(string path); -#pragma warning restore CA1716 // Identifiers should not match keywords /// /// Gets the of the file on the path. diff --git a/src/Renci.SshNet/KeyboardInteractiveAuthenticationMethod.cs b/src/Renci.SshNet/KeyboardInteractiveAuthenticationMethod.cs index 7169fabc0..55b792a9b 100644 --- a/src/Renci.SshNet/KeyboardInteractiveAuthenticationMethod.cs +++ b/src/Renci.SshNet/KeyboardInteractiveAuthenticationMethod.cs @@ -15,7 +15,7 @@ namespace Renci.SshNet /// public class KeyboardInteractiveAuthenticationMethod : AuthenticationMethod, IDisposable { - private readonly RequestMessage _requestMessage; + private readonly RequestMessageKeyboardInteractive _requestMessage; private AuthenticationResult _authenticationResult = AuthenticationResult.Failure; private Session _session; private EventWaitHandle _authenticationCompleted = new AutoResetEvent(initialState: false); diff --git a/src/Renci.SshNet/Messages/Authentication/FailureMessage.cs b/src/Renci.SshNet/Messages/Authentication/FailureMessage.cs index 1904fa1de..9b36c9122 100644 --- a/src/Renci.SshNet/Messages/Authentication/FailureMessage.cs +++ b/src/Renci.SshNet/Messages/Authentication/FailureMessage.cs @@ -68,9 +68,7 @@ protected override void LoadData() /// protected override void SaveData() { -#pragma warning disable MA0025 // Implement the functionality instead of throwing NotImplementedException throw new NotImplementedException(); -#pragma warning restore MA0025 // Implement the functionality instead of throwing NotImplementedException } internal override void Process(Session session) @@ -81,9 +79,7 @@ internal override void Process(Session session) /// public override string ToString() { -#pragma warning disable MA0089 // Optimize string method usage return $"SSH_MSG_USERAUTH_FAILURE {string.Join(",", AllowedAuthentications)} ({nameof(PartialSuccess)}:{PartialSuccess})"; -#pragma warning restore MA0089 // Optimize string method usage } } } diff --git a/src/Renci.SshNet/PasswordAuthenticationMethod.cs b/src/Renci.SshNet/PasswordAuthenticationMethod.cs index f53016240..3a679572d 100644 --- a/src/Renci.SshNet/PasswordAuthenticationMethod.cs +++ b/src/Renci.SshNet/PasswordAuthenticationMethod.cs @@ -15,7 +15,7 @@ namespace Renci.SshNet /// public class PasswordAuthenticationMethod : AuthenticationMethod, IDisposable { - private readonly RequestMessage _requestMessage; + private readonly RequestMessagePassword _requestMessage; private readonly byte[] _password; private AuthenticationResult _authenticationResult = AuthenticationResult.Failure; private Session _session; diff --git a/src/Renci.SshNet/PrivateKeyAuthenticationMethod.cs b/src/Renci.SshNet/PrivateKeyAuthenticationMethod.cs index a8f7f4bd3..dadc7025e 100644 --- a/src/Renci.SshNet/PrivateKeyAuthenticationMethod.cs +++ b/src/Renci.SshNet/PrivateKeyAuthenticationMethod.cs @@ -17,9 +17,7 @@ public class PrivateKeyAuthenticationMethod : AuthenticationMethod, IDisposable { private AuthenticationResult _authenticationResult = AuthenticationResult.Failure; private EventWaitHandle _authenticationCompleted = new ManualResetEvent(initialState: false); -#pragma warning disable S1450 // Private fields only used as local variables in methods should become local variables private bool _isSignatureRequired; -#pragma warning restore S1450 // Private fields only used as local variables in methods should become local variables private bool _isDisposed; /// diff --git a/src/Renci.SshNet/Security/Cryptography/EcdsaDigitalSignature.cs b/src/Renci.SshNet/Security/Cryptography/EcdsaDigitalSignature.cs index 74f114341..840eed49a 100644 --- a/src/Renci.SshNet/Security/Cryptography/EcdsaDigitalSignature.cs +++ b/src/Renci.SshNet/Security/Cryptography/EcdsaDigitalSignature.cs @@ -1,8 +1,5 @@ using System; using System.Globalization; -#if NETFRAMEWORK -using System.Security.Cryptography; -#endif // NETFRAMEWORK using Renci.SshNet.Common; @@ -45,7 +42,7 @@ public override bool Verify(byte[] input, byte[] signature) var sig_size = _key.KeyLength == 521 ? 132 : _key.KeyLength / 4; var ssh_data = new SshDataSignature(signature, sig_size); #if NETFRAMEWORK - var ecdsa = (ECDsaCng)_key.Ecdsa; + var ecdsa = _key.Ecdsa; ecdsa.HashAlgorithm = _key.HashAlgorithm; return ecdsa.VerifyData(input, ssh_data.Signature); #else @@ -63,7 +60,7 @@ public override bool Verify(byte[] input, byte[] signature) public override byte[] Sign(byte[] input) { #if NETFRAMEWORK - var ecdsa = (ECDsaCng)_key.Ecdsa; + var ecdsa = _key.Ecdsa; ecdsa.HashAlgorithm = _key.HashAlgorithm; var signed = ecdsa.SignData(input); #else diff --git a/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs b/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs index 7898a92c9..6bf244bc4 100644 --- a/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs +++ b/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs @@ -221,10 +221,17 @@ public override BigInteger[] Public /// public byte[] PrivateKey { get; private set; } +#if NETFRAMEWORK + /// + /// Gets the object. + /// + public ECDsaCng Ecdsa { get; private set; } +#else /// /// Gets the object. /// public ECDsa Ecdsa { get; private set; } +#endif /// /// Initializes a new instance of the class. @@ -371,7 +378,7 @@ private void Import(string curve_oid, byte[] publickey, byte[] privatekey) PrivateKey = privatekey; } - var headerSize = Marshal.SizeOf(typeof(BCRYPT_ECCKEY_BLOB)); + var headerSize = Marshal.SizeOf(); var blobSize = headerSize + qx.Length + qy.Length; if (privatekey != null) { diff --git a/src/Renci.SshNet/Security/Cryptography/HMACMD5.cs b/src/Renci.SshNet/Security/Cryptography/HMACMD5.cs index bd9585448..83bb31f34 100644 --- a/src/Renci.SshNet/Security/Cryptography/HMACMD5.cs +++ b/src/Renci.SshNet/Security/Cryptography/HMACMD5.cs @@ -15,9 +15,7 @@ public class HMACMD5 : System.Security.Cryptography.HMACMD5 /// /// The key. public HMACMD5(byte[] key) -#pragma warning disable CA5351 // Do Not Use Broken Cryptographic Algorithms : base(key) -#pragma warning restore CA5351 // Do Not Use Broken Cryptographic Algorithms { #pragma warning disable MA0056 // Do not call overridable members in constructor _hashSize = base.HashSize; @@ -31,9 +29,7 @@ public HMACMD5(byte[] key) /// The key. /// The size, in bits, of the computed hash code. public HMACMD5(byte[] key, int hashSize) -#pragma warning disable CA5351 // Do Not Use Broken Cryptographic Algorithms : base(key) -#pragma warning restore CA5351 // Do Not Use Broken Cryptographic Algorithms { _hashSize = hashSize; } @@ -57,9 +53,7 @@ public override int HashSize /// protected override byte[] HashFinal() { -#pragma warning disable CA5351 // Do Not Use Broken Cryptographic Algorithms var hash = base.HashFinal(); -#pragma warning restore CA5351 // Do Not Use Broken Cryptographic Algorithms return hash.Take(HashSize / 8); } } diff --git a/src/Renci.SshNet/Security/Cryptography/HMACSHA1.cs b/src/Renci.SshNet/Security/Cryptography/HMACSHA1.cs index ca4adfdaf..da66fec0d 100644 --- a/src/Renci.SshNet/Security/Cryptography/HMACSHA1.cs +++ b/src/Renci.SshNet/Security/Cryptography/HMACSHA1.cs @@ -16,9 +16,7 @@ public class HMACSHA1 : System.Security.Cryptography.HMACSHA1 /// /// The key. public HMACSHA1(byte[] key) -#pragma warning disable CA5350 // Do Not Use Weak Cryptographic Algorithms : base(key) -#pragma warning restore CA5350 // Do Not Use Weak Cryptographic Algorithms { #pragma warning disable MA0056 // Do not call overridable members in constructor _hashSize = base.HashSize; @@ -31,9 +29,7 @@ public HMACSHA1(byte[] key) /// The key. /// The size, in bits, of the computed hash code. public HMACSHA1(byte[] key, int hashSize) -#pragma warning disable CA5350 // Do Not Use Weak Cryptographic Algorithms : base(key) -#pragma warning restore CA5350 // Do Not Use Weak Cryptographic Algorithms { _hashSize = hashSize; } @@ -57,9 +53,7 @@ public override int HashSize /// protected override byte[] HashFinal() { -#pragma warning disable CA5350 // Do Not Use Weak Cryptographic Algorithms var hash = base.HashFinal(); -#pragma warning restore CA5350 // Do Not Use Weak Cryptographic Algorithms return hash.Take(HashSize / 8); } } diff --git a/src/Renci.SshNet/Sftp/SftpFileStream.cs b/src/Renci.SshNet/Sftp/SftpFileStream.cs index 312dd9952..f0086c7d0 100644 --- a/src/Renci.SshNet/Sftp/SftpFileStream.cs +++ b/src/Renci.SshNet/Sftp/SftpFileStream.cs @@ -13,9 +13,10 @@ namespace Renci.SshNet.Sftp /// Exposes a around a remote SFTP file, supporting both synchronous and asynchronous read and write operations. /// /// -#pragma warning disable CA1844 // Provide memory-based overrides of async methods when subclassing 'Stream' +#pragma warning disable IDE0079 // We intentionally want to suppress the below warning. + [SuppressMessage("Performance", "CA1844: Provide memory-based overrides of async methods when subclassing 'Stream'", Justification = "TODO: This should be addressed in the future.")] +#pragma warning restore IDE0079 public class SftpFileStream : Stream -#pragma warning restore CA1844 // Provide memory-based overrides of async methods when subclassing 'Stream' { private readonly object _lock = new object(); private readonly int _readBufferSize; @@ -88,7 +89,6 @@ public override bool CanTimeout /// A class derived from Stream does not support seeking. /// Methods were called after the stream was closed. /// IO operation failed. - [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Justification = "Be design this is the exception that stream need to throw.")] public override long Length { get diff --git a/src/Renci.SshNet/Sftp/SftpSession.cs b/src/Renci.SshNet/Sftp/SftpSession.cs index 0fec92230..0e8e89f3a 100644 --- a/src/Renci.SshNet/Sftp/SftpSession.cs +++ b/src/Renci.SshNet/Sftp/SftpSession.cs @@ -487,13 +487,10 @@ public byte[] RequestOpen(string path, Flags flags, bool nullOnError = false) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (!nullOnError && exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } -#pragma warning restore CA1508 // Avoid dead conditional code return handle; } @@ -625,9 +622,7 @@ public void RequestClose(byte[] handle) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -851,9 +846,7 @@ public byte[] RequestRead(byte[] handle, ulong offset, uint length) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -952,9 +945,7 @@ public void RequestWrite(byte[] handle, WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1041,9 +1032,7 @@ public SftpFileAttributes RequestLStat(string path) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1147,9 +1136,7 @@ public SftpFileAttributes RequestFStat(byte[] handle, bool nullOnError) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (!nullOnError && exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1215,9 +1202,7 @@ public void RequestSetStat(string path, SftpFileAttributes attributes) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1249,9 +1234,7 @@ public void RequestFSetStat(byte[] handle, SftpFileAttributes attributes) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1291,9 +1274,7 @@ public byte[] RequestOpenDir(string path, bool nullOnError = false) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (!nullOnError && exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1372,9 +1353,7 @@ public KeyValuePair[] RequestReadDir(byte[] handle) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1450,9 +1429,7 @@ public void RequestRemove(string path) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1523,9 +1500,7 @@ public void RequestMkDir(string path) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1556,9 +1531,7 @@ public void RequestRmDir(string path) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1600,9 +1573,7 @@ internal KeyValuePair[] RequestRealPath(string path, WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (!nullOnError && exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1735,9 +1706,7 @@ public SftpFileAttributes RequestStat(string path, bool nullOnError = false) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (!nullOnError && exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1833,9 +1802,7 @@ public void RequestRename(string oldPath, string newPath) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1925,9 +1892,7 @@ internal KeyValuePair[] RequestReadLink(string path, WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (!nullOnError && exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -1967,9 +1932,7 @@ public void RequestSymLink(string linkpath, string targetpath) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -2012,9 +1975,7 @@ public void RequestPosixRename(string oldPath, string newPath) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -2066,9 +2027,7 @@ public SftpFileSytemInformation RequestStatVfs(string path, bool nullOnError = f WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (!nullOnError && exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -2160,9 +2119,7 @@ internal SftpFileSytemInformation RequestFStatVfs(byte[] handle, bool nullOnErro WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (!nullOnError && exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } @@ -2206,9 +2163,7 @@ internal void HardLink(string oldPath, string newPath) WaitOnHandle(wait, OperationTimeout); } -#pragma warning disable CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed if (exception is not null) -#pragma warning restore CA1508 // Avoid dead conditional code; Remove when we upgrade to newer SDK in which bug is fixed { throw exception; } diff --git a/src/Renci.SshNet/ShellStream.cs b/src/Renci.SshNet/ShellStream.cs index 0eadd6f4c..193badd31 100644 --- a/src/Renci.SshNet/ShellStream.cs +++ b/src/Renci.SshNet/ShellStream.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Text; using System.Text.RegularExpressions; @@ -68,18 +69,16 @@ public bool DataAvailable } } -#pragma warning disable MA0076 // Do not use implicit culture-sensitive ToString in interpolated strings [Conditional("DEBUG")] private void AssertValid() { Debug.Assert(Monitor.IsEntered(_sync), $"Should be in lock on {nameof(_sync)}"); - Debug.Assert(_readHead >= 0, $"{nameof(_readHead)} should be non-negative but is {_readHead}"); - Debug.Assert(_readTail >= 0, $"{nameof(_readTail)} should be non-negative but is {_readTail}"); - Debug.Assert(_readHead <= _readBuffer.Length, $"{nameof(_readHead)} should be <= {nameof(_readBuffer)}.Length but is {_readHead}"); - Debug.Assert(_readTail <= _readBuffer.Length, $"{nameof(_readTail)} should be <= {nameof(_readBuffer)}.Length but is {_readTail}"); - Debug.Assert(_readHead <= _readTail, $"Should have {nameof(_readHead)} <= {nameof(_readTail)} but have {_readHead} <= {_readTail}"); + Debug.Assert(_readHead >= 0, $"{nameof(_readHead)} should be non-negative but is {_readHead.ToString(CultureInfo.InvariantCulture)}"); + Debug.Assert(_readTail >= 0, $"{nameof(_readTail)} should be non-negative but is {_readTail.ToString(CultureInfo.InvariantCulture)}"); + Debug.Assert(_readHead <= _readBuffer.Length, $"{nameof(_readHead)} should be <= {nameof(_readBuffer)}.Length but is {_readHead.ToString(CultureInfo.InvariantCulture)}"); + Debug.Assert(_readTail <= _readBuffer.Length, $"{nameof(_readTail)} should be <= {nameof(_readBuffer)}.Length but is {_readTail.ToString(CultureInfo.InvariantCulture)}"); + Debug.Assert(_readHead <= _readTail, $"Should have {nameof(_readHead)} <= {nameof(_readTail)} but have {_readHead.ToString(CultureInfo.InvariantCulture)} <= {_readTail.ToString(CultureInfo.InvariantCulture)}"); } -#pragma warning restore MA0076 // Do not use implicit culture-sensitive ToString in interpolated strings /// /// Initializes a new instance of the class. diff --git a/src/Renci.SshNet/SshClient.cs b/src/Renci.SshNet/SshClient.cs index 3f7ffb3c3..e702e99f8 100644 --- a/src/Renci.SshNet/SshClient.cs +++ b/src/Renci.SshNet/SshClient.cs @@ -60,7 +60,6 @@ public SshClient(ConnectionInfo connectionInfo) /// is . /// is invalid, or is or contains only whitespace characters. /// is not within and . - [SuppressMessage("Microsoft.Reliability", "C2A000:DisposeObjectsBeforeLosingScope", Justification = "Disposed in Dispose(bool) method.")] public SshClient(string host, int port, string username, string password) #pragma warning disable CA2000 // Dispose objects before losing scope : this(new PasswordConnectionInfo(host, port, username, password), ownsConnectionInfo: true) diff --git a/src/Renci.SshNet/SshCommand.cs b/src/Renci.SshNet/SshCommand.cs index 076cb901a..647b041bd 100644 --- a/src/Renci.SshNet/SshCommand.cs +++ b/src/Renci.SshNet/SshCommand.cs @@ -86,9 +86,7 @@ public TimeSpan CommandTimeout /// /// The stream that can be used to transfer data to the command's input stream. /// -#pragma warning disable CA1859 // Use concrete types when possible for improved performance public Stream CreateInputStream() -#pragma warning restore CA1859 // Use concrete types when possible for improved performance { if (_channel == null) { diff --git a/test/Renci.SshNet.Benchmarks/.editorconfig b/test/Renci.SshNet.Benchmarks/.editorconfig index e903a76d8..29255dc30 100644 --- a/test/Renci.SshNet.Benchmarks/.editorconfig +++ b/test/Renci.SshNet.Benchmarks/.editorconfig @@ -4,19 +4,19 @@ # S125: Sections of code should not be commented out https://rules.sonarsource.com/csharp/RSPEC-125/ -dotnet_diagnostic.S125.severity = suggestion +dotnet_diagnostic.S125.severity = silent # S1118: Utility classes should not have public constructors # https://rules.sonarsource.com/csharp/RSPEC-1118/ -dotnet_diagnostic.S1118.severity = suggestion +dotnet_diagnostic.S1118.severity = silent # S1450: Private fields only used as local variables in methods should become local variables # https://rules.sonarsource.com/csharp/RSPEC-1450/ -dotnet_diagnostic.S1450.severity = suggestion +dotnet_diagnostic.S1450.severity = silent # S4144: Methods should not have identical implementations # https://rules.sonarsource.com/csharp/RSPEC-4144/ -dotnet_diagnostic.S4144.severity = suggestion +dotnet_diagnostic.S4144.severity = silent #### SYSLIB diagnostics #### @@ -25,48 +25,68 @@ dotnet_diagnostic.S4144.severity = suggestion # SA1028: Code must not contain trailing whitespace # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md -dotnet_diagnostic.SA1028.severity = suggestion +dotnet_diagnostic.SA1028.severity = silent # SA1414: Tuple types in signatures should have element names https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1414.md -dotnet_diagnostic.SA1414.severity = suggestion +dotnet_diagnostic.SA1414.severity = silent # SA1400: Access modifier must be declared # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1400.md -dotnet_diagnostic.SA1400.severity = suggestion +dotnet_diagnostic.SA1400.severity = silent # SA1401: Fields must be private # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md -dotnet_diagnostic.SA1401.severity = suggestion +dotnet_diagnostic.SA1401.severity = silent # SA1411: Attribute constructor must not use unnecessary parenthesis # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1411.md -dotnet_diagnostic.SA1411.severity = suggestion +dotnet_diagnostic.SA1411.severity = silent # SA1505: Opening braces must not be followed by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1505.md -dotnet_diagnostic.SA1505.severity = suggestion +dotnet_diagnostic.SA1505.severity = silent # SA1512: Single line comments must not be followed by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1512.md -dotnet_diagnostic.SA1512.severity = suggestion +dotnet_diagnostic.SA1512.severity = silent # SA1513: Closing brace must be followed by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md -dotnet_diagnostic.SA1513.severity = suggestion +dotnet_diagnostic.SA1513.severity = silent #### Meziantou.Analyzer rules #### # MA0003: Add parameter name to improve readability # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0003.md -dotnet_diagnostic.MA0003.severity = suggestion +dotnet_diagnostic.MA0003.severity = silent # MA0053: Make class sealed # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0053.md -dotnet_diagnostic.MA0053.severity = suggestion +dotnet_diagnostic.MA0053.severity = silent + +# MA0026: Fix TODO comment +# https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0026.md +dotnet_diagnostic.MA0026.severity = silent #### .NET Compiler Platform analysers rules #### # CA2000: Dispose objects before losing scope # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2000 -dotnet_diagnostic.CA2000.severity = suggestion +dotnet_diagnostic.CA2000.severity = silent + +# IDE0046: Use conditional expression for return +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/style-rules/ide0046 +dotnet_diagnostic.IDE0046.severity = silent + +# IDE0047: Remove unnecessary parentheses +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/style-rules/ide0047-ide0048 +dotnet_diagnostic.IDE0047.severity = silent + +# IDE0032: Use auto-implemented property +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0032 +dotnet_diagnostic.IDE0032.severity = silent + +# CA1515: Consider making public types internal +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/quality-rules/ca1515 +dotnet_diagnostic.CA1515.severity = silent diff --git a/test/Renci.SshNet.Benchmarks/Common/ExtensionsBenchmarks.cs b/test/Renci.SshNet.Benchmarks/Common/ExtensionsBenchmarks.cs index 547c20d6a..8927d72d0 100644 --- a/test/Renci.SshNet.Benchmarks/Common/ExtensionsBenchmarks.cs +++ b/test/Renci.SshNet.Benchmarks/Common/ExtensionsBenchmarks.cs @@ -9,7 +9,7 @@ public class ExtensionsBenchmarks private byte[]? _data; [Params(1000, 10000)] - public int N; + public int N { get; set; } [GlobalSetup] public void Setup() diff --git a/test/Renci.SshNet.IntegrationBenchmarks/.editorconfig b/test/Renci.SshNet.IntegrationBenchmarks/.editorconfig index 9570f2b85..3e3e6d5eb 100644 --- a/test/Renci.SshNet.IntegrationBenchmarks/.editorconfig +++ b/test/Renci.SshNet.IntegrationBenchmarks/.editorconfig @@ -74,3 +74,7 @@ dotnet_diagnostic.CA2000.severity = suggestion # Error CS8892: Method 'TestingPlatformEntryPoint.Main(string[])' will not be used as an entry point because a synchronous entry point 'Program.Main(string[])' was found. # https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/warning-waves#cs8892---method-will-not-be-used-as-an-entry-point-because-a-synchronous-entry-point-method-was-found dotnet_diagnostic.CS8892.severity = suggestion + +# CA1515: Consider making public types internal +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/quality-rules/ca1515 +dotnet_diagnostic.CA1515.severity = silent diff --git a/test/Renci.SshNet.IntegrationTests/.editorconfig b/test/Renci.SshNet.IntegrationTests/.editorconfig index dfeca510a..bd35b7268 100644 --- a/test/Renci.SshNet.IntegrationTests/.editorconfig +++ b/test/Renci.SshNet.IntegrationTests/.editorconfig @@ -4,341 +4,361 @@ # S108: Nested blocks of code should not be left empty # https://rules.sonarsource.com/csharp/RSPEC-108/ -dotnet_diagnostic.S108.severity = none +dotnet_diagnostic.S108.severity = silent # S125: Sections of code should not be commented out # https://rules.sonarsource.com/csharp/RSPEC-125/ -dotnet_diagnostic.S125.severity = none +dotnet_diagnostic.S125.severity = silent # S1118: Utility classes should not have public constructors # https://rules.sonarsource.com/csharp/RSPEC-1118/ -dotnet_diagnostic.S1118.severity = none +dotnet_diagnostic.S1118.severity = silent # S1155: "Any()" should be used to test for emptiness # https://rules.sonarsource.com/csharp/RSPEC-1155/ -dotnet_diagnostic.S1155.severity = none +dotnet_diagnostic.S1155.severity = silent # S1607: Tests should not be ignored # https://rules.sonarsource.com/csharp/RSPEC-1607/ -dotnet_diagnostic.S1607.severity = none +dotnet_diagnostic.S1607.severity = silent # S2925: "Thread.Sleep" should not be used in tests # https://rules.sonarsource.com/csharp/RSPEC-2925/ -dotnet_diagnostic.S2925.severity = none +dotnet_diagnostic.S2925.severity = silent # 53241: Methods should not return values that are never used # https://rules.sonarsource.com/csharp/RSPEC-3241/ -dotnet_diagnostic.S3241.severity = none +dotnet_diagnostic.S3241.severity = silent # S3415: Assertion arguments should be passed in the correct order # https://rules.sonarsource.com/csharp/RSPEC-3415/ -dotnet_diagnostic.S3415.severity = none +dotnet_diagnostic.S3415.severity = silent # S3881: "IDisposable" should be implemented correctly # https://rules.sonarsource.com/csharp/RSPEC-3881/ -dotnet_diagnostic.S3881.severity = none +dotnet_diagnostic.S3881.severity = silent # S3966: Objects should not be disposed more than once # https://rules.sonarsource.com/csharp/RSPEC-3966/ -dotnet_diagnostic.S3966.severity = none +dotnet_diagnostic.S3966.severity = silent # S4144: Methods should not have identical implementations # https://rules.sonarsource.com/csharp/RSPEC-4144/ -dotnet_diagnostic.S4144.severity = none +dotnet_diagnostic.S4144.severity = silent # S6602: "Find" method should be used instead of the "FirstOrDefault" extension # https://rules.sonarsource.com/csharp/RSPEC-6602/ -dotnet_diagnostic.S6602.severity = none +dotnet_diagnostic.S6602.severity = silent # S6610: "StartsWith" and "EndsWith" overloads that take a "char" should be used instead of the ones that take a "string" # https://rules.sonarsource.com/csharp/RSPEC-6610/ -dotnet_diagnostic.S6610.severity = none +dotnet_diagnostic.S6610.severity = silent #### SYSLIB diagnostics #### # SYSLIB1045: Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time # # TODO: Remove this when https://github.com/sshnet/SSH.NET/issues/1131 is implemented. -dotnet_diagnostic.SYSLIB1045.severity = none +dotnet_diagnostic.SYSLIB1045.severity = silent ### StyleCop Analyzers rules ### # SA1000: Keywords must be spaced correctly # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1000.md -dotnet_diagnostic.SA1000.severity = suggestion +dotnet_diagnostic.SA1000.severity = silent # SA1004: Documentation lines must begin with single space # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1004.md -dotnet_diagnostic.SA1004.severity = suggestion +dotnet_diagnostic.SA1004.severity = silent # SA1005: Single line comments must begin with single space # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1005.md -dotnet_diagnostic.SA1005.severity = suggestion +dotnet_diagnostic.SA1005.severity = silent # SA1012: Opening braces must be spaced correctly # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1012.md -dotnet_diagnostic.SA1012.severity = suggestion +dotnet_diagnostic.SA1012.severity = silent # SA1025: Code must not contain multiple whitespace in a row # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1025.md -dotnet_diagnostic.SA1025.severity = suggestion +dotnet_diagnostic.SA1025.severity = silent # SA1028: Code must not contain trailing whitespace # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md -dotnet_diagnostic.SA1028.severity = suggestion +dotnet_diagnostic.SA1028.severity = silent # SA1111: Closing parenthesis must be on line of last parameter # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1111.md -dotnet_diagnostic.SA1111.severity = suggestion +dotnet_diagnostic.SA1111.severity = silent # SA1117: Parameters must be on same line or separate lines # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1117.md -dotnet_diagnostic.SA1117.severity = suggestion +dotnet_diagnostic.SA1117.severity = silent # SA1119: Statement must not use unnecessary parenthesis # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1119.md -dotnet_diagnostic.SA1119.severity = suggestion +dotnet_diagnostic.SA1119.severity = silent # SA1122: Use String.Empty for empty strings # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1122.md -dotnet_diagnostic.SA1122.severity = suggestion +dotnet_diagnostic.SA1122.severity = silent # SA1123:Do not place regions within elements # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1123.md -dotnet_diagnostic.SA1123.severity = suggestion +dotnet_diagnostic.SA1123.severity = silent # SA1130: Use lambda syntax # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1130.md -dotnet_diagnostic.SA1130.severity = suggestion +dotnet_diagnostic.SA1130.severity = silent # SA1133: Do not combine attributes # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1133.md -dotnet_diagnostic.SA1133.severity = suggestion +dotnet_diagnostic.SA1133.severity = silent # SA1203: Constants must appear before fields # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md -dotnet_diagnostic.SA1203.severity = suggestion +dotnet_diagnostic.SA1203.severity = silent # SA1204: Static elements must appear before instance elements # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1204.md -dotnet_diagnostic.SA1204.severity = suggestion +dotnet_diagnostic.SA1204.severity = silent # SA1400: Access modifier must be declared # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1400.md -dotnet_diagnostic.SA1400.severity = suggestion +dotnet_diagnostic.SA1400.severity = silent # SA1401: Fields must be private # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md -dotnet_diagnostic.SA1401.severity = suggestion +dotnet_diagnostic.SA1401.severity = silent # SA1411: Attribute constructor must not use unnecessary parenthesis # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1411.md -dotnet_diagnostic.SA1411.severity = suggestion +dotnet_diagnostic.SA1411.severity = silent # SA1505: Opening braces must not be followed by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1505.md -dotnet_diagnostic.SA1505.severity = suggestion +dotnet_diagnostic.SA1505.severity = silent # SA1507: Code must not contain multiple blank lines in a row # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md -dotnet_diagnostic.SA1507.severity = suggestion +dotnet_diagnostic.SA1507.severity = silent # SA1508: Closing braces must not be preceded by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1508.md -dotnet_diagnostic.SA1508.severity = suggestion +dotnet_diagnostic.SA1508.severity = silent # SA1510: Chained statement blocks must not be preceded by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1510.md -dotnet_diagnostic.SA1510.severity = suggestion +dotnet_diagnostic.SA1510.severity = silent # SA1512: Single line comments must not be followed by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1512.md -dotnet_diagnostic.SA1512.severity = suggestion +dotnet_diagnostic.SA1512.severity = silent # SA1513: Closing brace must be followed by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md -dotnet_diagnostic.SA1513.severity = suggestion +dotnet_diagnostic.SA1513.severity = silent # SA1514: Element documentation header must be preceded by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1514.md -dotnet_diagnostic.SA1514.severity = suggestion +dotnet_diagnostic.SA1514.severity = silent # SA1515: Single line comment must be preceded by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1515.md -dotnet_diagnostic.SA1515.severity = suggestion +dotnet_diagnostic.SA1515.severity = silent # SA1517: Code must not contain blank lines at start of file # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1517.md -dotnet_diagnostic.SA1517.severity = suggestion +dotnet_diagnostic.SA1517.severity = silent # SA1518: Use line endings correctly at end of file https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1518.md -dotnet_diagnostic.SA1518.severity = suggestion +dotnet_diagnostic.SA1518.severity = silent # SA1626: Single line comments must not use documentation style slashes https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1626.md -dotnet_diagnostic.SA1626.severity = suggestion +dotnet_diagnostic.SA1626.severity = silent #### Meziantou.Analyzer rules #### # MA0001: StringComparison is missing # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0001.md -dotnet_diagnostic.MA0001.severity = suggestion +dotnet_diagnostic.MA0001.severity = silent # MA0003: Add parameter name to improve readability # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0003.md -dotnet_diagnostic.MA0003.severity = suggestion +dotnet_diagnostic.MA0003.severity = silent # MA0004: Use Task.ConfigureAwait(false) # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0004.md -dotnet_diagnostic.MA0004.severity = suggestion +dotnet_diagnostic.MA0004.severity = silent # MA0011: IFormatProvider is missing # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0011.md -dotnet_diagnostic.MA0011.severity = suggestion +dotnet_diagnostic.MA0011.severity = silent # MA0042: Do not use blocking calls in an async method # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0042.md -dotnet_diagnostic.MA0042.severity = suggestion +dotnet_diagnostic.MA0042.severity = silent # MA0043: Use nameof operator in ArgumentException # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0043.md -dotnet_diagnostic.MA0043.severity = suggestion +dotnet_diagnostic.MA0043.severity = silent # MA0046: Use EventHandler to declare events # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0046.md -dotnet_diagnostic.MA0046.severity = suggestion +dotnet_diagnostic.MA0046.severity = silent # MA0053: Make class sealed # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0053.md -dotnet_diagnostic.MA0053.severity = suggestion +dotnet_diagnostic.MA0053.severity = silent # MA0060: The value returned by Stream.Read/Stream.ReadAsync is not used # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0060.md -dotnet_diagnostic.MA0060.severity = suggestion +dotnet_diagnostic.MA0060.severity = silent # MA0074: Avoid implicit culture-sensitive methods # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0074.md -dotnet_diagnostic.MA0074.severity = suggestion +dotnet_diagnostic.MA0074.severity = silent # MA0075: Do not use implicit culture-sensitive ToString # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0075.md -dotnet_diagnostic.MA0075.severity = suggestion +dotnet_diagnostic.MA0075.severity = silent # MA0076: Do not use implicit culture-sensitive ToString in interpolated strings # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0076.md -dotnet_diagnostic.MA0076.severity = suggestion +dotnet_diagnostic.MA0076.severity = silent # MA0099 - Use Explicit enum value instead of 0 # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0099.md -dotnet_diagnostic.MA0099.severity = suggestion +dotnet_diagnostic.MA0099.severity = silent # MA0101: String contains an implicit end of line character # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0101.md -dotnet_diagnostic.MA0101.severity = suggestion +dotnet_diagnostic.MA0101.severity = silent # MA0110: Use the Regex source generator # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0110.md -dotnet_diagnostic.MA0110.severity = suggestion +dotnet_diagnostic.MA0110.severity = silent + +# MA0026: Fix TODO comment +# https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0026.md +dotnet_diagnostic.MA0026.severity = silent + +# MA0089: Optimize string method usage +# https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0089.md +dotnet_diagnostic.MA0089.severity = silent #### .NET Compiler Platform analysers rules #### # CA1031: Do not catch general exception types # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1031 -dotnet_diagnostic.CA1031.severity = suggestion +dotnet_diagnostic.CA1031.severity = silent # CA1052: Static holder types should be Static or NotInheritable # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1052 -dotnet_diagnostic.CA1052.severity = suggestion +dotnet_diagnostic.CA1052.severity = silent # CA1062: Validate arguments of public methods # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1062 -dotnet_diagnostic.CA1062.severity = suggestion +dotnet_diagnostic.CA1062.severity = silent # CA1063: Implement IDisposable correctly # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1063 -dotnet_diagnostic.CA1063.severity = suggestion +dotnet_diagnostic.CA1063.severity = silent # CA1307: Specify StringComparison for clarity # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1307 -dotnet_diagnostic.CA1307.severity = suggestion +dotnet_diagnostic.CA1307.severity = silent # CA1310: Specify StringComparison for correctness # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1310 -dotnet_diagnostic.CA1310.severity = suggestion +dotnet_diagnostic.CA1310.severity = silent # CA1507: Use nameof in place of string # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1507 -dotnet_diagnostic.CA1507.severity = suggestion +dotnet_diagnostic.CA1507.severity = silent # CA1827: Do not use Count()/LongCount() when Any() can be used # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1827 -dotnet_diagnostic.CA1827.severity = suggestion +dotnet_diagnostic.CA1827.severity = silent -# CA1812: Avoid uninstantiated internal classes -# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1812 -dotnet_diagnostic.CA1812.severity = suggestion +# CA1515: Consider making public types internal +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/quality-rules/ca1515 +dotnet_diagnostic.CA1515.severity = silent # CA1816: Call GC.SuppressFinalize correctly # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1816 -dotnet_diagnostic.CA1816.severity = suggestion +dotnet_diagnostic.CA1816.severity = silent # CA1822: Mark members as static # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1822 -dotnet_diagnostic.CA1822.severity = suggestion +dotnet_diagnostic.CA1822.severity = silent # CA1840: Use Environment.CurrentManagedThreadId instead of Thread.CurrentThread.ManagedThreadId # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1840 -dotnet_diagnostic.CA1840.severity = suggestion +dotnet_diagnostic.CA1840.severity = silent # CA1851: Possible multiple enumerations of IEnumerable collection # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1851 -dotnet_diagnostic.CA1851.severity = suggestion +dotnet_diagnostic.CA1851.severity = silent # CA1859: Use concrete types when possible for improved performance # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1859 -dotnet_diagnostic.CA1859.severity = suggestion +dotnet_diagnostic.CA1859.severity = silent # CA2000: Dispose objects before losing scope # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2000 -dotnet_diagnostic.CA2000.severity = suggestion +dotnet_diagnostic.CA2000.severity = silent # CA2007: Do not directly await a Task # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2007 -dotnet_diagnostic.CA2007.severity = suggestion +dotnet_diagnostic.CA2007.severity = silent # CA2008: Do not create tasks without passing a TaskScheduler # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2008 -dotnet_diagnostic.CA2008.severity = suggestion +dotnet_diagnostic.CA2008.severity = silent # CA2201: Do not raise reserved exception types # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2201 -dotnet_diagnostic.CA2201.severity = suggestion +dotnet_diagnostic.CA2201.severity = silent # CA2213: Disposable fields should be disposed # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2213 -dotnet_diagnostic.CA2213.severity = suggestion +dotnet_diagnostic.CA2213.severity = silent # CA2234: Pass System.Uri objects instead of strings # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2234 -dotnet_diagnostic.CA2234.severity = suggestion +dotnet_diagnostic.CA2234.severity = silent # IDE0007: Use var instead of explicit type # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0007 -dotnet_diagnostic.IDE0007.severity = suggestion +dotnet_diagnostic.IDE0007.severity = silent # IDE0028: Use collection initializers # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0028 -dotnet_diagnostic.IDE0028.severity = suggestion +dotnet_diagnostic.IDE0028.severity = silent # IDE0058: Remove unnecessary expression value # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0058 -dotnet_diagnostic.IDE0058.severity = suggestion +dotnet_diagnostic.IDE0058.severity = silent # IDE0059: Remove unnecessary value assignment # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0059 -dotnet_diagnostic.IDE0059.severity = suggestion +dotnet_diagnostic.IDE0059.severity = silent # IDE0230: Use UTF-8 string literal # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0230 -dotnet_diagnostic.IDE0230.severity = suggestion +dotnet_diagnostic.IDE0230.severity = silent + +# IDE0046: Use conditional expression for return +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/style-rules/ide0046 +dotnet_diagnostic.IDE0046.severity = silent + +# IDE0047: Remove unnecessary parentheses +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/style-rules/ide0047-ide0048 +dotnet_diagnostic.IDE0047.severity = silent + +# IDE0032: Use auto-implemented property +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0032 +dotnet_diagnostic.IDE0032.severity = silent diff --git a/test/Renci.SshNet.TestTools.OpenSSH/.editorconfig b/test/Renci.SshNet.TestTools.OpenSSH/.editorconfig index 15b989dbb..f09ad6339 100644 --- a/test/Renci.SshNet.TestTools.OpenSSH/.editorconfig +++ b/test/Renci.SshNet.TestTools.OpenSSH/.editorconfig @@ -6,18 +6,34 @@ # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0001.md # # TODO: Re-enable when issues are fixed -dotnet_diagnostic.MA0001.severity = suggestion +dotnet_diagnostic.MA0001.severity = silent # MA0110: Use the Regex source generator # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0110.md -dotnet_diagnostic.MA0110.severity = none +dotnet_diagnostic.MA0110.severity = silent + +# MA0026: Fix TODO comment +# https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0026.md +dotnet_diagnostic.MA0026.severity = silent #### .NET Compiler Platform analysers rules #### # CA1307: Specify StringComparison for clarity # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1307 -dotnet_diagnostic.CA1307.severity = none +dotnet_diagnostic.CA1307.severity = silent # CA1822: Mark members as static # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1822 -dotnet_code_quality.CA1822.api_surface = none +dotnet_diagnostic.CA1822.severity = silent + +# IDE0046: Use conditional expression for return +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/style-rules/ide0046 +dotnet_diagnostic.IDE0046.severity = silent + +# IDE0047: Remove unnecessary parentheses +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/style-rules/ide0047-ide0048 +dotnet_diagnostic.IDE0047.severity = silent + +# IDE0032: Use auto-implemented property +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0032 +dotnet_diagnostic.IDE0032.severity = silent diff --git a/test/Renci.SshNet.Tests/.editorconfig b/test/Renci.SshNet.Tests/.editorconfig index aa6a9ba37..2e0c27477 100644 --- a/test/Renci.SshNet.Tests/.editorconfig +++ b/test/Renci.SshNet.Tests/.editorconfig @@ -4,381 +4,401 @@ # S108: Nested blocks of code should not be left empty # https://rules.sonarsource.com/csharp/RSPEC-108/ -dotnet_diagnostic.S108.severity = suggestion +dotnet_diagnostic.S108.severity = silent # S125: Sections of code should not be commented out # https://rules.sonarsource.com/csharp/RSPEC-125/ -dotnet_diagnostic.S125.severity = none +dotnet_diagnostic.S125.severity = silent # S1144: Unused private types or members should be removed # https://rules.sonarsource.com/csharp/RSPEC-1144/ -dotnet_diagnostic.S1144.severity = none +dotnet_diagnostic.S1144.severity = silent # S1186: Methods should not be empty # https://rules.sonarsource.com/csharp/RSPEC-1186/ -dotnet_diagnostic.S1186.severity = none +dotnet_diagnostic.S1186.severity = silent # S1607: Tests should not be ignored # https://rules.sonarsource.com/csharp/RSPEC-1607/ -dotnet_diagnostic.S1607.severity = none +dotnet_diagnostic.S1607.severity = silent # S2094: Classes should not be empty # https://rules.sonarsource.com/csharp/RSPEC-2094/ -dotnet_diagnostic.S2094.severity = none +dotnet_diagnostic.S2094.severity = silent # S2187: Test classes should contain at least one test case # https://rules.sonarsource.com/csharp/RSPEC-2187/ -dotnet_diagnostic.S2187.severity = none +dotnet_diagnostic.S2187.severity = silent # S2292: Trivial properties should be auto-implemented # https://rules.sonarsource.com/csharp/RSPEC-2292/ -dotnet_diagnostic.S2292.severity = none +dotnet_diagnostic.S2292.severity = silent # S2925: "Thread.Sleep" should not be used in tests # https://rules.sonarsource.com/csharp/RSPEC-2925/ -dotnet_diagnostic.S2925.severity = none +dotnet_diagnostic.S2925.severity = silent # S3415: Assertion arguments should be passed in the correct order # https://rules.sonarsource.com/csharp/RSPEC-3415/ -dotnet_diagnostic.S3415.severity = none +dotnet_diagnostic.S3415.severity = silent # S3881: "IDisposable" should be implemented correctly # https://rules.sonarsource.com/csharp/RSPEC-3881/ -dotnet_diagnostic.S3881.severity = none +dotnet_diagnostic.S3881.severity = silent # S4144: Methods should not have identical implementations # https://rules.sonarsource.com/csharp/RSPEC-4144/ -dotnet_diagnostic.S4144.severity = none +dotnet_diagnostic.S4144.severity = silent # S4158: Empty collections should not be accessed or iterated # https://rules.sonarsource.com/csharp/RSPEC-4158/ -dotnet_diagnostic.S4158.severity = none +dotnet_diagnostic.S4158.severity = silent #### SYSLIB diagnostics #### # SYSLIB1045: Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time # # TODO: Remove this when https://github.com/sshnet/SSH.NET/issues/1131 is implemented. -dotnet_diagnostic.SYSLIB1045.severity = none +dotnet_diagnostic.SYSLIB1045.severity = silent ### StyleCop Analyzers rules ### # SA1000: Keywords must be spaced correctly # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1000.md -dotnet_diagnostic.SA1000.severity = suggestion +dotnet_diagnostic.SA1000.severity = silent # SA1001: Commas must be spaced correctly # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md -dotnet_diagnostic.SA1001.severity = suggestion +dotnet_diagnostic.SA1001.severity = silent # SA1002: Semicolons must be spaced correctly # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1002.md -dotnet_diagnostic.SA1002.severity = suggestion +dotnet_diagnostic.SA1002.severity = silent # SA1004: Documentation lines must begin with single space # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1004.md -dotnet_diagnostic.SA1004.severity = suggestion +dotnet_diagnostic.SA1004.severity = silent # SA1005: Single line comments must begin with single space # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1005.md -dotnet_diagnostic.SA1005.severity = suggestion +dotnet_diagnostic.SA1005.severity = silent # SA1012: Opening braces must be spaced correctly # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1012.md -dotnet_diagnostic.SA1012.severity = suggestion +dotnet_diagnostic.SA1012.severity = silent # SA1013: Closing braces must be spaced correctly # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1013.md -dotnet_diagnostic.SA1013.severity = suggestion +dotnet_diagnostic.SA1013.severity = silent # SA1025: Code must not contain multiple whitespace in a row # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1025.md -dotnet_diagnostic.SA1025.severity = suggestion +dotnet_diagnostic.SA1025.severity = silent # SA1026: Code must not contain space after new keyword in implicitly typed array allocation # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1026.md -dotnet_diagnostic.SA1026.severity = suggestion +dotnet_diagnostic.SA1026.severity = silent # SA1028: Code must not contain trailing whitespace # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md -dotnet_diagnostic.SA1028.severity = suggestion +dotnet_diagnostic.SA1028.severity = silent # SA1111: Closing parenthesis must be on line of last parameter # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1111.md -dotnet_diagnostic.SA1111.severity = suggestion +dotnet_diagnostic.SA1111.severity = silent # SA1117: Parameters must be on same line or separate lines # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md -dotnet_diagnostic.SA1117.severity = suggestion +dotnet_diagnostic.SA1117.severity = silent # SA1119: Statement must not use unnecessary parenthesis # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1119.md -dotnet_diagnostic.SA1119.severity = suggestion +dotnet_diagnostic.SA1119.severity = silent # SA1120: Comments must contain text # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1120.md -dotnet_diagnostic.SA1120.severity = suggestion +dotnet_diagnostic.SA1120.severity = silent # SA1122: Use String.Empty for empty strings # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1122.md -dotnet_diagnostic.SA1122.severity = suggestion +dotnet_diagnostic.SA1122.severity = silent # SA1123:Do not place regions within elements # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1123.md -dotnet_diagnostic.SA1123.severity = suggestion +dotnet_diagnostic.SA1123.severity = silent # SA1124: Do not use regions # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1124.md -dotnet_diagnostic.SA1124.severity = suggestion +dotnet_diagnostic.SA1124.severity = silent # SA1128: Constructor initializer must be on own line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1128.md -dotnet_diagnostic.SA1128.severity = suggestion +dotnet_diagnostic.SA1128.severity = silent # SA1129: Do not use default value type constructor # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1129.md -dotnet_diagnostic.SA1129.severity = suggestion +dotnet_diagnostic.SA1129.severity = silent # SA1133: Do not combine attributes # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1133.md -dotnet_diagnostic.SA1133.severity = suggestion +dotnet_diagnostic.SA1133.severity = silent # SA1137: Elements should have the same indentation # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1137.md -dotnet_diagnostic.SA1137.severity = suggestion +dotnet_diagnostic.SA1137.severity = silent # SA1139: Use literals suffix notation instead of casting # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1139.md -dotnet_diagnostic.SA1139.severity = suggestion +dotnet_diagnostic.SA1139.severity = silent # SA1204: Static elements must appear before instance elements # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1204.md -dotnet_diagnostic.SA1204.severity = suggestion +dotnet_diagnostic.SA1204.severity = silent # SA1208: System using directives must be placed before other using directives # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1208.md -dotnet_diagnostic.SA1208.severity = suggestion +dotnet_diagnostic.SA1208.severity = silent # SA1210: Using directives must be ordered alphabetically by namespace # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1210.md -dotnet_diagnostic.SA1210.severity = suggestion +dotnet_diagnostic.SA1210.severity = silent # SA1214: Readonly elements must appear before non-readonly elements # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1214.md -dotnet_diagnostic.SA1214.severity = suggestion +dotnet_diagnostic.SA1214.severity = silent # SA1306: Field names must begin with lower case letter # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1306.md -dotnet_diagnostic.SA1306.severity = suggestion +dotnet_diagnostic.SA1306.severity = silent # SA1310: Field names must not contain underscore # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1310.md -dotnet_diagnostic.SA1310.severity = suggestion +dotnet_diagnostic.SA1310.severity = silent # SA1400: Access modifier must be declared # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1400.md -dotnet_diagnostic.SA1400.severity = suggestion +dotnet_diagnostic.SA1400.severity = silent # SA1401: Fields must be private # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md -dotnet_diagnostic.SA1401.severity = suggestion +dotnet_diagnostic.SA1401.severity = silent # SA1402: File may only contain a single type # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1402.md -dotnet_diagnostic.SA1402.severity = suggestion +dotnet_diagnostic.SA1402.severity = silent # SA1404: Code analysis suppression must have justification # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1404.md -dotnet_diagnostic.SA1404.severity = suggestion +dotnet_diagnostic.SA1404.severity = silent # SA1411: Attribute constructor must not use unnecessary parenthesis # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1411.md -dotnet_diagnostic.SA1411.severity = suggestion +dotnet_diagnostic.SA1411.severity = silent # SA1500: Braces for multiline statements must not share line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1500.md -dotnet_diagnostic.SA1500.severity = suggestion +dotnet_diagnostic.SA1500.severity = silent # SA1501: Statement must not be on single line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1501.md -dotnet_diagnostic.SA1501.severity = suggestion +dotnet_diagnostic.SA1501.severity = silent # SA1505: Opening braces must not be followed by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1505.md -dotnet_diagnostic.SA1505.severity = suggestion +dotnet_diagnostic.SA1505.severity = silent # SA1507: Code must not contain multiple blank lines in a row # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md -dotnet_diagnostic.SA1507.severity = suggestion +dotnet_diagnostic.SA1507.severity = silent # SA1508: Closing braces must not be preceded by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1508.md -dotnet_diagnostic.SA1508.severity = suggestion +dotnet_diagnostic.SA1508.severity = silent # SA1512: Single line comments must not be followed by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1512.md -dotnet_diagnostic.SA1512.severity = suggestion +dotnet_diagnostic.SA1512.severity = silent # SA1513: Closing brace must be followed by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md -dotnet_diagnostic.SA1513.severity = suggestion +dotnet_diagnostic.SA1513.severity = silent # SA1515: Single line comment must be preceded by blank line # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1515.md -dotnet_diagnostic.SA1515.severity = suggestion +dotnet_diagnostic.SA1515.severity = silent # SA1518: Use line endings correctly at end of file https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1518.md -dotnet_diagnostic.SA1518.severity = suggestion +dotnet_diagnostic.SA1518.severity = silent # SA1636: File header copyright text must match https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1636.md -dotnet_diagnostic.SA1636.severity = suggestion +dotnet_diagnostic.SA1636.severity = silent # SA1642: Constructor summary documentation must begin with standard text # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1642.md -dotnet_diagnostic.SA1642.severity = suggestion +dotnet_diagnostic.SA1642.severity = silent # SA1649: File name must match type name https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1649.md -dotnet_diagnostic.SA1649.severity = suggestion +dotnet_diagnostic.SA1649.severity = silent #### Meziantou.Analyzer rules #### # MA0001: StringComparison is missing # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0001.md -dotnet_diagnostic.MA0001.severity = suggestion +dotnet_diagnostic.MA0001.severity = silent # MA0003: Add parameter name to improve readability # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0003.md -dotnet_diagnostic.MA0003.severity = suggestion +dotnet_diagnostic.MA0003.severity = silent # MA0004: Use Task.ConfigureAwait(false) # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0004.md -dotnet_diagnostic.MA0004.severity = suggestion +dotnet_diagnostic.MA0004.severity = silent # MA0005: Use Array.Empty() # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0005.md -dotnet_diagnostic.MA0005.severity = suggestion +dotnet_diagnostic.MA0005.severity = silent # MA0011: IFormatProvider is missing # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0011.md -dotnet_diagnostic.MA0011.severity = suggestion +dotnet_diagnostic.MA0011.severity = silent # MA0015: Specify the parameter name in ArgumentException # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0015.md -dotnet_diagnostic.MA0015.severity = suggestion +dotnet_diagnostic.MA0015.severity = silent # MA0019: Use EventArgs.Empty # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0019.md -dotnet_diagnostic.MA0019.severity = suggestion +dotnet_diagnostic.MA0019.severity = silent # MA0035: Do not use dangerous threading methods # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0035.md -dotnet_diagnostic.MA0035.severity = suggestion +dotnet_diagnostic.MA0035.severity = silent # MA0040: Forward the CancellationToken parameter to methods that take one # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0040.md -dotnet_diagnostic.MA0040.severity = suggestion +dotnet_diagnostic.MA0040.severity = silent # MA0046: Use EventHandler to declare events # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0046.md -dotnet_diagnostic.MA0046.severity = suggestion +dotnet_diagnostic.MA0046.severity = silent # MA0053: Make class sealed # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0053.md -dotnet_diagnostic.MA0053.severity = suggestion +dotnet_diagnostic.MA0053.severity = silent # MA0060: The value returned by Stream.Read/Stream.ReadAsync is not used # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0060.md -dotnet_diagnostic.MA0060.severity = suggestion +dotnet_diagnostic.MA0060.severity = silent # MA0075: Do not use implicit culture-sensitive ToString # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0075.md -dotnet_diagnostic.MA0075.severity = suggestion +dotnet_diagnostic.MA0075.severity = silent # MA0099 - Use Explicit enum value instead of 0 # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0099.md -dotnet_diagnostic.MA0099.severity = suggestion +dotnet_diagnostic.MA0099.severity = silent # MA0110: Use the Regex source generator # https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0110.md -dotnet_diagnostic.MA0110.severity = suggestion +dotnet_diagnostic.MA0110.severity = silent + +# MA0026: Fix TODO comment +# https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0026.md +dotnet_diagnostic.MA0026.severity = silent #### .NET Compiler Platform analysers rules #### # CA1031: Do not catch general exception types # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1031 -dotnet_diagnostic.CA1031.severity = suggestion +dotnet_diagnostic.CA1031.severity = silent # CA1062: Validate arguments of public methods # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1062 -dotnet_diagnostic.CA1062.severity = suggestion +dotnet_diagnostic.CA1062.severity = silent # CA1063: Implement IDisposable correctly # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1063 -dotnet_diagnostic.CA1063.severity = suggestion +dotnet_diagnostic.CA1063.severity = silent # CA1307: Specify StringComparison for clarity https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1307 -dotnet_diagnostic.CA1307.severity = suggestion +dotnet_diagnostic.CA1307.severity = silent # CA1806: Do not ignore method results # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1806 -dotnet_diagnostic.CA1806.severity = suggestion +dotnet_diagnostic.CA1806.severity = silent -# CA1812: Avoid uninstantiated internal classes -# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1812 -dotnet_diagnostic.CA1812.severity = suggestion +# CA1515: Consider making public types internal +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/quality-rules/ca1515 +dotnet_diagnostic.CA1515.severity = silent # CA1822: Mark members as static # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1822 -dotnet_diagnostic.CA1822.severity = suggestion +dotnet_diagnostic.CA1822.severity = silent # CA1825: Avoid zero-length array allocations # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1825 -dotnet_diagnostic.CA1825.severity = suggestion +dotnet_diagnostic.CA1825.severity = silent # CA1859: Use concrete types when possible for improved performance # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1859 -dotnet_diagnostic.CA1859.severity = suggestion +dotnet_diagnostic.CA1859.severity = silent # CA2000: Dispose objects before losing scope # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2000 -dotnet_diagnostic.CA2000.severity = suggestion +dotnet_diagnostic.CA2000.severity = silent # CA2007: Do not directly await a Task # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2007 -dotnet_diagnostic.CA2007.severity = suggestion +dotnet_diagnostic.CA2007.severity = silent # CA2201: Do not raise reserved exception types # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2201 -dotnet_diagnostic.CA2201.severity = suggestion +dotnet_diagnostic.CA2201.severity = silent # CA2213: Disposable fields should be disposed # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2213 -dotnet_diagnostic.CA2213.severity = suggestion +dotnet_diagnostic.CA2213.severity = silent # CA2227: Collection properties should be read only # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2227 -dotnet_diagnostic.CA2227.severity = suggestion +dotnet_diagnostic.CA2227.severity = silent # IDE0007: Use var instead of explicit type # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0007 -dotnet_diagnostic.IDE0007.severity = suggestion +dotnet_diagnostic.IDE0007.severity = silent # IDE0028: Use collection initializers # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0028 -dotnet_diagnostic.IDE0028.severity = suggestion +dotnet_diagnostic.IDE0028.severity = silent # IDE0058: Remove unnecessary expression value # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0058 -dotnet_diagnostic.IDE0058.severity = suggestion +dotnet_diagnostic.IDE0058.severity = silent # IDE0059: Remove unnecessary value assignment # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0059 -dotnet_diagnostic.IDE0059.severity = suggestion +dotnet_diagnostic.IDE0059.severity = silent # IDE0230: Use UTF-8 string literal # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0230 -dotnet_diagnostic.IDE0230.severity = suggestion +dotnet_diagnostic.IDE0230.severity = silent + +# IDE0046: Use conditional expression for return +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/style-rules/ide0046 +dotnet_diagnostic.IDE0046.severity = silent + +# IDE0047: Remove unnecessary parentheses +# https://learn.microsoft.com/en-ca/dotnet/fundamentals/code-analysis/style-rules/ide0047-ide0048 +dotnet_diagnostic.IDE0047.severity = silent + +# IDE0032: Use auto-implemented property +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0032 +dotnet_diagnostic.IDE0032.severity = silent + +# CA1812: Avoid uninstantiated internal classes +# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1812 +dotnet_diagnostic.CA1812.severity = silent \ No newline at end of file diff --git a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Concat.cs b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Concat.cs index ad961bfc4..13b1d8eef 100644 --- a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Concat.cs +++ b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Concat.cs @@ -1,12 +1,10 @@ using System; -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Renci.SshNet.Common; namespace Renci.SshNet.Tests.Classes.Common { [TestClass] - [SuppressMessage("ReSharper", "InvokeAsExtensionMethod")] public class ExtensionsTest_Concat { private Random _random; diff --git a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_IsEqualTo_ByteArray.cs b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_IsEqualTo_ByteArray.cs index 8d1d18076..2513aebfb 100644 --- a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_IsEqualTo_ByteArray.cs +++ b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_IsEqualTo_ByteArray.cs @@ -1,12 +1,10 @@ using System; -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Renci.SshNet.Common; namespace Renci.SshNet.Tests.Classes.Common { [TestClass] - [SuppressMessage("ReSharper", "InvokeAsExtensionMethod")] public class ExtensionsTest_IsEqualTo_ByteArray { private Random _random; diff --git a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Pad.cs b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Pad.cs index ba41dfb39..1b933af0c 100644 --- a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Pad.cs +++ b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Pad.cs @@ -1,13 +1,10 @@ -using System.Diagnostics.CodeAnalysis; - -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using Renci.SshNet.Common; namespace Renci.SshNet.Tests.Classes.Common { [TestClass] - [SuppressMessage("ReSharper", "InvokeAsExtensionMethod")] public class ExtensionsTest_Pad { [TestMethod] diff --git a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Reverse.cs b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Reverse.cs index 32727ab75..019924a1a 100644 --- a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Reverse.cs +++ b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Reverse.cs @@ -1,12 +1,10 @@ using System; -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Renci.SshNet.Common; namespace Renci.SshNet.Tests.Classes.Common { [TestClass] - [SuppressMessage("ReSharper", "InvokeAsExtensionMethod")] public class ExtensionsTest_Reverse { [TestMethod] diff --git a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Take_Count.cs b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Take_Count.cs index 05a090611..ea43330d9 100644 --- a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Take_Count.cs +++ b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Take_Count.cs @@ -1,12 +1,10 @@ using System; -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Renci.SshNet.Common; namespace Renci.SshNet.Tests.Classes.Common { [TestClass] - [SuppressMessage("ReSharper", "InvokeAsExtensionMethod")] public class ExtensionsTest_Take_Count { private Random _random; diff --git a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Take_OffsetAndCount.cs b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Take_OffsetAndCount.cs index 137a3c48b..16527bf1c 100644 --- a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Take_OffsetAndCount.cs +++ b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Take_OffsetAndCount.cs @@ -1,12 +1,10 @@ using System; -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Renci.SshNet.Common; namespace Renci.SshNet.Tests.Classes.Common { [TestClass] - [SuppressMessage("ReSharper", "InvokeAsExtensionMethod")] public class ExtensionsTest_Take_OffsetAndCount { private Random _random; diff --git a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_TrimLeadingZeros.cs b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_TrimLeadingZeros.cs index 0aecfbe03..814f80397 100644 --- a/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_TrimLeadingZeros.cs +++ b/test/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_TrimLeadingZeros.cs @@ -1,12 +1,10 @@ using System; -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Renci.SshNet.Common; namespace Renci.SshNet.Tests.Classes.Common { [TestClass] - [SuppressMessage("ReSharper", "InvokeAsExtensionMethod")] public class ExtensionsTest_TrimLeadingZeros { [TestMethod] diff --git a/test/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs b/test/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs index dfd02044a..bcf0d4788 100644 --- a/test/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs +++ b/test/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs @@ -207,7 +207,7 @@ public void Test_PrivateKey_SSH2_Encrypted_ShouldThrowSshExceptionWhenPassphrase } catch (SshException ex) { - Assert.IsInstanceOfType(ex, typeof(SshException)); + Assert.IsInstanceOfType(ex); Assert.IsNull(ex.InnerException); Assert.AreEqual("Invalid passphrase.", ex.Message); } @@ -228,7 +228,7 @@ public void Test_PrivateKey_SSH2_Encrypted_ShouldThrowSshPassPhraseNullOrEmptyEx } catch (SshPassPhraseNullOrEmptyException ex) { - Assert.IsInstanceOfType(ex, typeof(SshPassPhraseNullOrEmptyException)); + Assert.IsInstanceOfType(ex); Assert.IsNull(ex.InnerException); Assert.AreEqual("Private key is encrypted but passphrase is empty.", ex.Message); } @@ -249,7 +249,7 @@ public void Test_PrivateKey_SSH2_Encrypted_ShouldThrowSshPassPhraseNullOrEmptyEx } catch (SshPassPhraseNullOrEmptyException ex) { - Assert.IsInstanceOfType(ex, typeof(SshPassPhraseNullOrEmptyException)); + Assert.IsInstanceOfType(ex); Assert.IsNull(ex.InnerException); Assert.AreEqual("Private key is encrypted but passphrase is empty.", ex.Message); } diff --git a/test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs b/test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs index 3752dfb52..1f116f796 100644 --- a/test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs +++ b/test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs @@ -192,7 +192,9 @@ public void Read_AfterDispose_StillWorks() _channelSessionStub.Receive(Encoding.UTF8.GetBytes("Hello World!")); _shellStream.Dispose(); +#pragma warning disable S3966 // Objects should not be disposed more than once _shellStream.Dispose(); // Check that multiple Dispose is OK. +#pragma warning restore S3966 // Objects should not be disposed more than once Assert.AreEqual("Hello World!", _shellStream.ReadLine()); Assert.IsNull(_shellStream.ReadLine());