diff --git a/README.md b/README.md index 7eb66c4..bbb4296 100644 --- a/README.md +++ b/README.md @@ -58,13 +58,13 @@ optimizations. ## Complexity Report -* 6,718 lines of code (loc) +* 6,782 lines of code (loc) -* 3,497 source lines of code (sloc) +* 3,511 source lines of code (sloc) -* 2,668 logical lines of code (lloc) +* 2,669 logical lines of code (lloc) -* 2,689 comment lines of code (cloc) +* 2,728 comment lines of code (cloc) * 405 cyclomatic complexity (mcc) @@ -72,7 +72,7 @@ optimizations. * 0 number of total code smells -* 76% comment source ratio +* 77% comment source ratio * 151 mcc per 1,000 lloc @@ -80,4 +80,4 @@ optimizations. ## Findings (0) -generated with [detekt version 1.23.5](https://detekt.dev/) on 2024-04-02 23:23:38 UTC +generated with [detekt version 1.23.5](https://detekt.dev/) on 2024-04-02 23:34:50 UTC diff --git a/src/main/kotlin/dev/shtanko/algorithms/Constants.kt b/src/main/kotlin/dev/shtanko/algorithms/Constants.kt index 562eb3c..9df3ca0 100644 --- a/src/main/kotlin/dev/shtanko/algorithms/Constants.kt +++ b/src/main/kotlin/dev/shtanko/algorithms/Constants.kt @@ -24,15 +24,67 @@ package dev.shtanko.algorithms -internal const val DECIMAL = 10 -internal const val OCTAL = 8 -internal const val HEXADECIMAL = 16 -internal const val SHUFFLE = 0xFFFF -internal const val MOD = 1_000_000_007 -internal const val BILLION = 1e9 -internal const val BYTE = 1024 -internal const val MILLISECOND = 1000L -internal const val EPSILON = 1e-5 -internal const val BIN_FORMAT = "%.1f %cB" -internal const val SI_FORMAT = "%.1f %ciB" -internal const val ALPHABET_LETTERS_COUNT = 26 +/** + * Constants used across the application. + */ +internal data object Constants { + /** + * Base for decimal numbers. + */ + const val DECIMAL = 10 + + /** + * Base for octal numbers. + */ + const val OCTAL = 8 + + /** + * Base for hexadecimal numbers. + */ + const val HEXADECIMAL = 16 + + /** + * Constant used for shuffling. + */ + const val SHUFFLE = 0xFFFF + + /** + * Modulus constant. + */ + const val MOD = 1_000_000_007 + + /** + * Constant representing one billion. + */ + const val BILLION = 1e9 + + /** + * Constant representing a byte (1024 bits). + */ + const val BYTE = 1024 + + /** + * Constant representing a millisecond. + */ + const val MILLISECOND = 1000L + + /** + * Small constant used for floating point comparisons. + */ + const val EPSILON = 1e-5 + + /** + * Format for binary size representation. + */ + const val BIN_FORMAT = "%.1f %cB" + + /** + * Format for SI size representation. + */ + const val SI_FORMAT = "%.1f %ciB" + + /** + * Number of letters in the English alphabet. + */ + const val ALPHABET_LETTERS_COUNT = 26 +} diff --git a/src/main/kotlin/dev/shtanko/algorithms/extensions/LongX.kt b/src/main/kotlin/dev/shtanko/algorithms/extensions/LongX.kt index da0eaae..6a2e20b 100644 --- a/src/main/kotlin/dev/shtanko/algorithms/extensions/LongX.kt +++ b/src/main/kotlin/dev/shtanko/algorithms/extensions/LongX.kt @@ -24,7 +24,7 @@ package dev.shtanko.algorithms.extensions -import dev.shtanko.algorithms.DECIMAL +import dev.shtanko.algorithms.Constants.DECIMAL /** * Checks if a Long number is a super palindrome. diff --git a/src/main/kotlin/dev/shtanko/algorithms/leetcode/AppealSum.kt b/src/main/kotlin/dev/shtanko/algorithms/leetcode/AppealSum.kt index 70284c6..bd3dc88 100644 --- a/src/main/kotlin/dev/shtanko/algorithms/leetcode/AppealSum.kt +++ b/src/main/kotlin/dev/shtanko/algorithms/leetcode/AppealSum.kt @@ -24,7 +24,7 @@ package dev.shtanko.algorithms.leetcode -import dev.shtanko.algorithms.ALPHABET_LETTERS_COUNT +import dev.shtanko.algorithms.Constants.ALPHABET_LETTERS_COUNT /** * 2262. Total Appeal of A String diff --git a/src/main/kotlin/dev/shtanko/algorithms/math/NarcissisticNumber.kt b/src/main/kotlin/dev/shtanko/algorithms/math/NarcissisticNumber.kt index 3e5c616..b6682d3 100644 --- a/src/main/kotlin/dev/shtanko/algorithms/math/NarcissisticNumber.kt +++ b/src/main/kotlin/dev/shtanko/algorithms/math/NarcissisticNumber.kt @@ -24,7 +24,7 @@ package dev.shtanko.algorithms.math -import dev.shtanko.algorithms.DECIMAL +import dev.shtanko.algorithms.Constants.DECIMAL import kotlin.math.pow /** diff --git a/src/main/kotlin/dev/shtanko/algorithms/math/Sqrt.kt b/src/main/kotlin/dev/shtanko/algorithms/math/Sqrt.kt index f825e81..4feacfa 100644 --- a/src/main/kotlin/dev/shtanko/algorithms/math/Sqrt.kt +++ b/src/main/kotlin/dev/shtanko/algorithms/math/Sqrt.kt @@ -24,7 +24,7 @@ package dev.shtanko.algorithms.math -import dev.shtanko.algorithms.EPSILON +import dev.shtanko.algorithms.Constants.EPSILON import kotlin.math.abs /** diff --git a/src/main/kotlin/dev/shtanko/algorithms/utils/ByteFormatter.kt b/src/main/kotlin/dev/shtanko/algorithms/utils/ByteFormatter.kt index abe9d36..93133a7 100644 --- a/src/main/kotlin/dev/shtanko/algorithms/utils/ByteFormatter.kt +++ b/src/main/kotlin/dev/shtanko/algorithms/utils/ByteFormatter.kt @@ -24,8 +24,8 @@ package dev.shtanko.algorithms.utils -import dev.shtanko.algorithms.BIN_FORMAT -import dev.shtanko.algorithms.SI_FORMAT +import dev.shtanko.algorithms.Constants.BIN_FORMAT +import dev.shtanko.algorithms.Constants.SI_FORMAT import java.util.Locale /** diff --git a/src/main/kotlin/dev/shtanko/algorithms/utils/ToHumanReadableByteCountBin.kt b/src/main/kotlin/dev/shtanko/algorithms/utils/ToHumanReadableByteCountBin.kt index f628ccf..9e3167d 100644 --- a/src/main/kotlin/dev/shtanko/algorithms/utils/ToHumanReadableByteCountBin.kt +++ b/src/main/kotlin/dev/shtanko/algorithms/utils/ToHumanReadableByteCountBin.kt @@ -24,8 +24,8 @@ package dev.shtanko.algorithms.utils -import dev.shtanko.algorithms.BYTE -import dev.shtanko.algorithms.DECIMAL +import dev.shtanko.algorithms.Constants.BYTE +import dev.shtanko.algorithms.Constants.DECIMAL import java.text.CharacterIterator import java.text.StringCharacterIterator import java.util.Locale diff --git a/src/main/kotlin/dev/shtanko/algorithms/utils/ToHumanReadableDuration.kt b/src/main/kotlin/dev/shtanko/algorithms/utils/ToHumanReadableDuration.kt index a9def91..e3f124a 100644 --- a/src/main/kotlin/dev/shtanko/algorithms/utils/ToHumanReadableDuration.kt +++ b/src/main/kotlin/dev/shtanko/algorithms/utils/ToHumanReadableDuration.kt @@ -24,7 +24,7 @@ package dev.shtanko.algorithms.utils -import dev.shtanko.algorithms.MILLISECOND +import dev.shtanko.algorithms.Constants.MILLISECOND import java.util.concurrent.TimeUnit /** diff --git a/src/test/kotlin/dev/shtanko/algorithms/ConstantsTest.kt b/src/test/kotlin/dev/shtanko/algorithms/ConstantsTest.kt index a464dba..a64ae24 100644 --- a/src/test/kotlin/dev/shtanko/algorithms/ConstantsTest.kt +++ b/src/test/kotlin/dev/shtanko/algorithms/ConstantsTest.kt @@ -24,6 +24,18 @@ package dev.shtanko.algorithms +import dev.shtanko.algorithms.Constants.ALPHABET_LETTERS_COUNT +import dev.shtanko.algorithms.Constants.BILLION +import dev.shtanko.algorithms.Constants.BIN_FORMAT +import dev.shtanko.algorithms.Constants.BYTE +import dev.shtanko.algorithms.Constants.DECIMAL +import dev.shtanko.algorithms.Constants.EPSILON +import dev.shtanko.algorithms.Constants.HEXADECIMAL +import dev.shtanko.algorithms.Constants.MILLISECOND +import dev.shtanko.algorithms.Constants.MOD +import dev.shtanko.algorithms.Constants.OCTAL +import dev.shtanko.algorithms.Constants.SHUFFLE +import dev.shtanko.algorithms.Constants.SI_FORMAT import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test diff --git a/src/test/kotlin/dev/shtanko/algorithms/math/NewtonMethodTest.kt b/src/test/kotlin/dev/shtanko/algorithms/math/NewtonMethodTest.kt index d6fe8ed..3c31309 100644 --- a/src/test/kotlin/dev/shtanko/algorithms/math/NewtonMethodTest.kt +++ b/src/test/kotlin/dev/shtanko/algorithms/math/NewtonMethodTest.kt @@ -24,7 +24,7 @@ package dev.shtanko.algorithms.math -import dev.shtanko.algorithms.EPSILON +import dev.shtanko.algorithms.Constants.EPSILON import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test