refactor: Address Resharper inspection issues

pull/138/head
Robert Dailey 2 years ago
parent 3d403ef737
commit c775bc3c4d

@ -2,6 +2,9 @@ using System.IO.Abstractions;
using System.IO.Abstractions.TestingHelpers;
using System.Reflection;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
namespace Common.TestLibrary;
public static class CommonMockFileSystemExtensions

@ -1,6 +0,0 @@
namespace Common;
public class AppContextProxy : IAppContext
{
public string BaseDirectory => AppContext.BaseDirectory;
}

@ -8,6 +8,5 @@ public class CommonAutofacModule : Module
{
builder.RegisterType<DefaultEnvironment>().As<IEnvironment>();
builder.RegisterType<FileUtilities>().As<IFileUtilities>();
builder.RegisterType<AppContextProxy>().As<IAppContext>();
}
}

@ -5,6 +5,7 @@ public static class DictionaryExtensions
public static TValue GetOrCreate<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key)
where TValue : new()
{
// ReSharper disable once InvertIf
if (!dict.TryGetValue(key, out var val))
{
val = new TValue();

@ -1,17 +0,0 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;
namespace Common.Extensions;
public static class RegexExtensions
{
[SuppressMessage("Design", "CA1021:Avoid out parameters",
Justification =
"The out param has a very specific design purpose. It's to allow regex match expressions " +
"to be executed inside an if condition while also providing match output variable.")]
public static bool Match(this Regex re, string strToCheck, out Match match)
{
match = re.Match(strToCheck);
return match.Success;
}
}

@ -6,6 +6,7 @@ namespace Common.Extensions;
public static class RxExtensions
{
// ReSharper disable once UnusedMember.Global
public static IObservable<T> Spy<T>(this IObservable<T> source, ILogger log, string? opName = null)
{
opName ??= "IObservable";

@ -1,5 +1,7 @@
using System.Globalization;
// ReSharper disable UnusedMember.Global
namespace Common.Extensions;
public static class StringExtensions

@ -6,6 +6,7 @@ namespace Common.FluentValidation;
public static class FluentValidationExtensions
{
// From: https://github.com/FluentValidation/FluentValidation/issues/1648
// ReSharper disable once UnusedMethodReturnValue.Global
public static IRuleBuilderOptions<T, TProperty?> SetNonNullableValidator<T, TProperty>(
this IRuleBuilder<T, TProperty?> ruleBuilder, IValidator<TProperty> validator, params string[] ruleSets)
{

@ -1,6 +0,0 @@
namespace Common;
public interface IAppContext
{
string BaseDirectory { get; }
}

@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace Common.YamlDotNet;
[AttributeUsage(AttributeTargets.Property)]
// ReSharper disable once UnusedType.Global
public sealed class CannotBeEmptyAttribute : RequiredAttribute
{
public override bool IsValid(object? value)

@ -2,6 +2,8 @@ using JetBrains.Annotations;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NodeDeserializers;
// ReSharper disable UnusedMember.Global
namespace Common.YamlDotNet;
public static class YamlDotNetExtensions

@ -1,7 +0,0 @@
namespace Recyclarr.Command.Helpers;
public enum ExitCode
{
Success = 0,
Failure = 1
}

@ -2,8 +2,5 @@ namespace Recyclarr.Command;
public interface IServiceCommand
{
bool Preview { get; }
bool Debug { get; }
ICollection<string> Config { get; }
string Name { get; }
}

@ -30,6 +30,7 @@ public class MigrateCommand : BaseCommand
msg.AppendLine($"Step That Failed: {e.OperationDescription}");
msg.AppendLine($"Failure Reason: {e.OriginalException.Message}");
// ReSharper disable once InvertIf
if (e.Remediation.Any())
{
msg.AppendLine("\nPossible remediation steps:");

@ -18,10 +18,12 @@ internal class RadarrCommand : ServiceCommand
{
[CommandOption("list-custom-formats", Description =
"List available custom formats from the guide in YAML format.")]
// ReSharper disable once MemberCanBePrivate.Global
public bool ListCustomFormats { get; [UsedImplicitly] set; }
[CommandOption("list-qualities", Description =
"List available quality definition types from the guide.")]
// ReSharper disable once MemberCanBePrivate.Global
public bool ListQualities { get; [UsedImplicitly] set; }
public override string Name => "Radarr";

@ -22,11 +22,13 @@ public abstract class ServiceCommand : BaseCommand, IServiceCommand
{
[CommandOption("preview", 'p', Description =
"Only display the processed markdown results without making any API calls.")]
// ReSharper disable once MemberCanBeProtected.Global
public bool Preview { get; [UsedImplicitly] set; } = false;
[CommandOption("config", 'c', Description =
"One or more YAML config files to use. All configs will be used and settings are additive. " +
"If not specified, the script will look for `recyclarr.yml` in the same directory as the executable.")]
// ReSharper disable once MemberCanBeProtected.Global
public ICollection<string> Config { get; [UsedImplicitly] set; } = new List<string>();
[CommandOption("app-data", Description =

@ -32,10 +32,12 @@ public class SonarrCommand : ServiceCommand
[CommandOption("list-qualities", Description =
"List available quality definition types from the guide.")]
// ReSharper disable once MemberCanBeProtected.Global
public bool ListQualities { get; [UsedImplicitly] set; }
[CommandOption("list-custom-formats", Description =
"List available custom formats from the guide in YAML format.")]
// ReSharper disable once MemberCanBeProtected.Global
public bool ListCustomFormats { get; [UsedImplicitly] set; }
public override string Name => "Sonarr";

@ -77,9 +77,6 @@ public class ConfigurationLoader<T> : IConfigurationLoader<T>
public IEnumerable<T> LoadMany(IEnumerable<string> configFiles, string configSection)
{
foreach (var config in configFiles.SelectMany(file => Load(file, configSection)))
{
yield return config;
}
return configFiles.SelectMany(file => Load(file, configSection));
}
}

@ -1,20 +1,22 @@
using JetBrains.Annotations;
namespace TrashLib.Config.Settings;
public record TrashRepository
{
public string CloneUrl { get; init; } = "https://github.com/TRaSH-/Guides.git";
public string Branch { get; init; } = "master";
public string? Sha1 { get; init; }
public string CloneUrl { get; [UsedImplicitly] init; } = "https://github.com/TRaSH-/Guides.git";
public string Branch { get; [UsedImplicitly] init; } = "master";
public string? Sha1 { get; [UsedImplicitly] init; }
}
public record LogJanitorSettings
{
public int MaxFiles { get; init; } = 20;
public int MaxFiles { get; [UsedImplicitly] init; } = 20;
}
public record SettingsValues
{
public TrashRepository Repository { get; init; } = new();
public bool EnableSslCertificateValidation { get; init; } = true;
public LogJanitorSettings LogJanitor { get; init; } = new();
public TrashRepository Repository { get; [UsedImplicitly] init; } = new();
public bool EnableSslCertificateValidation { get; [UsedImplicitly] init; } = true;
public LogJanitorSettings LogJanitor { get; [UsedImplicitly] init; } = new();
}

@ -1,6 +1,7 @@
namespace TrashLib.Services.Radarr.QualityDefinition;
public record RadarrQualityData(
// ReSharper disable once NotAccessedPositionalProperty.Global
string TrashId,
string Type,
IReadOnlyCollection<RadarrQualityItem> Qualities

@ -1,7 +1,9 @@
using JetBrains.Annotations;
namespace TrashLib.Services.Sonarr.Api.Objects;
public class SonarrTag
{
public string Label { get; set; } = "";
public int Id { get; set; }
public string Label { get; [UsedImplicitly] set; } = "";
public int Id { get; [UsedImplicitly] set; }
}

@ -1,23 +1,26 @@
using JetBrains.Annotations;
using TrashLib.Config.Services;
namespace TrashLib.Services.Sonarr.Config;
public class SonarrConfiguration : ServiceConfiguration
{
public IList<ReleaseProfileConfig> ReleaseProfiles { get; init; } = Array.Empty<ReleaseProfileConfig>();
public string QualityDefinition { get; init; } = "";
public IList<ReleaseProfileConfig> ReleaseProfiles { get; [UsedImplicitly] init; } =
Array.Empty<ReleaseProfileConfig>();
public string QualityDefinition { get; [UsedImplicitly] init; } = "";
}
public class ReleaseProfileConfig
{
public IReadOnlyCollection<string> TrashIds { get; init; } = Array.Empty<string>();
public bool StrictNegativeScores { get; init; }
public IReadOnlyCollection<string> Tags { get; init; } = Array.Empty<string>();
public SonarrProfileFilterConfig? Filter { get; init; }
public IReadOnlyCollection<string> TrashIds { get; [UsedImplicitly] init; } = Array.Empty<string>();
public bool StrictNegativeScores { get; [UsedImplicitly] init; }
public IReadOnlyCollection<string> Tags { get; [UsedImplicitly] init; } = Array.Empty<string>();
public SonarrProfileFilterConfig? Filter { get; [UsedImplicitly] init; }
}
public class SonarrProfileFilterConfig
{
public IReadOnlyCollection<string> Include { get; init; } = Array.Empty<string>();
public IReadOnlyCollection<string> Exclude { get; init; } = Array.Empty<string>();
public IReadOnlyCollection<string> Include { get; [UsedImplicitly] init; } = Array.Empty<string>();
public IReadOnlyCollection<string> Exclude { get; [UsedImplicitly] init; } = Array.Empty<string>();
}

@ -3,6 +3,7 @@ using TrashLib.Services.Common.QualityDefinition;
namespace TrashLib.Services.Sonarr.QualityDefinition;
public record SonarrQualityData(
// ReSharper disable once NotAccessedPositionalProperty.Global
string TrashId,
string Type,
IReadOnlyCollection<QualityItem> Qualities

Loading…
Cancel
Save