From a00084e643f394fec3482bdd1b3abe8015842e4f Mon Sep 17 00:00:00 2001 From: Simon Baynes Date: Mon, 12 Feb 2024 18:36:05 +0000 Subject: [PATCH] Fix sonar recommendations Closes #61 --- src/Console/Factories/ConfigFactory.cs | 2 +- src/Console/Factories/LoggerFactory.cs | 2 +- src/Console/Factories/WarmerFactory.cs | 2 +- src/SiteWarmer.Core/Logging/ConsoleLogger.cs | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Console/Factories/ConfigFactory.cs b/src/Console/Factories/ConfigFactory.cs index 605cce0..0c7eeef 100644 --- a/src/Console/Factories/ConfigFactory.cs +++ b/src/Console/Factories/ConfigFactory.cs @@ -3,7 +3,7 @@ namespace Console.Factories; -public class ConfigFactory +public static class ConfigFactory { public static IConfig Create(List input) { diff --git a/src/Console/Factories/LoggerFactory.cs b/src/Console/Factories/LoggerFactory.cs index ce9f091..006b371 100644 --- a/src/Console/Factories/LoggerFactory.cs +++ b/src/Console/Factories/LoggerFactory.cs @@ -2,7 +2,7 @@ namespace Console.Factories; -public class LoggerFactory +public static class LoggerFactory { public static ILogger Create(bool? logError) { diff --git a/src/Console/Factories/WarmerFactory.cs b/src/Console/Factories/WarmerFactory.cs index 3566989..cdc8749 100644 --- a/src/Console/Factories/WarmerFactory.cs +++ b/src/Console/Factories/WarmerFactory.cs @@ -5,7 +5,7 @@ namespace Console.Factories; -public class WarmerFactory +public static class WarmerFactory { public static Warmer Create(int? retries, IConfig config, IRequester requester, ILogger logger) { diff --git a/src/SiteWarmer.Core/Logging/ConsoleLogger.cs b/src/SiteWarmer.Core/Logging/ConsoleLogger.cs index 64b9dae..ee5bfe6 100644 --- a/src/SiteWarmer.Core/Logging/ConsoleLogger.cs +++ b/src/SiteWarmer.Core/Logging/ConsoleLogger.cs @@ -7,7 +7,7 @@ namespace SiteWarmer.Core.Logging; /// public class ConsoleLogger : ILogger { - private static ConsoleColor _originalTextColour; + private static readonly ConsoleColor OriginalTextColour = Console.ForegroundColor; private static readonly object LockObject = new(); private const ConsoleColor ErrorTextColour = ConsoleColor.Red; private const ConsoleColor ContentFailTextColour = ConsoleColor.Yellow; @@ -18,7 +18,6 @@ public class ConsoleLogger : ILogger /// public ConsoleLogger() { - _originalTextColour = Console.ForegroundColor; } public void Log(Check check) @@ -66,7 +65,7 @@ private static void WriteToConsoleInColour(Check check, string passed, ConsoleCo { Console.ForegroundColor = textColour; WriteToConsole(check, passed); - Console.ForegroundColor = _originalTextColour; + Console.ForegroundColor = OriginalTextColour; } }