Skip to content

Commit

Permalink
Fix detekt violations
Browse files Browse the repository at this point in the history
  • Loading branch information
uzzu committed Dec 17, 2023
1 parent 61dd802 commit 88c8144
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ tasks {
// region publishing

object Artifact {
val groupId = "co.uzzu.dotenv"
val artifactId = "gradle"
val version = "3.0.0"
const val GroupId = "co.uzzu.dotenv"
const val ArtifactId = "gradle"
const val Version = "3.0.0"
}

group = Artifact.groupId
version = Artifact.version
group = Artifact.GroupId
version = Artifact.Version

publishing {
publishing {
Expand All @@ -57,7 +57,7 @@ publishing {
}

publications.create("pluginMaven", MavenPublication::class) {
artifactId = Artifact.artifactId
artifactId = Artifact.ArtifactId
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/main/kotlin/co/uzzu/dotenv/DotEnvParser.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package co.uzzu.dotenv

object DotEnvParser {
private const val newLine = "\n"
private const val NewLine = "\n"
private val newLinesRegex = Regex("""\\n""", option = RegexOption.MULTILINE)
private val keyValRegex = Regex("""^\s*([\w.-]+)\s*=\s*(.*)?\s*$""")
private val newLinesMatches = Regex("""\n|\r|\r\n""")
Expand All @@ -23,7 +23,7 @@ object DotEnvParser {
val trimmedValue = if (isDoubleQuoted || isSingleQuoted) {
val dequoted = rawValue.substring(1, rawValue.lastIndex)
if (isDoubleQuoted) {
dequoted.replace(newLinesRegex, newLine)
dequoted.replace(newLinesRegex, NewLine)
} else {
dequoted
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ open class DotEnvRoot(
fun fetch(name: String) =
envProvider.getenv()[name]
?: dotenvMap[name]
?: throw IllegalStateException("""Environment variable $name was not set.""")
?: error("""Environment variable $name was not set.""")

/**
* @return An environment variable
Expand Down Expand Up @@ -112,7 +112,7 @@ open class DotEnvProperty(
get() =
envProvider.getenv()[name]
?: dotenvValue
?: throw IllegalStateException("""Environment variable $name was not set.""")
?: error("""Environment variable $name was not set.""")

/**
* @return An environment variable. If it was not set, returns specified default value
Expand Down
20 changes: 10 additions & 10 deletions plugin/src/test/kotlin/co/uzzu/dotenv/DotEnvParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class DotEnvParserTest {
@Test
fun testBasicParse() {
val text = """
HOGE_API_KEY="dummy_key"
HOGE_API_SECRET="dummy_secret"
HOGE_API_KEY="dummy_key"
HOGE_API_SECRET="dummy_secret"
""".trimIndent()

val actual = DotEnvParser.parse(text)
Expand All @@ -23,8 +23,8 @@ class DotEnvParserTest {
@Test
fun emptyValue() {
val text = """
HOGE_API_KEY=
HOGE_API_SECRET=
HOGE_API_KEY=
HOGE_API_SECRET=
""".trimIndent()

val actual = DotEnvParser.parse(text)
Expand All @@ -37,8 +37,8 @@ class DotEnvParserTest {
@Test
fun quotedValue() {
val text = """
HOGE_API_KEY="dummy_key"
HOGE_API_SECRET='dummy_secret'
HOGE_API_KEY="dummy_key"
HOGE_API_SECRET='dummy_secret'
""".trimIndent()

val actual = DotEnvParser.parse(text)
Expand All @@ -51,8 +51,8 @@ class DotEnvParserTest {
@Test
fun incompleteQuoteValue() {
val text = """
HOGE_API_KEY="dummy_key
HOGE_API_SECRET=dummy_secret'
HOGE_API_KEY="dummy_key
HOGE_API_SECRET=dummy_secret'
""".trimIndent()

val actual = DotEnvParser.parse(text)
Expand All @@ -65,8 +65,8 @@ class DotEnvParserTest {
@Test
fun singleCharQuoteValue() {
val text = """
HOGE_API_KEY="
HOGE_API_SECRET='
HOGE_API_KEY="
HOGE_API_SECRET='
""".trimIndent()

val actual = DotEnvParser.parse(text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class HierarchicalDotEnvDefinitionsTest {
file(
".env",
"""
HOGE=100
HOGE=100
""".trimIndent()
)
directory("sub")
Expand Down

0 comments on commit 88c8144

Please sign in to comment.