fix S2325: Methods and properties that don't access instance data should be static

This one is pretty redundant with CA1822 (which is also disabled in the
tests).

It caught a few more cases in the library itself, most of which can't
be changed because they are public API.

https://rules.sonarsource.com/csharp/RSPEC-2325/
This commit is contained in:
Marius Thesing
2024-09-14 10:54:57 +02:00
parent ec3bcc6f3e
commit 2020604958
7 changed files with 20 additions and 1 deletions
@@ -15,6 +15,7 @@
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
using Renci.SshNet.Abstractions;
using System;
using System.Diagnostics;
using System.Security.Cryptography;
@@ -902,7 +903,7 @@ namespace Renci.SshNet.Security.Cryptography
/// <param name="b1"></param>
/// <param name="others"></param>
/// <returns></returns>
private byte[] AppendArrays(byte[] b1, params byte[][] others)
private static byte[] AppendArrays(byte[] b1, params byte[][] others)
{
//from https://stackoverflow.com/questions/46534429/how-to-convert-java-messagedigest-with-two-update-statements-to-c-sharp
int n = b1.Length;
+2
View File
@@ -316,7 +316,9 @@ namespace Renci.SshNet
/// <value>
/// The client version.
/// </value>
#pragma warning disable S2325 // Methods and properties that don't access instance data should be static
public string ClientVersion
#pragma warning restore S2325 // Methods and properties that don't access instance data should be static
{
get
{
+2
View File
@@ -605,7 +605,9 @@ namespace Renci.SshNet
/// <returns>
/// The text available in the shell up to and including the expected expression.
/// </returns>
#pragma warning disable S2325 // Methods and properties that don't access instance data should be static
public string? EndExpect(IAsyncResult asyncResult)
#pragma warning restore S2325 // Methods and properties that don't access instance data should be static
{
return TaskToAsyncResult.End<string?>(asyncResult);
}
@@ -14,6 +14,9 @@ dotnet_diagnostic.S1118.severity = suggestion
# https://rules.sonarsource.com/csharp/RSPEC-1450/
dotnet_diagnostic.S1450.severity = suggestion
# S2325: Methods and properties that don't access instance data should be static
dotnet_diagnostic.S2325.severity = silent
# S4144: Methods should not have identical implementations
# https://rules.sonarsource.com/csharp/RSPEC-4144/
dotnet_diagnostic.S4144.severity = suggestion
@@ -22,6 +22,9 @@ dotnet_diagnostic.S1155.severity = silent
# https://rules.sonarsource.com/csharp/RSPEC-1607/
dotnet_diagnostic.S1607.severity = silent
# S2325: Methods and properties that don't access instance data should be static
dotnet_diagnostic.S2325.severity = silent
# S2925: "Thread.Sleep" should not be used in tests
# https://rules.sonarsource.com/csharp/RSPEC-2925/
dotnet_diagnostic.S2925.severity = silent
@@ -1,5 +1,10 @@
[*.cs]
#### Sonar rules ####
# S2325: Methods and properties that don't access instance data should be static
dotnet_diagnostic.S2325.severity = silent
#### Meziantou.Analyzer rules ####
# MA0001: StringComparison is missing
+3
View File
@@ -34,6 +34,9 @@ dotnet_diagnostic.S2187.severity = silent
# https://rules.sonarsource.com/csharp/RSPEC-2292/
dotnet_diagnostic.S2292.severity = silent
# S2325: Methods and properties that don't access instance data should be static
dotnet_diagnostic.S2325.severity = silent
# S2925: "Thread.Sleep" should not be used in tests
# https://rules.sonarsource.com/csharp/RSPEC-2925/
dotnet_diagnostic.S2925.severity = silent