Skip to content

Commit 7baf350

Browse files
committed
fix SA1312 SA1306
1 parent 44ad593 commit 7baf350

File tree

4 files changed

+41
-41
lines changed

4 files changed

+41
-41
lines changed

src/KubernetesClient/Kubernetes.Watch.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public async Task<Watcher<T>> WatchObjectAsync<T>(string path, string @continue
2121
CancellationToken cancellationToken = default(CancellationToken))
2222
{
2323
// Tracing
24-
bool _shouldTrace = ServiceClientTracing.IsEnabled;
25-
string _invocationId = null;
26-
if (_shouldTrace)
24+
bool shouldTrace = ServiceClientTracing.IsEnabled;
25+
string invocationId = null;
26+
if (shouldTrace)
2727
{
28-
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
28+
invocationId = ServiceClientTracing.NextInvocationId.ToString();
2929
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
3030
tracingParameters.Add("path", path);
3131
tracingParameters.Add("continue", @continue);
@@ -36,7 +36,7 @@ public async Task<Watcher<T>> WatchObjectAsync<T>(string path, string @continue
3636
tracingParameters.Add("pretty", pretty);
3737
tracingParameters.Add("timeoutSeconds", timeoutSeconds);
3838
tracingParameters.Add("resourceVersion", resourceVersion);
39-
ServiceClientTracing.Enter(_invocationId, this, nameof(WatchObjectAsync), tracingParameters);
39+
ServiceClientTracing.Enter(invocationId, this, nameof(WatchObjectAsync), tracingParameters);
4040
}
4141

4242
// Construct URL
@@ -124,19 +124,19 @@ public async Task<Watcher<T>> WatchObjectAsync<T>(string path, string @continue
124124
}
125125

126126
// Send Request
127-
if (_shouldTrace)
127+
if (shouldTrace)
128128
{
129-
ServiceClientTracing.SendRequest(_invocationId, httpRequest);
129+
ServiceClientTracing.SendRequest(invocationId, httpRequest);
130130
}
131131

132132
cancellationToken.ThrowIfCancellationRequested();
133133
var httpResponse = await HttpClient
134134
.SendAsync(httpRequest, HttpCompletionOption.ResponseHeadersRead, cancellationToken)
135135
.ConfigureAwait(false);
136136

137-
if (_shouldTrace)
137+
if (shouldTrace)
138138
{
139-
ServiceClientTracing.ReceiveResponse(_invocationId, httpResponse);
139+
ServiceClientTracing.ReceiveResponse(invocationId, httpResponse);
140140
}
141141

142142
cancellationToken.ThrowIfCancellationRequested();

src/KubernetesClient/Kubernetes.WebSocket.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public virtual Task<WebSocket> WebSocketNamespacedPodExecAsync(string name, stri
9090
}
9191

9292
// Tracing
93-
bool _shouldTrace = ServiceClientTracing.IsEnabled;
94-
string _invocationId = null;
95-
if (_shouldTrace)
93+
bool shouldTrace = ServiceClientTracing.IsEnabled;
94+
string invocationId = null;
95+
if (shouldTrace)
9696
{
97-
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
97+
invocationId = ServiceClientTracing.NextInvocationId.ToString();
9898
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
9999
tracingParameters.Add("command", command);
100100
tracingParameters.Add("container", container);
@@ -106,7 +106,7 @@ public virtual Task<WebSocket> WebSocketNamespacedPodExecAsync(string name, stri
106106
tracingParameters.Add("tty", tty);
107107
tracingParameters.Add("webSocketSubProtol", webSocketSubProtol);
108108
tracingParameters.Add("cancellationToken", cancellationToken);
109-
ServiceClientTracing.Enter(_invocationId, this, nameof(WebSocketNamespacedPodExecAsync),
109+
ServiceClientTracing.Enter(invocationId, this, nameof(WebSocketNamespacedPodExecAsync),
110110
tracingParameters);
111111
}
112112

@@ -143,7 +143,7 @@ public virtual Task<WebSocket> WebSocketNamespacedPodExecAsync(string name, stri
143143
uriBuilder.Query =
144144
query.ToString(1, query.Length - 1); // UriBuilder.Query doesn't like leading '?' chars, so trim it
145145

146-
return this.StreamConnectAsync(uriBuilder.Uri, _invocationId, webSocketSubProtol, customHeaders,
146+
return this.StreamConnectAsync(uriBuilder.Uri, invocationId, webSocketSubProtol, customHeaders,
147147
cancellationToken);
148148
}
149149

@@ -169,18 +169,18 @@ public Task<WebSocket> WebSocketNamespacedPodPortForwardAsync(string name, strin
169169
}
170170

171171
// Tracing
172-
bool _shouldTrace = ServiceClientTracing.IsEnabled;
173-
string _invocationId = null;
174-
if (_shouldTrace)
172+
bool shouldTrace = ServiceClientTracing.IsEnabled;
173+
string invocationId = null;
174+
if (shouldTrace)
175175
{
176-
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
176+
invocationId = ServiceClientTracing.NextInvocationId.ToString();
177177
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
178178
tracingParameters.Add("name", name);
179179
tracingParameters.Add("@namespace", @namespace);
180180
tracingParameters.Add("ports", ports);
181181
tracingParameters.Add("webSocketSubProtocol", webSocketSubProtocol);
182182
tracingParameters.Add("cancellationToken", cancellationToken);
183-
ServiceClientTracing.Enter(_invocationId, this, nameof(WebSocketNamespacedPodPortForwardAsync),
183+
ServiceClientTracing.Enter(invocationId, this, nameof(WebSocketNamespacedPodPortForwardAsync),
184184
tracingParameters);
185185
}
186186

@@ -208,7 +208,7 @@ public Task<WebSocket> WebSocketNamespacedPodPortForwardAsync(string name, strin
208208

209209
uriBuilder.Query = q.ToString();
210210

211-
return StreamConnectAsync(uriBuilder.Uri, _invocationId, webSocketSubProtocol, customHeaders,
211+
return StreamConnectAsync(uriBuilder.Uri, invocationId, webSocketSubProtocol, customHeaders,
212212
cancellationToken);
213213
}
214214

@@ -229,11 +229,11 @@ public Task<WebSocket> WebSocketNamespacedPodAttachAsync(string name, string @na
229229
}
230230

231231
// Tracing
232-
bool _shouldTrace = ServiceClientTracing.IsEnabled;
233-
string _invocationId = null;
234-
if (_shouldTrace)
232+
bool shouldTrace = ServiceClientTracing.IsEnabled;
233+
string invocationId = null;
234+
if (shouldTrace)
235235
{
236-
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
236+
invocationId = ServiceClientTracing.NextInvocationId.ToString();
237237
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
238238
tracingParameters.Add("container", container);
239239
tracingParameters.Add("name", name);
@@ -244,7 +244,7 @@ public Task<WebSocket> WebSocketNamespacedPodAttachAsync(string name, string @na
244244
tracingParameters.Add("tty", tty);
245245
tracingParameters.Add("webSocketSubProtol", webSocketSubProtol);
246246
tracingParameters.Add("cancellationToken", cancellationToken);
247-
ServiceClientTracing.Enter(_invocationId, this, nameof(WebSocketNamespacedPodAttachAsync),
247+
ServiceClientTracing.Enter(invocationId, this, nameof(WebSocketNamespacedPodAttachAsync),
248248
tracingParameters);
249249
}
250250

@@ -268,25 +268,25 @@ public Task<WebSocket> WebSocketNamespacedPodAttachAsync(string name, string @na
268268
uriBuilder.Query =
269269
query.ToString(1, query.Length - 1); // UriBuilder.Query doesn't like leading '?' chars, so trim it
270270

271-
return StreamConnectAsync(uriBuilder.Uri, _invocationId, webSocketSubProtol, customHeaders,
271+
return StreamConnectAsync(uriBuilder.Uri, invocationId, webSocketSubProtol, customHeaders,
272272
cancellationToken);
273273
}
274274

275275
protected async Task<WebSocket> StreamConnectAsync(Uri uri, string invocationId = null,
276276
string webSocketSubProtocol = null, Dictionary<string, List<string>> customHeaders = null,
277277
CancellationToken cancellationToken = default(CancellationToken))
278278
{
279-
bool _shouldTrace = ServiceClientTracing.IsEnabled;
279+
bool shouldTrace = ServiceClientTracing.IsEnabled;
280280

281281
// Create WebSocket transport objects
282282
WebSocketBuilder webSocketBuilder = this.CreateWebSocketBuilder();
283283

284284
// Set Headers
285285
if (customHeaders != null)
286286
{
287-
foreach (var _header in customHeaders)
287+
foreach (var header in customHeaders)
288288
{
289-
webSocketBuilder.SetRequestHeader(_header.Key, string.Join(" ", _header.Value));
289+
webSocketBuilder.SetRequestHeader(header.Key, string.Join(" ", header.Value));
290290
}
291291
}
292292

@@ -306,9 +306,9 @@ protected async Task<WebSocket> StreamConnectAsync(Uri uri, string invocationId
306306
HttpRequestMessage message = new HttpRequestMessage();
307307
await this.Credentials.ProcessHttpRequestAsync(message, cancellationToken).ConfigureAwait(false);
308308

309-
foreach (var _header in message.Headers)
309+
foreach (var header in message.Headers)
310310
{
311-
webSocketBuilder.SetRequestHeader(_header.Key, string.Join(" ", _header.Value));
311+
webSocketBuilder.SetRequestHeader(header.Key, string.Join(" ", header.Value));
312312
}
313313
}
314314

@@ -392,7 +392,7 @@ wse.InnerException is WebSocketException &&
392392
}
393393
catch (Exception ex)
394394
{
395-
if (_shouldTrace)
395+
if (shouldTrace)
396396
{
397397
ServiceClientTracing.Error(invocationId, ex);
398398
}
@@ -401,7 +401,7 @@ wse.InnerException is WebSocketException &&
401401
}
402402
finally
403403
{
404-
if (_shouldTrace)
404+
if (shouldTrace)
405405
{
406406
ServiceClientTracing.Exit(invocationId, null);
407407
}

src/KubernetesClient/KubernetesClientConfiguration.InCluster.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace k8s
77
{
88
public partial class KubernetesClientConfiguration
99
{
10-
private static string ServiceAccountPath =
10+
private static string serviceAccountPath =
1111
Path.Combine(new string[]
1212
{
1313
$"{Path.DirectorySeparatorChar}var", "run", "secrets", "kubernetes.io", "serviceaccount",
@@ -25,13 +25,13 @@ public static Boolean IsInCluster()
2525
return false;
2626
}
2727

28-
var tokenPath = Path.Combine(ServiceAccountPath, ServiceAccountTokenKeyFileName);
28+
var tokenPath = Path.Combine(serviceAccountPath, ServiceAccountTokenKeyFileName);
2929
if (!File.Exists(tokenPath))
3030
{
3131
return false;
3232
}
3333

34-
var certPath = Path.Combine(ServiceAccountPath, ServiceAccountRootCAKeyFileName);
34+
var certPath = Path.Combine(serviceAccountPath, ServiceAccountRootCAKeyFileName);
3535
return File.Exists(certPath);
3636
}
3737

@@ -43,14 +43,14 @@ public static KubernetesClientConfiguration InClusterConfig()
4343
"unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined");
4444
}
4545

46-
var rootCAFile = Path.Combine(ServiceAccountPath, ServiceAccountRootCAKeyFileName);
46+
var rootCAFile = Path.Combine(serviceAccountPath, ServiceAccountRootCAKeyFileName);
4747
var host = Environment.GetEnvironmentVariable("KUBERNETES_SERVICE_HOST");
4848
var port = Environment.GetEnvironmentVariable("KUBERNETES_SERVICE_PORT");
4949

5050
return new KubernetesClientConfiguration
5151
{
5252
Host = new UriBuilder("https", host, Convert.ToInt32(port)).ToString(),
53-
TokenProvider = new TokenFileAuth(Path.Combine(ServiceAccountPath, ServiceAccountTokenKeyFileName)),
53+
TokenProvider = new TokenFileAuth(Path.Combine(serviceAccountPath, ServiceAccountTokenKeyFileName)),
5454
SslCaCerts = CertUtils.LoadPemFileCert(rootCAFile),
5555
};
5656
}

tests/KubernetesClient.Tests/WebSocketTestBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public abstract class WebSocketTestBase : IDisposable
2424
/// <summary>
2525
/// The next server port to use.
2626
/// </summary>
27-
private static int NextPort = 13255;
27+
private static int nextPort = 13255;
2828

2929
private readonly ITestOutputHelper testOutput;
3030

@@ -38,7 +38,7 @@ protected WebSocketTestBase(ITestOutputHelper testOutput)
3838
{
3939
this.testOutput = testOutput;
4040

41-
int port = Interlocked.Increment(ref NextPort);
41+
int port = Interlocked.Increment(ref nextPort);
4242

4343
// Useful to diagnose test timeouts.
4444
TestCancellation.Register(

0 commit comments

Comments
 (0)