From f986f3a8ab8ec7774bed9de4b7fbd50fd2e5a0f1 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Wed, 9 Apr 2025 12:38:29 -0400 Subject: [PATCH] [BUGFIX] sonarcloud (Maintainability) Add a 'protected' constructor or the 'static' keyword to the class declaration. Utility classes should not have public constructors csharpsquid:S1118 --- .../dictionaries_and_hashmaps/CountTriplets.cs | 4 ++++ .../dictionaries_and_hashmaps/CountTripletsBruteForce.cs | 3 +++ .../dictionaries_and_hashmaps/RansomNote.cs | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/CountTriplets.cs b/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/CountTriplets.cs index 0dc12fb..2f782cc 100644 --- a/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/CountTriplets.cs +++ b/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/CountTriplets.cs @@ -4,10 +4,14 @@ namespace algorithm_exercises_csharp.hackerrank.interview_preparation_kit.dictionaries_and_hashmaps; +using System.Diagnostics.CodeAnalysis; using System.Collections.Generic; public class CountTriplets { + [ExcludeFromCodeCoverage] + protected CountTriplets() { } + public static long countTriplets(List arr, long r) { Dictionary aCounter = []; diff --git a/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/CountTripletsBruteForce.cs b/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/CountTripletsBruteForce.cs index fd12046..29c6f04 100644 --- a/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/CountTripletsBruteForce.cs +++ b/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/CountTripletsBruteForce.cs @@ -7,6 +7,9 @@ namespace algorithm_exercises_csharp.hackerrank.interview_preparation_kit.dictio public class CountTripletsBruteForce { + [ExcludeFromCodeCoverage] + protected CountTripletsBruteForce() { } + public static long countTriplets(List arr, long r) { long size = arr.Count; diff --git a/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/RansomNote.cs b/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/RansomNote.cs index d2055be..7a72a0d 100644 --- a/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/RansomNote.cs +++ b/src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/RansomNote.cs @@ -7,6 +7,9 @@ namespace algorithm_exercises_csharp.hackerrank.interview_preparation_kit.dictio public class RansomNote { + [ExcludeFromCodeCoverage] + protected RansomNote() { } + public class InvalidValueException : Exception { // constructor for the InvalidAgeException class @@ -16,9 +19,6 @@ public InvalidValueException(string msg) } } - [ExcludeFromCodeCoverage] - protected RansomNote() { } - private static readonly string __YES__ = "Yes"; private static readonly string __NO__ = "No";