Skip to content

Commit

Permalink
Merge pull request #114 from sir-gon/develop
Browse files Browse the repository at this point in the history
[REFACTOR] Codefactor issues, fixed.
  • Loading branch information
sir-gon authored Sep 4, 2024
2 parents ffefa59 + 2826c96 commit 79f0b42
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ namespace algorithm_exercises_csharp.hackerrank.interview_preparation_kit;
using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;

public class InvalidValueException : Exception
public class RansomNote
{
// constructor for the InvalidAgeException class
public InvalidValueException(string msg)
public class InvalidValueException : Exception
{
Console.WriteLine(msg);
// constructor for the InvalidAgeException class
public InvalidValueException(string msg)
{
Console.WriteLine(msg);
}
}
}

public class RansomNote
{
[ExcludeFromCodeCoverage]
protected RansomNote() { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ namespace algorithm_exercises_csharp.hackerrank.interview_preparation_kit;

using System.Diagnostics.CodeAnalysis;

public class Competition(int _luck, int _important)
{
public int luck => _luck;
public int important => _important;
}

public class LuckBalance
{
public class Competition(int _luck, int _important)
{
public int luck => _luck;
public int important => _important;
}

[ExcludeFromCodeCoverage]
protected LuckBalance() { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected Euler003() { }
int i = 2;
while (i <= Math.Sqrt(divisor))
{
if (0 == divisor % i)
if (divisor % i == 0)
{
divisor = divisor / i;
max_prime_factor = divisor;
Expand Down
56 changes: 28 additions & 28 deletions algorithm_exercises_csharp_base/src/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@ namespace algorithm_exercises_csharp;
using Microsoft.Extensions.Logging;
using System;

public sealed class LoggerSingleton
public static class Log
{
private static readonly Lazy<LoggerSingleton> _instance = new(() => new LoggerSingleton());

public static LoggerSingleton Instance => _instance.Value;
sealed class LoggerSingleton
{
private static readonly Lazy<LoggerSingleton> _instance = new(() => new LoggerSingleton());

public ILogger Logger { get; }
public static LoggerSingleton Instance => _instance.Value;

private LoggerSingleton()
{
// Read the LOG_LEVEL environment variable
var logLevelEnv = Environment.GetEnvironmentVariable("LOG_LEVEL") ?? "Information";
public ILogger Logger { get; }

// Convert the environment variable value to LogLevel
if (!Enum.TryParse<LogLevel>(logLevelEnv, ignoreCase: true, out var logLevel))
private LoggerSingleton()
{
logLevel = LogLevel.Information; // Set the minimum logging level
}
// Read the LOG_LEVEL environment variable
var logLevelEnv = Environment.GetEnvironmentVariable("LOG_LEVEL") ?? "Information";

var loggerFactory = LoggerFactory.Create(builder =>
{
builder
.AddConsole()
.SetMinimumLevel(logLevel); // set minimum logging level
});
// Convert the environment variable value to LogLevel
if (!Enum.TryParse<LogLevel>(logLevelEnv, ignoreCase: true, out var logLevel))
{
logLevel = LogLevel.Information; // Set the minimum logging level
}

Logger = loggerFactory.CreateLogger("GlobalLogger");
var loggerFactory = LoggerFactory.Create(builder =>
{
builder
.AddConsole()
.SetMinimumLevel(logLevel); // set minimum logging level
});

Logger.LogInformation("Initializing");
Logger = loggerFactory.CreateLogger("GlobalLogger");

Logger.LogInformation("Info level enabled");
Logger.LogWarning("Warning level enabled");
Logger.LogError("Error level enabled");
Logger.LogDebug("Debug level enabled");
Logger.LogInformation("Initializing");

Logger.LogInformation("Info level enabled");
Logger.LogWarning("Warning level enabled");
Logger.LogError("Error level enabled");
Logger.LogDebug("Debug level enabled");
}
}
}

public static class Log
{
public static ILogger getLogger()
{
return LoggerSingleton.Instance.Logger;
Expand Down

0 comments on commit 79f0b42

Please sign in to comment.