Skip to content

Commit

Permalink
Fixed code suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasArdal committed Oct 1, 2024
1 parent e4aa65e commit 1fec20f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Elmah.Io/ErrorLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace Elmah.Io
/// <summary>
/// <see cref="ErrorLog"/>
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S2223", Justification = "The public Api field is kept for backwards compatibility")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S1104", Justification = "The public Api field is kept for backwards compatibility")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S3010", Justification = "The public Api field is kept for backwards compatibility")]
public class ErrorLog : global::Elmah.ErrorLog, IErrorLog
{
internal static readonly string _assemblyVersion = typeof(ErrorLog).Assembly.GetName().Version.ToString();
Expand Down Expand Up @@ -199,14 +202,14 @@ public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList)
return EndGetErrors(BeginGetErrors(pageIndex, pageSize, errorEntryList, null, null));
}

private T EndImpl<T>(IAsyncResult asyncResult)
private static T EndImpl<T>(IAsyncResult asyncResult)
{
if (asyncResult == null)
{
throw new ArgumentNullException(nameof(asyncResult));
}

if (!(asyncResult is Task<T> task))
if (asyncResult is not Task<T> task)
{
throw new ArgumentException(null, nameof(asyncResult));
}
Expand Down Expand Up @@ -248,10 +251,10 @@ private ErrorLogEntry MapErrorLogEntry(Message message)
User = message.User,
};

(message.Cookies ?? new List<Item>()).ToList().ForEach(c => error.Cookies.Add(c.Key, c.Value));
(message.Form ?? new List<Item>()).ToList().ForEach(c => error.Form.Add(c.Key, c.Value));
(message.QueryString ?? new List<Item>()).ToList().ForEach(c => error.QueryString.Add(c.Key, c.Value));
(message.ServerVariables ?? new List<Item>()).ToList().ForEach(c => error.ServerVariables.Add(c.Key, c.Value));
(message.Cookies ?? []).ToList().ForEach(c => error.Cookies.Add(c.Key, c.Value));
(message.Form ?? []).ToList().ForEach(c => error.Form.Add(c.Key, c.Value));
(message.QueryString ?? []).ToList().ForEach(c => error.QueryString.Add(c.Key, c.Value));
(message.ServerVariables ?? []).ToList().ForEach(c => error.ServerVariables.Add(c.Key, c.Value));

var errorLogEntry = new ErrorLogEntry(this, message.Id, error);
return errorLogEntry;
Expand Down Expand Up @@ -296,7 +299,7 @@ private IList<Item> Itemize(NameValueCollection nameValues)

private IList<Item> Data(Exception exception)
{
if (exception == null) return new List<Item>();
if (exception == null) return [];
var items = new List<Item>();
var dataItems = exception.ToDataList();
if (dataItems.Count > 0)
Expand Down Expand Up @@ -324,7 +327,7 @@ private IList<Item> Data(Exception exception)
return items;
}

private string UserAgent()
private static string UserAgent()
{
return new StringBuilder()
.Append(new ProductInfoHeaderValue(new ProductHeaderValue("Elmah.Io", _assemblyVersion)).ToString())
Expand Down

0 comments on commit 1fec20f

Please sign in to comment.