Simplify ShouldHaveApiKey and HasErrors

This commit is contained in:
Bogdan 2023-05-26 18:32:35 +03:00 committed by Mark McDowall
parent efab1b0793
commit 7343616a47
3 changed files with 3 additions and 23 deletions

View File

@ -23,12 +23,7 @@ namespace NzbDrone.Core.Indexers.Newznab
private static bool ShouldHaveApiKey(NewznabSettings settings) private static bool ShouldHaveApiKey(NewznabSettings settings)
{ {
if (settings.BaseUrl == null) return settings.BaseUrl != null && ApiKeyWhiteList.Any(c => settings.BaseUrl.ToLowerInvariant().Contains(c));
{
return false;
}
return ApiKeyWhiteList.Any(c => settings.BaseUrl.ToLowerInvariant().Contains(c));
} }
private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled); private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled);

View File

@ -17,12 +17,7 @@ namespace NzbDrone.Core.Indexers.Torznab
private static bool ShouldHaveApiKey(TorznabSettings settings) private static bool ShouldHaveApiKey(TorznabSettings settings)
{ {
if (settings.BaseUrl == null) return settings.BaseUrl != null && ApiKeyWhiteList.Any(c => settings.BaseUrl.ToLowerInvariant().Contains(c));
{
return false;
}
return ApiKeyWhiteList.Any(c => settings.BaseUrl.ToLowerInvariant().Contains(c));
} }
private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled); private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled);

View File

@ -24,17 +24,7 @@ namespace NzbDrone.Core.Validation
public static bool HasErrors(this List<ValidationFailure> list) public static bool HasErrors(this List<ValidationFailure> list)
{ {
foreach (var item in list) return list.Any(item => item is not NzbDroneValidationFailure { IsWarning: true });
{
if (item is NzbDroneValidationFailure { IsWarning: true })
{
continue;
}
return true;
}
return false;
} }
} }
} }