Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,21 @@ csharp_new_line_before_else = true
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# 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 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -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>
2 changes: 0 additions & 2 deletions src/KubernetesClient/Authentication/ExecTokenProvider.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/KubernetesClient/Autorest/HttpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

namespace k8s.Autorest
{
Expand Down
2 changes: 0 additions & 2 deletions src/KubernetesClient/Autorest/HttpMessageWrapper.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/KubernetesClient/Autorest/HttpOperationException.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
1 change: 0 additions & 1 deletion src/KubernetesClient/Autorest/HttpOperationResponse.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/KubernetesClient/Autorest/HttpRequestMessageWrapper.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
1 change: 0 additions & 1 deletion src/KubernetesClient/Autorest/RestException.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion src/KubernetesClient/Autorest/TokenCredentials.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/KubernetesClient/CertUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
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
{
Expand Down
4 changes: 0 additions & 4 deletions src/KubernetesClient/Kubernetes.ConfigInit.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
16 changes: 0 additions & 16 deletions src/KubernetesClient/Kubernetes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,6 @@ public Uri BaseUri

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).
Expand Down
2 changes: 0 additions & 2 deletions src/KubernetesClient/KubernetesList.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using k8s.Autorest;

namespace k8s.Models
{
public class KubernetesList<T> : IMetadata<V1ListMeta>, IItems<T>
Expand Down
1 change: 1 addition & 0 deletions src/KubernetesClient/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class Watcher<T> : IDisposable
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;


Expand Down
2 changes: 0 additions & 2 deletions src/LibKubernetesGenerator/ApiGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using NSwag;
using Nustache.Core;

namespace LibKubernetesGenerator
{
Expand Down
1 change: 0 additions & 1 deletion src/LibKubernetesGenerator/GeneralNameHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
Expand Down
2 changes: 0 additions & 2 deletions src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Nustache.Core;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;

Expand Down
3 changes: 0 additions & 3 deletions src/LibKubernetesGenerator/ModelExtGenerator.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
2 changes: 0 additions & 2 deletions src/LibKubernetesGenerator/ModelGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.IO;
using Microsoft.CodeAnalysis;
using NSwag;
using Nustache.Core;

namespace LibKubernetesGenerator
{
Expand Down
1 change: 0 additions & 1 deletion src/LibKubernetesGenerator/UtilHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using NSwag;
using Nustache.Core;

Expand Down
7 changes: 0 additions & 7 deletions tests/KubernetesClient.Tests/StreamDemuxerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
10 changes: 5 additions & 5 deletions tests/KubernetesClient.Tests/Util/Informer/Cache/CacheTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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();
cache.GetIndexers().ContainsKey(Caches.NamespaceIndex).Should().BeTrue();
}

[Fact(DisplayName = "Add cache item success")]
private void AddCacheItemSuccess()
public void AddCacheItemSuccess()
{
var aPod = Helpers.CreatePods(1).First();
var cache = new Cache<V1Pod>();
Expand All @@ -30,7 +30,7 @@ private void AddCacheItemSuccess()
}

[Fact(DisplayName = "Update cache item success")]
private void UpdateCacheItemSuccess()
public void UpdateCacheItemSuccess()
{
var aPod = Helpers.CreatePods(1).First();

Expand All @@ -44,7 +44,7 @@ private void UpdateCacheItemSuccess()
}

[Fact(DisplayName = "Delete cache item success")]
private void DeleteCacheItemSuccess()
public void DeleteCacheItemSuccess()
{
var aPod = Helpers.CreatePods(1).First();

Expand All @@ -58,7 +58,7 @@ private void DeleteCacheItemSuccess()
}

[Fact(DisplayName = "Replace cache items success")]
private void ReplaceCacheItemsSuccess()
public void ReplaceCacheItemsSuccess()
{
var pods = Helpers.CreatePods(3);
var aPod = pods.First();
Expand Down
12 changes: 6 additions & 6 deletions tests/KubernetesClient.Tests/Util/Informer/Cache/ListerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -18,7 +18,7 @@ private void CreateListerDefaultsSuccess()
}

[Fact(DisplayName = "List with null namespace success")]
private void ListNullNamespaceSuccess()
public void ListNullNamespaceSuccess()
{
var aPod = Helpers.CreatePods(1).First();
var cache = new Cache<V1Pod>();
Expand All @@ -33,7 +33,7 @@ private void ListNullNamespaceSuccess()
}

[Fact(DisplayName = "List with custom namespace success")]
private void ListCustomNamespaceSuccess()
public void ListCustomNamespaceSuccess()
{
var aPod = Helpers.CreatePods(1).First();
var cache = new Cache<V1Pod>();
Expand All @@ -48,7 +48,7 @@ private void ListCustomNamespaceSuccess()
}

[Fact(DisplayName = "Get with null namespace success")]
private void GetNullNamespaceSuccess()
public void GetNullNamespaceSuccess()
{
var aPod = Helpers.CreatePods(1).First();
var cache = new Cache<V1Pod>();
Expand All @@ -63,7 +63,7 @@ private void GetNullNamespaceSuccess()
}

[Fact(DisplayName = "Get with custom namespace success")]
private void GetCustomNamespaceSuccess()
public void GetCustomNamespaceSuccess()
{
var aPod = Helpers.CreatePods(1).First();
var cache = new Cache<V1Pod>();
Expand All @@ -76,7 +76,7 @@ private void GetCustomNamespaceSuccess()
}

[Fact(DisplayName = "Set custom namespace success")]
private void SetCustomNamespaceSuccess()
public void SetCustomNamespaceSuccess()
{
var aPod = Helpers.CreatePods(1).First();
var cache = new Cache<V1Pod>();
Expand Down