From 50980fda9391e0733fd1f8f962d0d45e07478d2f Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sat, 3 Mar 2018 14:08:52 +0000 Subject: [PATCH] Fix various violations SA1216, CS0105, CS0169, CS0414, CS0649 --- src/Ocelot/Raft/HttpPeer.cs | 3 ++- test/Ocelot.AcceptanceTests/AggregateTests.cs | 2 -- test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs | 5 ----- test/Ocelot.AcceptanceTests/Steps.cs | 8 -------- .../Authentication/AuthenticationMiddlewareTests.cs | 7 ------- .../Cache/OutputCacheMiddlewareRealCacheTests.cs | 8 -------- .../Claims/ClaimsBuilderMiddlewareTests.cs | 2 -- .../Configuration/ConsulFileConfigurationPollerTests.cs | 2 +- .../DependencyInjection/OcelotBuilderTests.cs | 1 - .../LoadBalancer/LoadBalancerHouseTests.cs | 2 -- .../LoadBalancer/LoadBalancerMiddlewareTests.cs | 6 ------ .../Middleware/OcelotPiplineBuilderTests.cs | 3 --- .../RequestId/ReRouteRequestIdMiddlewareTests.cs | 2 -- test/Ocelot.UnitTests/Requester/HttpClientBuilderTests.cs | 1 - test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs | 1 - .../Responder/ErrorsToHttpStatusCodeMapperTests.cs | 2 +- .../Responder/ResponderMiddlewareTests.cs | 3 --- 17 files changed, 4 insertions(+), 54 deletions(-) diff --git a/src/Ocelot/Raft/HttpPeer.cs b/src/Ocelot/Raft/HttpPeer.cs index 34a94b27..cd5ceef5 100644 --- a/src/Ocelot/Raft/HttpPeer.cs +++ b/src/Ocelot/Raft/HttpPeer.cs @@ -89,7 +89,8 @@ namespace Ocelot.Raft } } - public Response Request(T command) where T : ICommand + public Response Request(T command) + where T : ICommand { if(_token == null) { diff --git a/test/Ocelot.AcceptanceTests/AggregateTests.cs b/test/Ocelot.AcceptanceTests/AggregateTests.cs index 8510fd1b..3944adfc 100644 --- a/test/Ocelot.AcceptanceTests/AggregateTests.cs +++ b/test/Ocelot.AcceptanceTests/AggregateTests.cs @@ -15,7 +15,6 @@ namespace Ocelot.AcceptanceTests public class AggregateTests : IDisposable { private IWebHost _serviceOneBuilder; - private IWebHost _serviceTwoBuilder; private readonly Steps _steps; private string _downstreamPathOne; private string _downstreamPathTwo; @@ -364,7 +363,6 @@ namespace Ocelot.AcceptanceTests public void Dispose() { _serviceOneBuilder?.Dispose(); - _serviceTwoBuilder?.Dispose(); _steps.Dispose(); } } diff --git a/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs b/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs index f6c77b1c..e555ade7 100644 --- a/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs +++ b/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs @@ -1,18 +1,14 @@ using System; using System.Collections.Generic; -using Microsoft.AspNetCore.Hosting; using Ocelot.Configuration.File; using Shouldly; -using TestStack.BDDfy; using Xunit; namespace Ocelot.AcceptanceTests { public class CannotStartOcelotTests : IDisposable { - private IWebHost _builder; private readonly Steps _steps; - private string _downstreamPath; public CannotStartOcelotTests() { @@ -50,7 +46,6 @@ namespace Ocelot.AcceptanceTests public void Dispose() { - _builder?.Dispose(); _steps.Dispose(); } } diff --git a/test/Ocelot.AcceptanceTests/Steps.cs b/test/Ocelot.AcceptanceTests/Steps.cs index 09f68998..61a01059 100644 --- a/test/Ocelot.AcceptanceTests/Steps.cs +++ b/test/Ocelot.AcceptanceTests/Steps.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Net; @@ -19,15 +17,11 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Ocelot.Configuration.File; -using Ocelot.Configuration.Repository; using Ocelot.DependencyInjection; using Ocelot.Middleware; -using Ocelot.ServiceDiscovery; using Shouldly; using ConfigurationBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder; using Ocelot.AcceptanceTests.Caching; -using Butterfly.Client.AspNetCore; -using Butterfly.Client.Tracing; namespace Ocelot.AcceptanceTests { @@ -42,11 +36,9 @@ namespace Ocelot.AcceptanceTests public string RequestIdKey = "OcRequestId"; private readonly Random _random; private IWebHostBuilder _webHostBuilder; - private readonly string _baseUrl; public Steps() { - _baseUrl = "http://localhost:5000"; _random = new Random(); } diff --git a/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs b/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs index 1ab81895..e5cb64ae 100644 --- a/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs @@ -6,24 +6,17 @@ namespace Ocelot.UnitTests.Authentication using System.Collections.Generic; using System.IO; using System.Text; - using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; - using Microsoft.Extensions.DependencyInjection; using Moq; using Ocelot.Authentication.Middleware; using Ocelot.Configuration.Builder; - using Ocelot.DownstreamRouteFinder; - using Ocelot.DownstreamRouteFinder.Middleware; - using Ocelot.DownstreamRouteFinder.UrlMatcher; using Ocelot.Logging; - using Ocelot.Responses; using Shouldly; using TestStack.BDDfy; using Xunit; public class AuthenticationMiddlewareTests { - private OkResponse _downstreamRoute; private AuthenticationMiddleware _middleware; private Mock _factory; private Mock _logger; diff --git a/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs b/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs index 4e9ef04d..c0a76b2a 100644 --- a/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs +++ b/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs @@ -1,5 +1,4 @@ using Ocelot.Errors; -using Ocelot.Infrastructure.RequestData; using Ocelot.Middleware; namespace Ocelot.UnitTests.Cache @@ -11,26 +10,19 @@ namespace Ocelot.UnitTests.Cache using Shouldly; using System.Collections.Generic; using System.Net.Http; - using Microsoft.AspNetCore.Builder; - using Microsoft.Extensions.DependencyInjection; using Moq; using Ocelot.Cache; using Ocelot.Cache.Middleware; using Ocelot.Configuration; using Ocelot.Configuration.Builder; - using Ocelot.DownstreamRouteFinder; - using Ocelot.DownstreamRouteFinder.UrlMatcher; using Ocelot.Logging; - using Ocelot.Responses; using TestStack.BDDfy; using Xunit; - using Ocelot.DownstreamRouteFinder.Middleware; using Microsoft.AspNetCore.Http; public class OutputCacheMiddlewareRealCacheTests { private IOcelotCache _cacheManager; - private CachedResponse _response; private OutputCacheMiddleware _middleware; private DownstreamContext _downstreamContext; private OcelotRequestDelegate _next; diff --git a/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs b/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs index 5b5e386c..f6bf052c 100644 --- a/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs @@ -15,12 +15,10 @@ namespace Ocelot.UnitTests.Claims using Ocelot.Responses; using TestStack.BDDfy; using Xunit; - using Ocelot.DownstreamRouteFinder.Middleware; public class ClaimsBuilderMiddlewareTests { private readonly Mock _addHeaders; - private Response _downstreamRoute; private Mock _loggerFactory; private Mock _logger; private readonly ClaimsBuilderMiddleware _middleware; diff --git a/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs b/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs index b743b598..4a6faba2 100644 --- a/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs +++ b/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs @@ -83,7 +83,7 @@ namespace Ocelot.UnitTests.Configuration _setter.Verify(x => x.Set(fileConfig), Times.Once); return true; } - catch(Exception ex) + catch(Exception) { return false; } diff --git a/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs b/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs index 8ed1a327..c2f35990 100644 --- a/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs +++ b/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs @@ -15,7 +15,6 @@ using Ocelot.DependencyInjection; using Ocelot.Requester; using Ocelot.UnitTests.Requester; using Shouldly; -using System; using IdentityServer4.AccessTokenValidation; using TestStack.BDDfy; using Xunit; diff --git a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs index 2a4d3a24..e8808f17 100644 --- a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs +++ b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs @@ -17,9 +17,7 @@ namespace Ocelot.UnitTests.LoadBalancer private DownstreamReRoute _reRoute; private ILoadBalancer _loadBalancer; private readonly LoadBalancerHouse _loadBalancerHouse; - private Response _addResult; private Response _getResult; - private string _key; private readonly Mock _factory; private ServiceProviderConfiguration _serviceProviderConfig; diff --git a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs index 0af8b3af..242463a2 100644 --- a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs @@ -4,15 +4,10 @@ namespace Ocelot.UnitTests.LoadBalancer { using System.Collections.Generic; using System.Net.Http; - using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; - using Microsoft.Extensions.DependencyInjection; using Moq; using Ocelot.Configuration; using Ocelot.Configuration.Builder; - using Ocelot.Configuration.Provider; - using Ocelot.DownstreamRouteFinder; - using Ocelot.DownstreamRouteFinder.Middleware; using Ocelot.Errors; using Ocelot.LoadBalancer.LoadBalancers; using Ocelot.LoadBalancer.Middleware; @@ -28,7 +23,6 @@ namespace Ocelot.UnitTests.LoadBalancer private readonly Mock _loadBalancerHouse; private readonly Mock _loadBalancer; private ServiceHostAndPort _hostAndPort; - private OkResponse _downstreamRoute; private ErrorResponse _getLoadBalancerHouseError; private ErrorResponse _getHostAndPortError; private HttpRequestMessage _downstreamRequest; diff --git a/test/Ocelot.UnitTests/Middleware/OcelotPiplineBuilderTests.cs b/test/Ocelot.UnitTests/Middleware/OcelotPiplineBuilderTests.cs index dbb0ae63..988d0b21 100644 --- a/test/Ocelot.UnitTests/Middleware/OcelotPiplineBuilderTests.cs +++ b/test/Ocelot.UnitTests/Middleware/OcelotPiplineBuilderTests.cs @@ -1,6 +1,5 @@ namespace Ocelot.UnitTests.Middleware { - using System; using System.Collections.Generic; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Internal; @@ -17,9 +16,7 @@ public class OcelotPiplineBuilderTests { private readonly IServiceCollection _services; - private IServiceProvider _serviceProvider; private readonly IConfiguration _configRoot; - private IOcelotBuilder _ocelotBuilder; private DownstreamContext _downstreamContext; private int _counter; diff --git a/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs b/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs index c49f2c6a..f6bf4eb7 100644 --- a/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs @@ -4,7 +4,6 @@ namespace Ocelot.UnitTests.RequestId { using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; - using Ocelot.DownstreamRouteFinder.Middleware; using Ocelot.Infrastructure.RequestData; using System; using System.Collections.Generic; @@ -24,7 +23,6 @@ namespace Ocelot.UnitTests.RequestId public class ReRouteRequestIdMiddlewareTests { private readonly HttpRequestMessage _downstreamRequest; - private Response _downstreamRoute; private string _value; private string _key; private Mock _loggerFactory; diff --git a/test/Ocelot.UnitTests/Requester/HttpClientBuilderTests.cs b/test/Ocelot.UnitTests/Requester/HttpClientBuilderTests.cs index b5d7e1e6..b788c826 100644 --- a/test/Ocelot.UnitTests/Requester/HttpClientBuilderTests.cs +++ b/test/Ocelot.UnitTests/Requester/HttpClientBuilderTests.cs @@ -17,7 +17,6 @@ namespace Ocelot.UnitTests.Requester private readonly HttpClientBuilder _builder; private readonly Mock _house; private readonly Mock _provider; - private IHttpClientBuilder _builderResult; private IHttpClient _httpClient; private HttpResponseMessage _response; private DownstreamReRoute _request; diff --git a/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs b/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs index f6095034..ae027143 100644 --- a/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs +++ b/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs @@ -13,7 +13,6 @@ namespace Ocelot.UnitTests.Requester { private IQoSProvider _qoSProvider; private readonly QosProviderHouse _qosProviderHouse; - private Response _addResult; private Response _getResult; private DownstreamReRoute _reRoute; private readonly Mock _factory; diff --git a/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs b/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs index 977a0b12..9800ffef 100644 --- a/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs +++ b/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs @@ -42,7 +42,7 @@ namespace Ocelot.UnitTests.Responder [InlineData(OcelotErrorCode.RequestTimedOutError)] public void should_return_service_unavailable(OcelotErrorCode errorCode) { - ShouldMapErrorToStatusCode(OcelotErrorCode.RequestTimedOutError, HttpStatusCode.ServiceUnavailable); + ShouldMapErrorToStatusCode(errorCode, HttpStatusCode.ServiceUnavailable); } [Theory] diff --git a/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs b/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs index 28a0707a..54b795a2 100644 --- a/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs @@ -4,7 +4,6 @@ using Ocelot.Middleware; namespace Ocelot.UnitTests.Responder { using Microsoft.AspNetCore.Http; - using Ocelot.DownstreamRouteFinder.Middleware; using System.Net.Http; using Moq; using Ocelot.DownstreamRouteFinder.Finder; @@ -12,7 +11,6 @@ namespace Ocelot.UnitTests.Responder using Ocelot.Logging; using Ocelot.Responder; using Ocelot.Responder.Middleware; - using Ocelot.Responses; using TestStack.BDDfy; using Xunit; @@ -20,7 +18,6 @@ namespace Ocelot.UnitTests.Responder { private readonly Mock _responder; private readonly Mock _codeMapper; - private OkResponse _response; private Mock _loggerFactory; private Mock _logger; private readonly ResponderMiddleware _middleware;