Enable some of the unnecessary code rules (#799)
* CA1823 Avoid unused private fields * CA1847 Use string.Contains(char) instead of string.Contains(string) with single characters * IDE0005 Remove unnecessary import * IDE0051 Private member is unused * IDE0052 Private member is unread
This commit is contained in:
@@ -45,3 +45,20 @@ csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
|
||||
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules
|
||||
|
||||
# Avoid unused private fields
|
||||
dotnet_diagnostic.CA1823.severity = error
|
||||
|
||||
# Use string.Contains(char) instead of string.Contains(string) with single characters
|
||||
dotnet_diagnostic.CA1847.severity = error
|
||||
|
||||
# Remove unnecessary import
|
||||
dotnet_diagnostic.IDE0005.severity = error
|
||||
|
||||
# Private member is unused
|
||||
dotnet_diagnostic.IDE0051.severity = error
|
||||
|
||||
# Private member is unread
|
||||
dotnet_diagnostic.IDE0052.severity = error
|
||||
@@ -2,5 +2,7 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)\kubernetes-client.ruleset</CodeAnalysisRuleSet>
|
||||
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System.Diagnostics;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.Exceptions;
|
||||
using k8s.KubeConfigModels;
|
||||
using k8s.Autorest;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace k8s.Autorest
|
||||
{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace k8s.Autorest
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace k8s.Autorest
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace k8s.Autorest
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace k8s.Autorest
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace k8s.Autorest
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -5,11 +5,12 @@ using Org.BouncyCastle.OpenSsl;
|
||||
using Org.BouncyCastle.Pkcs;
|
||||
using Org.BouncyCastle.Security;
|
||||
using Org.BouncyCastle.X509;
|
||||
#else
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
#endif
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
|
||||
namespace k8s
|
||||
{
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Security;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Threading;
|
||||
using k8s.Exceptions;
|
||||
|
||||
@@ -31,22 +31,6 @@ namespace k8s
|
||||
|
||||
public HttpClient HttpClient { get; protected set; }
|
||||
|
||||
private IEnumerable<HttpMessageHandler> HttpMessageHandlers
|
||||
{
|
||||
get
|
||||
{
|
||||
var handler = FirstMessageHandler;
|
||||
|
||||
while (handler != null)
|
||||
{
|
||||
yield return handler;
|
||||
|
||||
DelegatingHandler delegating = handler as DelegatingHandler;
|
||||
handler = delegating != null ? delegating.InnerHandler : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the first HTTP handler (which is the start of send HTTP
|
||||
/// pipeline).
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using k8s.Autorest;
|
||||
|
||||
namespace k8s.Models
|
||||
{
|
||||
public class KubernetesList<T> : IMetadata<V1ListMeta>, IItems<T>
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace k8s
|
||||
private readonly Func<Task<TextReader>> _streamReaderCreator;
|
||||
|
||||
private bool disposedValue;
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "IDE0052:Remove unread private members", Justification = "Used in an async task loop")]
|
||||
private readonly Task _watcherLoop;
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using NSwag;
|
||||
using Nustache.Core;
|
||||
|
||||
namespace LibKubernetesGenerator
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Nustache.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ using NSwag;
|
||||
using Nustache.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using NSwag;
|
||||
using Nustache.Core;
|
||||
|
||||
namespace LibKubernetesGenerator
|
||||
{
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System.IO;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using NSwag;
|
||||
using Nustache.Core;
|
||||
|
||||
namespace LibKubernetesGenerator
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using NSwag;
|
||||
using Nustache.Core;
|
||||
|
||||
|
||||
@@ -12,13 +12,6 @@ namespace k8s.Tests
|
||||
{
|
||||
public class StreamDemuxerTests
|
||||
{
|
||||
private readonly ITestOutputHelper testOutput;
|
||||
|
||||
public StreamDemuxerTests(ITestOutputHelper testOutput)
|
||||
{
|
||||
this.testOutput = testOutput;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SendDataRemoteCommand()
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
public class CacheTest
|
||||
{
|
||||
[Fact(DisplayName = "Create default cache success")]
|
||||
private void CreateCacheSuccess()
|
||||
public void CreateCacheSuccess()
|
||||
{
|
||||
var cache = new Cache<V1Node>();
|
||||
cache.Should().NotBeNull();
|
||||
@@ -19,7 +19,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Add cache item success")]
|
||||
private void AddCacheItemSuccess()
|
||||
public void AddCacheItemSuccess()
|
||||
{
|
||||
var aPod = Helpers.CreatePods(1).First();
|
||||
var cache = new Cache<V1Pod>();
|
||||
@@ -30,7 +30,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Update cache item success")]
|
||||
private void UpdateCacheItemSuccess()
|
||||
public void UpdateCacheItemSuccess()
|
||||
{
|
||||
var aPod = Helpers.CreatePods(1).First();
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Delete cache item success")]
|
||||
private void DeleteCacheItemSuccess()
|
||||
public void DeleteCacheItemSuccess()
|
||||
{
|
||||
var aPod = Helpers.CreatePods(1).First();
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Replace cache items success")]
|
||||
private void ReplaceCacheItemsSuccess()
|
||||
public void ReplaceCacheItemsSuccess()
|
||||
{
|
||||
var pods = Helpers.CreatePods(3);
|
||||
var aPod = pods.First();
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
public class ListerTest
|
||||
{
|
||||
[Fact(DisplayName = "Create default lister success")]
|
||||
private void CreateListerDefaultsSuccess()
|
||||
public void CreateListerDefaultsSuccess()
|
||||
{
|
||||
var cache = new Cache<V1Pod>();
|
||||
var lister = new Lister<V1Pod>(cache);
|
||||
@@ -18,7 +18,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "List with null namespace success")]
|
||||
private void ListNullNamespaceSuccess()
|
||||
public void ListNullNamespaceSuccess()
|
||||
{
|
||||
var aPod = Helpers.CreatePods(1).First();
|
||||
var cache = new Cache<V1Pod>();
|
||||
@@ -33,7 +33,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "List with custom namespace success")]
|
||||
private void ListCustomNamespaceSuccess()
|
||||
public void ListCustomNamespaceSuccess()
|
||||
{
|
||||
var aPod = Helpers.CreatePods(1).First();
|
||||
var cache = new Cache<V1Pod>();
|
||||
@@ -48,7 +48,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Get with null namespace success")]
|
||||
private void GetNullNamespaceSuccess()
|
||||
public void GetNullNamespaceSuccess()
|
||||
{
|
||||
var aPod = Helpers.CreatePods(1).First();
|
||||
var cache = new Cache<V1Pod>();
|
||||
@@ -63,7 +63,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Get with custom namespace success")]
|
||||
private void GetCustomNamespaceSuccess()
|
||||
public void GetCustomNamespaceSuccess()
|
||||
{
|
||||
var aPod = Helpers.CreatePods(1).First();
|
||||
var cache = new Cache<V1Pod>();
|
||||
@@ -76,7 +76,7 @@ namespace k8s.Tests.Util.Informer.Cache
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Set custom namespace success")]
|
||||
private void SetCustomNamespaceSuccess()
|
||||
public void SetCustomNamespaceSuccess()
|
||||
{
|
||||
var aPod = Helpers.CreatePods(1).First();
|
||||
var cache = new Cache<V1Pod>();
|
||||
|
||||
Reference in New Issue
Block a user