Fix Sonar issues (#166)

* Fix Sonar issues

* Fix Sonar issues
This commit is contained in:
Stef Heyenrath
2018-07-16 20:04:35 +02:00
committed by GitHub
parent cc6b311814
commit a96c8100cf
21 changed files with 48 additions and 109 deletions

View File

@@ -9,15 +9,5 @@
/// Gets or sets the matcher.
/// </summary>
public MatcherModel Matcher { get; set; }
///// <summary>
///// Gets or sets the function.
///// </summary>
//public string Func { get; set; }
///// <summary>
///// Gets or sets the data function.
///// </summary>
//public string DataFunc { get; set; }
}
}

View File

@@ -9,10 +9,5 @@
/// Gets or sets the matchers.
/// </summary>
public MatcherModel[] Matchers { get; set; }
///// <summary>
///// Gets or sets the functions.
///// </summary>
//public string[] Funcs { get; set; }
}
}

View File

@@ -16,10 +16,5 @@ namespace WireMock.Admin.Mappings
/// Gets or sets the matchers.
/// </summary>
public IList<MatcherModel> Matchers { get; set; }
///// <summary>
///// Gets or sets the functions.
///// </summary>
//public string[] Funcs { get; set; }
}
}

View File

@@ -16,10 +16,5 @@ namespace WireMock.Admin.Mappings
/// Gets or sets the matchers.
/// </summary>
public IList<MatcherModel> Matchers { get; set; }
///// <summary>
///// Gets or sets the functions.
///// </summary>
//public string[] Funcs { get; set; }
}
}

View File

@@ -1,6 +1,4 @@
// using System.Collections.Generic;
namespace WireMock.Admin.Mappings
namespace WireMock.Admin.Mappings
{
/// <summary>
/// Param Model
@@ -12,19 +10,9 @@ namespace WireMock.Admin.Mappings
/// </summary>
public string Name { get; set; }
///// <summary>
///// Gets or sets the values.
///// </summary>
//public IList<string> Values { get; set; }
/// <summary>
/// Gets or sets the matchers.
/// </summary>
public MatcherModel[] Matchers { get; set; }
///// <summary>
///// Gets or sets the functions.
///// </summary>
//public string[] Funcs { get; set; }
}
}

View File

@@ -9,10 +9,5 @@
/// Gets or sets the matchers.
/// </summary>
public MatcherModel[] Matchers { get; set; }
///// <summary>
///// Gets or sets the functions.
///// </summary>
//public string[] Funcs { get; set; }
}
}

View File

@@ -9,10 +9,5 @@
/// Gets or sets the matchers.
/// </summary>
public MatcherModel[] Matchers { get; set; }
///// <summary>
///// Gets or sets the functions.
///// </summary>
//public string[] Funcs { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
namespace WireMock.HttpsCertificate
@@ -10,19 +11,19 @@ namespace WireMock.HttpsCertificate
X509Store certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
try
{
//Certificate must be in the local machine store
// Certificate must be in the local machine store
certStore.Open(OpenFlags.ReadOnly);
//Attempt to find by thumbprint first
// Attempt to find by thumbprint first
var matchingCertificates = certStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprintOrSubjectName, false);
if (matchingCertificates.Count == 0)
{
//Fallback to subject name
// Fallback to subject name
matchingCertificates = certStore.Certificates.Find(X509FindType.FindBySubjectName, thumbprintOrSubjectName, false);
if (matchingCertificates.Count == 0)
{
// No certificates matched the search criteria.
throw new Exception($"No certificate found with Thumbprint or SubjectName '{thumbprintOrSubjectName}'");
throw new FileNotFoundException("No certificate found with specified Thumbprint or SubjectName.", thumbprintOrSubjectName);
}
}
// Use the first matching certificate.

View File

@@ -49,8 +49,8 @@ namespace WireMock.Logging
/// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more).
/// </summary>
/// <param name="logEntryModel">The Request Log Model.</param>
/// <param name="isAdminrequest">Defines if this request is an admin request.</param>
/// <param name="isAdminRequest">Defines if this request is an admin request.</param>
[PublicAPI]
void DebugRequestResponse([NotNull] LogEntryModel logEntryModel, bool isAdminrequest);
void DebugRequestResponse([NotNull] LogEntryModel logEntryModel, bool isAdminRequest);
}
}

View File

@@ -11,26 +11,31 @@ namespace WireMock.Logging
/// <see cref="IWireMockLogger.Debug"/>
public void Debug(string formatString, params object[] args)
{
// Log nothing
}
/// <see cref="IWireMockLogger.Info"/>
public void Info(string formatString, params object[] args)
{
// Log nothing
}
/// <see cref="IWireMockLogger.Warn"/>
public void Warn(string formatString, params object[] args)
{
// Log nothing
}
/// <see cref="IWireMockLogger.Error"/>
public void Error(string formatString, params object[] args)
{
// Log nothing
}
/// <see cref="IWireMockLogger.DebugRequestResponse"/>
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
{
// Log nothing
}
}
}

View File

