Skip to content

Commit 624ee29

Browse files
authored
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
1 parent 6f4c479 commit 624ee29

27 files changed

+35
-70
lines changed

.editorconfig

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,21 @@ csharp_new_line_before_else = true
4444
csharp_new_line_before_catch = true
4545
csharp_new_line_before_finally = true
4646
csharp_new_line_before_members_in_object_initializers = true
47-
csharp_new_line_before_members_in_anonymous_types = true
47+
csharp_new_line_before_members_in_anonymous_types = true
48+
49+
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules
50+
51+
# Avoid unused private fields
52+
dotnet_diagnostic.CA1823.severity = error
53+
54+
# Use string.Contains(char) instead of string.Contains(string) with single characters
55+
dotnet_diagnostic.CA1847.severity = error
56+
57+
# Remove unnecessary import
58+
dotnet_diagnostic.IDE0005.severity = error
59+
60+
# Private member is unused
61+
dotnet_diagnostic.IDE0051.severity = error
62+
63+
# Private member is unread
64+
dotnet_diagnostic.IDE0052.severity = error

Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)\kubernetes-client.ruleset</CodeAnalysisRuleSet>
5+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
6+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
57
</PropertyGroup>
68
</Project>

src/KubernetesClient/Authentication/ExecTokenProvider.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System.Diagnostics;
21
using System.Net.Http.Headers;
32
using System.Threading;
43
using System.Threading.Tasks;
5-
using k8s.Exceptions;
64
using k8s.KubeConfigModels;
75
using k8s.Autorest;
86

src/KubernetesClient/Autorest/BasicAuthenticationCredentials.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using System;
54
using System.Globalization;
65
using System.Net.Http;
76
using System.Net.Http.Headers;

src/KubernetesClient/Autorest/HttpExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Net.Http;
55
using System.Net.Http.Headers;
6-
using System.Text;
76

87
namespace k8s.Autorest
98
{

src/KubernetesClient/Autorest/HttpMessageWrapper.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using System.Collections.Generic;
5-
using System.Linq;
64
using System.Net.Http.Headers;
75

86
namespace k8s.Autorest

src/KubernetesClient/Autorest/HttpOperationException.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using System;
5-
using System.Net.Http;
64
using System.Runtime.Serialization;
7-
using System.Security.Permissions;
85

96
namespace k8s.Autorest
107
{

src/KubernetesClient/Autorest/HttpOperationResponse.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using System;
54
using System.Net.Http;
65

76
namespace k8s.Autorest

src/KubernetesClient/Autorest/HttpRequestMessageWrapper.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using System;
5-
using System.Collections.Generic;
64
using System.Net.Http;
75

86
namespace k8s.Autorest

src/KubernetesClient/Autorest/HttpResponseMessageWrapper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using System;
54
using System.Net;
65
using System.Net.Http;
76

0 commit comments

Comments
 (0)