Skip to content

Commit

Permalink
Fix current indentation (#5059)
Browse files Browse the repository at this point in the history
  • Loading branch information
BraisGabin committed Aug 3, 2022
1 parent d42e6f0 commit 3bc81d2
Show file tree
Hide file tree
Showing 31 changed files with 509 additions and 528 deletions.
Expand Up @@ -15,14 +15,14 @@ class EntitySpec {
private val path = Paths.get("/full/path/to/Test.kt")
private val code = compileContentForTest(
"""
package test
package test
class C : Any() {
class C : Any() {
private fun memberFun(): Int = 5
}
private fun memberFun(): Int = 5
}
fun topLevelFun(number: Int) = Unit
fun topLevelFun(number: Int) = Unit
""".trimIndent(),
path.toString()
)
Expand Down
Expand Up @@ -154,11 +154,11 @@ private fun MutableMap<String, List<Finding>>.mergeSmells(other: Map<String, Lis

private fun throwIllegalStateException(file: KtFile, error: Throwable): Nothing {
val message = """
Analyzing ${file.absolutePath()} led to an exception.
Location: ${error.stackTrace.firstOrNull()?.toString()}
The original exception message was: ${error.localizedMessage}
Running detekt '${whichDetekt() ?: "unknown"}' on Java '${whichJava()}' on OS '${whichOS()}'
If the exception message does not help, please feel free to create an issue on our GitHub page.
Analyzing ${file.absolutePath()} led to an exception.
Location: ${error.stackTrace.firstOrNull()?.toString()}
The original exception message was: ${error.localizedMessage}
Running detekt '${whichDetekt() ?: "unknown"}' on Java '${whichJava()}' on OS '${whichOS()}'
If the exception message does not help, please feel free to create an issue on our GitHub page.
""".trimIndent()
throw IllegalStateException(message, error)
}
Expand Down
Expand Up @@ -49,14 +49,14 @@ class BaselineFacadeSpec {

assertThat(baselineFile).hasContent(
"""
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues>
<ID>LongParameterList:Signature</ID>
<ID>LongMethod:Signature</ID>
</ManuallySuppressedIssues>
<CurrentIssues></CurrentIssues>
</SmellBaseline>
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues>
<ID>LongParameterList:Signature</ID>
<ID>LongMethod:Signature</ID>
</ManuallySuppressedIssues>
<CurrentIssues></CurrentIssues>
</SmellBaseline>
""".trimIndent()
)
}
Expand All @@ -69,16 +69,16 @@ class BaselineFacadeSpec {

assertThat(baselineFile).hasContent(
"""
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues>
<ID>LongParameterList:Signature</ID>
<ID>LongMethod:Signature</ID>
</ManuallySuppressedIssues>
<CurrentIssues>
<ID>TestSmell:TestEntitySignature</ID>
</CurrentIssues>
</SmellBaseline>
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues>
<ID>LongParameterList:Signature</ID>
<ID>LongMethod:Signature</ID>
</ManuallySuppressedIssues>
<CurrentIssues>
<ID>TestSmell:TestEntitySignature</ID>
</CurrentIssues>
</SmellBaseline>
""".trimIndent()
)
}
Expand Down
Expand Up @@ -205,11 +205,11 @@ class ValidateConfigSpec {
fun `reports a deprecated property as a warning`(warningsAsErrors: Boolean) {
val config = yamlConfigFromContent(
"""
config:
warningsAsErrors: $warningsAsErrors
naming:
FunctionParameterNaming:
ignoreOverriddenFunctions: ''
config:
warningsAsErrors: $warningsAsErrors
naming:
FunctionParameterNaming:
ignoreOverriddenFunctions: ''
""".trimIndent()
)

Expand Down
Expand Up @@ -193,8 +193,8 @@ class YamlConfigSpec {
assertThatCode {
yamlConfigFromContent(
"""
map:
{}map
map:
{}map
""".trimIndent()
)
}.isInstanceOf(Config.InvalidConfigurationError::class.java)
Expand Down
Expand Up @@ -37,9 +37,9 @@ class SingleRuleProviderSpec {
fun `the right sub config is passed to the rule configures rule with active=$value`(value: Boolean) {
val config = yamlConfigFromContent(
"""
style:
MagicNumber:
active: $value
style:
MagicNumber:
active: $value
""".trimIndent()
)

Expand Down
Expand Up @@ -405,10 +405,10 @@ class AnnotationSuppressorSpec(private val env: KotlinCoreEnvironment) {
fun `Doesn't mix annotations`() {
val root = compileContentForTest(
"""
package foo.bar
package foo.bar
@Composable
fun function() = Unit
@Composable
fun function() = Unit
""".trimIndent()
)

Expand All @@ -426,10 +426,10 @@ class AnnotationSuppressorSpec(private val env: KotlinCoreEnvironment) {
fun `Works when no using imports`() {
val root = compileContentForTest(
"""
package foo.bar
package foo.bar
@androidx.compose.runtime.Composable
fun function() = Unit
@androidx.compose.runtime.Composable
fun function() = Unit
""".trimIndent()
)

Expand All @@ -447,12 +447,12 @@ class AnnotationSuppressorSpec(private val env: KotlinCoreEnvironment) {
fun `Works when using import alias`() {
val root = compileContentForTest(
"""
package foo.bar
package foo.bar
import androidx.compose.runtime.Composable as Bar
import androidx.compose.runtime.Composable as Bar
@Bar
fun function() = Unit
@Bar
fun function() = Unit
""".trimIndent()
)

Expand Down
Expand Up @@ -28,11 +28,11 @@ class SuppressorsSpec {
entity = Entity.from(
compileContentForTest(
"""
@file:Composable
@file:Composable
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Composable
fun foo() = Unit
fun foo() = Unit
""".trimIndent()
)
),
Expand Down
Expand Up @@ -13,22 +13,20 @@ import org.junit.jupiter.api.Test
class CommentWrappingSpec {
@Test
fun `Given a single line block comment that start starts and end on a separate line then report no error`() {
val code =
"""
val code = """
/* Some comment */
""".trimIndent()
""".trimIndent()
assertThat(CommentWrapping(Config.empty).lint(code)).isEmpty()
}

@Test
fun `Given a block comment followed by a code element on the same line as the block comment ended then report four errors`() {
val code =
"""
val code = """
/* Some comment 1 */ val foo1 = "foo1"
/* Some comment 2 */val foo2 = "foo2"
/* Some comment 3 */ fun foo3() = "foo3"
/* Some comment 4 */fun foo4() = "foo4"
""".trimIndent()
""".trimIndent()

assertThat(CommentWrapping(Config.empty).lint(code)).hasSize(4)
}
Expand Down
Expand Up @@ -33,7 +33,7 @@ class FinalNewlineSpec {
val findings = FinalNewline(TestConfig(INSERT_FINAL_NEWLINE_KEY to "false"))
.lint(
"""
fun main() = Unit
fun main() = Unit
"""
)
Expand Down
Expand Up @@ -25,9 +25,9 @@ class FormattingRuleSpec {
fun `does support suppression only on file level`() {
val findings = subject.lint(
"""
@file:Suppress("NoLineBreakBeforeAssignment")
fun main()
= Unit
@file:Suppress("NoLineBreakBeforeAssignment")
fun main()
= Unit
""".trimIndent()
)

Expand All @@ -38,9 +38,9 @@ class FormattingRuleSpec {
fun `does not support suppression on node level`() {
val findings = subject.lint(
"""
@Suppress("NoLineBreakBeforeAssignment")
fun main()
= Unit
@Suppress("NoLineBreakBeforeAssignment")
fun main()
= Unit
""".trimIndent()
)

Expand All @@ -55,8 +55,8 @@ class FormattingRuleSpec {
fun `has no package name`() {
val findings = subject.lint(
"""
fun main()
= Unit
fun main()
= Unit
""".trimIndent()
)

Expand All @@ -67,9 +67,9 @@ class FormattingRuleSpec {
fun `has a package name`() {
val findings = subject.lint(
"""
package test.test.test
fun main()
= Unit
package test.test.test
fun main()
= Unit
""".trimIndent()
)

Expand Down
Expand Up @@ -20,17 +20,17 @@ class ImportOrderingSpec {
fun `defaults to the idea layout`() {
val findings = ImportOrdering(Config.empty).lint(
"""
import android.app.Activity
import android.view.View
import android.view.ViewGroup
import kotlinx.coroutines.CoroutineDispatcher
import ru.example.a
import java.util.List
import javax.net.ssl.SSLHandshakeException
import kotlin.concurrent.Thread
import kotlin.io.Closeable
import android.content.Context as Ctx
import androidx.fragment.app.Fragment as F
import android.app.Activity
import android.view.View
import android.view.ViewGroup
import kotlinx.coroutines.CoroutineDispatcher
import ru.example.a
import java.util.List
import javax.net.ssl.SSLHandshakeException
import kotlin.concurrent.Thread
import kotlin.io.Closeable
import android.content.Context as Ctx
import androidx.fragment.app.Fragment as F
""".trimIndent()
)

Expand Down Expand Up @@ -90,13 +90,13 @@ class ImportOrderingSpec {
fun `misses a empty line between aliases and other imports`() {
val findings = ImportOrdering(TestConfig("layout" to "*,|,^*")).lint(
"""
import android.app.Activity
import android.view.View
import android.view.ViewGroup
import java.util.List
import kotlin.concurrent.Thread
import android.content.Context as Ctx
import androidx.fragment.app.Fragment as F
import android.app.Activity
import android.view.View
import android.view.ViewGroup
import java.util.List
import kotlin.concurrent.Thread
import android.content.Context as Ctx
import androidx.fragment.app.Fragment as F
""".trimIndent()
)
Expand All @@ -107,14 +107,14 @@ class ImportOrderingSpec {
fun `passes for empty line between aliases and other imports`() {
val findings = ImportOrdering(TestConfig("layout" to "*,|,^*")).lint(
"""
import android.app.Activity
import android.view.View
import android.view.ViewGroup
import java.util.List
import kotlin.concurrent.Thread
import android.content.Context as Ctx
import androidx.fragment.app.Fragment as F
import android.app.Activity
import android.view.View
import android.view.ViewGroup
import java.util.List
import kotlin.concurrent.Thread
import android.content.Context as Ctx
import androidx.fragment.app.Fragment as F
""".trimIndent()
)
Expand Down
Expand Up @@ -13,23 +13,21 @@ import org.junit.jupiter.api.Test
class KdocWrappingSpec {
@Test
fun `Given a single line KDoc comment that start starts and end on a separate line then do not reformat`() {
val code =
"""
val code = """
/** Some KDoc comment */
""".trimIndent()
""".trimIndent()

assertThat(KdocWrapping(Config.empty).lint(code)).isEmpty()
}

@Test
fun `Given a KDoc comment followed by a code element on the same line as the block comment ended then report four errors`() {
val code =
"""
val code = """
/** Some comment 1 */ val foo1 = "foo1"
/** Some comment 2 */val foo2 = "foo2"
/** Some comment 3 */ fun foo3() = "foo3"
/** Some comment 4 */fun foo4() = "foo4"
""".trimIndent()
""".trimIndent()

assertThat(KdocWrapping(Config.empty).lint(code)).hasSize(4)
}
Expand Down

0 comments on commit 3bc81d2

Please sign in to comment.