refactor: Address several analysis warnings

pull/201/head
Robert Dailey 10 months ago
parent def934ebeb
commit e0da419ffa

@ -94,6 +94,6 @@ public partial class ServiceCache : IServiceCache
return _storagePath.CalculatePath(config, objectName); return _storagePath.CalculatePath(config, objectName);
} }
[GeneratedRegex("^[\\w-]+$", RegexOptions.None, 1000)] [GeneratedRegex(@"^[\w-]+$", RegexOptions.None, 1000)]
private static partial Regex AllowedObjectNameCharactersRegex(); private static partial Regex AllowedObjectNameCharactersRegex();
} }

@ -5,6 +5,7 @@ namespace Recyclarr.Cli.Console.Settings;
public interface ISyncSettings public interface ISyncSettings
{ {
SupportedServices? Service { get; } SupportedServices? Service { get; }
// ReSharper disable once ReturnTypeCanBeEnumerable.Global
IReadOnlyCollection<string> Configs { get; } IReadOnlyCollection<string> Configs { get; }
bool Preview { get; } bool Preview { get; }
IReadOnlyCollection<string>? Instances { get; } IReadOnlyCollection<string>? Instances { get; }

@ -48,11 +48,6 @@ public class LoggerFactory
var logFilePrefix = $"recyclarr_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}"; var logFilePrefix = $"recyclarr_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}";
var logDir = _paths.LogDirectory; var logDir = _paths.LogDirectory;
string LogFilePath(string type)
{
return logDir.File($"{logFilePrefix}.{type}.log").FullName;
}
return new LoggerConfiguration() return new LoggerConfiguration()
.MinimumLevel.Is(LogEventLevel.Verbose) .MinimumLevel.Is(LogEventLevel.Verbose)
.Enrich.With<ExceptionMessageEnricher>() .Enrich.With<ExceptionMessageEnricher>()
@ -65,5 +60,10 @@ public class LoggerFactory
.WriteTo.File(GetFileTemplate(), LogFilePath("verbose"))) .WriteTo.File(GetFileTemplate(), LogFilePath("verbose")))
.Enrich.FromLogContext() .Enrich.FromLogContext()
.CreateLogger(); .CreateLogger();
string LogFilePath(string type)
{
return logDir.File($"{logFilePrefix}.{type}.log").FullName;
}
} }
} }

@ -68,14 +68,15 @@ public partial class CustomFormatCategoryParser : ICustomFormatCategoryParser
return tableRows return tableRows
// Filter out the `|---|---|---|` part of the table between the heading & data rows. // Filter out the `|---|---|---|` part of the table between the heading & data rows.
.Where(x => !Regex.IsMatch(x[0], @"^-+$", RegexOptions.None, TimeSpan.FromMilliseconds(1000))); .Where(x => !Regex.IsMatch(x[0], "^-+$", RegexOptions.None, TimeSpan.FromMilliseconds(1000)));
} }
private static List<string> GetTableRow(string line) private static List<string> GetTableRow(string line)
{ {
var fields = new List<string>(); var fields = new List<string>();
var match = TableRegex().Match(line); var match = TableRegex().Match(line);
// ReSharper disable once InvertIf
if (match.Success) if (match.Success)
{ {
var tableRow = match.Groups[1].Value; var tableRow = match.Groups[1].Value;
@ -85,9 +86,9 @@ public partial class CustomFormatCategoryParser : ICustomFormatCategoryParser
return fields; return fields;
} }
[GeneratedRegex("^\\s*\\|(.*)\\|\\s*$", RegexOptions.None, 1000)] [GeneratedRegex(@"^\s*\|(.*)\|\s*$", RegexOptions.None, 1000)]
private static partial Regex TableRegex(); private static partial Regex TableRegex();
[GeneratedRegex("^\\[(.+?)\\]\\(#(.+?)\\)$", RegexOptions.None, 1000)] [GeneratedRegex(@"^\[(.+?)\]\(#(.+?)\)$", RegexOptions.None, 1000)]
private static partial Regex LinkRegex(); private static partial Regex LinkRegex();
} }

Loading…
Cancel
Save