refactor: Address several SonarCloud code smells

pull/124/head
Robert Dailey 2 years ago
parent a124902f6d
commit 8acb3e17fc

@ -15,8 +15,8 @@ public sealed class ForceEmptySequences : INodeDeserializer
_objectFactory = objectFactory;
}
public bool Deserialize(IParser reader, Type expectedType, Func<IParser, Type, object?> nestedObjectDeserializer,
out object? value)
bool INodeDeserializer.Deserialize(IParser reader, Type expectedType,
Func<IParser, Type, object?> nestedObjectDeserializer, out object? value)
{
value = null;

@ -17,8 +17,8 @@ public class ServiceCompatibilityIntegrationTest : IntegrationFixture
var sut = Resolve<ISettingsProvider>();
var paths = Resolve<IAppPaths>();
// For this test, it doesn't really matter if the YAML data matches what SettingsValue expects;
// this test only ensures that the data deserialized is from the actual correct file.
// For this test, it doesn't really matter if the YAML data matches what SettingsValue expects.
// This test only ensures that the data deserialized is from the actual correct file.
const string yamlData = @"
repository:
clone_url: http://the_url.com

@ -87,7 +87,7 @@ public abstract class ServiceCommand : BaseCommand, IServiceCommand
return Task.CompletedTask;
}
private void SetupHttp(ILogger log, ISettingsProvider settingsProvider)
private static void SetupHttp(ILogger log, ISettingsProvider settingsProvider)
{
FlurlHttp.Configure(settings =>
{

@ -26,5 +26,6 @@ public class AppPathSetupTask : IBaseCommandSetupTask
public void OnFinish()
{
// No work to do for this event
}
}

@ -19,6 +19,7 @@ public class JanitorCleanupTask : IBaseCommandSetupTask
public void OnStart()
{
// No work to do for this event
}
public void OnFinish()

@ -67,7 +67,7 @@ public class CompositionRoot : ICompositionRoot
return new ServiceLocatorProxy(builder.Build());
}
private void RegisterLogger(ContainerBuilder builder, LogEventLevel logLevel)
private static void RegisterLogger(ContainerBuilder builder, LogEventLevel logLevel)
{
builder.RegisterType<LogJanitor>().As<ILogJanitor>();
builder.RegisterType<LoggerFactory>();
@ -76,7 +76,7 @@ public class CompositionRoot : ICompositionRoot
.InstancePerLifetimeScope();
}
private void RegisterAppPaths(ContainerBuilder builder, string? appDataDir)
private static void RegisterAppPaths(ContainerBuilder builder, string? appDataDir)
{
builder.RegisterModule<CommonAutofacModule>();
builder.RegisterType<FileSystem>().As<IFileSystem>();

@ -296,7 +296,7 @@ public class JsonTransactionStepTest
processor.Process(guideCfs, radarrCfs!);
processor.RecordDeletions(deletedCfsInCache, radarrCfs!);
var expectedJson = @"{
const string expectedJson = @"{
'id': 1,
'name': 'updated',
'specifications': [{

@ -34,11 +34,11 @@ internal class CustomFormatUpdater : ICustomFormatUpdater
private ILogger Log { get; }
public async Task Process(bool isPreview, IEnumerable<CustomFormatConfig> customFormats, IGuideService guideService)
public async Task Process(bool isPreview, IEnumerable<CustomFormatConfig> configs, IGuideService guideService)
{
_cache.Load();
await _guideProcessor.BuildGuideDataAsync(customFormats, _cache.CfCache, guideService);
await _guideProcessor.BuildGuideDataAsync(configs, _cache.CfCache, guideService);
if (!ValidateGuideDataAndCheckShouldProceed())
{

@ -64,44 +64,38 @@ public class CustomFormatGroupParser
break;
}
if (!line.Any())
if (line.Any())
{
if (tableRows.Any())
var fields = GetTableRow(line);
if (fields.Any())
{
break;
tableRows.Add(fields);
continue;
}
continue;
}
var match = TableRegex.Match(line);
if (!match.Success)
if (tableRows.Any())
{
if (tableRows.Any())
{
break;
}
continue;
}
var tableRow = match.Groups[1].Value;
var fields = tableRow.Split('|').Select(x => x.Trim()).ToList();
if (!fields.Any())
{
if (tableRows.Any())
{
break;
}
continue;
break;
}
tableRows.Add(fields);
}
return tableRows
// Filter out the `|---|---|---|` part of the table between the heading & data rows.
.Where(x => !Regex.IsMatch(x[0], @"^-+$"));
}
private static List<string> GetTableRow(string line)
{
var fields = new List<string>();
var match = TableRegex.Match(line);
if (match.Success)
{
var tableRow = match.Groups[1].Value;
fields = tableRow.Split('|').Select(x => x.Trim()).ToList();
}
return fields;
}
}

@ -5,5 +5,5 @@ namespace TrashLib.Services.CustomFormat;
public interface ICustomFormatUpdater
{
Task Process(bool isPreview, IEnumerable<CustomFormatConfig> config, IGuideService guideService);
Task Process(bool isPreview, IEnumerable<CustomFormatConfig> configs, IGuideService guideService);
}

@ -49,7 +49,6 @@ internal class SonarrQualityDefinitionUpdater : ISonarrQualityDefinitionUpdater
var qualityDefinitions = _guide.GetQualities();
var qualityTypeInConfig = config.QualityDefinition;
// var qualityDefinitions = _parser.ParseMarkdown(await _parser.GetMarkdownData());
SonarrQualityData? selectedQuality;
if (config.QualityDefinition.EqualsIgnoreCase("hybrid"))
@ -88,7 +87,6 @@ internal class SonarrQualityDefinitionUpdater : ISonarrQualityDefinitionUpdater
IReadOnlyCollection<QualityItem> anime,
IReadOnlyCollection<QualityItem> series)
{
// todo Verify anime & series are the same length? Probably not, because we might not care about some rows anyway.
_log.Information(
"Notice: Hybrid only functions on 720/1080 qualities and uses non-anime values for the rest (e.g. 2160)");

@ -44,7 +44,7 @@ public class ScopedState<T>
return prevCount != StackSize;
}
private class Node
private sealed class Node
{
public Node(T value, int scope)
{

Loading…
Cancel
Save