@@ -7,11 +7,6 @@ namespace WireMock.Matchers.Request
/// </summary>
internal class RequestMessageScenarioAndStateMatcher : IRequestMatcher
{
///// <summary>
///// Scenario.
///// </summary>
//[CanBeNull] private string _scenario;
/// <summary>
/// Execution state condition for the current mapping.
/// </summary>

View File

@@ -7,7 +7,6 @@ using System.Linq;
using WireMock.Matchers;
using WireMock.Util;
using Newtonsoft.Json;
using WireMock.Admin.Mappings;
using WireMock.Http;
using WireMock.Serialization;
#if !NETSTANDARD
@@ -24,8 +23,6 @@ namespace WireMock.Owin
internal class WireMockMiddleware
#endif
{
private readonly IDictionary<string, WireMockList<string>> _contentTypeJsonHeaders = new Dictionary<string, WireMockList<string>> { { HttpKnownHeaderNames.ContentType, new WireMockList<string> { "application/json" } } };
private static readonly Task CompletedTask = Task.FromResult(false);
private readonly WireMockMiddlewareOptions _options;

View File

@@ -85,8 +85,8 @@ namespace WireMock.RequestBuilders
/// <summary>
/// WithCookie: matching based on functions.
/// </summary>
/// <param name="cookieFuncs">The funcs.</param>
/// <param name="funcs">The funcs.</param>
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
IRequestBuilder WithCookie([NotNull] params Func<IDictionary<string, string>, bool>[] cookieFuncs);
IRequestBuilder WithCookie([NotNull] params Func<IDictionary<string, string>, bool>[] funcs);
}
}

View File

@@ -61,7 +61,7 @@ namespace WireMock.RequestBuilders
/// UsingAnyVerb: add HTTP Method matching on any method.
/// </summary>
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
[Obsolete]
[Obsolete("Use the method UsingAnyMethod().")]
IRequestBuilder UsingAnyVerb();
/// <summary>
@@ -84,7 +84,7 @@ namespace WireMock.RequestBuilders
/// </summary>
/// <param name="verbs">The methods.</param>
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
[Obsolete]
[Obsolete("Use the method UsingMethod(...).")]
IRequestBuilder UsingVerb([NotNull] params string[] verbs);
}
}

View File

@@ -63,8 +63,8 @@ namespace WireMock.RequestBuilders
/// <summary>
/// WithUrl: add url matching based on functions.
/// </summary>
/// <param name="func">The path func.</param>
/// <param name="funcs">The url functions.</param>
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
IRequestBuilder WithUrl([NotNull] params Func<string, bool>[] func);
IRequestBuilder WithUrl([NotNull] params Func<string, bool>[] funcs);
}
}

View File

@@ -59,7 +59,7 @@ namespace WireMock.ResponseBuilders
/// <param name="bodyAsbase64">The body.</param>
/// <param name="encoding">The Encoding.</param>
/// <returns>A <see cref="IResponseBuilder"/>.</returns>
[Obsolete]
[Obsolete("Should not be used, will be removed in future.")]
IResponseBuilder WithBodyFromBase64([NotNull] string bodyAsbase64, [CanBeNull] Encoding encoding = null);
/// <summary>

View File

@@ -173,7 +173,7 @@ namespace WireMock.ResponseBuilders
}
/// <inheritdoc cref="IBodyResponseBuilder.WithBody(byte[], string, Encoding)"/>
public IResponseBuilder WithBody(byte[] body, string destination, Encoding encoding = null)
public IResponseBuilder WithBody(byte[] body, string destination = BodyDestinationFormat.SameAsSource, Encoding encoding = null)
{
Check.NotNull(body, nameof(body));

View File

@@ -146,15 +146,5 @@ namespace WireMock.Serialization
return newDictionary;
}
//private static string[] Map<T>([CanBeNull] IEnumerable<Func<T, bool>> funcs)
//{
// return funcs?.Select(Map).Where(x => x != null).ToArray();
//}
//private static string Map<T>([CanBeNull] Func<T, bool> func)
//{
// return func?.ToString();
//}
}
}

View File

@@ -56,7 +56,30 @@ namespace WireMock.Server
/// Gets the scenarios.
/// </summary>
[PublicAPI]
public ConcurrentDictionary<string, object> Scenarios => new ConcurrentDictionary<string, object>(_options.Scenarios); // Checked
public ConcurrentDictionary<string, object> Scenarios => new ConcurrentDictionary<string, object>(_options.Scenarios);
#region IDisposable Members
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
if (_httpServer != null && _httpServer.IsStarted)
{
_httpServer.StopAsync();
}
}
#endregion
#region Start/Stop
/// <summary>
@@ -267,17 +290,6 @@ namespace WireMock.Server
.RespondWith(new DynamicResponseProvider(request => ResponseMessageBuilder.Create("No matching mapping found", 404)));
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
if (_httpServer != null && _httpServer.IsStarted)
{
_httpServer.StopAsync();
}
}
/// <summary>
/// Resets LogEntries and Mappings.
/// </summary>

View File

@@ -9,9 +9,8 @@ namespace WireMock.Util
/// <summary>
/// An EnhancedFileSystemWatcher, which can be used to suppress duplicate events that fire on a single change to the file.
/// </summary>
/// <seealso cref="System.IO.FileSystemWatcher" />
/// <seealso cref="System.IDisposable" />
public class EnhancedFileSystemWatcher : FileSystemWatcher, IDisposable
/// <seealso cref="FileSystemWatcher" />
public class EnhancedFileSystemWatcher : FileSystemWatcher
{
#region Private Members
// Default Watch Interval in Milliseconds
@@ -251,15 +250,5 @@ namespace WireMock.Util
}
#endregion
#endregion
#region IDisposable Members
/// <summary>
/// Releases all resources used by the <see cref="T:System.ComponentModel.Component" />.
/// </summary>
public new void Dispose()
{
base.Dispose();
}
#endregion
}
}

View File

@@ -38,10 +38,7 @@ namespace WireMock.Util
/// </summary>
public override string ToString()
{
if (this != null && this.Any())
return this.First().ToString();
return base.ToString();
return this.Any() ? this.First().ToString() : base.ToString();
}
}
}