Skip to content
Open
6 changes: 3 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@

<!-- Standard testing packages -->
<ItemGroup Condition="'$(TestProject)'=='true'">
<PackageReference Include="coverlet.collector" Version="10.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageReference Include="coverlet.collector" Version="10.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageReference Include="NUnit" Version="4.6.1" />
<PackageReference Include="NUnit3TestAdapter" Version="6.3.1" />
<PackageReference Include="NunitXml.TestLogger" Version="8.1.0" />
Expand All @@ -174,7 +174,7 @@
<!-- Set up stylecop -->
<ItemGroup Condition="'$(GamarrProject)'=='true' and '$(EnableAnalyzers)'!='false'">
<!-- StyleCop analysis -->
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PackageReference Include="StyleCop.Analyzers" Version="1.3.180">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/Gamarr.Api.V3/Config/NamingConfigController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public ActionResult<NamingConfigResource> UpdateNamingConfig([FromBody] NamingCo
}

[HttpGet("examples")]
public object GetExamples([FromQuery]NamingConfigResource config)
public object GetExamples([FromQuery] NamingConfigResource config)
{
if (config.Id == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Gamarr.Api.V3.CustomFormats
{
public class CustomFormatBulkResource
{
public HashSet<int> Ids { get; set; } = new ();
public HashSet<int> Ids { get; set; } = new();
public bool? IncludeCustomFormatWhenRenaming { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/Gamarr.Api.V3/DownloadClient/DownloadClientController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace Gamarr.Api.V3.DownloadClient
[V3ApiController]
public class DownloadClientController : ProviderControllerBase<DownloadClientResource, DownloadClientBulkResource, IDownloadClient, DownloadClientDefinition>
{
public static readonly DownloadClientResourceMapper ResourceMapper = new ();
public static readonly DownloadClientBulkResourceMapper BulkResourceMapper = new ();
public static readonly DownloadClientResourceMapper ResourceMapper = new();
public static readonly DownloadClientBulkResourceMapper BulkResourceMapper = new();

public DownloadClientController(IBroadcastSignalRMessage signalRBroadcaster, IDownloadClientFactory downloadClientFactory)
: base(signalRBroadcaster, downloadClientFactory, "downloadclient", ResourceMapper, BulkResourceMapper)
Expand Down
2 changes: 1 addition & 1 deletion src/Gamarr.Api.V3/GameFiles/GameFileListResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace Gamarr.Api.V3.GameFiles
{
public class GameFileListResource
{
public List<int> GameFileIds { get; set; } = new ();
public List<int> GameFileIds { get; set; } = new();
}
}
3 changes: 2 additions & 1 deletion src/Gamarr.Api.V3/Games/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ public ActionResult<GameResource> UpdateGame([FromBody] GameResource gamesResour
GameId = game.Id,
SourcePath = sourcePath,
DestinationPath = destinationPath
}, trigger: CommandTrigger.Manual);
},
trigger: CommandTrigger.Manual);
}

var model = gamesResource.ToModel(game);
Expand Down
4 changes: 2 additions & 2 deletions src/Gamarr.Api.V3/ImportLists/ImportListController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace Gamarr.Api.V3.ImportLists
[V3ApiController]
public class ImportListController : ProviderControllerBase<ImportListResource, ImportListBulkResource, IImportList, ImportListDefinition>
{
public static readonly ImportListResourceMapper ResourceMapper = new ();
public static readonly ImportListBulkResourceMapper BulkResourceMapper = new ();
public static readonly ImportListResourceMapper ResourceMapper = new();
public static readonly ImportListBulkResourceMapper BulkResourceMapper = new();

public ImportListController(IBroadcastSignalRMessage signalRBroadcaster,
IImportListFactory importListFactory,
Expand Down
11 changes: 7 additions & 4 deletions src/Gamarr.Api.V3/ImportLists/ImportListGamesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ public object GetDiscoverGames(bool includeRecommendations = false, bool include
// match (IgdbId == 0) into a single arbitrary row, and one
// Steam-only library game marked all of them as existing.
var groupedListGames = realResults.GroupBy(x =>
x.IgdbId > 0 ? $"igdb-{x.IgdbId}"
: x.SteamAppId > 0 ? $"steam-{x.SteamAppId}"
: $"title-{x.Title}-{x.Year}");
x.IgdbId > 0
? $"igdb-{x.IgdbId}"
: x.SteamAppId > 0
? $"steam-{x.SteamAppId}"
: $"title-{x.Title}-{x.Year}");

// Distinct Games
realResults = groupedListGames.Select(x =>
Expand Down Expand Up @@ -245,7 +247,8 @@ private IEnumerable<ImportListGamesResource> MapToResource(IEnumerable<ImportLis
resource.Folder = _fileNameBuilder.GetGameFolder(new Game
{
GameMetadata = currentGame.GameMetadata
}, namingConfig);
},
namingConfig);

yield return resource;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Gamarr.Api.V3/Indexers/IndexerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace Gamarr.Api.V3.Indexers
[V3ApiController]
public class IndexerController : ProviderControllerBase<IndexerResource, IndexerBulkResource, IIndexer, IndexerDefinition>
{
public static readonly IndexerResourceMapper ResourceMapper = new ();
public static readonly IndexerBulkResourceMapper BulkResourceMapper = new ();
public static readonly IndexerResourceMapper ResourceMapper = new();
public static readonly IndexerBulkResourceMapper BulkResourceMapper = new();

public IndexerController(IBroadcastSignalRMessage signalRBroadcaster,
IndexerFactory indexerFactory,
Expand Down
2 changes: 1 addition & 1 deletion src/Gamarr.Api.V3/Indexers/ReleasePushController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public ActionResult<List<ReleaseResource>> Create([FromBody] ReleaseResource rel

if (decision?.RemoteGame.ParsedGameInfo == null)
{
throw new ValidationException(new List<ValidationFailure> { new ("Title", "Unable to parse", release.Title) });
throw new ValidationException(new List<ValidationFailure> { new("Title", "Unable to parse", release.Title) });
}

if (grabResult != ProcessedDecisionResult.Grabbed)
Expand Down
4 changes: 2 additions & 2 deletions src/Gamarr.Api.V3/Metadata/MetadataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace Gamarr.Api.V3.Metadata
[V3ApiController]
public class MetadataController : ProviderControllerBase<MetadataResource, MetadataBulkResource, IMetadata, MetadataDefinition>
{
public static readonly MetadataResourceMapper ResourceMapper = new ();
public static readonly MetadataBulkResourceMapper BulkResourceMapper = new ();
public static readonly MetadataResourceMapper ResourceMapper = new();
public static readonly MetadataBulkResourceMapper BulkResourceMapper = new();

public MetadataController(IBroadcastSignalRMessage signalRBroadcaster, IMetadataFactory metadataFactory)
: base(signalRBroadcaster, metadataFactory, "metadata", ResourceMapper, BulkResourceMapper)
Expand Down
4 changes: 2 additions & 2 deletions src/Gamarr.Api.V3/Notifications/NotificationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace Gamarr.Api.V3.Notifications
[V3ApiController]
public class NotificationController : ProviderControllerBase<NotificationResource, NotificationBulkResource, INotification, NotificationDefinition>
{
public static readonly NotificationResourceMapper ResourceMapper = new ();
public static readonly NotificationBulkResourceMapper BulkResourceMapper = new ();
public static readonly NotificationResourceMapper ResourceMapper = new();
public static readonly NotificationBulkResourceMapper BulkResourceMapper = new();

public NotificationController(IBroadcastSignalRMessage signalRBroadcaster, NotificationFactory notificationFactory)
: base(signalRBroadcaster, notificationFactory, "notification", ResourceMapper, BulkResourceMapper)
Expand Down
8 changes: 4 additions & 4 deletions src/Gamarr.Api.V3/Profiles/Quality/QualityCutoffValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ValidCutoffValidator<T> : PropertyValidator<T, int>
{
public override string Name => "ValidCutoffValidator";

public override bool IsValid(ValidationContext<T> context, int cutoff)
public override bool IsValid(ValidationContext<T> context, int value)
{
var instance = context.InstanceToValidate;
var items = instance.Items;
Expand All @@ -28,19 +28,19 @@ public override bool IsValid(ValidationContext<T> context, int cutoff)
return false;
}

var cutoffItem = items.SingleOrDefault(i => (i.Quality == null && i.Id == cutoff) || i.Quality?.Id == cutoff);
var cutoffItem = items.SingleOrDefault(i => (i.Quality == null && i.Id == value) || i.Quality?.Id == value);

if (cutoffItem == null)
{
context.MessageFormatter.AppendArgument("ValidationMessage",
$"Cutoff ID '{cutoff}' does not match any quality or group in the profile");
$"Cutoff ID '{value}' does not match any quality or group in the profile");
return false;
}

if (!cutoffItem.Allowed)
{
context.MessageFormatter.AppendArgument("ValidationMessage",
$"Cutoff quality/group '{cutoffItem.Name ?? cutoffItem.Quality?.Name ?? cutoff.ToString()}' must be allowed");
$"Cutoff quality/group '{cutoffItem.Name ?? cutoffItem.Quality?.Name ?? value.ToString()}' must be allowed");
return false;
}

Expand Down
46 changes: 23 additions & 23 deletions src/Gamarr.Api.V3/Profiles/Quality/QualityItemsValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class AllowedValidator<T> : PropertyValidator<T, IList<QualityProfileQual
{
public override string Name => "AllowedValidator";

public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> list)
public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> value)
{
return list != null && list.Any(c => c.Allowed);
return value != null && value.Any(c => c.Allowed);
}

protected override string GetDefaultMessageTemplate(string errorCode) => "Must contain at least one allowed quality";
Expand All @@ -39,14 +39,14 @@ public class GroupItemValidator<T> : PropertyValidator<T, IList<QualityProfileQu
{
public override string Name => "GroupItemValidator";

public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> items)
public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> value)
{
if (items == null)
if (value == null)
{
return false;
}

return !items.Any(i => i.Name.IsNotNullOrWhiteSpace() && i.Items.Count <= 1);
return !value.Any(i => i.Name.IsNotNullOrWhiteSpace() && i.Items.Count <= 1);
}

protected override string GetDefaultMessageTemplate(string errorCode) => "Groups must contain multiple qualities";
Expand All @@ -56,14 +56,14 @@ public class QualityNameValidator<T> : PropertyValidator<T, IList<QualityProfile
{
public override string Name => "QualityNameValidator";

public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> items)
public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> value)
{
if (items == null)
if (value == null)
{
return false;
}

return !items.Any(i => i.Name.IsNotNullOrWhiteSpace() && i.Quality != null);
return !value.Any(i => i.Name.IsNotNullOrWhiteSpace() && i.Quality != null);
}

protected override string GetDefaultMessageTemplate(string errorCode) => "Individual qualities should not be named";
Expand All @@ -73,14 +73,14 @@ public class ItemGroupNameValidator<T> : PropertyValidator<T, IList<QualityProfi
{
public override string Name => "ItemGroupNameValidator";

public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> items)
public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> value)
{
if (items == null)
if (value == null)
{
return false;
}

return !items.Any(i => i.Quality == null && i.Name.IsNullOrWhiteSpace());
return !value.Any(i => i.Quality == null && i.Name.IsNullOrWhiteSpace());
}

protected override string GetDefaultMessageTemplate(string errorCode) => "Groups must have a name";
Expand All @@ -90,14 +90,14 @@ public class ItemGroupIdValidator<T> : PropertyValidator<T, IList<QualityProfile
{
public override string Name => "ItemGroupIdValidator";

public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> items)
public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> value)
{
if (items == null)
if (value == null)
{
return false;
}

return !items.Any(i => i.Quality == null && i.Id == 0);
return !value.Any(i => i.Quality == null && i.Id == 0);
}

protected override string GetDefaultMessageTemplate(string errorCode) => "Groups must have an ID";
Expand All @@ -107,14 +107,14 @@ public class UniqueIdValidator<T> : PropertyValidator<T, IList<QualityProfileQua
{
public override string Name => "UniqueIdValidator";

public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> items)
public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> value)
{
if (items == null)
if (value == null)
{
return false;
}

var ids = items.Where(i => i.Id > 0).Select(i => i.Id);
var ids = value.Where(i => i.Id > 0).Select(i => i.Id);
var groupedIds = ids.GroupBy(i => i);

return groupedIds.All(g => g.Count() == 1);
Expand All @@ -127,16 +127,16 @@ public class UniqueQualityIdValidator<T> : PropertyValidator<T, IList<QualityPro
{
public override string Name => "UniqueQualityIdValidator";

public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> items)
public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> value)
{
if (items == null)
if (value == null)
{
return false;
}

var qualityIds = new HashSet<int>();

foreach (var item in items)
foreach (var item in value)
{
if (item.Id > 0)
{
Expand Down Expand Up @@ -171,16 +171,16 @@ public class AllQualitiesValidator<T> : PropertyValidator<T, IList<QualityProfil
{
public override string Name => "AllQualitiesValidator";

public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> items)
public override bool IsValid(ValidationContext<T> context, IList<QualityProfileQualityItemResource> value)
{
if (items == null)
if (value == null)
{
return false;
}

var qualityIds = new HashSet<int>();

foreach (var item in items)
foreach (var item in value)
{
if (item.Id > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ActionResult<QualityProfileResource> Create([FromBody] QualityProfileReso
}
catch (Exception ex) when (UniqueConstraintViolation.IsNameViolation(ex))
{
throw new ValidationException(new List<ValidationFailure> { new ("Name", "Should be unique") });
throw new ValidationException(new List<ValidationFailure> { new("Name", "Should be unique") });
}

return Created(model.Id);
Expand Down
2 changes: 1 addition & 1 deletion src/Gamarr.Api.V3/ProviderControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public ActionResult<TProviderResource> CreateProvider([FromBody] TProviderResour
}
catch (Exception ex) when (UniqueConstraintViolation.IsNameViolation(ex))
{
throw new ValidationException(new List<ValidationFailure> { new ("Name", "Should be unique") });
throw new ValidationException(new List<ValidationFailure> { new("Name", "Should be unique") });
}

return Created(providerDefinition.Id);
Expand Down
2 changes: 1 addition & 1 deletion src/Gamarr.Api.V3/Qualities/QualityDefinitionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public object UpdateMany([FromBody] List<QualityDefinitionResource> resource)
// and it bypasses the validator pipeline entirely.
if (!_titleInUseValidator.ValidateBatch(qualityDefinitions))
{
throw new ValidationException(new List<ValidationFailure> { new ("Title", "Should be unique") });
throw new ValidationException(new List<ValidationFailure> { new("Title", "Should be unique") });
}

_qualityDefinitionService.UpdateMany(qualityDefinitions);
Expand Down
2 changes: 1 addition & 1 deletion src/Gamarr.Api.V3/System/Backup/BackupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class BackupController : Controller
private readonly IAppFolderInfo _appFolderInfo;
private readonly IDiskProvider _diskProvider;

private static readonly List<string> ValidExtensions = new () { ".zip", ".db", ".xml" };
private static readonly List<string> ValidExtensions = new() { ".zip", ".db", ".xml" };

public BackupController(IBackupService backupService,
IAppFolderInfo appFolderInfo,
Expand Down
2 changes: 1 addition & 1 deletion src/Gamarr.Http/Frontend/Mappers/MediaCoverProxyMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Gamarr.Http.Frontend.Mappers
{
public class MediaCoverProxyMapper : IMapHttpRequestsToDisk
{
private readonly Regex _regex = new (@"/MediaCoverProxy/(?<hash>\w+)/(?<filename>(.+)\.(jpg|png|gif))");
private readonly Regex _regex = new(@"/MediaCoverProxy/(?<hash>\w+)/(?<filename>(.+)\.(jpg|png|gif))");

private readonly IMediaCoverProxy _mediaCoverProxy;
private readonly IContentTypeProvider _mimeTypeProvider;
Expand Down
8 changes: 5 additions & 3 deletions src/Gamarr.Http/PagingResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class PagingResource<TResource>
public string SortKey { get; set; }
public SortDirection SortDirection { get; set; }
public int TotalRecords { get; set; }
public List<TResource> Records { get; set; } = new ();
public List<TResource> Records { get; set; } = new();

public PagingResource()
{
Expand Down Expand Up @@ -52,9 +52,11 @@ public static PagingSpec<TModel> MapToPagingSpec<TResource, TModel>(
SortDirection = pagingResource.SortDirection,
};

pagingSpec.SortKey = pagingResource.SortKey != null &&
var isAllowedSortKey = pagingResource.SortKey != null &&
allowedSortKeys is { Count: > 0 } &&
allowedSortKeys.Contains(pagingResource.SortKey)
allowedSortKeys.Contains(pagingResource.SortKey);

pagingSpec.SortKey = isAllowedSortKey
? pagingResource.SortKey
: defaultSortKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace NzbDrone.Api.Test.v3.Qualities;
[Parallelizable(ParallelScope.All)]
public class QualityDefinitionResourceValidatorTests
{
private readonly QualityDefinitionResourceValidator _validator = new ();
private readonly QualityDefinitionResourceValidator _validator = new();

[Test]
public void Validate_fails_when_min_size_is_below_min_limit()
Expand Down
Loading
Loading