Skip to content

Commit

Permalink
Enable trim multiline raw string (#5243)
Browse files Browse the repository at this point in the history
* Don't use raw string in annotation

* Improve tests

* Fix indentation

* Fix format

* Add missing .trimIndent()

* Remove unnecessary code

* Enable TrimMultilineRawString
  • Loading branch information
BraisGabin committed Sep 4, 2022
1 parent 37584c2 commit d516562
Show file tree
Hide file tree
Showing 208 changed files with 2,328 additions and 2,295 deletions.
2 changes: 2 additions & 0 deletions config/detekt/detekt.yml
Expand Up @@ -229,6 +229,8 @@ style:
excludeGuardClauses: true
SpacingBetweenPackageAndImports:
active: true
TrimMultilineRawString:
active: true
UnderscoresInNumericLiterals:
active: true
UnnecessaryAnnotationUseSiteTarget:
Expand Down
Expand Up @@ -51,10 +51,7 @@ constructor(

@Suppress("DEPRECATION")
@Deprecated(
"""
locationString was removed and won't get passed to the main constructor.
Use queries on 'ktElement' instead.
""",
"locationString was removed and won't get passed to the main constructor. Use queries on 'ktElement' instead.",
ReplaceWith(
"Location(source, text, file)",
"io.gitlab.arturbosch.detekt.api.Location"
Expand Down
Expand Up @@ -169,7 +169,7 @@ class SuppressionSpec {
println("FAILED TEST")
}
}
"""
""".trimIndent()
)
val rule = TestRule()
rule.visitFile(ktFile)
Expand All @@ -187,7 +187,7 @@ class SuppressionSpec {
println("FAILED TEST")
}
}
"""
""".trimIndent()
)
val rule = TestRule()
rule.visitFile(ktFile)
Expand All @@ -205,7 +205,7 @@ class SuppressionSpec {
println("FAILED TEST")
}
}
"""
""".trimIndent()
)
val rule = TestRule()
rule.visitFile(ktFile)
Expand All @@ -227,7 +227,7 @@ class SuppressionSpec {
println("FAILED TEST")
}
}
"""
""".trimIndent()
)
val rule = TestRule(TestConfig(mutableMapOf("aliases" to "[MyTest]")))
rule.visitFile(ktFile)
Expand Down Expand Up @@ -314,7 +314,7 @@ private fun isSuppressedBy(annotation: String, argument: String): Boolean {
val annotated = """
@$annotation("$argument")
class Test
"""
""".trimIndent()
val file = compileContentForTest(annotated)
val annotatedClass = file.children.first { it is KtClass } as KtAnnotated
return annotatedClass.isSuppressedBy("Test", setOf("alias"))
Expand Down
Expand Up @@ -26,7 +26,7 @@ class CheckConfigurationSpec {
"""
unknown_property:
unknown_var: ""
"""
""".trimIndent()
)
createProcessingSettings(
testDir,
Expand Down Expand Up @@ -55,7 +55,7 @@ class CheckConfigurationSpec {
my_additional_properties:
magic_number: 7
magic_string: 'Hello World'
"""
""".trimIndent()
)
createProcessingSettings(testDir, config).use {
assertThatCode { checkConfiguration(it, spec.getDefaultConfiguration()) }
Expand All @@ -74,7 +74,7 @@ class CheckConfigurationSpec {
TooManyFunctions:
# This property is tested via the SampleConfigValidator
active: 1 # should be true
"""
""".trimIndent()
)
createProcessingSettings(testDir, config).use {
assertThatCode { checkConfiguration(it, spec.getDefaultConfiguration()) }
Expand Down Expand Up @@ -104,7 +104,7 @@ class CheckConfigurationSpec {
my_additional_properties:
magic_number: 7
magic_string: 'Hello World'
"""
""".trimIndent()
)
createProcessingSettings(testDir, config).use {
assertThatCode { checkConfiguration(it, spec.getDefaultConfiguration()) }
Expand Down
Expand Up @@ -22,7 +22,7 @@ class FinalNewlineSpec {
"""
fun main() = Unit
"""
""".trimIndent()
)

assertThat(findings).isEmpty()
Expand All @@ -35,7 +35,7 @@ class FinalNewlineSpec {
"""
fun main() = Unit
"""
""".trimIndent()
)

assertThat(findings).hasSize(1)
Expand Down
Expand Up @@ -85,7 +85,7 @@ class FormattingRuleSpec {
"""
fun main()
= Unit
""",
""".trimIndent(),
expectedPath
)

Expand Down
Expand Up @@ -50,7 +50,7 @@ class MultiRuleCollectorSpec {
p2
)
}
"""
""".trimIndent()
val items = subject.run(code)
assertThat(items[0].rules).hasSize(4)
assertThat(items[0].rules).contains("Rule1", "Rule2", "Rule3", "Rule4")
Expand Down

0 comments on commit d516562

Please sign in to comment.