refactor: Fix resharper analysis suggestions

pull/139/head
Robert Dailey 2 years ago
parent fc92e2937d
commit e5750a97ba

@ -2,19 +2,18 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Recyclarr.Gui.Pages
namespace Recyclarr.Gui.Pages;
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}

@ -45,6 +45,8 @@ public abstract class IntegrationFixture : IDisposable
SetupMetadataJson();
}
// ReSharper disable once VirtualMemberNeverOverridden.Global
// ReSharper disable once UnusedParameter.Global
protected virtual void RegisterExtraTypes(ContainerBuilder builder)
{
}
@ -63,17 +65,22 @@ public abstract class IntegrationFixture : IDisposable
Fs.AddFileFromResource(metadataFile, "metadata.json");
}
// ReSharper disable MemberCanBePrivate.Global
protected MockFileSystem Fs { get; } = new();
protected FakeInMemoryConsole Console { get; } = new();
protected ILifetimeScope Container { get; }
protected IAppPaths Paths { get; }
protected ILogger Logger { get; }
// ReSharper restore MemberCanBePrivate.Global
private static void RegisterMockFor<T>(ContainerBuilder builder) where T : class
{
builder.RegisterInstance(Substitute.For<T>()).As<T>();
}
// ReSharper disable once UnusedMember.Global
protected T Resolve<T>(Action<ContainerBuilder> customRegistrations) where T : notnull
{
var childScope = Container.BeginLifetimeScope(customRegistrations);
@ -85,6 +92,7 @@ public abstract class IntegrationFixture : IDisposable
return Container.Resolve<T>();
}
// ReSharper disable once VirtualMemberNeverOverridden.Global
protected virtual void Dispose(bool disposing)
{
if (!disposing)

@ -125,7 +125,7 @@ public class ConfigurationLoaderTest : IntegrationFixture
Errors = {new ValidationFailure("PropertyName", "Test Validation Failure")}
});
var testYml = @"
const string testYml = @"
fubar:
- api_key: abc
";
@ -137,7 +137,7 @@ fubar:
[Test, AutoMockData]
public void Validation_success_does_not_throw(ConfigurationLoader<TestConfig> configLoader)
{
var testYml = @"
const string testYml = @"
fubar:
- api_key: abc
";

@ -20,6 +20,7 @@ public abstract class BaseCommand : ICommand
[CommandOption("debug", 'd', Description =
"Display additional logs useful for development/debug purposes.")]
// ReSharper disable once MemberCanBeProtected.Global
public bool Debug { get; [UsedImplicitly] set; } = false;
protected virtual void RegisterServices(ContainerBuilder builder)

@ -16,16 +16,18 @@ namespace Recyclarr.Command;
[UsedImplicitly]
internal class RadarrCommand : ServiceCommand
{
// ReSharper disable MemberCanBePrivate.Global
[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; }
// ReSharper restore MemberCanBePrivate.Global
public override string Name => "Radarr";
public override async Task Process(ILifetimeScope container)
@ -59,6 +61,8 @@ internal class RadarrCommand : ServiceCommand
log.Information("Processing server {Url}", FlurlLogging.SanitizeUrl(config.BaseUrl));
// ReSharper disable InvertIf
if (config.QualityDefinition != null)
{
var updater = scope.Resolve<IRadarrQualityDefinitionUpdater>();
@ -70,6 +74,8 @@ internal class RadarrCommand : ServiceCommand
var updater = scope.Resolve<ICustomFormatUpdater>();
await updater.Process(Preview, config.CustomFormats, guideService);
}
// ReSharper restore InvertIf
}
}
}

@ -103,6 +103,7 @@ public abstract class ServiceCommand : BaseCommand, IServiceCommand
settings.JsonSerializer = new NewtonsoftJsonSerializer(jsonSettings);
FlurlLogging.SetupLogging(settings, log);
// ReSharper disable once InvertIf
if (!settingsProvider.Settings.EnableSslCertificateValidation)
{
log.Warning(

@ -19,6 +19,8 @@ namespace Recyclarr.Command;
[UsedImplicitly]
public class SonarrCommand : ServiceCommand
{
// ReSharper disable MemberCanBePrivate.Global
[CommandOption("list-release-profiles", Description =
"List available release profiles from the guide in YAML format.")]
public bool ListReleaseProfiles { get; [UsedImplicitly] set; }
@ -32,14 +34,14 @@ 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; }
// ReSharper restore MemberCanBePrivate.Global
public override string Name => "Sonarr";
public override async Task Process(ILifetimeScope container)
@ -97,6 +99,8 @@ public class SonarrCommand : ServiceCommand
var versionEnforcement = scope.Resolve<ISonarrVersionEnforcement>();
await versionEnforcement.DoVersionEnforcement(config);
// ReSharper disable InvertIf
if (config.ReleaseProfiles.Count > 0)
{
var updater = scope.Resolve<IReleaseProfileUpdater>();
@ -114,6 +118,8 @@ public class SonarrCommand : ServiceCommand
var updater = scope.Resolve<ICustomFormatUpdater>();
await updater.Process(Preview, config.CustomFormats, guideService);
}
// ReSharper restore InvertIf
}
}
}

@ -41,6 +41,8 @@ public class ConfigurationException : Exception
const string delim = "\n - ";
var builder = new StringBuilder(
$"An exception occurred while deserializing type '{DeserializableType}' for YML property '{PropertyName}'");
// ReSharper disable once InvertIf
if (ErrorMessages.Count > 0)
{
builder.Append(":" + delim);

@ -5,7 +5,5 @@ namespace Recyclarr.Config;
public interface IConfigurationLoader<out T>
where T : IServiceConfiguration
{
IEnumerable<T> Load(string file, string configSection);
IEnumerable<T> LoadFromStream(TextReader stream, string configSection);
IEnumerable<T> LoadMany(IEnumerable<string> configFiles, string configSection);
}

Loading…
Cancel
Save