style: Code cleanup on entire solution

snyk
Robert Dailey 1 year ago
parent 63d852a4b4
commit fea6575ae8

@ -10,7 +10,7 @@ public sealed class CannotBeEmptyAttribute : RequiredAttribute
public override bool IsValid(object? value) public override bool IsValid(object? value)
{ {
return base.IsValid(value) && return base.IsValid(value) &&
value is IEnumerable list && value is IEnumerable list &&
list.GetEnumerator().MoveNext(); list.GetEnumerator().MoveNext();
} }
} }

@ -16,7 +16,7 @@ public class YamlNullableEnumTypeConverter : IYamlTypeConverter
public object? ReadYaml(IParser parser, Type type) public object? ReadYaml(IParser parser, Type type)
{ {
type = Nullable.GetUnderlyingType(type) ?? type = Nullable.GetUnderlyingType(type) ??
throw new ArgumentException("Expected nullable enum type for ReadYaml"); throw new ArgumentException("Expected nullable enum type for ReadYaml");
if (parser.Accept<NodeEvent>(out var @event) && NodeIsNull(@event)) if (parser.Accept<NodeEvent>(out var @event) && NodeIsNull(@event))
{ {
@ -38,7 +38,7 @@ public class YamlNullableEnumTypeConverter : IYamlTypeConverter
public void WriteYaml(IEmitter emitter, object? value, Type type) public void WriteYaml(IEmitter emitter, object? value, Type type)
{ {
type = Nullable.GetUnderlyingType(type) ?? type = Nullable.GetUnderlyingType(type) ??
throw new ArgumentException("Expected nullable enum type for WriteYaml"); throw new ArgumentException("Expected nullable enum type for WriteYaml");
if (value == null) if (value == null)
{ {
@ -46,7 +46,7 @@ public class YamlNullableEnumTypeConverter : IYamlTypeConverter
} }
var toWrite = Enum.GetName(type, value) ?? var toWrite = Enum.GetName(type, value) ??
throw new InvalidOperationException($"Invalid value {value} for enum: {type}"); throw new InvalidOperationException($"Invalid value {value} for enum: {type}");
emitter.Emit(new Scalar(null!, null!, toWrite, ScalarStyle.Any, true, false)); emitter.Emit(new Scalar(null!, null!, toWrite, ScalarStyle.Any, true, false));
} }

@ -30,5 +30,5 @@ public class ProcessedCustomFormatData
[SuppressMessage("Microsoft.Design", "CA1024", Justification = "Method throws an exception")] [SuppressMessage("Microsoft.Design", "CA1024", Justification = "Method throws an exception")]
public int GetCustomFormatId() public int GetCustomFormatId()
=> CacheEntry?.CustomFormatId ?? => CacheEntry?.CustomFormatId ??
throw new InvalidOperationException("CacheEntry must exist to obtain custom format ID"); throw new InvalidOperationException("CacheEntry must exist to obtain custom format ID");
} }

@ -5,10 +5,9 @@ using Recyclarr.TrashLib.Services.CustomFormat.Models;
namespace Recyclarr.TrashLib.Services.CustomFormat.Processors.GuideSteps; namespace Recyclarr.TrashLib.Services.CustomFormat.Processors.GuideSteps;
/// <remarks> /// <remarks>
/// The purpose of this step is to validate the custom format data in the configs: /// The purpose of this step is to validate the custom format data in the configs:
/// /// - Validate that custom formats specified in the config exist in the guide.
/// - Validate that custom formats specified in the config exist in the guide. /// - Removal of duplicates.
/// - Removal of duplicates.
/// </remarks> /// </remarks>
public class ConfigStep : IConfigStep public class ConfigStep : IConfigStep
{ {

@ -80,6 +80,6 @@ internal class QualityProfileApiPersistenceStep : IQualityProfileApiPersistenceS
{ {
return scoreMap.Mapping.FirstOrDefault( return scoreMap.Mapping.FirstOrDefault(
m => m.CustomFormat.CacheEntry != null && m => m.CustomFormat.CacheEntry != null &&
formatItem.Value<int>("format") == m.CustomFormat.CacheEntry.CustomFormatId); formatItem.Value<int>("format") == m.CustomFormat.CacheEntry.CustomFormatId);
} }
} }

@ -6,7 +6,8 @@ namespace Recyclarr.TrashLib.Services.Radarr;
// code does not need to be changed later. // code does not need to be changed later.
public record RadarrCapabilities(Version Version) public record RadarrCapabilities(Version Version)
{ {
public RadarrCapabilities() : this(new Version()) public RadarrCapabilities()
: this(new Version())
{ {
} }
} }

@ -51,10 +51,10 @@ public record ReleaseProfileData
public override string ToString() public override string ToString()
{ {
return $"[TrashId: {TrashId}] " + return $"[TrashId: {TrashId}] " +
$"[Name: {Name}] " + $"[Name: {Name}] " +
$"[IncludePreferred: {IncludePreferredWhenRenaming}] " + $"[IncludePreferred: {IncludePreferredWhenRenaming}] " +
$"[Required: {Required.Count}] " + $"[Required: {Required.Count}] " +
$"[Ignored: {Ignored.Count}] " + $"[Ignored: {Ignored.Count}] " +
$"[Preferred: {Preferred.Count}]"; $"[Preferred: {Preferred.Count}]";
} }
} }

@ -2,7 +2,8 @@ namespace Recyclarr.TrashLib.Services.Sonarr;
public record SonarrCapabilities(Version Version) public record SonarrCapabilities(Version Version)
{ {
public SonarrCapabilities() : this(new Version()) public SonarrCapabilities()
: this(new Version())
{ {
} }

@ -60,7 +60,7 @@ public class SonarrGuideDataLister : ISonarrGuideDataLister
if (!validator.Validate(profile).IsValid) if (!validator.Validate(profile).IsValid)
{ {
_console.Output.WriteLine("This release profile has no terms that can be filtered. " + _console.Output.WriteLine("This release profile has no terms that can be filtered. " +
"Terms must have Trash IDs assigned in order to be filtered."); "Terms must have Trash IDs assigned in order to be filtered.");
return; return;
} }

@ -12,9 +12,9 @@ public static class AutoMapperConfig
cfg.AddMaps(typeof(AutoMapperConfig)); cfg.AddMaps(typeof(AutoMapperConfig));
}); });
#if DEBUG #if DEBUG
mapperConfig.AssertConfigurationIsValid(); mapperConfig.AssertConfigurationIsValid();
#endif #endif
return mapperConfig.CreateMapper(); return mapperConfig.CreateMapper();
} }

Loading…
Cancel
Save