Skip to content

Commit 995901f

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] Codefactor issues, fixed.
1 parent ffefa59 commit 995901f

File tree

4 files changed

+42
-41
lines changed

4 files changed

+42
-41
lines changed

algorithm_exercises_csharp/src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/RansomNote.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ namespace algorithm_exercises_csharp.hackerrank.interview_preparation_kit;
55
using System.Diagnostics.CodeAnalysis;
66
using System.Collections.Generic;
77

8-
public class InvalidValueException : Exception
8+
public class RansomNote
99
{
10-
// constructor for the InvalidAgeException class
11-
public InvalidValueException(string msg)
10+
public class InvalidValueException : Exception
1211
{
13-
Console.WriteLine(msg);
12+
// constructor for the InvalidAgeException class
13+
public InvalidValueException(string msg)
14+
{
15+
Console.WriteLine(msg);
16+
}
1417
}
15-
}
1618

17-
public class RansomNote
18-
{
1919
[ExcludeFromCodeCoverage]
2020
protected RansomNote() { }
2121

algorithm_exercises_csharp/src/hackerrank/interview_preparation_kit/greedy_algorithms/LuckBalance.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ namespace algorithm_exercises_csharp.hackerrank.interview_preparation_kit;
44

55
using System.Diagnostics.CodeAnalysis;
66

7-
public class Competition(int _luck, int _important)
8-
{
9-
public int luck => _luck;
10-
public int important => _important;
11-
}
12-
137
public class LuckBalance
148
{
9+
public class Competition(int _luck, int _important)
10+
{
11+
public int luck => _luck;
12+
public int important => _important;
13+
}
14+
1515
[ExcludeFromCodeCoverage]
1616
protected LuckBalance() { }
1717

algorithm_exercises_csharp/src/hackerrank/projecteuler/Euler003.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected Euler003() { }
2222
int i = 2;
2323
while (i <= Math.Sqrt(divisor))
2424
{
25-
if (0 == divisor % i)
25+
if (divisor % i == 0)
2626
{
2727
divisor = divisor / i;
2828
max_prime_factor = divisor;

algorithm_exercises_csharp_base/src/Logger.cs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,46 @@ namespace algorithm_exercises_csharp;
33
using Microsoft.Extensions.Logging;
44
using System;
55

6-
public sealed class LoggerSingleton
6+
public static class Log
77
{
8-
private static readonly Lazy<LoggerSingleton> _instance = new(() => new LoggerSingleton());
98

10-
public static LoggerSingleton Instance => _instance.Value;
9+
sealed class LoggerSingleton
10+
{
11+
private static readonly Lazy<LoggerSingleton> _instance = new(() => new LoggerSingleton());
1112

12-
public ILogger Logger { get; }
13+
public static LoggerSingleton Instance => _instance.Value;
1314

14-
private LoggerSingleton()
15-
{
16-
// Read the LOG_LEVEL environment variable
17-
var logLevelEnv = Environment.GetEnvironmentVariable("LOG_LEVEL") ?? "Information";
15+
public ILogger Logger { get; }
1816

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

25-
var loggerFactory = LoggerFactory.Create(builder =>
26-
{
27-
builder
28-
.AddConsole()
29-
.SetMinimumLevel(logLevel); // set minimum logging level
30-
});
22+
// Convert the environment variable value to LogLevel
23+
if (!Enum.TryParse<LogLevel>(logLevelEnv, ignoreCase: true, out var logLevel))
24+
{
25+
logLevel = LogLevel.Information; // Set the minimum logging level
26+
}
3127

32-
Logger = loggerFactory.CreateLogger("GlobalLogger");
28+
var loggerFactory = LoggerFactory.Create(builder =>
29+
{
30+
builder
31+
.AddConsole()
32+
.SetMinimumLevel(logLevel); // set minimum logging level
33+
});
3334

34-
Logger.LogInformation("Initializing");
35+
Logger = loggerFactory.CreateLogger("GlobalLogger");
3536

36-
Logger.LogInformation("Info level enabled");
37-
Logger.LogWarning("Warning level enabled");
38-
Logger.LogError("Error level enabled");
39-
Logger.LogDebug("Debug level enabled");
37+
Logger.LogInformation("Initializing");
38+
39+
Logger.LogInformation("Info level enabled");
40+
Logger.LogWarning("Warning level enabled");
41+
Logger.LogError("Error level enabled");
42+
Logger.LogDebug("Debug level enabled");
43+
}
4044
}
41-
}
4245

43-
public static class Log
44-
{
4546
public static ILogger getLogger()
4647
{
4748
return LoggerSingleton.Instance.Logger;

0 commit comments

Comments
 (0)