diff --git a/.github/workflows/codecoverage.yaml b/.github/workflows/codecoverage.yaml index 346b3f7b17d..74e6593d592 100644 --- a/.github/workflows/codecoverage.yaml +++ b/.github/workflows/codecoverage.yaml @@ -29,7 +29,7 @@ jobs: distribution: 'temurin' - name: Generate Coverage Report - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: jacocoMergedReport diff --git a/.github/workflows/danger.yaml b/.github/workflows/danger.yaml index a9503d2f022..f216d7a228e 100644 --- a/.github/workflows/danger.yaml +++ b/.github/workflows/danger.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 - name: Setup Node uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # tag=v3 diff --git a/.github/workflows/deploy-snapshot.yaml b/.github/workflows/deploy-snapshot.yaml index 7f4f2b62023..7b972abe427 100644 --- a/.github/workflows/deploy-snapshot.yaml +++ b/.github/workflows/deploy-snapshot.yaml @@ -26,12 +26,12 @@ jobs: distribution: 'temurin' - name: Build detekt - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: build - name: Deploy Snapshot - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 env: ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }} ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }} diff --git a/.github/workflows/detekt-with-type-resolution.yaml b/.github/workflows/detekt-with-type-resolution.yaml index 8d877270471..479a389a75e 100644 --- a/.github/workflows/detekt-with-type-resolution.yaml +++ b/.github/workflows/detekt-with-type-resolution.yaml @@ -34,12 +34,12 @@ jobs: distribution: 'temurin' - name: Run detekt-cli with argsfile - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: :detekt-cli:runWithArgsFile - name: Upload SARIF to Github using the upload-sarif action - uses: github/codeql-action/upload-sarif@2ca79b6fa8d3ec278944088b4aa5f46912db5d63 # tag=v2 + uses: github/codeql-action/upload-sarif@b398f525a5587552e573b247ac661067fafa920b # tag=v2 if: ${{ always() }} with: sarif_file: build/detekt-report.sarif @@ -58,6 +58,6 @@ jobs: java-version: 17 distribution: 'temurin' - name: Run analysis - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: detektMain detektTest diff --git a/.github/workflows/pre-merge.yaml b/.github/workflows/pre-merge.yaml index d6a2c3b930f..d9f74b2655b 100644 --- a/.github/workflows/pre-merge.yaml +++ b/.github/workflows/pre-merge.yaml @@ -37,7 +37,7 @@ jobs: java-version: ${{ matrix.jdk }} distribution: 'temurin' - name: Build detekt - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: build -x detekt - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3 @@ -46,15 +46,15 @@ jobs: path: '**.hprof' if-no-files-found: ignore - name: Run detekt-cli --help - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: :detekt-cli:runWithHelpFlag - name: Run detekt-cli with argsfile - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: :detekt-cli:runWithArgsFile - name: Try to publish to Maven Local - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: publishToMavenLocal @@ -70,7 +70,7 @@ jobs: java-version: 17 distribution: 'temurin' - name: Verify Generated Detekt Config File - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: verifyGeneratorOutput @@ -86,7 +86,7 @@ jobs: java-version: 17 distribution: 'temurin' - name: Build and compile test snippets - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: test -Pcompile-test-snippets=true @@ -102,6 +102,6 @@ jobs: java-version: 17 distribution: 'temurin' - name: Run with allWarningsAsErrors - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: build -x detekt -PwarningsAsErrors=true diff --git a/.github/workflows/website.yaml b/.github/workflows/website.yaml index 73ba0bce51d..02a547ac643 100644 --- a/.github/workflows/website.yaml +++ b/.github/workflows/website.yaml @@ -36,7 +36,7 @@ jobs: cache-dependency-path: 'website/yarn.lock' - name: Build Detekt Documentation - uses: gradle/gradle-build-action@cd3cedc781988c804f626f4cd2dc51d0bdf02a12 # tag=v2 + uses: gradle/gradle-build-action@356abb47e7664b5505e25d7997a5a522a17c62d9 # tag=v2 with: arguments: :detekt-generator:generateDocumentation diff --git a/bots/package.json b/bots/package.json index ff868b80d54..8ad60ca572d 100644 --- a/bots/package.json +++ b/bots/package.json @@ -7,6 +7,6 @@ "main": "index.js", "license": "MIT", "devDependencies": { - "danger": "^11.1.1" + "danger": "11.1.2" } } diff --git a/bots/yarn.lock b/bots/yarn.lock index ad02cdb9056..9c7374e7044 100644 --- a/bots/yarn.lock +++ b/bots/yarn.lock @@ -196,10 +196,10 @@ core-js@^3.8.2: resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.24.1.tgz#cf7724d41724154010a6576b7b57d94c5d66e64f" integrity sha512-0QTBSYSUZ6Gq21utGzkfITDylE8jWC9Ne1D2MrhvlsZBI1x39OdDIVbzSqtgMndIy6BlHxBXpMGqzZmnztg2rg== -danger@^11.1.1: - version "11.1.1" - resolved "https://registry.yarnpkg.com/danger/-/danger-11.1.1.tgz#b745f6191c1478dd4ef81596ac96be8f8e2d0634" - integrity sha512-kQX1/Rggut/KFgArOloAdw6paB7hkoznRaUhpPFKVHKRgc6FtlhC8zpb480jVE71Z6eI7rrHVDGEYLv8x96yyA== +danger@11.1.2: + version "11.1.2" + resolved "https://registry.yarnpkg.com/danger/-/danger-11.1.2.tgz#6fa7807c8721e9f8a040252ae8a22db222b8c4e0" + integrity sha512-tlAyADE7BRHbnoAA7BB7RzcO/ZLvXMpnWms7dBT/Tm4ntxdbrTT6wCPO1qFcd5Jc9LfM0Iez3hKUSINtnPLH+g== dependencies: "@octokit/rest" "^18.12.0" async-retry "1.2.3" diff --git a/build-logic/src/main/kotlin/releasing.gradle.kts b/build-logic/src/main/kotlin/releasing.gradle.kts index c44b5c97a0a..677ead33137 100644 --- a/build-logic/src/main/kotlin/releasing.gradle.kts +++ b/build-logic/src/main/kotlin/releasing.gradle.kts @@ -26,7 +26,7 @@ project.afterEvaluate { draft.set(true) targetCommitish.set("main") body { - var changelog = project.file("website/docs/introduction/changelog 1.x.x.md").readText() + var changelog = project.file("website/docs/introduction/changelog.md").readText() val nextNonBetaVersion = project.version.toString() val sectionStart = "#### $nextNonBetaVersion" changelog = changelog.substring(changelog.indexOf(sectionStart)) diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml index 62332182dba..5237f6c5f66 100644 --- a/config/detekt/detekt.yml +++ b/config/detekt/detekt.yml @@ -69,29 +69,21 @@ formatting: active: true android: false autoCorrect: true - AnnotationSpacing: - active: true - EnumEntryNameCase: - active: true Filename: active: false - MaximumLineLength: - active: false - MultiLineIfElse: - active: true - NoEmptyFirstLineInMethodBlock: + FunctionReturnTypeSpacing: active: true - PackageName: + FunctionStartOfBodySpacing: active: true - SpacingAroundAngleBrackets: - active: true - SpacingAroundDoubleColon: + MaximumLineLength: + active: false + NullableTypeSpacing: active: true - SpacingAroundUnaryOperator: + ParameterListSpacing: active: true - SpacingBetweenDeclarationsWithAnnotations: + SpacingBetweenFunctionNameAndOpeningParenthesis: active: true - SpacingBetweenDeclarationsWithComments: + TypeParameterListSpacing: active: true naming: @@ -237,6 +229,8 @@ style: excludeGuardClauses: true SpacingBetweenPackageAndImports: active: true + TrimMultilineRawString: + active: true UnderscoresInNumericLiterals: active: true UnnecessaryAnnotationUseSiteTarget: diff --git a/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/Location.kt b/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/Location.kt index 99bed074c65..e07dcec859a 100644 --- a/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/Location.kt +++ b/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/Location.kt @@ -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" diff --git a/detekt-cli/src/test/kotlin/io/gitlab/arturbosch/detekt/cli/runners/ElementPrinterSpec.kt b/detekt-cli/src/test/kotlin/io/gitlab/arturbosch/detekt/cli/runners/ElementPrinterSpec.kt index 319684a5067..303aa1509d8 100644 --- a/detekt-cli/src/test/kotlin/io/gitlab/arturbosch/detekt/cli/runners/ElementPrinterSpec.kt +++ b/detekt-cli/src/test/kotlin/io/gitlab/arturbosch/detekt/cli/runners/ElementPrinterSpec.kt @@ -18,7 +18,8 @@ class ElementPrinterSpec { } } -private val expected = """0: KtFile +private val expected = """ +0: KtFile 1: KtPackageDirective 1: KtNameReferenceExpression 1: KtImportList diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFacade.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFacade.kt index dead8c6fac9..becc0fbb31e 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFacade.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFacade.kt @@ -11,7 +11,7 @@ class BaselineFacade { fun transformResult(baselineFile: Path, result: Detektion): Detektion { return if (baselineExists(baselineFile)) { - BaselineFilteredResult(result, Baseline.load(baselineFile)) + BaselineFilteredResult(result, DefaultBaseline.load(baselineFile)) } else { result } @@ -20,14 +20,15 @@ class BaselineFacade { fun createOrUpdate(baselineFile: Path, findings: List) { val ids = findings.map { it.baselineId }.toSortedSet() val oldBaseline = if (baselineExists(baselineFile)) { - Baseline.load(baselineFile) + DefaultBaseline.load(baselineFile) } else { - Baseline(emptySet(), emptySet()) + DefaultBaseline(emptySet(), emptySet()) } - val baseline = oldBaseline.copy(currentIssues = ids) + val baselineFormat = BaselineFormat() + val baseline = baselineFormat.of(oldBaseline.manuallySuppressedIssues, ids) if (oldBaseline != baseline) { baselineFile.parent?.let { Files.createDirectories(it) } - BaselineFormat().write(baseline, baselineFile) + baselineFormat.write(baselineFile, baseline) } } diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFilteredResult.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFilteredResult.kt index 944ec58b8e1..23ce026e006 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFilteredResult.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFilteredResult.kt @@ -1,12 +1,13 @@ package io.gitlab.arturbosch.detekt.core.baseline +import io.github.detekt.tooling.api.Baseline import io.gitlab.arturbosch.detekt.api.Detektion import io.gitlab.arturbosch.detekt.api.Finding import io.gitlab.arturbosch.detekt.api.RuleSetId internal class BaselineFilteredResult( result: Detektion, - private val baseline: Baseline + private val baseline: Baseline, ) : Detektion by result { override val findings: Map> = result.findings diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFormat.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFormat.kt index ac8c41e7756..888537415f8 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFormat.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFormat.kt @@ -1,5 +1,10 @@ package io.gitlab.arturbosch.detekt.core.baseline +import io.github.detekt.tooling.api.Baseline +import io.github.detekt.tooling.api.BaselineProvider +import io.github.detekt.tooling.api.FindingId +import io.github.detekt.tooling.api.FindingsIdList +import io.gitlab.arturbosch.detekt.api.Finding import org.xml.sax.SAXParseException import java.nio.file.Files import java.nio.file.Path @@ -8,16 +13,21 @@ import javax.xml.parsers.SAXParserFactory import javax.xml.stream.XMLStreamException import javax.xml.stream.XMLStreamWriter -internal class BaselineFormat { +internal class BaselineFormat : BaselineProvider { private val XMLStreamException.positions get() = location.lineNumber to location.columnNumber class InvalidState(msg: String, error: Throwable) : IllegalStateException(msg, error) - fun read(path: Path): Baseline { + override fun id(finding: Finding): FindingId = finding.baselineId + + override fun of(manuallySuppressedIssues: FindingsIdList, currentIssues: FindingsIdList): DefaultBaseline = + DefaultBaseline(manuallySuppressedIssues, currentIssues) + + override fun read(sourcePath: Path): DefaultBaseline { try { - Files.newInputStream(path).use { + Files.newInputStream(sourcePath).use { val reader = SAXParserFactory.newInstance() .apply { setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true) @@ -33,9 +43,9 @@ internal class BaselineFormat { } } - fun write(baseline: Baseline, path: Path) { + override fun write(targetPath: Path, baseline: Baseline) { try { - Files.newBufferedWriter(path).addFinalNewLine().use { + Files.newBufferedWriter(targetPath).addFinalNewLine().use { it.streamXml().prettyPrinter().save(baseline) } } catch (error: XMLStreamException) { diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineHandler.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineHandler.kt index cfb11affafa..d6db1278e82 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineHandler.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineHandler.kt @@ -11,7 +11,7 @@ internal class BaselineHandler : DefaultHandler() { private val currentIssues = mutableSetOf() private val manuallySuppressedIssues = mutableSetOf() - internal fun createBaseline() = Baseline(manuallySuppressedIssues, currentIssues) + internal fun createBaseline() = DefaultBaseline(manuallySuppressedIssues, currentIssues) override fun startElement(uri: String, localName: String, qName: String, attributes: Attributes) { when (qName) { diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/Baseline.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/DefaultBaseline.kt similarity index 74% rename from detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/Baseline.kt rename to detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/DefaultBaseline.kt index 33ce40a23d4..eba4ddce0ee 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/Baseline.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/baseline/DefaultBaseline.kt @@ -1,19 +1,19 @@ package io.gitlab.arturbosch.detekt.core.baseline +import io.github.detekt.tooling.api.Baseline +import io.github.detekt.tooling.api.FindingId +import io.github.detekt.tooling.api.FindingsIdList import io.gitlab.arturbosch.detekt.api.Finding import io.gitlab.arturbosch.detekt.core.exists import io.gitlab.arturbosch.detekt.core.isFile import java.nio.file.Path -internal typealias FindingsIdList = Set -internal typealias FindingId = String +internal data class DefaultBaseline( + override val manuallySuppressedIssues: FindingsIdList, + override val currentIssues: FindingsIdList, +) : Baseline { -internal data class Baseline( - val manuallySuppressedIssues: FindingsIdList, - val currentIssues: FindingsIdList -) { - - fun contains(id: FindingId): Boolean = + override fun contains(id: FindingId): Boolean = currentIssues.contains(id) || manuallySuppressedIssues.contains(id) companion object { diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfig.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfig.kt index 26d8e5e88a7..9522973cd8d 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfig.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/AllRulesConfig.kt @@ -1,6 +1,8 @@ package io.gitlab.arturbosch.detekt.core.config import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.core.config.validation.ValidatableConfiguration +import io.gitlab.arturbosch.detekt.core.config.validation.validateConfig @Suppress("UNCHECKED_CAST") internal data class AllRulesConfig( diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/CompositeConfig.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/CompositeConfig.kt index 90aeca227a7..9e7075d85e7 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/CompositeConfig.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/CompositeConfig.kt @@ -2,6 +2,8 @@ package io.gitlab.arturbosch.detekt.core.config import io.gitlab.arturbosch.detekt.api.Config import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.core.config.validation.ValidatableConfiguration +import io.gitlab.arturbosch.detekt.core.config.validation.validateConfig /** * Wraps two different configuration which should be considered when retrieving properties. diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/ConfigValidators.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/ConfigValidators.kt deleted file mode 100644 index bd00be46dc2..00000000000 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/ConfigValidators.kt +++ /dev/null @@ -1,39 +0,0 @@ -package io.gitlab.arturbosch.detekt.core.config - -import io.github.detekt.tooling.api.InvalidConfig -import io.gitlab.arturbosch.detekt.api.Config -import io.gitlab.arturbosch.detekt.api.ConfigValidator -import io.gitlab.arturbosch.detekt.api.Notification -import io.gitlab.arturbosch.detekt.core.NL -import io.gitlab.arturbosch.detekt.core.ProcessingSettings -import io.gitlab.arturbosch.detekt.core.extensions.loadExtensions -import io.gitlab.arturbosch.detekt.core.reporting.red -import io.gitlab.arturbosch.detekt.core.reporting.yellow - -internal fun checkConfiguration(settings: ProcessingSettings, baseline: Config) { - var shouldValidate = settings.spec.configSpec.shouldValidateBeforeAnalysis - if (shouldValidate == null) { - val props = settings.config.subConfig("config") - shouldValidate = props.valueOrDefault("validation", true) - } - if (shouldValidate) { - val validators = - loadExtensions(settings) + DefaultPropertiesConfigValidator(settings, baseline) - val notifications = validators.flatMap { it.validate(settings.config) } - notifications.map(Notification::message).forEach(settings::info) - val errors = notifications.filter(Notification::isError) - if (errors.isNotEmpty()) { - val problems = notifications.joinToString(NL) { "\t- ${it.renderMessage()}" } - val propsString = if (errors.size == 1) "property" else "properties" - val title = "Run failed with ${errors.size} invalid config $propsString.".red() - throw InvalidConfig("$title$NL$problems") - } - } -} - -internal fun Notification.renderMessage(): String = - when (level) { - Notification.Level.Error -> message.red() - Notification.Level.Warning -> message.yellow() - Notification.Level.Info -> message - } diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/DisabledAutoCorrectConfig.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/DisabledAutoCorrectConfig.kt index 193751a0039..6e7bffae848 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/DisabledAutoCorrectConfig.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/DisabledAutoCorrectConfig.kt @@ -2,6 +2,8 @@ package io.gitlab.arturbosch.detekt.core.config import io.gitlab.arturbosch.detekt.api.Config import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.core.config.validation.ValidatableConfiguration +import io.gitlab.arturbosch.detekt.core.config.validation.validateConfig @Suppress("UNCHECKED_CAST") class DisabledAutoCorrectConfig(private val wrapped: Config) : Config, ValidatableConfiguration { diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/ValidateConfig.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/ValidateConfig.kt deleted file mode 100644 index 4f6dfe62d52..00000000000 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/ValidateConfig.kt +++ /dev/null @@ -1,153 +0,0 @@ -package io.gitlab.arturbosch.detekt.core.config - -import io.github.detekt.utils.openSafeStream -import io.gitlab.arturbosch.detekt.api.Config -import io.gitlab.arturbosch.detekt.api.Notification -import io.gitlab.arturbosch.detekt.api.internal.CommaSeparatedPattern -import io.gitlab.arturbosch.detekt.api.internal.SimpleNotification -import java.util.Properties - -/** - * Known existing properties on rule's which my be absent in the default-detekt-config.yml. - * - * We need to predefine them as the user may not have already declared an 'config'-block - * in the configuration and we want to validate the config by default. - */ -val DEFAULT_PROPERTY_EXCLUDES = setOf( - ".*>excludes", - ".*>includes", - ".*>active", - ".*>.*>excludes", - ".*>.*>includes", - ".*>.*>active", - ".*>.*>autoCorrect", - ".*>severity", - ".*>.*>severity", - "build>weights.*", - ".*>.*>ignoreAnnotated", - ".*>.*>ignoreFunction", -).joinToString(",") - -fun validateConfig( - config: Config, - baseline: Config, - excludePatterns: Set = CommaSeparatedPattern(DEFAULT_PROPERTY_EXCLUDES).mapToRegex() -): List = validateConfig( - config, - baseline, - ValidationSettings( - config.subConfig("config").valueOrDefault("warningsAsErrors", false), - excludePatterns, - ) -) - -internal data class ValidationSettings( - val warningsAsErrors: Boolean, - val excludePatterns: Set, -) - -@Suppress("UNCHECKED_CAST", "ComplexMethod") -internal fun validateConfig( - config: Config, - baseline: Config, - settings: ValidationSettings, -): List { - require(baseline != Config.empty) { "Cannot validate configuration based on an empty baseline config." } - require(baseline is YamlConfig) { - val yamlConfigClass = YamlConfig::class.simpleName - val actualClass = baseline.javaClass.simpleName - - "Only supported baseline config is the $yamlConfigClass. Actual type is $actualClass" - } - - if (config == Config.empty) { - return emptyList() - } - - val (warningsAsErrors, excludePatterns) = settings - val notifications = mutableListOf() - - fun getDeprecatedProperties(): List> { - return settings.javaClass.classLoader - .getResource("deprecation.properties")!! - .openSafeStream() - .use { inputStream -> - val prop = Properties().apply { load(inputStream) } - - prop.entries.map { entry -> - (entry.key as String).toRegex() to (entry.value as String) - } - } - } - - fun testKeys(current: Map, base: Map, parentPath: String?) { - for (prop in current.keys) { - val propertyPath = "${if (parentPath == null) "" else "$parentPath>"}$prop" - - val deprecationWarning = getDeprecatedProperties() - .find { (regex, _) -> regex.matches(propertyPath) } - ?.second - val isExcluded = excludePatterns.any { it.matches(propertyPath) } - - if (deprecationWarning != null) { - notifications.add(propertyIsDeprecated(propertyPath, deprecationWarning, warningsAsErrors)) - } - - if (deprecationWarning != null || isExcluded) { - continue - } - - if (!base.contains(prop)) { - notifications.add(propertyDoesNotExists(propertyPath)) - } else if (current[prop] is String && base[prop] is List<*>) { - notifications.add(propertyShouldBeAnArray(propertyPath, warningsAsErrors)) - } - - val next = current[prop] as? Map - val nextBase = base[prop] as? Map - - when { - next == null && nextBase != null -> notifications.add(nestedConfigurationExpected(propertyPath)) - base.contains(prop) && next != null && nextBase == null -> - notifications.add(unexpectedNestedConfiguration(propertyPath)) - next != null && nextBase != null -> testKeys(next, nextBase, propertyPath) - } - } - } - - when (config) { - is YamlConfig -> testKeys(config.properties, baseline.properties, null) - is ValidatableConfiguration -> notifications.addAll(config.validate(baseline, excludePatterns)) - else -> error("Unsupported config type for validation: '${config::class}'.") - } - - return notifications -} - -internal fun propertyDoesNotExists(prop: String): Notification = - SimpleNotification("Property '$prop' is misspelled or does not exist.") - -internal fun nestedConfigurationExpected(prop: String): Notification = - SimpleNotification("Nested config expected for '$prop'.") - -internal fun unexpectedNestedConfiguration(prop: String): Notification = - SimpleNotification("Unexpected nested config for '$prop'.") - -internal fun propertyIsDeprecated( - prop: String, - deprecationDescription: String, - reportAsError: Boolean, -): Notification = - SimpleNotification( - "Property '$prop' is deprecated. $deprecationDescription.", - if (reportAsError) Notification.Level.Error else Notification.Level.Warning, - ) - -internal fun propertyShouldBeAnArray( - prop: String, - reportAsError: Boolean, -): Notification = - SimpleNotification( - "Property '$prop' should be a YAML array instead of a comma-separated String.", - if (reportAsError) Notification.Level.Error else Notification.Level.Warning, - ) diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/YamlConfig.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/YamlConfig.kt index 24c9d5cd25e..b0ae1d6481d 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/YamlConfig.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/YamlConfig.kt @@ -5,6 +5,8 @@ package io.gitlab.arturbosch.detekt.core.config import io.gitlab.arturbosch.detekt.api.Config import io.gitlab.arturbosch.detekt.api.Config.Companion.CONFIG_SEPARATOR import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.core.config.validation.ValidatableConfiguration +import io.gitlab.arturbosch.detekt.core.config.validation.validateConfig import org.yaml.snakeyaml.Yaml import java.io.Reader import java.nio.file.Path diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/AbstractYamlConfigValidator.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/AbstractYamlConfigValidator.kt new file mode 100644 index 00000000000..9bb1270cf09 --- /dev/null +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/AbstractYamlConfigValidator.kt @@ -0,0 +1,28 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.ConfigValidator +import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.core.config.YamlConfig + +internal abstract class AbstractYamlConfigValidator : ConfigValidator { + + override fun validate(config: Config): Collection { + require(config is YamlConfig) { + val yamlConfigClass = YamlConfig::class.simpleName + val actualClass = config.javaClass.simpleName + + "Only supported config is the $yamlConfigClass. Actual type is $actualClass" + } + val settings = ValidationSettings( + config.subConfig("config").valueOrDefault("checkExhaustiveness", false), + ) + + return validate(config, settings) + } + + abstract fun validate( + configToValidate: YamlConfig, + settings: ValidationSettings + ): Collection +} diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ConfigValidation.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ConfigValidation.kt new file mode 100644 index 00000000000..3e6051077e3 --- /dev/null +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ConfigValidation.kt @@ -0,0 +1,118 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.github.detekt.tooling.api.InvalidConfig +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.ConfigValidator +import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.api.Notification.Level +import io.gitlab.arturbosch.detekt.api.internal.SimpleNotification +import io.gitlab.arturbosch.detekt.core.NL +import io.gitlab.arturbosch.detekt.core.ProcessingSettings +import io.gitlab.arturbosch.detekt.core.config.YamlConfig +import io.gitlab.arturbosch.detekt.core.extensions.loadExtensions +import io.gitlab.arturbosch.detekt.core.reporting.red +import io.gitlab.arturbosch.detekt.core.reporting.yellow + +/** + * Known existing properties on rule's which my be absent in the default-detekt-config.yml. + * + * We need to predefine them as the user may not have already declared an 'config'-block + * in the configuration and we want to validate the config by default. + */ +internal val DEFAULT_PROPERTY_EXCLUDES = setOf( + ".*>excludes", + ".*>includes", + ".*>active", + ".*>.*>excludes", + ".*>.*>includes", + ".*>.*>active", + ".*>.*>autoCorrect", + ".*>severity", + ".*>.*>severity", + "build>weights.*", + ".*>.*>ignoreAnnotated", + ".*>.*>ignoreFunction", +).joinToString(",") + +internal fun checkConfiguration(settings: ProcessingSettings, baseline: Config) { + var shouldValidate = settings.spec.configSpec.shouldValidateBeforeAnalysis + if (shouldValidate == null) { + val props = settings.config.subConfig("config") + shouldValidate = props.valueOrDefault("validation", true) + } + if (shouldValidate) { + val validators = + loadExtensions(settings) + DefaultPropertiesConfigValidator(settings, baseline) + val notifications = validators.flatMap { it.validate(settings.config) } + notifications.map(Notification::message).forEach(settings::info) + val errors = notifications.filter(Notification::isError) + if (errors.isNotEmpty()) { + val problems = notifications.joinToString(NL) { "\t- ${it.renderMessage()}" } + val propsString = if (errors.size == 1) "property" else "properties" + val title = "Run failed with ${errors.size} invalid config $propsString.".red() + throw InvalidConfig("$title$NL$problems") + } + } +} + +internal fun validateConfig( + config: Config, + baseline: Config, + excludePatterns: Set +): List { + require(baseline != Config.empty) { "Cannot validate configuration based on an empty baseline config." } + require(baseline is YamlConfig) { + val yamlConfigClass = YamlConfig::class.simpleName + val actualClass = baseline.javaClass.simpleName + + "Only supported baseline config is the $yamlConfigClass. Actual type is $actualClass" + } + + if (config == Config.empty) { + return emptyList() + } + + return when (config) { + is YamlConfig -> validateYamlConfig(config, baseline, excludePatterns) + is ValidatableConfiguration -> config.validate(baseline, excludePatterns) + else -> error("Unsupported config type for validation: '${config::class}'.") + } +} + +private fun validateYamlConfig( + configToValidate: YamlConfig, + baseline: YamlConfig, + excludePatterns: Set +): List { + val deprecatedProperties = loadDeprecations() + val warningsAsErrors = configToValidate + .subConfig("config") + .valueOrDefault("warningsAsErrors", false) + + val validators: List = listOf( + InvalidPropertiesConfigValidator(baseline, deprecatedProperties.keys, excludePatterns), + DeprecatedPropertiesConfigValidator(deprecatedProperties), + MissingRulesConfigValidator(baseline, excludePatterns) + ) + + return validators + .flatMap { it.validate(configToValidate) } + .map { notification -> + notification.transformIf(warningsAsErrors && notification.level == Level.Warning) { + SimpleNotification( + message = notification.message, + level = Level.Error + ) + } + } +} + +private fun T.transformIf(condition: Boolean, transform: () -> T): T = + if (condition) transform() else this + +internal fun Notification.renderMessage(): String = + when (level) { + Level.Error -> message.red() + Level.Warning -> message.yellow() + Level.Info -> message + } diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/DefaultPropertiesConfigValidator.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DefaultPropertiesConfigValidator.kt similarity index 91% rename from detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/DefaultPropertiesConfigValidator.kt rename to detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DefaultPropertiesConfigValidator.kt index 302b9c18033..7578ad2fa72 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/DefaultPropertiesConfigValidator.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DefaultPropertiesConfigValidator.kt @@ -1,4 +1,4 @@ -package io.gitlab.arturbosch.detekt.core.config +package io.gitlab.arturbosch.detekt.core.config.validation import io.gitlab.arturbosch.detekt.api.Config import io.gitlab.arturbosch.detekt.api.ConfigValidator @@ -8,7 +8,7 @@ import io.gitlab.arturbosch.detekt.api.internal.DefaultRuleSetProvider import io.gitlab.arturbosch.detekt.core.ProcessingSettings import io.gitlab.arturbosch.detekt.core.rules.RuleSetLocator -class DefaultPropertiesConfigValidator( +internal class DefaultPropertiesConfigValidator( private val settings: ProcessingSettings, private val baseline: Config, ) : ConfigValidator { diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DeprecatedPropertiesConfigValidator.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DeprecatedPropertiesConfigValidator.kt new file mode 100644 index 00000000000..a77d6c8b119 --- /dev/null +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DeprecatedPropertiesConfigValidator.kt @@ -0,0 +1,44 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.api.internal.SimpleNotification +import io.gitlab.arturbosch.detekt.core.config.YamlConfig + +internal class DeprecatedPropertiesConfigValidator( + private val deprecatedProperties: Map, +) : AbstractYamlConfigValidator() { + override fun validate( + configToValidate: YamlConfig, + settings: ValidationSettings + ): Collection { + val configAsMap = configToValidate.properties + return deprecatedProperties + .map { (path, description) -> path.split(">") to description } + .filter { (path, _) -> configAsMap.hasValue(path) } + .map { (path, description) -> createNotification(path, description) } + } + + @Suppress("UNCHECKED_CAST") + private fun Map.hasValue(propertyPath: List): Boolean { + if (propertyPath.isEmpty()) { + return false + } + if (propertyPath.size == 1) { + return this.containsKey(propertyPath.first()) + } + + val subMap = this[propertyPath.first()] as? Map ?: return false + return subMap.hasValue(propertyPath.drop(1)) + } + + private fun createNotification( + propertyPath: List, + deprecationDescription: String, + ): Notification { + val prop = propertyPath.joinToString(">") + return SimpleNotification( + "Property '$prop' is deprecated. $deprecationDescription.", + Notification.Level.Warning, + ) + } +} diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/Deprecations.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/Deprecations.kt new file mode 100644 index 00000000000..869b745f041 --- /dev/null +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/Deprecations.kt @@ -0,0 +1,17 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.github.detekt.utils.openSafeStream +import java.util.Properties + +internal fun loadDeprecations(): Map { + return ValidationSettings::class.java.classLoader + .getResource("deprecation.properties")!! + .openSafeStream() + .use { inputStream -> + val prop = Properties().apply { load(inputStream) } + + prop.entries.associate { entry -> + (entry.key as String) to (entry.value as String) + } + } +} diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/InvalidPropertiesConfigValidator.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/InvalidPropertiesConfigValidator.kt new file mode 100644 index 00000000000..f2c7c68528e --- /dev/null +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/InvalidPropertiesConfigValidator.kt @@ -0,0 +1,89 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.api.internal.SimpleNotification +import io.gitlab.arturbosch.detekt.core.config.YamlConfig + +internal class InvalidPropertiesConfigValidator( + private val baseline: YamlConfig, + private val deprecatedProperties: Set, + private val excludePatterns: Set, +) : AbstractYamlConfigValidator() { + + override fun validate( + configToValidate: YamlConfig, + settings: ValidationSettings + ): Collection { + return testKeys(configToValidate.properties, baseline.properties) + } + + private fun testKeys( + configToValidate: Map, + baseline: Map, + parentPath: String? = null + ): List { + val notifications = mutableListOf() + for (prop in configToValidate.keys) { + val propertyPath = "${if (parentPath == null) "" else "$parentPath>"}$prop" + val isExcluded = excludePatterns.any { it.matches(propertyPath) } + val isDeprecated = deprecatedProperties.contains(propertyPath) + if (isExcluded || isDeprecated) { + continue + } + notifications.addAll( + checkProp( + propertyName = prop, + propertyPath = propertyPath, + configToValidate = configToValidate, + baseline = baseline + ) + ) + } + return notifications + } + + @Suppress("UNCHECKED_CAST") + private fun checkProp( + propertyName: String, + propertyPath: String, + configToValidate: Map, + baseline: Map + ): List { + if (!baseline.contains(propertyName)) { + return listOf(propertyDoesNotExists(propertyPath)) + } + if (configToValidate[propertyName] is String && baseline[propertyName] is List<*>) { + return listOf(propertyShouldBeAnArray(propertyPath)) + } + + val next = configToValidate[propertyName] as? Map + val nextBase = baseline[propertyName] as? Map + return when { + next == null && nextBase != null -> + listOf(nestedConfigurationExpected(propertyPath)) + baseline.contains(propertyName) && next != null && nextBase == null -> + listOf(unexpectedNestedConfiguration(propertyPath)) + next != null && nextBase != null -> + testKeys(next, nextBase, propertyPath) + else -> emptyList() + } + } + + companion object { + + internal fun propertyDoesNotExists(prop: String): Notification = + SimpleNotification("Property '$prop' is misspelled or does not exist.") + + internal fun nestedConfigurationExpected(prop: String): Notification = + SimpleNotification("Nested config expected for '$prop'.") + + internal fun unexpectedNestedConfiguration(prop: String): Notification = + SimpleNotification("Unexpected nested config for '$prop'.") + + internal fun propertyShouldBeAnArray(prop: String): Notification = + SimpleNotification( + "Property '$prop' should be a YAML array instead of a comma-separated String.", + Notification.Level.Warning, + ) + } +} diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/MissingRulesConfigValidator.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/MissingRulesConfigValidator.kt new file mode 100644 index 00000000000..fe22e8ab2ff --- /dev/null +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/MissingRulesConfigValidator.kt @@ -0,0 +1,81 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.api.RuleSetProvider +import io.gitlab.arturbosch.detekt.api.internal.DefaultRuleSetProvider +import io.gitlab.arturbosch.detekt.api.internal.SimpleNotification +import io.gitlab.arturbosch.detekt.core.config.YamlConfig +import java.util.ServiceLoader + +internal class MissingRulesConfigValidator( + private val baseline: YamlConfig, + private val excludePatterns: Set, +) : AbstractYamlConfigValidator() { + + override fun validate( + configToValidate: YamlConfig, + settings: ValidationSettings + ): Collection { + if (!settings.checkExhaustiveness) { + return emptyList() + } + return defaultRuleSetNames.flatMap { ruleSet -> validateRuleSet(ruleSet, configToValidate) } + } + + private fun validateRuleSet( + ruleSet: String, + configToValidate: YamlConfig, + ): List { + val ruleSetConfigToValidate = configToValidate.getSubMapOrNull(ruleSet) + val ruleSetConfigFromBaseline = baseline.getSubMapOrNull(ruleSet) + return when { + ruleSetConfigFromBaseline == null -> emptyList() + ruleSetConfigToValidate == null -> listOf(ruleSetMissing(ruleSet)) + else -> checkForMissingRules(ruleSet, ruleSetConfigToValidate, ruleSetConfigFromBaseline) + } + } + + private fun checkForMissingRules( + ruleSetName: String, + ruleSetConfigToValidate: Map, + ruleSetConfigFromBaseline: Map, + ): List { + if (ruleSetConfigToValidate[Config.ACTIVE_KEY] == false) { + return emptyList() + } + + return ruleSetConfigFromBaseline.keys + .filter { ruleNameCandidate -> excludePatterns.none { it.matches("$ruleSetName>$ruleNameCandidate") } } + .filter { ruleName -> !ruleSetConfigToValidate.containsKey(ruleName) } + .map { ruleName -> ruleMissing(ruleName, ruleSetName) } + } + + private fun ruleMissing(ruleName: String, ruleSetName: String): Notification = + SimpleNotification( + "Rule '$ruleName' from the '$ruleSetName' rule set is missing in the configuration.", + Notification.Level.Warning, + ) + + private fun ruleSetMissing(ruleSetName: String): Notification = + SimpleNotification( + "Rule set '$ruleSetName' is missing in the configuration.", + Notification.Level.Warning, + ) + + @Suppress("UNCHECKED_CAST") + private fun YamlConfig.getSubMapOrNull(propertyName: String) = properties[propertyName] as? Map + + companion object { + + private val defaultRuleSetNames: List by lazy(Companion::loadDefaultRuleSets) + private fun loadDefaultRuleSets(): List { + return ServiceLoader.load( + RuleSetProvider::class.java, + MissingRulesConfigValidator::class.java.classLoader + ) + .filterIsInstance() + .map { it.ruleSetId } + } + } +} diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/ValidatableConfiguration.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ValidatableConfiguration.kt similarity index 79% rename from detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/ValidatableConfiguration.kt rename to detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ValidatableConfiguration.kt index 78a97e9dea8..8b69fbfe475 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/ValidatableConfiguration.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ValidatableConfiguration.kt @@ -1,4 +1,4 @@ -package io.gitlab.arturbosch.detekt.core.config +package io.gitlab.arturbosch.detekt.core.config.validation import io.gitlab.arturbosch.detekt.api.Config import io.gitlab.arturbosch.detekt.api.Notification diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ValidationSettings.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ValidationSettings.kt new file mode 100644 index 00000000000..a1ddf9d4a42 --- /dev/null +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ValidationSettings.kt @@ -0,0 +1,5 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +internal data class ValidationSettings( + val checkExhaustiveness: Boolean = false, +) diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/tooling/Lifecycle.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/tooling/Lifecycle.kt index c2070413a3c..5e04be5baac 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/tooling/Lifecycle.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/tooling/Lifecycle.kt @@ -11,7 +11,7 @@ import io.gitlab.arturbosch.detekt.core.Analyzer import io.gitlab.arturbosch.detekt.core.DetektResult import io.gitlab.arturbosch.detekt.core.FileProcessorLocator import io.gitlab.arturbosch.detekt.core.ProcessingSettings -import io.gitlab.arturbosch.detekt.core.config.checkConfiguration +import io.gitlab.arturbosch.detekt.core.config.validation.checkConfiguration import io.gitlab.arturbosch.detekt.core.extensions.handleReportingExtensions import io.gitlab.arturbosch.detekt.core.generateBindingContext import io.gitlab.arturbosch.detekt.core.reporting.OutputFacade diff --git a/detekt-core/src/main/resources/META-INF/services/io.github.detekt.tooling.api.BaselineProvider b/detekt-core/src/main/resources/META-INF/services/io.github.detekt.tooling.api.BaselineProvider new file mode 100644 index 00000000000..d09d3865ea5 --- /dev/null +++ b/detekt-core/src/main/resources/META-INF/services/io.github.detekt.tooling.api.BaselineProvider @@ -0,0 +1 @@ +io.gitlab.arturbosch.detekt.core.baseline.BaselineFormat diff --git a/detekt-core/src/main/resources/default-detekt-config.yml b/detekt-core/src/main/resources/default-detekt-config.yml index 59de0ada0e4..219fcc7ad02 100644 --- a/detekt-core/src/main/resources/default-detekt-config.yml +++ b/detekt-core/src/main/resources/default-detekt-config.yml @@ -10,6 +10,7 @@ build: config: validation: true warningsAsErrors: false + checkExhaustiveness: false # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' excludes: '' diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/SuppressionSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/SuppressionSpec.kt index 56ff05e4fb7..1dcf0ce6f6a 100644 --- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/SuppressionSpec.kt +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/SuppressionSpec.kt @@ -169,7 +169,7 @@ class SuppressionSpec { println("FAILED TEST") } } - """ + """.trimIndent() ) val rule = TestRule() rule.visitFile(ktFile) @@ -187,7 +187,7 @@ class SuppressionSpec { println("FAILED TEST") } } - """ + """.trimIndent() ) val rule = TestRule() rule.visitFile(ktFile) @@ -205,7 +205,7 @@ class SuppressionSpec { println("FAILED TEST") } } - """ + """.trimIndent() ) val rule = TestRule() rule.visitFile(ktFile) @@ -227,7 +227,7 @@ class SuppressionSpec { println("FAILED TEST") } } - """ + """.trimIndent() ) val rule = TestRule(TestConfig(mutableMapOf("aliases" to "[MyTest]"))) rule.visitFile(ktFile) @@ -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")) diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFilteredResultSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFilteredResultSpec.kt index 43e2ef43d76..b88431235ec 100644 --- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFilteredResultSpec.kt +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFilteredResultSpec.kt @@ -28,13 +28,13 @@ class BaselineFilteredResultSpec { @Test fun `does return the same finding on empty baseline`() { - val actual = BaselineFilteredResult(result, Baseline(emptySet(), emptySet())) + val actual = BaselineFilteredResult(result, DefaultBaseline(emptySet(), emptySet())) assertThat(actual.findings).hasSize(3) } @Test fun `filters with an existing baseline file`() { - val baseline = Baseline.load(baselineFile) + val baseline = DefaultBaseline.load(baselineFile) val actual = BaselineFilteredResult(result, baseline) // Note: Detektion works with Map // but the TestDetektion maps the RuleId as RuleSetId diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFormatSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFormatSpec.kt index bb00b0bd808..28fc74438f6 100644 --- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFormatSpec.kt +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineFormatSpec.kt @@ -2,6 +2,8 @@ package io.gitlab.arturbosch.detekt.core.baseline import io.github.detekt.test.utils.createTempFileForTest import io.github.detekt.test.utils.resourceAsPath +import io.github.detekt.tooling.api.BaselineProvider +import io.gitlab.arturbosch.detekt.test.createFinding import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatIllegalStateException import org.assertj.core.api.Assertions.assertThatThrownBy @@ -11,6 +13,34 @@ import java.nio.file.Files class BaselineFormatSpec { + @Nested + inner class `implements tooling api` { + + @Test + fun `core implements provider`() { + assertThat(BaselineProvider.load()).isInstanceOf(BaselineFormat::class.java) + } + + @Test + fun `provider allows to query finding baseline ids`() { + assertThat(BaselineProvider.load().id(createFinding())).isEqualTo("TestSmell:TestEntitySignature") + } + + @Test + fun `reads and writes baselines`() { + val provider = BaselineProvider.load() + val path = resourceAsPath("/baseline_feature/valid-baseline.xml") + + val referenceBaseline = provider.read(path) + val tempFile = createTempFileForTest("baseline1", ".xml") + provider.write(tempFile, referenceBaseline) + val actualBaseline = provider.read(path) + + assertThat(actualBaseline.currentIssues).containsAll(referenceBaseline.currentIssues) + assertThat(actualBaseline.manuallySuppressedIssues).containsAll(referenceBaseline.manuallySuppressedIssues) + } + } + @Nested inner class `read a baseline file` { @@ -57,14 +87,14 @@ class BaselineFormatSpec { @Nested inner class `writes a baseline file` { - private val savedBaseline = Baseline(setOf("4", "2", "2"), setOf("1", "2", "3")) + private val savedBaseline = DefaultBaseline(setOf("4", "2", "2"), setOf("1", "2", "3")) @Test fun `has a new line at the end of the written baseline file`() { val tempFile = createTempFileForTest("baseline1", ".xml") val format = BaselineFormat() - format.write(savedBaseline, tempFile) + format.write(tempFile, savedBaseline) val bytes = Files.readAllBytes(tempFile) val content = String(bytes, Charsets.UTF_8) @@ -76,7 +106,7 @@ class BaselineFormatSpec { val tempFile = createTempFileForTest("baseline-saved", ".xml") val format = BaselineFormat() - format.write(savedBaseline, tempFile) + format.write(tempFile, savedBaseline) val loadedBaseline = format.read(tempFile) assertThat(loadedBaseline).isEqualTo(savedBaseline) diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineResultMappingSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineResultMappingSpec.kt index 6d5698045d0..f70276934c3 100644 --- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineResultMappingSpec.kt +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/baseline/BaselineResultMappingSpec.kt @@ -55,7 +55,7 @@ class BaselineResultMappingSpec { @Test fun `should not update an existing baseline file if option configured as false`() { - val existing = Baseline.load(existingBaselineFile) + val existing = DefaultBaseline.load(existingBaselineFile) val mapping = resultMapping( baselineFile = existingBaselineFile, createBaseline = false, @@ -63,13 +63,13 @@ class BaselineResultMappingSpec { mapping.transformFindings(findings) - val changed = Baseline.load(existingBaselineFile) + val changed = DefaultBaseline.load(existingBaselineFile) assertThat(existing).isEqualTo(changed) } @Test fun `should not update an existing baseline file if option is not configured`() { - val existing = Baseline.load(existingBaselineFile) + val existing = DefaultBaseline.load(existingBaselineFile) val mapping = resultMapping( baselineFile = existingBaselineFile, createBaseline = null, @@ -77,7 +77,7 @@ class BaselineResultMappingSpec { mapping.transformFindings(findings) - val changed = Baseline.load(existingBaselineFile) + val changed = DefaultBaseline.load(existingBaselineFile) assertThat(existing).isEqualTo(changed) } @@ -108,7 +108,7 @@ class BaselineResultMappingSpec { @Test fun `should update an existing baseline file if a file is configured`() { Files.copy(existingBaselineFile, baselineFile) - val existing = Baseline.load(baselineFile) + val existing = DefaultBaseline.load(baselineFile) val mapping = resultMapping( baselineFile = baselineFile, createBaseline = true, @@ -116,7 +116,7 @@ class BaselineResultMappingSpec { mapping.transformFindings(findings) - val changed = Baseline.load(baselineFile) + val changed = DefaultBaseline.load(baselineFile) assertThat(existing).isNotEqualTo(changed) } } diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/DefaultConfigValidationSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/DefaultConfigValidationSpec.kt deleted file mode 100644 index c18e954802f..00000000000 --- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/DefaultConfigValidationSpec.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.gitlab.arturbosch.detekt.core.config - -import io.gitlab.arturbosch.detekt.test.yamlConfig -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class DefaultConfigValidationSpec { - - private val baseline = yamlConfig("default-detekt-config.yml") - - @Test - fun `is valid comparing itself`() { - assertThat(validateConfig(baseline, baseline)).isEmpty() - } - - @Test - fun `does not flag common known config sub sections`() { - assertThat(validateConfig(yamlConfig("common_known_sections.yml"), baseline)).isEmpty() - } -} diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/AbstractYamlConfigValidatorSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/AbstractYamlConfigValidatorSpec.kt new file mode 100644 index 00000000000..641293a6c69 --- /dev/null +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/AbstractYamlConfigValidatorSpec.kt @@ -0,0 +1,49 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.core.config.YamlConfig +import io.gitlab.arturbosch.detekt.test.yamlConfigFromContent +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource + +internal class AbstractYamlConfigValidatorSpec { + + @Test + fun `use default validation settings`() { + val validator = SettingsCapturingValidatorAbstract() + val config = yamlConfigFromContent("") + + validator.validate(config) + + assertThat(validator.validationSettings.checkExhaustiveness).isFalse() + } + + @ParameterizedTest + @ValueSource(booleans = [true, false]) + fun `extract checkExhaustiveness settings from config`(configValue: Boolean) { + val config = yamlConfigFromContent( + """ + config: + checkExhaustiveness: $configValue + """.trimIndent() + ) + val validator = SettingsCapturingValidatorAbstract() + + validator.validate(config) + + assertThat(validator.validationSettings.checkExhaustiveness).isEqualTo(configValue) + } + + private class SettingsCapturingValidatorAbstract : AbstractYamlConfigValidator() { + lateinit var validationSettings: ValidationSettings + override fun validate( + configToValidate: YamlConfig, + settings: ValidationSettings + ): Collection { + validationSettings = settings + return emptyList() + } + } +} diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/CheckConfigurationSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/CheckConfigurationSpec.kt similarity index 95% rename from detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/CheckConfigurationSpec.kt rename to detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/CheckConfigurationSpec.kt index 9a0d468063c..43ba281b6ef 100644 --- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/CheckConfigurationSpec.kt +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/CheckConfigurationSpec.kt @@ -1,4 +1,4 @@ -package io.gitlab.arturbosch.detekt.core.config +package io.gitlab.arturbosch.detekt.core.config.validation import io.github.detekt.test.utils.createTempDirectoryForTest import io.github.detekt.tooling.api.InvalidConfig @@ -15,7 +15,7 @@ import io.gitlab.arturbosch.detekt.test.yamlConfigFromContent import org.assertj.core.api.Assertions.assertThatCode import org.junit.jupiter.api.Test -class SupportConfigValidationSpec { +class CheckConfigurationSpec { private val testDir = createTempDirectoryForTest("detekt-sample") private val spec = createNullLoggingSpec {} @@ -26,7 +26,7 @@ class SupportConfigValidationSpec { """ unknown_property: unknown_var: "" - """ + """.trimIndent() ) createProcessingSettings( testDir, @@ -55,7 +55,7 @@ class SupportConfigValidationSpec { my_additional_properties: magic_number: 7 magic_string: 'Hello World' - """ + """.trimIndent() ) createProcessingSettings(testDir, config).use { assertThatCode { checkConfiguration(it, spec.getDefaultConfiguration()) } @@ -74,7 +74,7 @@ class SupportConfigValidationSpec { TooManyFunctions: # This property is tested via the SampleConfigValidator active: 1 # should be true - """ + """.trimIndent() ) createProcessingSettings(testDir, config).use { assertThatCode { checkConfiguration(it, spec.getDefaultConfiguration()) } @@ -104,7 +104,7 @@ class SupportConfigValidationSpec { my_additional_properties: magic_number: 7 magic_string: 'Hello World' - """ + """.trimIndent() ) createProcessingSettings(testDir, config).use { assertThatCode { checkConfiguration(it, spec.getDefaultConfiguration()) } diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DefaultConfigValidationSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DefaultConfigValidationSpec.kt new file mode 100644 index 00000000000..2a9b3b5f775 --- /dev/null +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DefaultConfigValidationSpec.kt @@ -0,0 +1,24 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.gitlab.arturbosch.detekt.api.internal.CommaSeparatedPattern +import io.gitlab.arturbosch.detekt.test.yamlConfig +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class DefaultConfigValidationSpec { + + private val baseline = yamlConfig("default-detekt-config.yml") + private val defaultExcludePatterns = CommaSeparatedPattern(DEFAULT_PROPERTY_EXCLUDES).mapToRegex() + + @Test + fun `is valid comparing itself`() { + val actual = validateConfig(baseline, baseline, defaultExcludePatterns) + assertThat(actual).isEmpty() + } + + @Test + fun `does not flag common known config sub sections`() { + val actual = validateConfig(yamlConfig("common_known_sections.yml"), baseline, defaultExcludePatterns) + assertThat(actual).isEmpty() + } +} diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DeprecatedPropertiesConfigValidatorSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DeprecatedPropertiesConfigValidatorSpec.kt new file mode 100644 index 00000000000..6dd5ff709ff --- /dev/null +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/DeprecatedPropertiesConfigValidatorSpec.kt @@ -0,0 +1,36 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.core.config.YamlConfig +import io.gitlab.arturbosch.detekt.test.yamlConfigFromContent +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeprecatedPropertiesConfigValidatorSpec { + private val deprecatedProperties = + mapOf("naming>FunctionParameterNaming>ignoreOverriddenFunctions" to "Use `ignoreOverridden` instead") + + private val subject = DeprecatedPropertiesConfigValidator(deprecatedProperties) + + @Test + fun `reports a deprecated property as a warning`() { + val settings = ValidationSettings() + val config = yamlConfigFromContent( + """ + naming: + FunctionParameterNaming: + ignoreOverriddenFunctions: '' + """.trimIndent() + ) as YamlConfig + + val result = subject.validate(config, settings) + + assertThat(result).anySatisfy { notification -> + assertThat(notification.level) + .isEqualTo(Notification.Level.Warning) + assertThat(notification.message) + .contains("naming>FunctionParameterNaming>ignoreOverriddenFunctions") + .contains("Use `ignoreOverridden` instead") + } + } +} diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/ValidateConfigSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/InvalidPropertiesConfigValidatorSpec.kt similarity index 52% rename from detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/ValidateConfigSpec.kt rename to detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/InvalidPropertiesConfigValidatorSpec.kt index 6d88958c699..93617c8f048 100644 --- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/ValidateConfigSpec.kt +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/InvalidPropertiesConfigValidatorSpec.kt @@ -1,53 +1,48 @@ -package io.gitlab.arturbosch.detekt.core.config +package io.gitlab.arturbosch.detekt.core.config.validation import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.Notification import io.gitlab.arturbosch.detekt.api.internal.CommaSeparatedPattern -import io.gitlab.arturbosch.detekt.test.TestConfig +import io.gitlab.arturbosch.detekt.core.config.CompositeConfig +import io.gitlab.arturbosch.detekt.core.config.YamlConfig +import io.gitlab.arturbosch.detekt.core.config.validation.InvalidPropertiesConfigValidator.Companion.nestedConfigurationExpected +import io.gitlab.arturbosch.detekt.core.config.validation.InvalidPropertiesConfigValidator.Companion.propertyDoesNotExists +import io.gitlab.arturbosch.detekt.core.config.validation.InvalidPropertiesConfigValidator.Companion.unexpectedNestedConfiguration import io.gitlab.arturbosch.detekt.test.yamlConfig import io.gitlab.arturbosch.detekt.test.yamlConfigFromContent import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatIllegalArgumentException -import org.assertj.core.api.Assertions.assertThatIllegalStateException import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.ValueSource -class ValidateConfigSpec { - - private val baseline = yamlConfig("config_validation/baseline.yml") +internal class InvalidPropertiesConfigValidatorSpec { + private val deprecatedProperties = setOf("complexity>LongParameterList>threshold") + private val baseline = yamlConfig("config_validation/baseline.yml") as YamlConfig + private val defaultExcludePatterns = CommaSeparatedPattern(DEFAULT_PROPERTY_EXCLUDES).mapToRegex() + private val subject = InvalidPropertiesConfigValidator(baseline, deprecatedProperties, defaultExcludePatterns) @Test fun `passes for same config test`() { - val result = validateConfig(baseline, baseline) + val result = subject.validate(baseline) assertThat(result).isEmpty() } @Test fun `passes for properties which may appear on rules and rule sets but may be not present in default config`() { - val result = validateConfig( - yamlConfig("config_validation/default-excluded-properties.yml"), - baseline - ) + val result = subject.validate(yamlConfig("config_validation/default-excluded-properties.yml")) assertThat(result).isEmpty() } @Test fun `reports different rule set name`() { - val result = validateConfig( - yamlConfig("config_validation/other-ruleset-name.yml"), - baseline - ) + val result = subject.validate(yamlConfig("config_validation/other-ruleset-name.yml")) assertThat(result).contains(propertyDoesNotExists("code-smell")) } @Test fun `reports different nested property names`() { - val result = validateConfig( - yamlConfig("config_validation/other-nested-property-names.yml"), - baseline - ) + val result = subject.validate(yamlConfig("config_validation/other-nested-property-names.yml")) + assertThat(result).contains( propertyDoesNotExists("complexity>LongLongMethod"), propertyDoesNotExists("complexity>LongParameterList>enabled"), @@ -59,10 +54,7 @@ class ValidateConfigSpec { @Test fun `reports nested configuration expected`() { - val result = validateConfig( - yamlConfig("config_validation/no-nested-config.yml"), - baseline - ) + val result = subject.validate(yamlConfig("config_validation/no-nested-config.yml")) assertThat(result).contains( nestedConfigurationExpected("complexity"), nestedConfigurationExpected("style>WildcardImport") @@ -71,8 +63,14 @@ class ValidateConfigSpec { @Test fun `reports unexpected nested configs`() { - // note that the baseline config is now the first argument - val result = validateConfig(baseline, yamlConfig("config_validation/no-value.yml")) + // note that the baseline config is now the config to validate + val subject = + InvalidPropertiesConfigValidator( + yamlConfig("config_validation/no-value.yml") as YamlConfig, + deprecatedProperties, + defaultExcludePatterns + ) + val result = subject.validate(baseline) assertThat(result).contains( unexpectedNestedConfiguration("style"), unexpectedNestedConfiguration("comments") @@ -80,27 +78,29 @@ class ValidateConfigSpec { } @Test - fun `returns an error for an invalid config type`() { - val invalidConfig = TestConfig() - assertThatIllegalStateException().isThrownBy { - validateConfig(invalidConfig, baseline) - }.withMessageStartingWith("Unsupported config type for validation") + fun `does not report missing property when it is deprecated`() { + val result = subject.validate(yamlConfig("config_validation/deprecated-properties.yml")) + assertThat(result).isEmpty() } @Test - fun `returns an error for an invalid baseline`() { - val invalidBaseline = TestConfig() - assertThatIllegalArgumentException().isThrownBy { - validateConfig(Config.empty, invalidBaseline) - }.withMessageStartingWith("Only supported baseline config is the YamlConfig.") - } + fun `reports a string that should be an array as a warning`() { + val config = yamlConfigFromContent( + """ + style: + MagicNumber: + ignoreNumbers: '-1,0,1,2' + """.trimIndent() + ) - @Test - fun `returns an error for an empty baseline`() { - val invalidBaseline = Config.empty - assertThatIllegalArgumentException().isThrownBy { - validateConfig(Config.empty, invalidBaseline) - }.withMessageStartingWith("Cannot validate configuration based on an empty baseline config.") + val result = subject.validate(config) + + assertThat(result).anySatisfy { notification -> + assertThat(notification.message) + .contains("style>MagicNumber>ignoreNumbers") + .contains("should be a YAML array instead of a comma-separated String") + assertThat(notification.level).isEqualTo(Notification.Level.Warning) + } } @Nested @@ -108,25 +108,22 @@ class ValidateConfigSpec { @Test fun `passes for same left, right and baseline config`() { - val result = validateConfig(CompositeConfig(baseline, baseline), baseline) + val result = CompositeConfig(baseline, baseline).validate(baseline, emptySet()) assertThat(result).isEmpty() } @Test fun `passes for empty configs`() { - val result = validateConfig(CompositeConfig(Config.empty, Config.empty), baseline) + val result = CompositeConfig(Config.empty, Config.empty).validate(baseline, emptySet()) assertThat(result).isEmpty() } @Test fun `finds accumulated errors`() { - val result = validateConfig( - CompositeConfig( - yamlConfig("config_validation/other-nested-property-names.yml"), - yamlConfig("config_validation/no-nested-config.yml") - ), - baseline - ) + val result = CompositeConfig( + yamlConfig("config_validation/other-nested-property-names.yml"), + yamlConfig("config_validation/no-nested-config.yml") + ).validate(baseline, emptySet()) assertThat(result).contains( nestedConfigurationExpected("complexity"), @@ -147,20 +144,19 @@ class ValidateConfigSpec { @Test fun `does not report any complexity properties`() { - val result = validateConfig( - yamlConfig("config_validation/other-nested-property-names.yml"), - baseline, - patterns("complexity") + val subject = InvalidPropertiesConfigValidator(baseline, deprecatedProperties, patterns("complexity")) + + val result = subject.validate( + yamlConfig("config_validation/other-nested-property-names.yml") as YamlConfig, ) assertThat(result).isEmpty() } @Test fun `does not report 'complexity_LargeClass_howMany'`() { - val result = validateConfig( - yamlConfig("config_validation/other-nested-property-names.yml"), - baseline, - patterns(".*>.*>howMany") + val subject = InvalidPropertiesConfigValidator(baseline, deprecatedProperties, patterns(".*>.*>howMany")) + val result = subject.validate( + yamlConfig("config_validation/other-nested-property-names.yml") as YamlConfig ) assertThat(result).contains( @@ -178,10 +174,9 @@ class ValidateConfigSpec { @Test @DisplayName("does not report .*>InnerMap") fun `does not report innerMap`() { - val result = validateConfig( - yamlConfig("config_validation/other-nested-property-names.yml"), - baseline, - patterns(".*>InnerMap") + val subject = InvalidPropertiesConfigValidator(baseline, deprecatedProperties, patterns(".*>InnerMap")) + val result = subject.validate( + yamlConfig("config_validation/other-nested-property-names.yml") as YamlConfig ) assertThat(result).contains( @@ -196,55 +191,4 @@ class ValidateConfigSpec { ) } } - - @Nested - inner class `deprecated configuration option` { - - @ParameterizedTest - @ValueSource(booleans = [true, false]) - fun `reports a deprecated property as a warning`(warningsAsErrors: Boolean) { - val config = yamlConfigFromContent( - """ - config: - warningsAsErrors: $warningsAsErrors - naming: - FunctionParameterNaming: - ignoreOverriddenFunctions: '' - """.trimIndent() - ) - - val result = validateConfig(config, config) - - assertThat(result).contains( - propertyIsDeprecated( - "naming>FunctionParameterNaming>ignoreOverriddenFunctions", - "Use `ignoreOverridden` instead", - reportAsError = warningsAsErrors - ) - ) - } - } - - @ParameterizedTest - @ValueSource(booleans = [true, false]) - fun `reports a string that should be an array as a warning`(warningsAsErrors: Boolean) { - val config = yamlConfigFromContent( - """ - config: - warningsAsErrors: $warningsAsErrors - style: - MagicNumber: - ignoreNumbers: '-1,0,1,2' - """.trimIndent() - ) - - val result = validateConfig(config, baseline) - - assertThat(result).contains( - propertyShouldBeAnArray( - "style>MagicNumber>ignoreNumbers", - reportAsError = warningsAsErrors - ) - ) - } } diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/MissingRulesConfigValidatorSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/MissingRulesConfigValidatorSpec.kt new file mode 100644 index 00000000000..9b862d83f92 --- /dev/null +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/MissingRulesConfigValidatorSpec.kt @@ -0,0 +1,48 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.gitlab.arturbosch.detekt.api.internal.CommaSeparatedPattern +import io.gitlab.arturbosch.detekt.core.config.YamlConfig +import io.gitlab.arturbosch.detekt.test.yamlConfig +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MissingRulesConfigValidatorSpec { + private val baseline = yamlConfig("config_validation/baseline.yml") as YamlConfig + private val subject = MissingRulesConfigValidator( + baseline, + CommaSeparatedPattern(DEFAULT_PROPERTY_EXCLUDES).mapToRegex() + ) + + @Test + fun `do not check for exhaustiveness if disabled by config`() { + val config = yamlConfig("config_validation/exhaustiveness-check-disabled.yml") + + val result = subject.validate(config) + + assertThat(result).isEmpty() + } + + @Test + fun `do not report violations if all rules are mentioned or rule set is disabled`() { + val config = yamlConfig("config_validation/exhaustiveness-check-successful.yml") + + val result = subject.validate(config) + + assertThat(result).isEmpty() + } + + @Test + fun `report violations of missing rules and rule sets`() { + val config = yamlConfig("config_validation/exhaustiveness-check-with-error.yml") + + val result = subject.validate(config) + + assertThat(result) + .extracting("message") + .containsExactlyInAnyOrder( + "Rule set 'comments' is missing in the configuration.", + "Rule 'LongMethod' from the 'complexity' rule set is missing in the configuration.", + "Rule 'WildcardImport' from the 'style' rule set is missing in the configuration.", + ) + } +} diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ValidateConfigSpec.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ValidateConfigSpec.kt new file mode 100644 index 00000000000..91b4cd7c64c --- /dev/null +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ValidateConfigSpec.kt @@ -0,0 +1,63 @@ +package io.gitlab.arturbosch.detekt.core.config.validation + +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.Notification +import io.gitlab.arturbosch.detekt.test.TestConfig +import io.gitlab.arturbosch.detekt.test.yamlConfig +import io.gitlab.arturbosch.detekt.test.yamlConfigFromContent +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatIllegalArgumentException +import org.assertj.core.api.Assertions.assertThatIllegalStateException +import org.junit.jupiter.api.Test +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource + +internal class ValidateConfigSpec { + private val baseline = yamlConfig("config_validation/baseline.yml") + + @Test + fun `returns an error for an invalid config type`() { + val invalidConfig = TestConfig() + assertThatIllegalStateException().isThrownBy { + validateConfig(invalidConfig, baseline, emptySet()) + }.withMessageStartingWith("Unsupported config type for validation") + } + + @Test + fun `returns an error for an invalid baseline`() { + val invalidBaseline = TestConfig() + assertThatIllegalArgumentException().isThrownBy { + validateConfig(Config.empty, invalidBaseline, emptySet()) + }.withMessageStartingWith("Only supported baseline config is the YamlConfig.") + } + + @Test + fun `returns an error for an empty baseline`() { + val invalidBaseline = Config.empty + assertThatIllegalArgumentException().isThrownBy { + validateConfig(Config.empty, invalidBaseline, emptySet()) + }.withMessageStartingWith("Cannot validate configuration based on an empty baseline config.") + } + + @ParameterizedTest + @ValueSource(booleans = [true, false]) + fun `converts warnings to error if config is set up this way`(warningsAsErrors: Boolean) { + val config = yamlConfigFromContent( + """ + config: + warningsAsErrors: $warningsAsErrors + style: + MagicNumber: + ignoreNumbers: '-1,0,1,2' + """.trimIndent() + ) + + val result = validateConfig(config, baseline, emptySet()) + + val expectedLevel = if (warningsAsErrors) Notification.Level.Error else Notification.Level.Warning + assertThat(result).anySatisfy { notification -> + assertThat(notification.message).contains("style>MagicNumber") + assertThat(notification.level).isEqualTo(expectedLevel) + } + } +} diff --git a/detekt-core/src/test/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.ConfigValidator b/detekt-core/src/test/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.ConfigValidator index 67f0618954f..4b8243351cd 100644 --- a/detekt-core/src/test/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.ConfigValidator +++ b/detekt-core/src/test/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.ConfigValidator @@ -1 +1 @@ -io.gitlab.arturbosch.detekt.core.config.SampleConfigValidator +io.gitlab.arturbosch.detekt.core.config.validation.SampleConfigValidator diff --git a/detekt-core/src/test/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider b/detekt-core/src/test/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider index 02f24d5b65e..5767e4ad01f 100644 --- a/detekt-core/src/test/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider +++ b/detekt-core/src/test/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider @@ -1,3 +1,3 @@ io.gitlab.arturbosch.detekt.core.TestProvider io.gitlab.arturbosch.detekt.core.TestProvider2 -io.gitlab.arturbosch.detekt.core.config.SampleRuleProvider +io.gitlab.arturbosch.detekt.core.config.validation.SampleRuleProvider diff --git a/detekt-core/src/test/resources/config_validation/baseline.yml b/detekt-core/src/test/resources/config_validation/baseline.yml index dc814e5a41a..47e16f0e037 100644 --- a/detekt-core/src/test/resources/config_validation/baseline.yml +++ b/detekt-core/src/test/resources/config_validation/baseline.yml @@ -1,5 +1,15 @@ +build: + maxIssues: 1 config: warningsAsErrors: true + checkExhaustiveness: false +processors: + active: true +console-reports: + active: true +output-reports: + active: true + complexity: LongMethod: active: true @@ -17,6 +27,7 @@ complexity: active: true style: + active: true WildcardImport: active: true NoElseInWhenExpression: @@ -26,4 +37,5 @@ style: ignoreNumbers: ['-1', '0', '1', '2'] comments: - active: false + CommentOverPrivateProperty: + active: false diff --git a/detekt-core/src/test/resources/config_validation/deprecated-properties.yml b/detekt-core/src/test/resources/config_validation/deprecated-properties.yml new file mode 100644 index 00000000000..acd2cfcd348 --- /dev/null +++ b/detekt-core/src/test/resources/config_validation/deprecated-properties.yml @@ -0,0 +1,3 @@ +complexity: + LongParameterList: + threshold: 5 diff --git a/detekt-core/src/test/resources/config_validation/exhaustiveness-check-disabled.yml b/detekt-core/src/test/resources/config_validation/exhaustiveness-check-disabled.yml new file mode 100644 index 00000000000..cd71203b0a0 --- /dev/null +++ b/detekt-core/src/test/resources/config_validation/exhaustiveness-check-disabled.yml @@ -0,0 +1,6 @@ +config: + checkExhaustiveness: false + +complexity: +style: +comments: diff --git a/detekt-core/src/test/resources/config_validation/exhaustiveness-check-successful.yml b/detekt-core/src/test/resources/config_validation/exhaustiveness-check-successful.yml new file mode 100644 index 00000000000..bad46ef78fa --- /dev/null +++ b/detekt-core/src/test/resources/config_validation/exhaustiveness-check-successful.yml @@ -0,0 +1,17 @@ +config: + checkExhaustiveness: true + +complexity: + active: false + +style: + WildcardImport: + active: true + NoElseInWhenExpression: + active: true + MagicNumber: + active: true + +comments: + CommentOverPrivateProperty: + active: false diff --git a/detekt-core/src/test/resources/config_validation/exhaustiveness-check-with-error.yml b/detekt-core/src/test/resources/config_validation/exhaustiveness-check-with-error.yml new file mode 100644 index 00000000000..2088d0ee472 --- /dev/null +++ b/detekt-core/src/test/resources/config_validation/exhaustiveness-check-with-error.yml @@ -0,0 +1,21 @@ +config: + checkExhaustiveness: true + +complexity: + LongParameterList: + active: false + LargeClass: + active: false + InnerMap: + Inner1: + active: true + Inner2: + active: true + +style: + NoElseInWhenExpression: + active: true + MagicNumber: + active: true + +comments: diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/KtLintMultiRule.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/KtLintMultiRule.kt index c9dbcaebd32..b003a594357 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/KtLintMultiRule.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/KtLintMultiRule.kt @@ -14,6 +14,9 @@ import io.gitlab.arturbosch.detekt.formatting.wrappers.EnumEntryNameCase import io.gitlab.arturbosch.detekt.formatting.wrappers.Filename import io.gitlab.arturbosch.detekt.formatting.wrappers.FinalNewline import io.gitlab.arturbosch.detekt.formatting.wrappers.FunKeywordSpacing +import io.gitlab.arturbosch.detekt.formatting.wrappers.FunctionReturnTypeSpacing +import io.gitlab.arturbosch.detekt.formatting.wrappers.FunctionSignature +import io.gitlab.arturbosch.detekt.formatting.wrappers.FunctionStartOfBodySpacing import io.gitlab.arturbosch.detekt.formatting.wrappers.FunctionTypeReferenceSpacing import io.gitlab.arturbosch.detekt.formatting.wrappers.ImportOrdering import io.gitlab.arturbosch.detekt.formatting.wrappers.Indentation @@ -35,7 +38,9 @@ import io.gitlab.arturbosch.detekt.formatting.wrappers.NoTrailingSpaces import io.gitlab.arturbosch.detekt.formatting.wrappers.NoUnitReturn import io.gitlab.arturbosch.detekt.formatting.wrappers.NoUnusedImports import io.gitlab.arturbosch.detekt.formatting.wrappers.NoWildcardImports +import io.gitlab.arturbosch.detekt.formatting.wrappers.NullableTypeSpacing import io.gitlab.arturbosch.detekt.formatting.wrappers.PackageName +import io.gitlab.arturbosch.detekt.formatting.wrappers.ParameterListSpacing import io.gitlab.arturbosch.detekt.formatting.wrappers.ParameterListWrapping import io.gitlab.arturbosch.detekt.formatting.wrappers.SpacingAroundAngleBrackets import io.gitlab.arturbosch.detekt.formatting.wrappers.SpacingAroundColon @@ -50,9 +55,11 @@ import io.gitlab.arturbosch.detekt.formatting.wrappers.SpacingAroundRangeOperato import io.gitlab.arturbosch.detekt.formatting.wrappers.SpacingAroundUnaryOperator import io.gitlab.arturbosch.detekt.formatting.wrappers.SpacingBetweenDeclarationsWithAnnotations import io.gitlab.arturbosch.detekt.formatting.wrappers.SpacingBetweenDeclarationsWithComments +import io.gitlab.arturbosch.detekt.formatting.wrappers.SpacingBetweenFunctionNameAndOpeningParenthesis import io.gitlab.arturbosch.detekt.formatting.wrappers.StringTemplate import io.gitlab.arturbosch.detekt.formatting.wrappers.TrailingComma import io.gitlab.arturbosch.detekt.formatting.wrappers.TypeArgumentListSpacing +import io.gitlab.arturbosch.detekt.formatting.wrappers.TypeParameterListSpacing import io.gitlab.arturbosch.detekt.formatting.wrappers.UnnecessaryParenthesesBeforeTrailingLambda import io.gitlab.arturbosch.detekt.formatting.wrappers.Wrapping import org.jetbrains.kotlin.com.intellij.lang.ASTNode @@ -70,18 +77,24 @@ class KtLintMultiRule(config: Config = Config.empty) : override val rules: List = listOf( // Wrappers for ktlint-ruleset-standard rules. Enabled by default. + AnnotationOnSeparateLine(config), + AnnotationSpacing(config), + ArgumentListWrapping(config), ChainWrapping(config), CommentSpacing(config), + EnumEntryNameCase(config), Filename(config), FinalNewline(config), ImportOrdering(config), Indentation(config), MaximumLineLength(config), ModifierOrdering(config), + MultiLineIfElse(config), NoBlankLineBeforeRbrace(config), NoBlankLinesInChainedMethodCalls(config), NoConsecutiveBlankLines(config), NoEmptyClassBody(config), + NoEmptyFirstLineInMethodBlock(config), NoLineBreakAfterElse(config), NoLineBreakBeforeAssignment(config), NoMultipleSpaces(config), @@ -90,40 +103,41 @@ class KtLintMultiRule(config: Config = Config.empty) : NoUnitReturn(config), NoUnusedImports(config), NoWildcardImports(config), + PackageName(config), ParameterListWrapping(config), + SpacingAroundAngleBrackets(config), SpacingAroundColon(config), SpacingAroundComma(config), SpacingAroundCurly(config), SpacingAroundDot(config), + SpacingAroundDoubleColon(config), SpacingAroundKeyword(config), SpacingAroundOperators(config), SpacingAroundParens(config), SpacingAroundRangeOperator(config), + SpacingAroundUnaryOperator(config), + SpacingBetweenDeclarationsWithAnnotations(config), + SpacingBetweenDeclarationsWithComments(config), StringTemplate(config), + TrailingComma(config), // in standard ruleset but not enabled by default Wrapping(config), // Wrappers for ktlint-ruleset-experimental rules. Disabled by default. - AnnotationOnSeparateLine(config), - AnnotationSpacing(config), - ArgumentListWrapping(config), BlockCommentInitialStarAlignment(config), CommentWrapping(config), DiscouragedCommentLocation(config), - EnumEntryNameCase(config), - FunctionTypeReferenceSpacing(config), + FunctionReturnTypeSpacing(config), FunKeywordSpacing(config), + FunctionSignature(config), + FunctionStartOfBodySpacing(config), + FunctionTypeReferenceSpacing(config), KdocWrapping(config), ModifierListSpacing(config), - MultiLineIfElse(config), - NoEmptyFirstLineInMethodBlock(config), - PackageName(config), - SpacingAroundAngleBrackets(config), - SpacingAroundDoubleColon(config), - SpacingAroundUnaryOperator(config), - SpacingBetweenDeclarationsWithAnnotations(config), - SpacingBetweenDeclarationsWithComments(config), - TrailingComma(config), + NullableTypeSpacing(config), + ParameterListSpacing(config), + SpacingBetweenFunctionNameAndOpeningParenthesis(config), TypeArgumentListSpacing(config), + TypeParameterListSpacing(config), UnnecessaryParenthesesBeforeTrailingLambda(config), ) diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/AnnotationOnSeparateLine.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/AnnotationOnSeparateLine.kt index afe438a8317..adbac2a31b9 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/AnnotationOnSeparateLine.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/AnnotationOnSeparateLine.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#annotation-formatting) for documentation. */ @AutoCorrectable(since = "1.0.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/AnnotationSpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/AnnotationSpacing.kt index f2ef0f61188..1206beba60a 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/AnnotationSpacing.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/AnnotationSpacing.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#annotation-spacing) for documentation. */ @AutoCorrectable(since = "1.0.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ArgumentListWrapping.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ArgumentListWrapping.kt index ac35986edb7..758f87542a7 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ArgumentListWrapping.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ArgumentListWrapping.kt @@ -12,7 +12,7 @@ import io.gitlab.arturbosch.detekt.api.internal.Configuration import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#argument-list-wrapping) for documentation. */ @AutoCorrectable(since = "1.0.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/BlockCommentInitialStarAlignment.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/BlockCommentInitialStarAlignment.kt index b2ff7280b4b..4fb272317c3 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/BlockCommentInitialStarAlignment.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/BlockCommentInitialStarAlignment.kt @@ -6,7 +6,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#experimental-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#block-comment-initial-star-alignment) for + * documentation. */ @AutoCorrectable(since = "1.20.0") class BlockCommentInitialStarAlignment(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ChainWrapping.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ChainWrapping.kt index 969c11f29f3..49ba95f05aa 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ChainWrapping.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ChainWrapping.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#chain-wrapping) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/CommentSpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/CommentSpacing.kt index 01ccfae5441..ba9d18cee34 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/CommentSpacing.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/CommentSpacing.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#comment-spacing) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/CommentWrapping.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/CommentWrapping.kt index 923ba37cc35..3be8bb186b2 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/CommentWrapping.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/CommentWrapping.kt @@ -10,7 +10,7 @@ import io.gitlab.arturbosch.detekt.api.internal.Configuration import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#experimental-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#comment-wrapping) for documentation. */ @AutoCorrectable(since = "1.20.0") class CommentWrapping(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/DiscouragedCommentLocation.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/DiscouragedCommentLocation.kt index 53c19cb15fb..305fa64156f 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/DiscouragedCommentLocation.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/DiscouragedCommentLocation.kt @@ -6,7 +6,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#experimental-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#discouraged-comment-location) for + * documentation. */ @AutoCorrectable(since = "1.20.0") class DiscouragedCommentLocation(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/EnumEntryNameCase.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/EnumEntryNameCase.kt index 5338c219fa6..5a17c111741 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/EnumEntryNameCase.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/EnumEntryNameCase.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#enum-entry) for documentation. */ @AutoCorrectable(since = "1.4.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Filename.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Filename.kt index 1ef732390d4..aa8dede5439 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Filename.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Filename.kt @@ -6,7 +6,7 @@ import io.gitlab.arturbosch.detekt.api.internal.ActiveByDefault import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#file-name) for documentation. * * This rules overlaps with [naming>MatchingDeclarationName](https://detekt.dev/naming.html#matchingdeclarationname) * from the standard rules, make sure to enable just one. diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FinalNewline.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FinalNewline.kt index 810f0f1d7fa..9b2990a1be2 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FinalNewline.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FinalNewline.kt @@ -11,7 +11,7 @@ import io.gitlab.arturbosch.detekt.api.internal.Configuration import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#final-newline) for documentation. * * This rules overlaps with [style>NewLineAtEndOfFile](https://detekt.dev/style.html#newlineatendoffile) * from the standard rules, make sure to enable just one. The pro of this rule is that it can auto-correct the issue. diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunKeywordSpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunKeywordSpacing.kt index 81f4e1213a4..1c512e2b66f 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunKeywordSpacing.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunKeywordSpacing.kt @@ -6,7 +6,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#experimental-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#fun-keyword-spacing) for documentation. */ @AutoCorrectable(since = "1.20.0") class FunKeywordSpacing(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionReturnTypeSpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionReturnTypeSpacing.kt new file mode 100644 index 00000000000..0f85c9efd94 --- /dev/null +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionReturnTypeSpacing.kt @@ -0,0 +1,17 @@ +package io.gitlab.arturbosch.detekt.formatting.wrappers + +import com.pinterest.ktlint.ruleset.experimental.FunctionReturnTypeSpacingRule +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable +import io.gitlab.arturbosch.detekt.formatting.FormattingRule + +/** + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#function-return-type-spacing) for + * documentation. + */ +@AutoCorrectable(since = "1.22.0") +class FunctionReturnTypeSpacing(config: Config) : FormattingRule(config) { + + override val wrapping = FunctionReturnTypeSpacingRule() + override val issue = issueFor("Checks the spacing between colon and return type.") +} diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionSignature.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionSignature.kt new file mode 100644 index 00000000000..5ce2ffc619c --- /dev/null +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionSignature.kt @@ -0,0 +1,43 @@ +package io.gitlab.arturbosch.detekt.formatting.wrappers + +import com.pinterest.ktlint.core.api.DefaultEditorConfigProperties +import com.pinterest.ktlint.core.api.UsesEditorConfigProperties +import com.pinterest.ktlint.ruleset.experimental.FunctionSignatureRule +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.config +import io.gitlab.arturbosch.detekt.api.configWithAndroidVariants +import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable +import io.gitlab.arturbosch.detekt.api.internal.Configuration +import io.gitlab.arturbosch.detekt.formatting.FormattingRule + +/** + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#function-signature) for + * documentation. + */ +@AutoCorrectable(since = "1.22.0") +class FunctionSignature(config: Config) : FormattingRule(config) { + + override val wrapping = FunctionSignatureRule() + override val issue = issueFor("Format signature to be single when possible, multiple lines otherwise.") + + @Configuration("parameter count means multiline threshold") + private val forceMultilineWhenParameterCountGreaterOrEqualThan by config(2_147_483_647) + + @Configuration("indentation size") + private val functionBodyExpressionWrapping by config("default") + + @Configuration("maximum line length") + private val maxLineLength by configWithAndroidVariants(120, 100) + + @Configuration("indentation size") + private val indentSize by config(4) + + override fun overrideEditorConfigProperties(): Map, String> = + mapOf( + FunctionSignatureRule.forceMultilineWhenParameterCountGreaterOrEqualThanProperty to + forceMultilineWhenParameterCountGreaterOrEqualThan.toString(), + FunctionSignatureRule.functionBodyExpressionWrappingProperty to functionBodyExpressionWrapping, + DefaultEditorConfigProperties.maxLineLengthProperty to maxLineLength.toString(), + DefaultEditorConfigProperties.indentSizeProperty to indentSize.toString(), + ) +} diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionStartOfBodySpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionStartOfBodySpacing.kt new file mode 100644 index 00000000000..9aa3148c8e8 --- /dev/null +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionStartOfBodySpacing.kt @@ -0,0 +1,17 @@ +package io.gitlab.arturbosch.detekt.formatting.wrappers + +import com.pinterest.ktlint.ruleset.experimental.FunctionStartOfBodySpacingRule +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable +import io.gitlab.arturbosch.detekt.formatting.FormattingRule + +/** + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#function-start-of-body-spacing) for + * documentation. + */ +@AutoCorrectable(since = "1.22.0") +class FunctionStartOfBodySpacing(config: Config) : FormattingRule(config) { + + override val wrapping = FunctionStartOfBodySpacingRule() + override val issue = issueFor("Check for consistent spacing before start of function body.") +} diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionTypeReferenceSpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionTypeReferenceSpacing.kt index d5770b2cfee..4d73f6a8047 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionTypeReferenceSpacing.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/FunctionTypeReferenceSpacing.kt @@ -6,7 +6,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#experimental-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#function-type-reference-spacing) for + * documentation. */ @AutoCorrectable(since = "1.20.0") class FunctionTypeReferenceSpacing(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ImportOrdering.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ImportOrdering.kt index 845834bcada..a44fa4ddc86 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ImportOrdering.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ImportOrdering.kt @@ -10,7 +10,7 @@ import io.gitlab.arturbosch.detekt.api.internal.Configuration import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#import-ordering) for documentation. * * For defining import layout patterns see the [KtLint Source Code](https://github.com/pinterest/ktlint/blob/a6ca5b2edf95cc70a138a9470cfb6c4fd5d9d3ce/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/ImportOrderingRule.kt) */ diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Indentation.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Indentation.kt index c5c100c74c6..f943995d347 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Indentation.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Indentation.kt @@ -13,7 +13,7 @@ import io.gitlab.arturbosch.detekt.formatting.FormattingRule import org.jetbrains.kotlin.com.intellij.lang.ASTNode /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#indentation) for documentation. */ @ActiveByDefault(since = "1.19.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/KdocWrapping.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/KdocWrapping.kt index 1d104cafd1c..715b99abde4 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/KdocWrapping.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/KdocWrapping.kt @@ -10,7 +10,7 @@ import io.gitlab.arturbosch.detekt.api.internal.Configuration import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#experimental-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#kdoc-wrapping) for documentation. */ @AutoCorrectable(since = "1.20.0") class KdocWrapping(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/MaximumLineLength.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/MaximumLineLength.kt index f8274d04bf9..e0c1d67772e 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/MaximumLineLength.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/MaximumLineLength.kt @@ -11,7 +11,7 @@ import io.gitlab.arturbosch.detekt.api.internal.Configuration import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#max-line-length) for documentation. * * This rules overlaps with [style>MaxLineLength](https://detekt.dev/style.html#maxlinelength) * from the standard rules, make sure to enable just one or keep them aligned. The pro of this rule is that it can diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ModifierListSpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ModifierListSpacing.kt index 87acc9b0240..384d362bbd8 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ModifierListSpacing.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ModifierListSpacing.kt @@ -6,7 +6,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#experimental-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#modifier-list-spacing) for documentation. */ @AutoCorrectable(since = "1.20.0") class ModifierListSpacing(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ModifierOrdering.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ModifierOrdering.kt index 94ffe2316f1..9b34a37b699 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ModifierOrdering.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ModifierOrdering.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#modifier-order) for documentation. * * This rules overlaps with [style>ModifierOrder](https://detekt.dev/style.html#modifierorder) * from the standard rules, make sure to enable just one. The pro of this rule is that it can auto-correct the issue. diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/MultiLineIfElse.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/MultiLineIfElse.kt index 7fceed19463..5ba07996938 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/MultiLineIfElse.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/MultiLineIfElse.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#multiline-if-else) for documentation. */ @AutoCorrectable(since = "1.0.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoBlankLineBeforeRbrace.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoBlankLineBeforeRbrace.kt index 437ca8ab090..f3677835faf 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoBlankLineBeforeRbrace.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoBlankLineBeforeRbrace.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-blank-lines-before) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoBlankLinesInChainedMethodCalls.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoBlankLinesInChainedMethodCalls.kt index dfc35b0cc4e..bc8250daf07 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoBlankLinesInChainedMethodCalls.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoBlankLinesInChainedMethodCalls.kt @@ -7,7 +7,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-website](https://ktlint.github.io) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-blank-lines-in-chained-method-calls) for + * documentation. */ @ActiveByDefault(since = "1.22.0") @AutoCorrectable(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoConsecutiveBlankLines.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoConsecutiveBlankLines.kt index dd2479e1e42..58b52889e76 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoConsecutiveBlankLines.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoConsecutiveBlankLines.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-consecutive-blank-lines) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoEmptyClassBody.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoEmptyClassBody.kt index c379e6fc90d..c22c4261dd5 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoEmptyClassBody.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoEmptyClassBody.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-empty-class-bodies) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoEmptyFirstLineInMethodBlock.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoEmptyFirstLineInMethodBlock.kt index 61e1aa05ef6..1848dc6077a 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoEmptyFirstLineInMethodBlock.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoEmptyFirstLineInMethodBlock.kt @@ -7,7 +7,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-leading-empty-lines-in-method-blocks) for + * documentation. */ @AutoCorrectable(since = "1.4.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoLineBreakAfterElse.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoLineBreakAfterElse.kt index e5f3b6bd6bd..638c0ea2f61 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoLineBreakAfterElse.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoLineBreakAfterElse.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-line-break-after-else) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoLineBreakBeforeAssignment.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoLineBreakBeforeAssignment.kt index bfabbae64f3..1b6c09fee2e 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoLineBreakBeforeAssignment.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoLineBreakBeforeAssignment.kt @@ -7,7 +7,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-line-break-before-assignment) for + * documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoMultipleSpaces.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoMultipleSpaces.kt index d81fb568d01..9332ea075b1 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoMultipleSpaces.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoMultipleSpaces.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-multi-spaces) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoSemicolons.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoSemicolons.kt index d2f6413a8ee..0072d4d51b8 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoSemicolons.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoSemicolons.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-semicolons) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoTrailingSpaces.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoTrailingSpaces.kt index 76a5b2b0333..8037ab367b3 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoTrailingSpaces.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoTrailingSpaces.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-trailing-whitespaces) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoUnitReturn.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoUnitReturn.kt index b9313798dd6..7dfbe903d37 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoUnitReturn.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoUnitReturn.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-unit-as-return-type) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoUnusedImports.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoUnusedImports.kt index 9ce661acff1..b31e4da087d 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoUnusedImports.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoUnusedImports.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-unused-imports) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoWildcardImports.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoWildcardImports.kt index aea84fcdd37..3dc3a50deef 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoWildcardImports.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NoWildcardImports.kt @@ -9,7 +9,7 @@ import io.gitlab.arturbosch.detekt.api.internal.Configuration import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-wildcard-imports) for documentation. */ @ActiveByDefault(since = "1.0.0") class NoWildcardImports(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NullableTypeSpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NullableTypeSpacing.kt new file mode 100644 index 00000000000..0f213b76779 --- /dev/null +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/NullableTypeSpacing.kt @@ -0,0 +1,17 @@ +package io.gitlab.arturbosch.detekt.formatting.wrappers + +import com.pinterest.ktlint.ruleset.experimental.NullableTypeSpacingRule +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable +import io.gitlab.arturbosch.detekt.formatting.FormattingRule + +/** + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#nullable-type-spacing) for + * documentation. + */ +@AutoCorrectable(since = "1.22.0") +class NullableTypeSpacing(config: Config) : FormattingRule(config) { + + override val wrapping = NullableTypeSpacingRule() + override val issue = issueFor("Ensure no spaces in nullable type.") +} diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/PackageName.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/PackageName.kt index 7d99d34e390..a15d6d59418 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/PackageName.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/PackageName.kt @@ -7,7 +7,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#no-underscores-in-package-names) for + * documentation. */ @AutoCorrectable(since = "1.0.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ParameterListSpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ParameterListSpacing.kt new file mode 100644 index 00000000000..790729e23e9 --- /dev/null +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ParameterListSpacing.kt @@ -0,0 +1,17 @@ +package io.gitlab.arturbosch.detekt.formatting.wrappers + +import com.pinterest.ktlint.ruleset.experimental.ParameterListSpacingRule +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable +import io.gitlab.arturbosch.detekt.formatting.FormattingRule + +/** + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#parameter-list-spacing) for + * documentation. + */ +@AutoCorrectable(since = "1.22.0") +class ParameterListSpacing(config: Config) : FormattingRule(config) { + + override val wrapping = ParameterListSpacingRule() + override val issue = issueFor("Ensure consistent spacing inside the parameter list.") +} diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ParameterListWrapping.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ParameterListWrapping.kt index 6a360326a8f..8f315391ff9 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ParameterListWrapping.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/ParameterListWrapping.kt @@ -12,7 +12,7 @@ import io.gitlab.arturbosch.detekt.api.internal.Configuration import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#parameter-list-wrapping) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundAngleBrackets.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundAngleBrackets.kt index 67548b647c4..bae5366d5f3 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundAngleBrackets.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundAngleBrackets.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#angle-bracket-spacing) for documentation. */ @AutoCorrectable(since = "1.16.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundColon.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundColon.kt index ceb4bafd93e..19decf270e1 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundColon.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundColon.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#colon-spacing) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundComma.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundComma.kt index e3762286434..e221b43f045 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundComma.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundComma.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#comma-spacing) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundCurly.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundCurly.kt index 33c5e34f772..9bc9fad2126 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundCurly.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundCurly.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#curly-spacing) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundDot.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundDot.kt index faa9699b2e3..8559bb4f8cf 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundDot.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundDot.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#dot-spacing) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundDoubleColon.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundDoubleColon.kt index 87931efce23..253e79b0776 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundDoubleColon.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundDoubleColon.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#double-colon-spacing) for documentation. */ @AutoCorrectable(since = "1.10.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundKeyword.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundKeyword.kt index a0286fed8cb..a89755be178 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundKeyword.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundKeyword.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#keyword-spacing) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundOperators.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundOperators.kt index 7ac5bdb4f6e..a2df88da72b 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundOperators.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundOperators.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#operator-spacing) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundParens.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundParens.kt index 6a5633fad94..6cf121e5572 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundParens.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundParens.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#parenthesis-spacing) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundRangeOperator.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundRangeOperator.kt index ed09bfe87b8..f52f2b20c79 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundRangeOperator.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundRangeOperator.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#range-spacing) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundUnaryOperator.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundUnaryOperator.kt index 84d778004f8..718491ebd92 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundUnaryOperator.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingAroundUnaryOperator.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#unary-operator-spacing) for documentation. */ @AutoCorrectable(since = "1.16.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenDeclarationsWithAnnotations.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenDeclarationsWithAnnotations.kt index 5b3e0205b00..3de70ed9a96 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenDeclarationsWithAnnotations.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenDeclarationsWithAnnotations.kt @@ -7,7 +7,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#blank-line-between-declarations-with-annotations) + * for documentation. */ @AutoCorrectable(since = "1.10.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenDeclarationsWithComments.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenDeclarationsWithComments.kt index 8c1c72f68ef..8eff82529c7 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenDeclarationsWithComments.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenDeclarationsWithComments.kt @@ -7,7 +7,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#spacing) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#blank-line-between-declaration-with-comments) + * for documentation. */ @AutoCorrectable(since = "1.10.0") @ActiveByDefault(since = "1.22.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenFunctionNameAndOpeningParenthesis.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenFunctionNameAndOpeningParenthesis.kt new file mode 100644 index 00000000000..b4168bb5145 --- /dev/null +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/SpacingBetweenFunctionNameAndOpeningParenthesis.kt @@ -0,0 +1,17 @@ +package io.gitlab.arturbosch.detekt.formatting.wrappers + +import com.pinterest.ktlint.ruleset.experimental.SpacingBetweenFunctionNameAndOpeningParenthesisRule +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable +import io.gitlab.arturbosch.detekt.formatting.FormattingRule + +/** + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#spacing-between-function-name-and-opening-parenthesis) for + * documentation. + */ +@AutoCorrectable(since = "1.22.0") +class SpacingBetweenFunctionNameAndOpeningParenthesis(config: Config) : FormattingRule(config) { + + override val wrapping = SpacingBetweenFunctionNameAndOpeningParenthesisRule() + override val issue = issueFor("Ensure consistent spacing between function name and opening parenthesis.") +} diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/StringTemplate.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/StringTemplate.kt index 92f2964834a..a0f339c8212 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/StringTemplate.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/StringTemplate.kt @@ -7,7 +7,7 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#string-template) for documentation. */ @ActiveByDefault(since = "1.0.0") @AutoCorrectable(since = "1.0.0") diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TrailingComma.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TrailingComma.kt index 6570b68facb..98ca6a7e3e1 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TrailingComma.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TrailingComma.kt @@ -9,7 +9,7 @@ import io.gitlab.arturbosch.detekt.api.internal.Configuration import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/) for documentation. */ @AutoCorrectable(since = "1.20.0") class TrailingComma(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TypeArgumentListSpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TypeArgumentListSpacing.kt index 259fb2f0358..917b78d1bf9 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TypeArgumentListSpacing.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TypeArgumentListSpacing.kt @@ -6,7 +6,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#experimental-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#type-argument-list-spacing) for + * documentation. */ @AutoCorrectable(since = "1.20.0") class TypeArgumentListSpacing(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TypeParameterListSpacing.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TypeParameterListSpacing.kt new file mode 100644 index 00000000000..fec09926104 --- /dev/null +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/TypeParameterListSpacing.kt @@ -0,0 +1,17 @@ +package io.gitlab.arturbosch.detekt.formatting.wrappers + +import com.pinterest.ktlint.ruleset.experimental.TypeParameterListSpacingRule +import io.gitlab.arturbosch.detekt.api.Config +import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable +import io.gitlab.arturbosch.detekt.formatting.FormattingRule + +/** + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#type-parameter-list-spacing) for + * documentation. + */ +@AutoCorrectable(since = "1.22.0") +class TypeParameterListSpacing(config: Config) : FormattingRule(config) { + + override val wrapping = TypeParameterListSpacingRule() + override val issue = issueFor("Check spacing after a type parameter list in function and class declarations.") +} diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/UnnecessaryParenthesesBeforeTrailingLambda.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/UnnecessaryParenthesesBeforeTrailingLambda.kt index 9a3cf745ceb..4c04133b785 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/UnnecessaryParenthesesBeforeTrailingLambda.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/UnnecessaryParenthesesBeforeTrailingLambda.kt @@ -6,7 +6,8 @@ import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable import io.gitlab.arturbosch.detekt.formatting.FormattingRule /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#experimental-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/experimental/#unnecessary-parenthesis-before-trailing-lambda) + * for documentation. */ @AutoCorrectable(since = "1.20.0") class UnnecessaryParenthesesBeforeTrailingLambda(config: Config) : FormattingRule(config) { diff --git a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Wrapping.kt b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Wrapping.kt index fc2ba013c8f..82b0283ac02 100644 --- a/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Wrapping.kt +++ b/detekt-formatting/src/main/kotlin/io/gitlab/arturbosch/detekt/formatting/wrappers/Wrapping.kt @@ -13,7 +13,7 @@ import io.gitlab.arturbosch.detekt.formatting.FormattingRule import org.jetbrains.kotlin.com.intellij.lang.ASTNode /** - * See [ktlint-readme](https://github.com/pinterest/ktlint#standard-rules) for documentation. + * See [ktlint docs](https://pinterest.github.io/ktlint/rules/standard/#wrapping) for documentation. */ @ActiveByDefault(since = "1.20.0") @AutoCorrectable(since = "1.20.0") diff --git a/detekt-formatting/src/main/resources/config/config.yml b/detekt-formatting/src/main/resources/config/config.yml index 8a620c0ecdf..340a53c90dc 100644 --- a/detekt-formatting/src/main/resources/config/config.yml +++ b/detekt-formatting/src/main/resources/config/config.yml @@ -41,6 +41,19 @@ formatting: FunKeywordSpacing: active: false autoCorrect: true + FunctionReturnTypeSpacing: + active: false + autoCorrect: true + FunctionSignature: + active: false + autoCorrect: true + forceMultilineWhenParameterCountGreaterOrEqualThan: 2147483647 + functionBodyExpressionWrapping: 'default' + maxLineLength: 120 + indentSize: 4 + FunctionStartOfBodySpacing: + active: false + autoCorrect: true FunctionTypeReferenceSpacing: active: false autoCorrect: true @@ -108,9 +121,15 @@ formatting: NoWildcardImports: active: true packagesToUseImportOnDemandProperty: 'java.util.*,kotlinx.android.synthetic.**' + NullableTypeSpacing: + active: false + autoCorrect: true PackageName: active: true autoCorrect: true + ParameterListSpacing: + active: false + autoCorrect: true ParameterListWrapping: active: true autoCorrect: true @@ -154,6 +173,9 @@ formatting: SpacingBetweenDeclarationsWithComments: active: true autoCorrect: true + SpacingBetweenFunctionNameAndOpeningParenthesis: + active: false + autoCorrect: true StringTemplate: active: true autoCorrect: true @@ -165,6 +187,9 @@ formatting: TypeArgumentListSpacing: active: false autoCorrect: true + TypeParameterListSpacing: + active: false + autoCorrect: true UnnecessaryParenthesesBeforeTrailingLambda: active: false autoCorrect: true diff --git a/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/FinalNewlineSpec.kt b/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/FinalNewlineSpec.kt index ec242cf7df1..9af9f387d95 100644 --- a/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/FinalNewlineSpec.kt +++ b/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/FinalNewlineSpec.kt @@ -22,7 +22,7 @@ class FinalNewlineSpec { """ fun main() = Unit - """ + """.trimIndent() ) assertThat(findings).isEmpty() @@ -35,7 +35,7 @@ class FinalNewlineSpec { """ fun main() = Unit - """ + """.trimIndent() ) assertThat(findings).hasSize(1) diff --git a/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/FormattingRuleSpec.kt b/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/FormattingRuleSpec.kt index 362e9ae83fe..aaa3699a077 100644 --- a/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/FormattingRuleSpec.kt +++ b/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/FormattingRuleSpec.kt @@ -85,7 +85,7 @@ class FormattingRuleSpec { """ fun main() = Unit - """, + """.trimIndent(), expectedPath ) diff --git a/detekt-generator/src/main/kotlin/io/gitlab/arturbosch/detekt/generator/printer/defaultconfig/ConfigPrinter.kt b/detekt-generator/src/main/kotlin/io/gitlab/arturbosch/detekt/generator/printer/defaultconfig/ConfigPrinter.kt index 1029d93145d..10bf2f683ac 100644 --- a/detekt-generator/src/main/kotlin/io/gitlab/arturbosch/detekt/generator/printer/defaultconfig/ConfigPrinter.kt +++ b/detekt-generator/src/main/kotlin/io/gitlab/arturbosch/detekt/generator/printer/defaultconfig/ConfigPrinter.kt @@ -36,11 +36,12 @@ object ConfigPrinter : DocumentationPrinter> { """.trimIndent() private fun defaultConfigConfiguration(): String = """ - config: - validation: true - warningsAsErrors: false - # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' - excludes: '' + config: + validation: true + warningsAsErrors: false + checkExhaustiveness: false + # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' + excludes: '' """.trimIndent() private fun defaultProcessorsConfiguration(): String = """ diff --git a/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/MultiRuleCollectorSpec.kt b/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/MultiRuleCollectorSpec.kt index c2ddccbfdf4..66e1bc4a25a 100644 --- a/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/MultiRuleCollectorSpec.kt +++ b/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/MultiRuleCollectorSpec.kt @@ -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") diff --git a/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt b/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt index d7d5ce6e37e..5c866935504 100644 --- a/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt +++ b/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt @@ -54,7 +54,7 @@ class RuleCollectorSpec { * description */ class $name : Rule - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].name).isEqualTo(name) } @@ -67,7 +67,7 @@ class RuleCollectorSpec { * $description */ class SomeRandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].description).isEqualTo(description) } @@ -82,7 +82,7 @@ class RuleCollectorSpec { * more... */ class SomeRandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].description).startsWith(description) assertThat(items[0].description).contains("more...") @@ -95,7 +95,7 @@ class RuleCollectorSpec { * description */ class SomeRandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].defaultActivationStatus.active).isFalse() } @@ -108,7 +108,7 @@ class RuleCollectorSpec { */ @ActiveByDefault("1.12.123") class SomeRandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) val defaultActivationStatus = items[0].defaultActivationStatus as Active assertThat(defaultActivationStatus.since).isEqualTo("1.12.123") @@ -122,7 +122,7 @@ class RuleCollectorSpec { */ @ActiveByDefault(since = "1.2.3") class SomeRandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) val defaultActivationStatus = items[0].defaultActivationStatus as Active assertThat(defaultActivationStatus.since).isEqualTo("1.2.3") @@ -136,7 +136,7 @@ class RuleCollectorSpec { */ @ActiveByDefault("1.2.x") class SomeRandomClass : Rule - """ + """.trimIndent() assertThatExceptionOfType(InvalidDocumentationException::class.java).isThrownBy { subject.run(code) } } @@ -149,7 +149,7 @@ class RuleCollectorSpec { */ @AutoCorrectable(since = "1.0.0") class SomeRandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].autoCorrect).isTrue() } @@ -164,7 +164,7 @@ class RuleCollectorSpec { override val defaultRuleIdAliases = setOf("RULE", "RULE2") override val issue = Issue(javaClass.simpleName, Severity.Style, "", Debt.TEN_MINS) } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].severity).isEqualTo("Style") assertThat(items[0].debt).isEqualTo("10min") @@ -180,7 +180,7 @@ class RuleCollectorSpec { * description */ class SomeRandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration).isEmpty() } @@ -195,7 +195,7 @@ class RuleCollectorSpec { @Configuration("description") private val config: String by config("[A-Z$]") } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration).hasSize(1) val expectedConfiguration = Configuration( @@ -218,7 +218,7 @@ class RuleCollectorSpec { @Configuration("description") private val config: Int by config(1_999_000) } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration).hasSize(1) assertThat(items[0].configuration[0].defaultValue).isEqualTo(of(1_999_000)) @@ -234,7 +234,7 @@ class RuleCollectorSpec { @Configuration("description") private val config: String by config(""${"\""}abcd""${"\""}) } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration[0].defaultValue).isEqualTo(of("abcd")) } @@ -249,7 +249,7 @@ class RuleCollectorSpec { @Configuration("description") private val config: Int by config(defaultValue = 99) } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration[0].defaultValue).isEqualTo(of(99)) } @@ -269,7 +269,7 @@ class RuleCollectorSpec { ) ) } - """ + """.trimIndent() val items = subject.run(code) val expected = of(listOf("a", "b")) assertThat(items[0].configuration[0].defaultValue).isEqualTo(expected) @@ -288,7 +288,7 @@ class RuleCollectorSpec { @Configuration("description") private val config2: String by config("") } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration).hasSize(2) } @@ -306,7 +306,7 @@ class RuleCollectorSpec { "description") private val config: String by config("a") } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration[0].description).isEqualTo("This is a multi line description") assertThat(items[0].configuration[0].defaultValue).isEqualTo(of("a")) @@ -326,7 +326,7 @@ class RuleCollectorSpec { private const val DEFAULT_CONFIG_VALUE = 99 } } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration[0].defaultValue).isEqualTo(of(99)) } @@ -345,7 +345,7 @@ class RuleCollectorSpec { private const val DEFAULT_CONFIG_VALUE = 99 } } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration[0].defaultValue).isEqualTo(of(99)) } @@ -364,7 +364,7 @@ class RuleCollectorSpec { private const val DEFAULT_CONFIG_VALUE = "a" } } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration[0].defaultValue).isEqualTo(of("a")) } @@ -387,7 +387,7 @@ class RuleCollectorSpec { private val DEFAULT_CONFIG_VALUE_A = "a" } } - """ + """.trimIndent() val items = subject.run(code) val expected = of(listOf("a", "b")) assertThat(items[0].configuration[0].defaultValue).isEqualTo(expected) @@ -407,7 +407,7 @@ class RuleCollectorSpec { @Configuration("description") private val config2: List by config(emptyList()) } - """ + """.trimIndent() val items = subject.run(code) val expected = of(emptyList()) assertThat(items[0].configuration[0].defaultValue).isEqualTo(expected) @@ -431,7 +431,7 @@ class RuleCollectorSpec { private val DEFAULT_CONFIG_VALUE: List = emptyList() } } - """ + """.trimIndent() val items = subject.run(code) val expected = of(emptyList()) assertThat(items[0].configuration[0].defaultValue).isEqualTo(expected) @@ -449,7 +449,7 @@ class RuleCollectorSpec { @Configuration("description") private val config: String by config("") } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration[0].deprecated).isEqualTo("use config1 instead") } @@ -463,7 +463,7 @@ class RuleCollectorSpec { */ class SomeRandomClass() : Rule { } - """ + """.trimIndent() assertThatExceptionOfType(InvalidDocumentationException::class.java).isThrownBy { subject.run(code) } } @@ -477,7 +477,7 @@ class RuleCollectorSpec { @Configuration("description") private val config: String = "foo" } - """ + """.trimIndent() assertThatExceptionOfType(InvalidDocumentationException::class.java).isThrownBy { subject.run(code) } } @@ -491,7 +491,7 @@ class RuleCollectorSpec { @Configuration("description") private val config: String by lazy { "foo" } } - """ + """.trimIndent() assertThatExceptionOfType(InvalidDocumentationException::class.java).isThrownBy { subject.run(code) } } @@ -504,7 +504,7 @@ class RuleCollectorSpec { class SomeRandomClass() : Rule { private val config: String by config("") } - """ + """.trimIndent() assertThatExceptionOfType(InvalidDocumentationException::class.java).isThrownBy { subject.run(code) } } @@ -520,7 +520,7 @@ class RuleCollectorSpec { @Configuration("description") private val maxLineLength: Int by configWithAndroidVariants(120, 100) } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration[0]).isEqualTo( Configuration( @@ -544,7 +544,7 @@ class RuleCollectorSpec { private val maxLineLength: Int by configWithAndroidVariants(defaultValue = 120, defaultAndroidValue = 100) } - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].configuration[0]).isEqualTo( Configuration( @@ -576,7 +576,7 @@ class RuleCollectorSpec { @Configuration("description") private val config3: Int by configWithFallback(defaultValue = 99, fallbackProperty = ::prop) } - """ + """.trimIndent() val items = subject.run(code) val fallbackProperties = items[0].configuration.filter { it.name.startsWith("config") } assertThat(fallbackProperties).hasSize(3) @@ -594,7 +594,7 @@ class RuleCollectorSpec { @Configuration("description") private val config: Int by configWithFallback(::prop, 99) } - """ + """.trimIndent() assertThatThrownBy { subject.run(code) } .isInstanceOf(InvalidDocumentationException::class.java) .hasMessageContaining("delegate") @@ -613,7 +613,7 @@ class RuleCollectorSpec { @Configuration("description") private val config2: String by config(false, Boolean::toString) } - """ + """.trimIndent() @Test fun `extracts default value with transformer function`() { @@ -658,7 +658,7 @@ class RuleCollectorSpec { private val DEFAULT_VALUE = valuesWithReason("value" to "reason") } } - """ + """.trimIndent() @Test fun `parse options of type ValuesWithReason`() { @@ -711,7 +711,7 @@ class RuleCollectorSpec { * description */ class SomeRandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].requiresTypeResolution).isFalse() } @@ -724,7 +724,7 @@ class RuleCollectorSpec { */ @RequiresTypeResolution class SomeRandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].requiresTypeResolution).isTrue() } @@ -737,7 +737,7 @@ class RuleCollectorSpec { */ @io.gitlab.arturbosch.detekt.api.internal.RequiresTypeResolution class SomeRandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].requiresTypeResolution).isTrue() } @@ -758,7 +758,7 @@ class RuleCollectorSpec { * */ class RandomClass : Rule - """ + """.trimIndent() val items = subject.run(code) assertThat(items[0].nonCompliantCodeExample).isEqualTo("val one = 2") assertThat(items[0].compliantCodeExample).isEqualTo("val one = 1") @@ -773,7 +773,7 @@ class RuleCollectorSpec { * */ class RandomClass : Rule - """ + """.trimIndent() assertThatExceptionOfType(InvalidCodeExampleDocumentationException::class.java) .isThrownBy { subject.run(code) } } @@ -790,7 +790,7 @@ class RuleCollectorSpec { * */ class RandomClass : Rule - """ + """.trimIndent() assertThatExceptionOfType(InvalidCodeExampleDocumentationException::class.java) .isThrownBy { subject.run(code) } } @@ -806,7 +806,7 @@ class RuleCollectorSpec { * */ class RandomClass : Rule - """ + """.trimIndent() assertThatExceptionOfType(InvalidCodeExampleDocumentationException::class.java) .isThrownBy { subject.run(code) } } @@ -825,7 +825,7 @@ class RuleCollectorSpec { "", debt = Debt.TEN_MINS) } - """ + """.trimIndent() assertThatExceptionOfType(InvalidIssueDeclaration::class.java).isThrownBy { subject.run(code) } } @@ -844,7 +844,7 @@ class RuleCollectorSpec { "", debt = Debt.TEN_MINS) } - """ + """.trimIndent() assertThatExceptionOfType(InvalidAliasesDeclaration::class.java).isThrownBy { subject.run(code) } } @@ -856,7 +856,7 @@ class RuleCollectorSpec { * $description */ class SomeRandomClass : Rule - """ + """.trimIndent() assertThatExceptionOfType(InvalidDocumentationException::class.java).isThrownBy { subject.run(code) } } } diff --git a/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleSetProviderCollectorSpec.kt b/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleSetProviderCollectorSpec.kt index 0f6720061a1..d47e820fe97 100644 --- a/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleSetProviderCollectorSpec.kt +++ b/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleSetProviderCollectorSpec.kt @@ -29,7 +29,7 @@ class RuleSetProviderCollectorSpec { println(message) } } - """ + """.trimIndent() @Test fun `collects no rulesets`() { @@ -48,7 +48,7 @@ class RuleSetProviderCollectorSpec { println(message) } } - """ + """.trimIndent() @Test fun `collects no rulesets`() { @@ -67,7 +67,7 @@ class RuleSetProviderCollectorSpec { println(message) } } - """ + """.trimIndent() @Test fun `throws an exception`() { @@ -86,7 +86,7 @@ class RuleSetProviderCollectorSpec { println(message) } } - """ + """.trimIndent() @Test fun `throws an exception`() { @@ -118,7 +118,7 @@ class RuleSetProviderCollectorSpec { )) } } - """ + """.trimIndent() @Test fun `collects a RuleSetProvider`() { @@ -176,7 +176,7 @@ class RuleSetProviderCollectorSpec { )) } } - """ + """.trimIndent() @Test fun `is not active`() { @@ -203,7 +203,7 @@ class RuleSetProviderCollectorSpec { )) } } - """ + """.trimIndent() @Test fun `throws an exception`() { @@ -228,7 +228,7 @@ class RuleSetProviderCollectorSpec { )) } } - """ + """.trimIndent() @Test fun `throws an exception`() { @@ -255,7 +255,7 @@ class RuleSetProviderCollectorSpec { )) } } - """ + """.trimIndent() @Test fun `throws an exception`() { @@ -277,7 +277,7 @@ class RuleSetProviderCollectorSpec { return RuleSet(ruleSetId, emptyListOf()) } } - """ + """.trimIndent() @Test fun `throws an exception`() { @@ -309,7 +309,7 @@ class RuleSetProviderCollectorSpec { )) } } - """ + """.trimIndent() @Test fun `collects multiple rules`() { @@ -364,7 +364,7 @@ class RuleSetProviderCollectorSpec { val aString by ruleSetConfig("a") } } - """ + """.trimIndent() private val items = subject.run(code) @Test @@ -414,7 +414,7 @@ class RuleSetProviderCollectorSpec { val aConfig by ruleSetConfig(listOf("a")) } } - """ + """.trimIndent() @Test fun `fails`() { diff --git a/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/printer/defaultconfig/RuleSetConfigPrinterTest.kt b/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/printer/defaultconfig/RuleSetConfigPrinterTest.kt index ee016a857d5..70aa6a78e7c 100644 --- a/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/printer/defaultconfig/RuleSetConfigPrinterTest.kt +++ b/detekt-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/printer/defaultconfig/RuleSetConfigPrinterTest.kt @@ -194,7 +194,8 @@ internal class RuleSetConfigPrinterTest { fun `string list default value`() { val given = configurationTemplate.copy(defaultValue = DefaultValue.of(listOf("a", "b", "c"))) val actual = yaml { printConfiguration(given) } - val expected = """name: + val expected = """ + |name: | - 'a' | - 'b' | - 'c' @@ -221,7 +222,8 @@ internal class RuleSetConfigPrinterTest { ) ) val actual = yaml { printConfiguration(given) } - val expected = """name: + val expected = """ + |name: | - reason: 'reason a' | value: 'a' | - value: 'b' diff --git a/detekt-gradle-plugin/build.gradle.kts b/detekt-gradle-plugin/build.gradle.kts index a9ce2d993f2..0199f3b7407 100644 --- a/detekt-gradle-plugin/build.gradle.kts +++ b/detekt-gradle-plugin/build.gradle.kts @@ -6,7 +6,7 @@ plugins { alias(libs.plugins.pluginPublishing) // We use this published version of the Detekt plugin to self analyse this project. id("io.gitlab.arturbosch.detekt") version "1.21.0" - id("org.gradle.test-retry") version "1.4.0" + id("org.gradle.test-retry") version "1.4.1" } repositories { diff --git a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/ConfigurationCacheSpec.kt b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/ConfigurationCacheSpec.kt index c763cf66c17..56ed6bee8cd 100644 --- a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/ConfigurationCacheSpec.kt +++ b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/ConfigurationCacheSpec.kt @@ -23,10 +23,11 @@ class ConfigurationCacheSpec { inner class `Create baseline task` { @Test fun `can be loaded from the configuration cache`() { + @Suppress("TrimMultilineRawString") val detektConfig = """ - |detekt { - | baseline = file("build/baseline.xml") - |} + |detekt { + | baseline = file("build/baseline.xml") + |} """ val gradleRunner = DslTestBuilder.kotlin() .withDetektConfig(detektConfig) diff --git a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/CreateBaselineTaskDslSpec.kt b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/CreateBaselineTaskDslSpec.kt index 9b6e7f69bd2..336076c1a7e 100644 --- a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/CreateBaselineTaskDslSpec.kt +++ b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/CreateBaselineTaskDslSpec.kt @@ -11,6 +11,7 @@ class CreateBaselineTaskDslSpec { fun `detektBaseline task can be executed when baseline file is specified`() { val baselineFilename = "baseline.xml" + @Suppress("TrimMultilineRawString") val detektConfig = """ |detekt { | baseline = file("$baselineFilename") @@ -35,6 +36,7 @@ class CreateBaselineTaskDslSpec { @Test fun `detektBaseline task can be executed when baseline file is not specified`() { + @Suppress("TrimMultilineRawString") val detektConfig = """ |detekt { |} @@ -57,6 +59,7 @@ class CreateBaselineTaskDslSpec { @Test fun `detektBaseline task can not be executed when baseline file is specified null`() { + @Suppress("TrimMultilineRawString") val detektConfig = """ |detekt { | baseline = null diff --git a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektReportMergeSpec.kt b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektReportMergeSpec.kt index 2dc9bc2b41d..6285a1b19f3 100644 --- a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektReportMergeSpec.kt +++ b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektReportMergeSpec.kt @@ -13,33 +13,33 @@ class DetektReportMergeSpec { val builder = DslTestBuilder.kotlin() val buildFileContent = """ - |${builder.gradlePlugins} - | - |allprojects { - | ${builder.gradleRepositories} - |} - | - |val sarifReportMerge by tasks.registering(io.gitlab.arturbosch.detekt.report.ReportMergeTask::class) { - | output.set(project.layout.buildDirectory.file("reports/detekt/merge.sarif")) - |} - | - |subprojects { - | ${builder.gradleSubprojectsApplyPlugins} - | - | detekt { - | reports.sarif.enabled = true - | } - | - | plugins.withType(io.gitlab.arturbosch.detekt.DetektPlugin::class) { - | tasks.withType(io.gitlab.arturbosch.detekt.Detekt::class) detekt@{ - | sarifReportMerge.configure { - | this.mustRunAfter(this@detekt) - | input.from(this@detekt.sarifReportFile) - | } - | } - | } - |} - | + |${builder.gradlePlugins} + | + |allprojects { + | ${builder.gradleRepositories} + |} + | + |val sarifReportMerge by tasks.registering(io.gitlab.arturbosch.detekt.report.ReportMergeTask::class) { + | output.set(project.layout.buildDirectory.file("reports/detekt/merge.sarif")) + |} + | + |subprojects { + | ${builder.gradleSubprojectsApplyPlugins} + | + | detekt { + | reports.sarif.enabled = true + | } + | + | plugins.withType(io.gitlab.arturbosch.detekt.DetektPlugin::class) { + | tasks.withType(io.gitlab.arturbosch.detekt.Detekt::class) detekt@{ + | sarifReportMerge.configure { + | this.mustRunAfter(this@detekt) + | input.from(this@detekt.sarifReportFile) + | } + | } + | } + |} + | """.trimMargin() val projectLayout = ProjectLayout(numberOfSourceFilesInRootPerSourceDir = 0).apply { @@ -61,15 +61,15 @@ class DetektReportMergeSpec { assertThat(result.output).contains("FAILURE: Build completed with 2 failures.") assertThat(result.output).containsIgnoringWhitespaces( """ - Execution failed for task ':child1:detekt'. - > Analysis failed with 2 weighted issues. - """ + Execution failed for task ':child1:detekt'. + > Analysis failed with 2 weighted issues. + """.trimIndent() ) assertThat(result.output).containsIgnoringWhitespaces( """ - Execution failed for task ':child2:detekt'. - > Analysis failed with 4 weighted issues. - """ + Execution failed for task ':child2:detekt'. + > Analysis failed with 4 weighted issues. + """.trimIndent() ) assertThat(projectFile("build/reports/detekt/detekt.sarif")).doesNotExist() assertThat(projectFile("build/reports/detekt/merge.sarif")).exists() @@ -98,11 +98,11 @@ class DetektReportMergeSpec { | |subprojects { | ${builder.gradleSubprojectsApplyPlugins} - | + | | detekt { | reports.xml.enabled = true | } - | + | | plugins.withType(io.gitlab.arturbosch.detekt.DetektPlugin::class) { | tasks.withType(io.gitlab.arturbosch.detekt.Detekt::class) detekt@{ | xmlReportMerge.configure { @@ -134,15 +134,15 @@ class DetektReportMergeSpec { assertThat(result.output).contains("FAILURE: Build completed with 2 failures.") assertThat(result.output).containsIgnoringWhitespaces( """ - Execution failed for task ':child1:detekt'. - > Analysis failed with 2 weighted issues. - """ + Execution failed for task ':child1:detekt'. + > Analysis failed with 2 weighted issues. + """.trimIndent() ) assertThat(result.output).containsIgnoringWhitespaces( """ - Execution failed for task ':child2:detekt'. - > Analysis failed with 4 weighted issues. - """ + Execution failed for task ':child2:detekt'. + > Analysis failed with 4 weighted issues. + """.trimIndent() ) assertThat(projectFile("build/reports/detekt/detekt.xml")).doesNotExist() assertThat(projectFile("build/reports/detekt/merge.xml")).exists() diff --git a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskDslSpec.kt b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskDslSpec.kt index d0b43e87d2f..1d95ff815b9 100644 --- a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskDslSpec.kt +++ b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskDslSpec.kt @@ -76,10 +76,11 @@ class DetektTaskDslSpec { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |detekt { - | config.setFrom(files("firstConfig.yml", "secondConfig.yml")) - |} + |detekt { + | config.setFrom(files("firstConfig.yml", "secondConfig.yml")) + |} """ gradleRunner = builder.withDetektConfig(config).build() @@ -103,10 +104,11 @@ class DetektTaskDslSpec { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |detekt { - | baseline = file("$baselineFilename") - |} + |detekt { + | baseline = file("$baselineFilename") + |} """ gradleRunner = builder @@ -130,10 +132,11 @@ class DetektTaskDslSpec { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |detekt { - | baseline = file("$baselineFilename") - |} + |detekt { + | baseline = file("$baselineFilename") + |} """ gradleRunner = builder @@ -156,10 +159,11 @@ class DetektTaskDslSpec { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |detekt { - | input = files("$customSrc1", "$customSrc2", "folder_that_does_not_exist") - |} + |detekt { + | input = files("$customSrc1", "$customSrc2", "folder_that_does_not_exist") + |} """ val projectLayout = ProjectLayout(1, srcDirs = listOf(customSrc1, customSrc2)) @@ -191,10 +195,11 @@ class DetektTaskDslSpec { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |detekt { - | source = files("$customSrc1", "$customSrc2", "folder_that_does_not_exist") - |} + |detekt { + | source = files("$customSrc1", "$customSrc2", "folder_that_does_not_exist") + |} """ val projectLayout = ProjectLayout(1, srcDirs = listOf(customSrc1, customSrc2)) @@ -224,10 +229,11 @@ class DetektTaskDslSpec { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |detekt { - | reportsDir = file("build/detekt-reports") - |} + |detekt { + | reportsDir = file("build/detekt-reports") + |} """ gradleRunner = builder @@ -266,16 +272,17 @@ class DetektTaskDslSpec { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |detekt { - | reportsDir = file("build/detekt-reports") - |} - | - |tasks.detekt { - | reports { - | xml.destination = file("build/xml-reports/custom-detekt.xml") - | } - |} + |detekt { + | reportsDir = file("build/detekt-reports") + |} + | + |tasks.detekt { + | reports { + | xml.destination = file("build/xml-reports/custom-detekt.xml") + | } + |} """ gradleRunner = builder @@ -308,24 +315,25 @@ class DetektTaskDslSpec { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |tasks.detekt { - | reports { - | xml.enabled = false - | html { - | enabled = false - | } - | txt { - | enabled = false - | } - | sarif { - | enabled = false - | } - | md { - | enabled = false - | } - | } - |} + |tasks.detekt { + | reports { + | xml.enabled = false + | html { + | enabled = false + | } + | txt { + | enabled = false + | } + | sarif { + | enabled = false + | } + | md { + | enabled = false + | } + | } + |} """ gradleRunner = builder @@ -346,19 +354,20 @@ class DetektTaskDslSpec { inner class `configured correctly` { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |tasks.detekt { - | reports { - | custom { - | reportId = "customXml" - | destination = file("build/reports/custom.xml") - | } - | custom { - | reportId = "customJson" - | destination = file("build/reports/custom.json") - | } - | } - |} + |tasks.detekt { + | reports { + | custom { + | reportId = "customXml" + | destination = file("build/reports/custom.xml") + | } + | custom { + | reportId = "customJson" + | destination = file("build/reports/custom.json") + | } + | } + |} """ gradleRunner = builder.withDetektConfig(config).build() @@ -382,14 +391,15 @@ class DetektTaskDslSpec { inner class `report id is missing` { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |tasks.withType().configureEach { - | reports { - | custom { - | destination = file("build/reports/custom.xml") - | } - | } - |} + |tasks.withType().configureEach { + | reports { + | custom { + | destination = file("build/reports/custom.xml") + | } + | } + |} """ gradleRunner = builder.withDetektConfig(config).build() @@ -408,14 +418,15 @@ class DetektTaskDslSpec { inner class `report filename is missing` { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |tasks.withType().configureEach { - | reports { - | custom { - | reportId = "customJson" - | } - | } - |} + |tasks.withType().configureEach { + | reports { + | custom { + | reportId = "customJson" + | } + | } + |} """ gradleRunner = builder.withDetektConfig(config).build() @@ -436,15 +447,16 @@ class DetektTaskDslSpec { fun beforeGroup() { val aDirectory = "\${rootDir}/src" + @Suppress("TrimMultilineRawString") val config = """ - |tasks.withType().configureEach { - | reports { - | custom { - | reportId = "foo" - | destination = file("$aDirectory") - | } - | } - |} + |tasks.withType().configureEach { + | reports { + | custom { + | reportId = "foo" + | destination = file("$aDirectory") + | } + | } + |} """ gradleRunner = builder.withDetektConfig(config).build() @@ -463,15 +475,16 @@ class DetektTaskDslSpec { @ParameterizedTest @EnumSource(DetektReportType::class) fun `fails the build`(wellKnownType: DetektReportType) { + @Suppress("TrimMultilineRawString") val config = """ - |tasks.withType().configureEach { - | reports { - | custom { - | reportId = "${wellKnownType.reportId}" - | destination = file("build/reports/custom.xml") - | } - | } - |} + |tasks.withType().configureEach { + | reports { + | custom { + | reportId = "${wellKnownType.reportId}" + | destination = file("build/reports/custom.xml") + | } + | } + |} """ gradleRunner = builder.withDetektConfig(config).build() @@ -488,17 +501,18 @@ class DetektTaskDslSpec { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |detekt { - | debug = true - | parallel = true - | disableDefaultRuleSets = true - | failFast = true - | allRules = true - | autoCorrect = true - | buildUponDefaultConfig = true - | ignoreFailures = true - |} + |detekt { + | debug = true + | parallel = true + | disableDefaultRuleSets = true + | failFast = true + | allRules = true + | autoCorrect = true + | buildUponDefaultConfig = true + | ignoreFailures = true + |} """ gradleRunner = builder @@ -567,10 +581,11 @@ class DetektTaskDslSpec { inner class `with an additional plugin` { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |dependencies { - | detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$defaultDetektVersion") - |} + |dependencies { + | detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$defaultDetektVersion") + |} """ gradleRunner = builder @@ -596,10 +611,11 @@ class DetektTaskDslSpec { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ - |detekt { - | toolVersion = "$customVersion" - |} + |detekt { + | toolVersion = "$customVersion" + |} """ gradleRunner = builder @@ -623,6 +639,7 @@ class DetektTaskDslSpec { inner class `and creating a custom task` { @BeforeAll fun beforeGroup() { + @Suppress("TrimMultilineRawString") val config = """ |task("myDetekt") { | description = "Runs a custom detekt build." diff --git a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskGroovyDslSpec.kt b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskGroovyDslSpec.kt index d5abc314f16..2735edc197e 100644 --- a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskGroovyDslSpec.kt +++ b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskGroovyDslSpec.kt @@ -9,6 +9,7 @@ class DetektTaskGroovyDslSpec { @Test fun `detekt extension can be configured without errors`() { + @Suppress("TrimMultilineRawString") val config = """ |detekt { | toolVersion = "1.0.0.RC8" @@ -36,6 +37,7 @@ class DetektTaskGroovyDslSpec { @Test fun `detekt task can be fully configured without errors`() { + @Suppress("TrimMultilineRawString") val config = """ |tasks.create("customDetektTask", io.gitlab.arturbosch.detekt.Detekt) { | source = files("${"$"}projectDir") @@ -81,6 +83,7 @@ class DetektTaskGroovyDslSpec { @Test fun `detekt create baseline task can be configured without errors`() { + @Suppress("TrimMultilineRawString") val config = """ |tasks.create("customDetektCreateBaselineTask", io.gitlab.arturbosch.detekt.DetektCreateBaselineTask) { | source = files("${"$"}projectDir") @@ -110,6 +113,7 @@ class DetektTaskGroovyDslSpec { @Test fun `detekt generate config task can be configured without errors`() { + @Suppress("TrimMultilineRawString") val config = """ |tasks.create("customDetektGenerateConfigTask", io.gitlab.arturbosch.detekt.DetektGenerateConfigTask) { | detektClasspath.setFrom(files("config.yml")) diff --git a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskSpec.kt b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskSpec.kt index 866b01a7b86..e469b2c279b 100644 --- a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskSpec.kt +++ b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/DetektTaskSpec.kt @@ -15,6 +15,7 @@ class DetektTaskSpec { @Test fun `build succeeds with more issues than threshold if ignoreFailures = true`() { + @Suppress("TrimMultilineRawString") val config = """ |detekt { | ignoreFailures = true @@ -33,6 +34,7 @@ class DetektTaskSpec { @Test fun `build fails with more issues than threshold successfully if ignoreFailures = false`() { + @Suppress("TrimMultilineRawString") val config = """ |detekt { | ignoreFailures = false diff --git a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/GenerateConfigTaskSpec.kt b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/GenerateConfigTaskSpec.kt index e011929ade1..da4b2835829 100644 --- a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/GenerateConfigTaskSpec.kt +++ b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/GenerateConfigTaskSpec.kt @@ -22,10 +22,11 @@ class GenerateConfigTaskSpec { fun `chooses the last config file when configured`() { val builder = DslTestBuilder.kotlin() val gradleRunner = builder.withDetektConfig( + @Suppress("TrimMultilineRawString") """ - |detekt { - | config = files("config/detekt/detekt.yml", "config/other/detekt.yml") - |} + |detekt { + | config = files("config/detekt/detekt.yml", "config/other/detekt.yml") + |} """ ).withConfigFile("config/detekt/detekt.yml").build() gradleRunner.writeProjectFile("config/other/detekt.yml", content = "") diff --git a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/PluginTaskBehaviorSpec.kt b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/PluginTaskBehaviorSpec.kt index 666768777d4..1de6dd3ab0d 100644 --- a/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/PluginTaskBehaviorSpec.kt +++ b/detekt-gradle-plugin/src/functionalTest/kotlin/io/gitlab/arturbosch/detekt/PluginTaskBehaviorSpec.kt @@ -16,11 +16,12 @@ class PluginTaskBehaviorSpec { val configFileName = "config.yml" val baselineFileName = "baseline.xml" + @Suppress("TrimMultilineRawString") val detektConfig = """ - |detekt { - | config = files("$configFileName") - | baseline = file("$baselineFileName") - |} + |detekt { + | config = files("$configFileName") + | baseline = file("$baselineFileName") + |} """ lateinit var gradleRunner: DslGradleRunner diff --git a/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektAndroid.kt b/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektAndroid.kt index cce07fc6e0c..a2a75b72177 100644 --- a/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektAndroid.kt +++ b/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektAndroid.kt @@ -126,7 +126,7 @@ internal fun Project.registerAndroidDetektTask( // If a baseline file is configured as input file, it must exist to be configured, otherwise the task fails. // We try to find the configured baseline or alternatively a specific variant matching this task. extension.baseline?.existingVariantOrBaseFile(variant.name)?.let { baselineFile -> - baseline.set(layout.file(project.provider { baselineFile })) + baseline.convention(layout.file(project.provider { baselineFile })) } setReportOutputConventions(reports, extension, variant.name) description = "EXPERIMENTAL: Run detekt analysis for ${variant.name} classes with type resolution" @@ -148,7 +148,7 @@ internal fun Project.registerAndroidCreateBaselineTask( javaCompileDestination(variant), ) val variantBaselineFile = extension.baseline?.addVariantName(variant.name) - baseline.set(project.layout.file(project.provider { variantBaselineFile })) + baseline.convention(project.layout.file(project.provider { variantBaselineFile })) description = "EXPERIMENTAL: Creates detekt baseline for ${variant.name} classes with type resolution" } diff --git a/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektJvm.kt b/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektJvm.kt index 0742e21aca9..15ba228b050 100644 --- a/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektJvm.kt +++ b/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektJvm.kt @@ -29,7 +29,7 @@ internal class DetektJvm(private val project: Project) { // If a baseline file is configured as input file, it must exist to be configured, otherwise the task fails. // We try to find the configured baseline or alternatively a specific variant matching this task. extension.baseline?.existingVariantOrBaseFile(sourceSet.name)?.let { baselineFile -> - baseline.set(layout.file(project.provider { baselineFile })) + baseline.convention(layout.file(project.provider { baselineFile })) } setReportOutputConventions(reports, extension, sourceSet.name) description = "EXPERIMENTAL: Run detekt analysis for ${sourceSet.name} classes with type resolution" @@ -43,7 +43,7 @@ internal class DetektJvm(private val project: Project) { source = kotlinSourceSet.kotlin classpath.setFrom(sourceSet.compileClasspath.existingFiles(), sourceSet.output.classesDirs.existingFiles()) val variantBaselineFile = extension.baseline?.addVariantName(sourceSet.name) - baseline.set(project.layout.file(project.provider { variantBaselineFile })) + baseline.convention(project.layout.file(project.provider { variantBaselineFile })) description = "EXPERIMENTAL: Creates detekt baseline for ${sourceSet.name} classes with type resolution" } } diff --git a/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektMultiplatform.kt b/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektMultiplatform.kt index e9e456b356d..a6c11490e41 100644 --- a/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektMultiplatform.kt +++ b/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektMultiplatform.kt @@ -105,7 +105,7 @@ internal class DetektMultiplatform(private val project: Project) { } else { extension.baseline?.takeIf { it.exists() } }?.let { baselineFile -> - baseline.set(layout.file(provider { baselineFile })) + baseline.convention(layout.file(provider { baselineFile })) } setReportOutputConventions(reports, extension, compilation.name) description = @@ -128,7 +128,7 @@ internal class DetektMultiplatform(private val project: Project) { } else { extension.baseline } - baseline.set( + baseline.convention( layout.file(provider { variantBaselineFile }) ) diff --git a/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektPlain.kt b/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektPlain.kt index 396145d323f..76cc1df65a2 100644 --- a/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektPlain.kt +++ b/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/DetektPlain.kt @@ -17,12 +17,12 @@ internal class DetektPlain(private val project: Project) { private fun Project.registerDetektTask(extension: DetektExtension) { val detektTaskProvider = registerDetektTask(DetektPlugin.DETEKT_TASK_NAME, extension) { extension.baseline?.takeIf { it.exists() }?.let { baselineFile -> - baseline.set(project.layout.file(project.provider { baselineFile })) + baseline.convention(project.layout.file(project.provider { baselineFile })) } setSource(existingInputDirectoriesProvider(project, extension)) setIncludes(DetektPlugin.defaultIncludes) setExcludes(DetektPlugin.defaultExcludes) - reportsDir.set(project.provider { extension.reportsDir }) + reportsDir.convention(project.provider { extension.reportsDir }) } tasks.matching { it.name == LifecycleBasePlugin.CHECK_TASK_NAME }.configureEach { @@ -32,7 +32,7 @@ internal class DetektPlain(private val project: Project) { private fun Project.registerCreateBaselineTask(extension: DetektExtension) { registerCreateBaselineTask(DetektPlugin.BASELINE_TASK_NAME, extension) { - baseline.set(project.layout.file(project.provider { extension.baseline })) + baseline.convention(project.layout.file(project.provider { extension.baseline })) setSource(existingInputDirectoriesProvider(project, extension)) } } diff --git a/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/SharedTasks.kt b/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/SharedTasks.kt index f9431ae6e84..c663e448360 100644 --- a/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/SharedTasks.kt +++ b/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/internal/SharedTasks.kt @@ -40,16 +40,16 @@ internal fun Project.registerDetektTask( } } - it.debugProp.set(provider { extension.debug }) - it.parallelProp.set(provider { extension.parallel }) - it.disableDefaultRuleSetsProp.set(provider { extension.disableDefaultRuleSets }) - it.buildUponDefaultConfigProp.set(provider { extension.buildUponDefaultConfig }) - it.failFastProp.set(provider { @Suppress("DEPRECATION") extension.failFast }) - it.autoCorrectProp.set(provider { extension.autoCorrect }) + it.debugProp.convention(provider { extension.debug }) + it.parallelProp.convention(provider { extension.parallel }) + it.disableDefaultRuleSetsProp.convention(provider { extension.disableDefaultRuleSets }) + it.buildUponDefaultConfigProp.convention(provider { extension.buildUponDefaultConfig }) + it.failFastProp.convention(provider { @Suppress("DEPRECATION") extension.failFast }) + it.autoCorrectProp.convention(provider { extension.autoCorrect }) it.config.setFrom(provider { extension.config }) - it.ignoreFailuresProp.set(project.provider { extension.ignoreFailures }) - it.basePathProp.set(extension.basePath) - it.allRulesProp.set(provider { extension.allRules }) + it.ignoreFailuresProp.convention(project.provider { extension.ignoreFailures }) + it.basePathProp.convention(extension.basePath) + it.allRulesProp.convention(provider { extension.allRules }) configuration(it) } @@ -60,13 +60,13 @@ internal fun Project.registerCreateBaselineTask( ): TaskProvider = tasks.register(name, DetektCreateBaselineTask::class.java) { it.config.setFrom(project.provider { extension.config }) - it.debug.set(project.provider { extension.debug }) - it.parallel.set(project.provider { extension.parallel }) - it.disableDefaultRuleSets.set(project.provider { extension.disableDefaultRuleSets }) - it.buildUponDefaultConfig.set(project.provider { extension.buildUponDefaultConfig }) - @Suppress("DEPRECATION") it.failFast.set(project.provider { extension.failFast }) - it.autoCorrect.set(project.provider { extension.autoCorrect }) - it.basePathProp.set(extension.basePath) - it.allRules.set(provider { extension.allRules }) + it.debug.convention(project.provider { extension.debug }) + it.parallel.convention(project.provider { extension.parallel }) + it.disableDefaultRuleSets.convention(project.provider { extension.disableDefaultRuleSets }) + it.buildUponDefaultConfig.convention(project.provider { extension.buildUponDefaultConfig }) + @Suppress("DEPRECATION") it.failFast.convention(project.provider { extension.failFast }) + it.autoCorrect.convention(project.provider { extension.autoCorrect }) + it.basePathProp.convention(extension.basePath) + it.allRules.convention(provider { extension.allRules }) configuration(it) } diff --git a/detekt-gradle-plugin/src/testFixtures/kotlin/io/gitlab/arturbosch/detekt/testkit/DslTestBuilder.kt b/detekt-gradle-plugin/src/testFixtures/kotlin/io/gitlab/arturbosch/detekt/testkit/DslTestBuilder.kt index 5075756f5d6..6309690ed54 100644 --- a/detekt-gradle-plugin/src/testFixtures/kotlin/io/gitlab/arturbosch/detekt/testkit/DslTestBuilder.kt +++ b/detekt-gradle-plugin/src/testFixtures/kotlin/io/gitlab/arturbosch/detekt/testkit/DslTestBuilder.kt @@ -76,6 +76,8 @@ abstract class DslTestBuilder { private class GroovyBuilder : DslTestBuilder() { override val gradleBuildName: String = "build.gradle" + + @Suppress("TrimMultilineRawString") override val gradlePlugins = """ |plugins { | id 'java-library' @@ -94,6 +96,7 @@ private class GroovyBuilder : DslTestBuilder() { |} """.trimMargin() + @Suppress("TrimMultilineRawString") override val gradleSubprojectsApplyPlugins = """ |apply plugin: "io.gitlab.arturbosch.detekt" | @@ -105,6 +108,7 @@ private class GroovyBuilder : DslTestBuilder() { private class KotlinBuilder : DslTestBuilder() { override val gradleBuildName: String = "build.gradle.kts" + @Suppress("TrimMultilineRawString") override val gradlePlugins = """ |plugins { | `java-library` @@ -123,6 +127,7 @@ private class KotlinBuilder : DslTestBuilder() { |} """.trimMargin() + @Suppress("TrimMultilineRawString") override val gradleSubprojectsApplyPlugins = """ |plugins.apply("io.gitlab.arturbosch.detekt") | diff --git a/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/CognitiveComplexitySpec.kt b/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/CognitiveComplexitySpec.kt index a69ba4a9008..f29de58624d 100644 --- a/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/CognitiveComplexitySpec.kt +++ b/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/CognitiveComplexitySpec.kt @@ -24,7 +24,7 @@ class CognitiveComplexitySpec { } return total } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(7) @@ -40,7 +40,7 @@ class CognitiveComplexitySpec { 3 -> "a few" else -> "lots" } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(1) @@ -57,7 +57,7 @@ class CognitiveComplexitySpec { fun factorial(n: Int): Int = if (n >= 1) n * this.factorial(n - 1) else 1 } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(2) @@ -69,7 +69,7 @@ class CognitiveComplexitySpec { """ fun factorial(n: Int): Int = if (n >= 1) n * factorial(n - 1) else 1 - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(2) @@ -82,7 +82,7 @@ class CognitiveComplexitySpec { object O { fun factorial(i: Int): Int = i - 1 } fun factorial(n: Int): Int = if (n >= 1) n * O.factorial(n - 1) else 1 - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(1) @@ -97,7 +97,7 @@ class CognitiveComplexitySpec { fun main(args: Array) { args.takeIf { it.size > 3 }?.let(::parse) ?: error("not enough arguments") } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(0) @@ -113,7 +113,7 @@ class CognitiveComplexitySpec { } catch (e: IllegalStateException) { } catch (e: Throwable) {} } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(3) @@ -136,7 +136,7 @@ class CognitiveComplexitySpec { do {} while(true) // +2 } } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(9) @@ -147,7 +147,7 @@ class CognitiveComplexitySpec { val code = compileContentForTest( """ fun main() { run { if (true) {} } } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(2) @@ -158,7 +158,7 @@ class CognitiveComplexitySpec { val code = compileContentForTest( """ fun main() { fun run() { if (true) {} } } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(2) @@ -172,7 +172,7 @@ class CognitiveComplexitySpec { val code = compileContentForTest( """ fun test(cond_ Boolean) = !cond - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(0) @@ -186,7 +186,7 @@ class CognitiveComplexitySpec { val code = compileContentForTest( """ fun test(cond_ Boolean) = !cond && !cond - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(1) @@ -197,7 +197,7 @@ class CognitiveComplexitySpec { val code = compileContentForTest( """ fun test(cond_ Boolean) = !cond && !cond && !cond - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(1) @@ -208,7 +208,7 @@ class CognitiveComplexitySpec { val code = compileContentForTest( """ fun test(cond_ Boolean) = !cond && !cond || cond - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(2) @@ -226,7 +226,7 @@ class CognitiveComplexitySpec { && cond // +1 ) {} } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(4) @@ -242,7 +242,7 @@ class CognitiveComplexitySpec { && !(cond && cond) // +2 ) {} } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(3) @@ -258,7 +258,7 @@ class CognitiveComplexitySpec { && !(cond && cond && cond) // +2 ) {} } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(3) @@ -275,7 +275,7 @@ class CognitiveComplexitySpec { || !(cond || cond) // +2 ) {} } - """ + """.trimIndent() ) assertThat(CognitiveComplexity.calculate(code)).isEqualTo(5) diff --git a/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/CyclomaticComplexitySpec.kt b/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/CyclomaticComplexitySpec.kt index 35068df0a99..af9e1d6d0db 100644 --- a/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/CyclomaticComplexitySpec.kt +++ b/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/CyclomaticComplexitySpec.kt @@ -22,7 +22,7 @@ class CyclomaticComplexitySpec { val code = compileContentForTest( """ fun test() = null as? String ?: "" - """ + """.trimIndent() ) val actual = CyclomaticComplexity.calculate(code) @@ -35,7 +35,7 @@ class CyclomaticComplexitySpec { val code = compileContentForTest( """ fun test() = if (true || true && false) 1 else 0 - """ + """.trimIndent() ) val actual = CyclomaticComplexity.calculate(code) @@ -60,7 +60,7 @@ class CyclomaticComplexitySpec { } println("finished") } - """ + """.trimIndent() ) val actual = CyclomaticComplexity.calculate(code) @@ -77,7 +77,7 @@ class CyclomaticComplexitySpec { fun test(i: Int) { (1..10).forEach { println(it) } } - """ + """.trimIndent() ) @Test @@ -129,7 +129,7 @@ class CyclomaticComplexitySpec { else -> println("Meh") } } - """ + """.trimIndent() ).getFunctionByName("test") val actual = CyclomaticComplexity.calculate(function) { @@ -152,7 +152,7 @@ class CyclomaticComplexitySpec { else -> println("Meh") } } - """ + """.trimIndent() ).getFunctionByName("test") val actual = CyclomaticComplexity.calculate(function) { @@ -177,7 +177,7 @@ class CyclomaticComplexitySpec { else -> println("Meh") } } - """ + """.trimIndent() ).getFunctionByName("test") val actual = CyclomaticComplexity.calculate(function) { @@ -203,7 +203,7 @@ class CyclomaticComplexitySpec { else -> println("Meh") } } - """ + """.trimIndent() ).getFunctionByName("test") val actual = CyclomaticComplexity.calculate(function) { @@ -231,7 +231,7 @@ class CyclomaticComplexitySpec { else -> println("Meh") } } - """ + """.trimIndent() ).getFunctionByName("test") val actual = CyclomaticComplexity.calculate(function) { diff --git a/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/processors/LOCVisitorSpec.kt b/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/processors/LOCVisitorSpec.kt index b62630f46f4..ec24703b54a 100644 --- a/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/processors/LOCVisitorSpec.kt +++ b/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/processors/LOCVisitorSpec.kt @@ -13,6 +13,6 @@ class LOCVisitorSpec { accept(LOCVisitor()) getUserData(linesKey) } - assertThat(loc).isEqualTo(8) + assertThat(loc).isEqualTo(7) } } diff --git a/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/processors/package.kt b/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/processors/package.kt index 4ed90eb3139..e9851a9e071 100644 --- a/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/processors/package.kt +++ b/detekt-metrics/src/test/kotlin/io/github/detekt/metrics/processors/package.kt @@ -8,21 +8,21 @@ package cases */ @Suppress("Unused") class Default -""".trimStart() +""".trimIndent() val emptyEnum = """ package empty @Suppress("Unused") enum class EmptyEnum -""".trimStart() +""".trimIndent() val emptyInterface = """ package empty @Suppress("Unused") interface EmptyInterface -""".trimStart() +""".trimIndent() val classWithFields = """ package fields @@ -33,7 +33,7 @@ class ClassWithFields { private var x = 0 val y = 0 } -""".trimStart() +""".trimIndent() val commentsClass = """ package comments @@ -58,7 +58,7 @@ class CommentsClass { println("// no comment //") } } -""".trimStart() +""".trimIndent() val complexClass = """ package cases @@ -206,4 +206,4 @@ class ComplexClass {// McCabe: 44, LLOC: 20 + 20 + 4x4 } } } -""".trimStart() +""".trimIndent() diff --git a/detekt-psi-utils/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/ThrowExtensionsSpec.kt b/detekt-psi-utils/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/ThrowExtensionsSpec.kt index a0dc4b0839d..d28ac070017 100644 --- a/detekt-psi-utils/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/ThrowExtensionsSpec.kt +++ b/detekt-psi-utils/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/ThrowExtensionsSpec.kt @@ -18,7 +18,7 @@ internal class ThrowExtensionsSpec { fun test() { if (i == 1) throw IllegalArgumentException() } - """ + """.trimIndent() verifyThrowExpression(code) { assertThat(isEnclosedByConditionalStatement()).isTrue() @@ -32,7 +32,7 @@ internal class ThrowExtensionsSpec { if (i == 1) throw IllegalArgumentException() } - """ + """.trimIndent() verifyThrowExpression(code) { assertThat(isEnclosedByConditionalStatement()).isTrue() @@ -48,7 +48,7 @@ internal class ThrowExtensionsSpec { throw IllegalArgumentException() } } - """ + """.trimIndent() verifyThrowExpression(code) { assertThat(isEnclosedByConditionalStatement()).isTrue() @@ -61,7 +61,7 @@ internal class ThrowExtensionsSpec { fun test() { throw IllegalArgumentException() } - """ + """.trimIndent() verifyThrowExpression(code) { assertThat(isEnclosedByConditionalStatement()).isFalse() @@ -78,7 +78,7 @@ internal class ThrowExtensionsSpec { else -> println("other") } } - """ + """.trimIndent() verifyThrowExpression(code) { assertThat(isEnclosedByConditionalStatement()).isFalse() @@ -91,7 +91,7 @@ internal class ThrowExtensionsSpec { fun test(a: Int) { if (a == 2) println("2") else throw IllegalArgumentException() } - """ + """.trimIndent() verifyThrowExpression(code) { assertThat(isEnclosedByConditionalStatement()).isTrue() @@ -108,7 +108,7 @@ internal class ThrowExtensionsSpec { throw IllegalArgumentException() } } - """ + """.trimIndent() verifyThrowExpression(code) { assertThat(isEnclosedByConditionalStatement()).isTrue() diff --git a/detekt-report-sarif/src/test/kotlin/io/github/detekt/report/sarif/SarifOutputReportSpec.kt b/detekt-report-sarif/src/test/kotlin/io/github/detekt/report/sarif/SarifOutputReportSpec.kt index d2935e69ddc..05e8897682e 100644 --- a/detekt-report-sarif/src/test/kotlin/io/github/detekt/report/sarif/SarifOutputReportSpec.kt +++ b/detekt-report-sarif/src/test/kotlin/io/github/detekt/report/sarif/SarifOutputReportSpec.kt @@ -171,7 +171,7 @@ private fun constrainRegion(startLine: Int, startColumn: Int, endLine: Int, endC "startColumn": $startColumn, "startLine": $startLine } -""" +""".trimIndent() class TestRule : Rule() { override val issue = Issue(javaClass.simpleName, Severity.Warning, "", Debt.FIVE_MINS) diff --git a/detekt-rules-complexity/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctions.kt b/detekt-rules-complexity/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctions.kt index 81a0dc39d7f..4d037aad5a3 100644 --- a/detekt-rules-complexity/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctions.kt +++ b/detekt-rules-complexity/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctions.kt @@ -120,16 +120,15 @@ class NestedScopeFunctions(config: Config = Config.empty) : Rule(config) { } private fun KtCallExpression.isScopeFunction(): Boolean { - val descriptors = resolveDescriptors() - return !descriptors.any { it.matchesScopeFunction() } + val descriptors = resolveDescriptors() ?: return false + return descriptors.any { it.matchesScopeFunction() } } - private fun KtCallExpression.resolveDescriptors(): List = + private fun KtCallExpression.resolveDescriptors(): List? = getResolvedCall(bindingContext)?.resultingDescriptor ?.let { listOf(it) + it.overriddenDescriptors } - .orEmpty() private fun CallableDescriptor.matchesScopeFunction(): Boolean = - !functions.any { it.match(this) } + functions.any { it.match(this) } } } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexConditionSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexConditionSpec.kt index 19a514565ac..6c28bfcfa42 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexConditionSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexConditionSpec.kt @@ -13,7 +13,7 @@ class ComplexConditionSpec { while (5 > 4 && 4 < 6 || (3 < 5 || 2 < 5)) {} do { } while (5 > 4 && 4 < 6 || (3 < 5 || 2 < 5)) } - """ + """.trimIndent() @Test fun `reports some complex conditions`() { diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexInterfaceSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexInterfaceSpec.kt index 466df744877..72c62ab5be4 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexInterfaceSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexInterfaceSpec.kt @@ -34,7 +34,7 @@ class ComplexInterfaceSpec { val i1: Int fun fImpl() {} } - """ + """.trimIndent() @Test fun `reports complex interface`() { @@ -59,7 +59,7 @@ class ComplexInterfaceSpec { fun fImpl() {} } } - """ + """.trimIndent() @Test fun `reports complex interface`() { @@ -84,7 +84,7 @@ class ComplexInterfaceSpec { val v = 0 } } - """ + """.trimIndent() @Test fun `does not report static declarations per default`() { @@ -107,7 +107,7 @@ class ComplexInterfaceSpec { val i1: Int private fun fImpl() {} } - """ + """.trimIndent() @Test fun `does not report complex interface`() { @@ -131,7 +131,7 @@ class ComplexInterfaceSpec { get() = 42 fun fImpl() {} } - """ + """.trimIndent() @Test fun `does not report complex interface`() { @@ -154,7 +154,7 @@ class ComplexInterfaceSpec { val i1: Int fun fImpl() {} } - """ + """.trimIndent() @Test fun `reports complex interface with overloaded methods`() { @@ -176,7 +176,7 @@ class ComplexInterfaceSpec { val i1: Int fun fImpl() {} } - """ + """.trimIndent() val rule = ComplexInterface(ignoreOverloadedConfig) assertThat(rule.compileAndLint(interfaceWithExtension)).hasSize(1) } @@ -190,7 +190,7 @@ class ComplexInterfaceSpec { val i1: Int fun fImpl() {} } - """ + """.trimIndent() val rule = ComplexInterface(ignoreOverloadedConfig) assertThat(rule.compileAndLint(interfaceWithOverloadedExtensions)).isEmpty() } @@ -212,7 +212,7 @@ class ComplexInterfaceSpec { val i: Int // a comment shouldn't be detected } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -227,7 +227,7 @@ class ComplexInterfaceSpec { const val c = 0 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexMethodSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexMethodSpec.kt index c5027ee7eba..744f94da651 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexMethodSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexMethodSpec.kt @@ -29,7 +29,7 @@ class ComplexMethodSpec { do {} while(true) (1..10).forEach {} } - """ + """.trimIndent() ) assertThat(findings.first()).isThresholded().withValue(defaultComplexity + 4) @@ -42,7 +42,7 @@ class ComplexMethodSpec { fun test() { try {} catch(e: IllegalArgumentException) {} catch(e: Exception) {} finally {} } - """ + """.trimIndent() ) assertThat(findings.first()).isThresholded().withValue(defaultComplexity + 2) @@ -66,7 +66,7 @@ class ComplexMethodSpec { // only catches count } } - """ + """.trimIndent() ) assertThat(findings.first()).isThresholded().withValue(defaultComplexity + 4) @@ -81,7 +81,7 @@ class ComplexMethodSpec { for (i in 1..10) {} (1..10).forEach {} } - """ + """.trimIndent() @Test fun `counts three with nesting function 'forEach'`() { @@ -167,7 +167,7 @@ class ComplexMethodSpec { } } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).isEmpty() @@ -223,7 +223,7 @@ class ComplexMethodSpec { } } } - """ + """.trimIndent() @Test fun `should not count these overridden functions to base functions complexity`() { diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LabeledExpressionSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LabeledExpressionSpec.kt index d96a5ae791f..9bfb957cca2 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LabeledExpressionSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LabeledExpressionSpec.kt @@ -20,7 +20,7 @@ class LabeledExpressionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(3) } @@ -33,7 +33,7 @@ class LabeledExpressionSpec { println(it) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -46,7 +46,7 @@ class LabeledExpressionSpec { println(it) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -65,7 +65,7 @@ class LabeledExpressionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(3) } @@ -79,7 +79,7 @@ class LabeledExpressionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -94,7 +94,7 @@ class LabeledExpressionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -108,7 +108,7 @@ class LabeledExpressionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -129,7 +129,7 @@ class LabeledExpressionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -139,7 +139,7 @@ class LabeledExpressionSpec { fun f() { loop@ for (i in 1..5) {} } - """ + """.trimIndent() val config = TestConfig(mapOf("ignoredLabels" to listOf("loop"))) val findings = LabeledExpression(config).compileAndLint(code) assertThat(findings).isEmpty() @@ -151,7 +151,7 @@ class LabeledExpressionSpec { fun f() { loop@ for (i in 1..5) {} } - """ + """.trimIndent() val config = TestConfig(mapOf("ignoredLabels" to "loop")) val findings = LabeledExpression(config).compileAndLint(code) assertThat(findings).isEmpty() @@ -163,7 +163,7 @@ class LabeledExpressionSpec { fun f() { loop@ for (i in 1..5) {} } - """ + """.trimIndent() val config = TestConfig(mapOf("ignoredLabels" to "*loop*,other")) val findings = LabeledExpression(config).compileAndLint(code) assertThat(findings).isEmpty() diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LargeClassSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LargeClassSpec.kt index 641b90d38ce..a1c6c139845 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LargeClassSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LargeClassSpec.kt @@ -28,7 +28,7 @@ class LargeClassSpec { println() println() } - """ + """.trimIndent() val rule = subject(threshold = 2) assertThat(rule.compileAndLint(code)).isEmpty() } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LongMethodSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LongMethodSpec.kt index e5e521a9350..0aa4d9bdd6a 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LongMethodSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LongMethodSpec.kt @@ -24,7 +24,7 @@ class LongMethodSpec { println() } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(2) @@ -41,7 +41,7 @@ class LongMethodSpec { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -55,7 +55,7 @@ class LongMethodSpec { println() println() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -70,7 +70,7 @@ class LongMethodSpec { println() println() } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -94,7 +94,7 @@ class LongMethodSpec { y2 ) } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -120,7 +120,7 @@ class LongMethodSpec { println() } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -145,7 +145,7 @@ class LongMethodSpec { println() } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LongParameterListSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LongParameterListSpec.kt index 3c2222b606f..5e14b8f8578 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LongParameterListSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LongParameterListSpec.kt @@ -127,7 +127,7 @@ class LongParameterListSpec { annotation class CustomAnnotation class Data constructor(@CustomAnnotation val a: Int) - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).hasSize(1) } @@ -138,7 +138,7 @@ class LongParameterListSpec { annotation class CustomAnnotation class Data { fun foo(@CustomAnnotation a: Int) {} } - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).hasSize(1) } @@ -150,9 +150,11 @@ class LongParameterListSpec { @Test fun `does not report long parameter list for functions if enough function parameters are annotated with ignored annotation`() { - val code = """class Data { - fun foo(@kotlin.Suppress("") a: Int) {} } - """ + val code = """ + class Data { + fun foo(@kotlin.Suppress("") a: Int) {} + } + """.trimIndent() assertThat(rule.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/MethodOverloadingSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/MethodOverloadingSpec.kt index 6473ea4b66f..76eb001cd18 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/MethodOverloadingSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/MethodOverloadingSpec.kt @@ -23,7 +23,7 @@ class MethodOverloadingSpec { fun x(i: Int) {} fun x(i: Int, j: Int) {} } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings[0].message).isEqualTo("The method 'x' is overloaded 3 times.") @@ -35,7 +35,7 @@ class MethodOverloadingSpec { fun x() {} fun x(i: Int) {} fun x(i: Int, j: Int) {} - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -47,7 +47,7 @@ class MethodOverloadingSpec { fun x() { } fun x(i: Int) { } } - """ + """.trimIndent() ) assertThat(subject.findings.size).isZero() } @@ -63,7 +63,7 @@ class MethodOverloadingSpec { fun Boolean.foo() {} fun Int.foo() {} fun Long.foo() {} - """ + """.trimIndent() ) assertThat(subject.findings.size).isZero() } @@ -75,7 +75,7 @@ class MethodOverloadingSpec { fun Int.foo() {} fun Int.foo(i: Int) {} fun Int.foo(i: String) {} - """ + """.trimIndent() ) assertThat(subject.findings.size).isEqualTo(1) } @@ -94,7 +94,7 @@ class MethodOverloadingSpec { fun f(i: Int, j: Int) {} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -110,7 +110,7 @@ class MethodOverloadingSpec { fun f(i: Int, j: Int) {} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } @@ -126,7 +126,7 @@ class MethodOverloadingSpec { fun f(i: Int) {} fun f(i: Int, j: Int) {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -137,7 +137,7 @@ class MethodOverloadingSpec { fun f() {} fun f(i: Int) {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -151,7 +151,7 @@ class MethodOverloadingSpec { fun f(i: Int, j: Int) {} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -164,7 +164,7 @@ class MethodOverloadingSpec { fun f(i: Int) {} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -180,7 +180,7 @@ class MethodOverloadingSpec { fun f(i: Int) {} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -197,7 +197,7 @@ class MethodOverloadingSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } } @@ -221,7 +221,7 @@ class MethodOverloadingSpec { abstract fun f() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -235,7 +235,7 @@ class MethodOverloadingSpec { }; fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -249,7 +249,7 @@ class MethodOverloadingSpec { fun f(i: Int) {} fun f(i: Int, j: Int) {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } } @@ -268,7 +268,7 @@ class MethodOverloadingSpec { fun f(i: Int) {} fun f(i: Int, j: Int) {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NamedArgumentsSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NamedArgumentsSpec.kt index b077cca74f0..f1ca69595c0 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NamedArgumentsSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NamedArgumentsSpec.kt @@ -23,7 +23,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun call() { sum(1, 2, 3) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -37,7 +37,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun call() { sum(a = 1, b = 2, c = 3) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) } @@ -51,7 +51,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun call() { sum(1, b = 2, c = 3) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -65,7 +65,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun call() { sum(1, 2) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) } @@ -79,7 +79,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun call() { sum(a = 1, b = 2) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) } @@ -90,7 +90,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { class C(val a: Int, val b:Int, val c:Int) val obj = C(1, 2, 3) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -101,7 +101,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { class C(val a: Int, val b:Int, val c:Int) val obj = C(a = 1, b = 2, c= 3) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) } @@ -112,7 +112,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { class C(val a: Int, val b:Int) val obj = C(1, 2) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) } @@ -125,7 +125,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun test() { LocalDateTime.of(2020, 3, 13, 14, 0, 0) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) } @@ -139,7 +139,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { foo(1, 2, 3, 4, 5) bar(1, 2, 3, "a") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) } @@ -151,7 +151,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun test() { bar(1, 2, 3, *arrayOf("a")) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -166,7 +166,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun test() { foo(a = 1, b = 2, c = 3, { it }) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -179,7 +179,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun test() { foo(a = 1, b = 2, c = 3) { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) } @@ -192,7 +192,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun test() { foo(a = 1, b = 2, 3) { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -203,7 +203,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun test(n: Int) { require(n == 2) { "N is not 2" } } - """ + """.trimIndent() val subject = NamedArguments(TestConfig(mapOf("threshold" to 1))) val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) @@ -224,7 +224,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun bar(a: Int, b: Int, c: Int) { foo(a, b, c) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) } @@ -236,7 +236,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun bar(a: Int, b: Int, c: Int) { foo(a, c, b) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -251,7 +251,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { foo(a, this.b, c) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -264,7 +264,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun bar(a: Int, c: Int, baz: Baz?) { baz?.let { foo(a, it.b, c) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -279,7 +279,7 @@ class NamedArgumentsSpec(val env: KotlinCoreEnvironment) { fun bar(a: Int, b: Int, c: Int) { foo(a, b, c) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedBlockDepthSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedBlockDepthSpec.kt index 67c9a72926d..e2d06f4e69a 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedBlockDepthSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedBlockDepthSpec.kt @@ -35,7 +35,7 @@ class NestedBlockDepthSpec { } } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) @@ -53,7 +53,7 @@ class NestedBlockDepthSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -69,7 +69,7 @@ class NestedBlockDepthSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -87,7 +87,7 @@ class NestedBlockDepthSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctionsSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctionsSpec.kt index 583ab5dd918..9ba423a7a9a 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctionsSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctionsSpec.kt @@ -31,7 +31,7 @@ class NestedScopeFunctionsSpec(private val env: KotlinCoreEnvironment) { 1.run { } } } - """ + """.trimIndent() whenLintRuns() expectSourceLocation(3 to 11) expectFunctionInMsg("run") @@ -45,7 +45,7 @@ class NestedScopeFunctionsSpec(private val env: KotlinCoreEnvironment) { with(1) { } } } - """ + """.trimIndent() whenLintRuns() expectSourceLocation(3 to 9) expectFunctionInMsg("with") @@ -61,7 +61,7 @@ class NestedScopeFunctionsSpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() whenLintRuns() expectSourceLocation(4 to 13) } @@ -75,7 +75,7 @@ class NestedScopeFunctionsSpec(private val env: KotlinCoreEnvironment) { with(1) { } } } - """ + """.trimIndent() whenLintRuns() expectNoFindings() } @@ -89,7 +89,7 @@ class NestedScopeFunctionsSpec(private val env: KotlinCoreEnvironment) { with(1) {} with(1) {} } - """ + """.trimIndent() whenLintRuns() expectNoFindings() } @@ -102,7 +102,7 @@ class NestedScopeFunctionsSpec(private val env: KotlinCoreEnvironment) { 1.run { } } } - """ + """.trimIndent() whenLintRunsWithoutContext() expectNoFindings() } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ReplaceSafeCallChainWithRunSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ReplaceSafeCallChainWithRunSpec.kt index 9e52b91e6e8..18c2360579c 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ReplaceSafeCallChainWithRunSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ReplaceSafeCallChainWithRunSpec.kt @@ -22,7 +22,7 @@ class ReplaceSafeCallChainWithRunSpec(val env: KotlinCoreEnvironment) { ?.distinctBy { it } ?.iterator() ?.forEach(::println) - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -35,7 +35,7 @@ class ReplaceSafeCallChainWithRunSpec(val env: KotlinCoreEnvironment) { val y = x ?.asSequence() ?.map { it } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -47,7 +47,7 @@ class ReplaceSafeCallChainWithRunSpec(val env: KotlinCoreEnvironment) { val y = x ?.asSequence() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -66,7 +66,7 @@ class ReplaceSafeCallChainWithRunSpec(val env: KotlinCoreEnvironment) { fun modifyList() { z?.element?.list = listOf("strings") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/StringLiteralDuplicationSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/StringLiteralDuplicationSpec.kt index 2f83d9403f4..9d46fce28ec 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/StringLiteralDuplicationSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/StringLiteralDuplicationSpec.kt @@ -28,7 +28,7 @@ class StringLiteralDuplicationSpec { s1.equals("lorem") } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -49,7 +49,7 @@ class StringLiteralDuplicationSpec { class B @Suppress("unused") class C - """ + """.trimIndent() @Test fun `does not report strings in annotations`() { @@ -86,14 +86,14 @@ class StringLiteralDuplicationSpec { val regexTestingCode = """ val str1 = "lorem" + "lorem" + "lorem" val str2 = "ipsum" + "ipsum" + "ipsum" - """ + """.trimIndent() @Test fun `does not report lorem or ipsum according to config in regex`() { val code = """ val str1 = "lorem" + "lorem" + "lorem" val str2 = "ipsum" + "ipsum" + "ipsum" - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_STRINGS_REGEX to "(lorem|ipsum)")) assertFindingWithConfig(code, config, 0) } @@ -129,7 +129,7 @@ class StringLiteralDuplicationSpec { s1.equals("lorem") } } - """ + """.trimIndent() val finding = subject.compileAndLint(code)[0] val locations = finding.references.map { it.location } + finding.entity.location assertThat(locations).hasSize(3) @@ -148,7 +148,7 @@ class StringLiteralDuplicationSpec { | | ""${'"'} - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/TooManyFunctionsSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/TooManyFunctionsSpec.kt index 9cc27a8f1d9..053c03ef7bb 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/TooManyFunctionsSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/TooManyFunctionsSpec.kt @@ -35,7 +35,7 @@ class TooManyFunctionsSpec { class A { fun a() = Unit } - """ + """.trimIndent() val findings = rule.compileAndLint(code) assertThat(findings).hasSize(1) @@ -48,7 +48,7 @@ class TooManyFunctionsSpec { object O { fun o() = Unit } - """ + """.trimIndent() val findings = rule.compileAndLint(code) assertThat(findings).hasSize(1) @@ -61,7 +61,7 @@ class TooManyFunctionsSpec { interface I { fun i() } - """ + """.trimIndent() val findings = rule.compileAndLint(code) assertThat(findings).hasSize(1) @@ -75,7 +75,7 @@ class TooManyFunctionsSpec { A; fun e() {} } - """ + """.trimIndent() val findings = rule.compileAndLint(code) assertThat(findings).hasSize(1) @@ -99,7 +99,7 @@ class TooManyFunctionsSpec { interface I enum class E fun f3() = Unit - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).hasSize(1) } @@ -112,7 +112,7 @@ class TooManyFunctionsSpec { fun a() = Unit } } - """ + """.trimIndent() val findings = rule.compileAndLint(code) assertThat(findings).hasSize(1) @@ -131,7 +131,7 @@ class TooManyFunctionsSpec { fun f() { } } - """ + """.trimIndent() @Test fun `finds all deprecated functions per default`() { @@ -160,7 +160,7 @@ class TooManyFunctionsSpec { class A { private fun f() {} } - """ + """.trimIndent() @Test fun `finds the private function per default`() { @@ -204,7 +204,7 @@ class TooManyFunctionsSpec { override fun a() = Unit override fun b() = Unit } - """ + """.trimIndent() val configuredRule = TooManyFunctions( TestConfig( mapOf( @@ -233,7 +233,7 @@ class TooManyFunctionsSpec { override fun func1() = Unit override fun func2() = Unit } - """ + """.trimIndent() @Test fun `should not report class with overridden functions, if ignoreOverridden is enabled`() { diff --git a/detekt-rules-coroutines/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/InjectDispatcher.kt b/detekt-rules-coroutines/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/InjectDispatcher.kt index a3453a61c1f..48301c29675 100644 --- a/detekt-rules-coroutines/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/InjectDispatcher.kt +++ b/detekt-rules-coroutines/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/InjectDispatcher.kt @@ -13,6 +13,7 @@ import io.gitlab.arturbosch.detekt.api.internal.Configuration import io.gitlab.arturbosch.detekt.api.internal.RequiresTypeResolution import io.gitlab.arturbosch.detekt.rules.fqNameOrNull import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.psi.KtConstructorDelegationCall import org.jetbrains.kotlin.psi.KtParameter import org.jetbrains.kotlin.psi.KtSimpleNameExpression import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType @@ -60,7 +61,8 @@ class InjectDispatcher(config: Config) : Rule(config) { val type = expression.getType(bindingContext) ?: return val isCoroutineDispatcher = type.fqNameOrNull() == COROUTINE_DISPATCHER_FQCN || type.supertypes().any { it.fqNameOrNull() == COROUTINE_DISPATCHER_FQCN } - val isUsedAsParameter = expression.getStrictParentOfType() != null + val isUsedAsParameter = expression.getStrictParentOfType() != null || + expression.getStrictParentOfType() != null if (isCoroutineDispatcher && !isUsedAsParameter) { report( CodeSmell( diff --git a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/GlobalCoroutineUsageSpec.kt b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/GlobalCoroutineUsageSpec.kt index 14bc4921bd0..6d52d4e6461 100644 --- a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/GlobalCoroutineUsageSpec.kt +++ b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/GlobalCoroutineUsageSpec.kt @@ -20,7 +20,7 @@ class GlobalCoroutineUsageSpec { fun foo() { GlobalScope.launch { delay(1_000L) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -35,7 +35,7 @@ class GlobalCoroutineUsageSpec { fun foo() { GlobalScope.async { delay(1_000L) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -50,7 +50,7 @@ class GlobalCoroutineUsageSpec { fun foo() { bar(GlobalScope) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -66,7 +66,7 @@ class GlobalCoroutineUsageSpec { val scope = GlobalScope bar(scope) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/InjectDispatcherSpec.kt b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/InjectDispatcherSpec.kt index 3fcd827dd00..45f03be8395 100644 --- a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/InjectDispatcherSpec.kt +++ b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/InjectDispatcherSpec.kt @@ -29,7 +29,7 @@ class InjectDispatcherSpec(val env: KotlinCoreEnvironment) { launch(Dispatchers.IO) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -46,7 +46,7 @@ class InjectDispatcherSpec(val env: KotlinCoreEnvironment) { launch(dispatcher) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -57,7 +57,20 @@ class InjectDispatcherSpec(val env: KotlinCoreEnvironment) { import kotlinx.coroutines.Dispatchers class MyRepository(dispatcher: CoroutineDispatcher = Dispatchers.IO) - """ + """.trimIndent() + assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() + } + + @Test + fun `does not report when dispatcher is used as a secondary constructor parameter`() { + val code = """ + import kotlinx.coroutines.CoroutineDispatcher + import kotlinx.coroutines.Dispatchers + + class MyRepository(dispatcher: CoroutineDispatcher) { + constructor() : this(Dispatchers.IO) + } + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -68,7 +81,7 @@ class InjectDispatcherSpec(val env: KotlinCoreEnvironment) { import kotlinx.coroutines.Dispatchers class MyRepository(private val dispatcher: CoroutineDispatcher = Dispatchers.IO) - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -84,7 +97,7 @@ class InjectDispatcherSpec(val env: KotlinCoreEnvironment) { launch(Dispatchers.Main) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -106,7 +119,7 @@ class InjectDispatcherSpec(val env: KotlinCoreEnvironment) { launch(Dispatchers.Main) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } diff --git a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/RedundantSuspendModifierSpec.kt b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/RedundantSuspendModifierSpec.kt index 5a32f0325a5..4e49b2e9834 100644 --- a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/RedundantSuspendModifierSpec.kt +++ b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/RedundantSuspendModifierSpec.kt @@ -28,7 +28,7 @@ class RedundantSuspendModifierSpec(val env: KotlinCoreEnvironment) { println("hello world") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -46,7 +46,7 @@ class RedundantSuspendModifierSpec(val env: KotlinCoreEnvironment) { suspend fun doesSuspend() { suspendCoroutine() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -58,7 +58,7 @@ class RedundantSuspendModifierSpec(val env: KotlinCoreEnvironment) { println("hello world") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -68,7 +68,7 @@ class RedundantSuspendModifierSpec(val env: KotlinCoreEnvironment) { interface SuspendInterface { suspend fun empty() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -84,7 +84,7 @@ class RedundantSuspendModifierSpec(val env: KotlinCoreEnvironment) { println("hello world") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -100,7 +100,7 @@ class RedundantSuspendModifierSpec(val env: KotlinCoreEnvironment) { println(x) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -121,7 +121,7 @@ class RedundantSuspendModifierSpec(val env: KotlinCoreEnvironment) { "Hello" } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SleepInsteadOfDelaySpec.kt b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SleepInsteadOfDelaySpec.kt index f8812d315e9..9bf7578339b 100644 --- a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SleepInsteadOfDelaySpec.kt +++ b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SleepInsteadOfDelaySpec.kt @@ -22,7 +22,7 @@ class SleepInsteadOfDelaySpec(val env: KotlinCoreEnvironment) { suspend fun foo() { delay(1000L) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0) } @@ -33,7 +33,7 @@ class SleepInsteadOfDelaySpec(val env: KotlinCoreEnvironment) { suspend fun foo() { Thread.sleep(1000L) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -50,7 +50,7 @@ class SleepInsteadOfDelaySpec(val env: KotlinCoreEnvironment) { Thread.sleep(1000L) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -68,7 +68,7 @@ class SleepInsteadOfDelaySpec(val env: KotlinCoreEnvironment) { Thread.sleep(1000L) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } diff --git a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SuspendFunWithCoroutineScopeReceiverSpec.kt b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SuspendFunWithCoroutineScopeReceiverSpec.kt index 7a7b4287873..f8e1d1529b3 100644 --- a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SuspendFunWithCoroutineScopeReceiverSpec.kt +++ b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SuspendFunWithCoroutineScopeReceiverSpec.kt @@ -28,7 +28,7 @@ class SuspendFunWithCoroutineScopeReceiverSpec(val env: KotlinCoreEnvironment) { delay(timeMillis = 1000) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -42,7 +42,7 @@ class SuspendFunWithCoroutineScopeReceiverSpec(val env: KotlinCoreEnvironment) { delay(timeMillis = 1000) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -57,7 +57,7 @@ class SuspendFunWithCoroutineScopeReceiverSpec(val env: KotlinCoreEnvironment) { delay(timeMillis = 1000) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -75,7 +75,7 @@ class SuspendFunWithCoroutineScopeReceiverSpec(val env: KotlinCoreEnvironment) { delay(timeMillis = 1000) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -91,7 +91,7 @@ class SuspendFunWithCoroutineScopeReceiverSpec(val env: KotlinCoreEnvironment) { delay(timeMillis = 1000) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -107,7 +107,7 @@ class SuspendFunWithCoroutineScopeReceiverSpec(val env: KotlinCoreEnvironment) { delay(timeMillis = 1000) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -123,7 +123,7 @@ class SuspendFunWithCoroutineScopeReceiverSpec(val env: KotlinCoreEnvironment) { delay(timeMillis = this@foo) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -142,7 +142,7 @@ class SuspendFunWithCoroutineScopeReceiverSpec(val env: KotlinCoreEnvironment) { suspend fun CoroutineScope.foo(action: suspend CoroutineScope.() -> Unit) { action() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } diff --git a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SuspendFunWithFlowReturnTypeSpec.kt b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SuspendFunWithFlowReturnTypeSpec.kt index 447e17d38ce..1574867e2ae 100644 --- a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SuspendFunWithFlowReturnTypeSpec.kt +++ b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/SuspendFunWithFlowReturnTypeSpec.kt @@ -35,7 +35,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { yield() return MutableStateFlow(value = 1L) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(3) } @@ -59,7 +59,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { yield() return MutableStateFlow(value = 1L) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(3) } @@ -82,7 +82,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { yield() return kotlinx.coroutines.flow.MutableStateFlow(value = 1L) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(3) } @@ -94,7 +94,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { suspend fun flowValues() = flowOf(1L, 2L, 3L) suspend fun mutableStateFlowValues() = MutableStateFlow(value = 1L) - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -110,7 +110,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { suspend fun stateFlowValues(): StateFlow suspend fun mutableStateFlowValues(): MutableStateFlow } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(3) } @@ -139,7 +139,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { return MutableStateFlow(value = 1L) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(3) } @@ -153,7 +153,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { suspend fun flowValues() = flowOf(1L, 2L, 3L) suspend fun mutableStateFlowValues() = MutableStateFlow(value = 1L) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -180,7 +180,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { yield() return MutableStateFlow(value = this) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(3) } @@ -192,7 +192,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { suspend fun Long.flowValues() = (0..this).asFlow() suspend fun Long.mutableStateFlowValues() = MutableStateFlow(value = this) - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -213,7 +213,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { fun doSomething3(block: suspend () -> MutableStateFlow) { TODO() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -250,7 +250,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { class ValueRepository3 { suspend fun getValue() = 5L.apply { delay(1_000L) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -273,7 +273,7 @@ class SuspendFunWithFlowReturnTypeSpec(val env: KotlinCoreEnvironment) { fun mutableStateFlowValues(): MutableStateFlow { return MutableStateFlow(value = 1L) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentSmellProvider.kt b/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentSmellProvider.kt index 860996b59ca..033bdbdf873 100644 --- a/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentSmellProvider.kt +++ b/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentSmellProvider.kt @@ -19,7 +19,8 @@ class CommentSmellProvider : DefaultRuleSetProvider { listOf( CommentOverPrivateFunction(config), CommentOverPrivateProperty(config), - KDocStyle(config), + DeprecatedBlockTag(config), + EndOfSentenceFormat(config), OutdatedDocumentation(config), UndocumentedPublicClass(config), UndocumentedPublicFunction(config), diff --git a/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocStyle.kt b/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocStyle.kt deleted file mode 100644 index 81d32f57d09..00000000000 --- a/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocStyle.kt +++ /dev/null @@ -1,22 +0,0 @@ -package io.gitlab.arturbosch.detekt.rules.documentation - -import io.gitlab.arturbosch.detekt.api.Config -import org.jetbrains.kotlin.psi.KtDeclaration - -class KDocStyle(config: Config = Config.empty) : - @Suppress("DEPRECATION") - io.gitlab.arturbosch.detekt.api.MultiRule() { - - private val deprecatedBlockTag = DeprecatedBlockTag(config) - private val endOfSentenceFormat = EndOfSentenceFormat(config) - - override val rules = listOf( - deprecatedBlockTag, - endOfSentenceFormat - ) - - override fun visitDeclaration(dcl: KtDeclaration) { - deprecatedBlockTag.visitDeclaration(dcl) - endOfSentenceFormat.visitDeclaration(dcl) - } -} diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/AbsentOrWrongFileLicenseSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/AbsentOrWrongFileLicenseSpec.kt index c34f49370f9..37f8f71ec67 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/AbsentOrWrongFileLicenseSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/AbsentOrWrongFileLicenseSpec.kt @@ -24,7 +24,7 @@ class AbsentOrWrongFileLicenseSpec { """ /* LICENSE */ package cases - """ + """.trimIndent() ) assertThat(findings).isEmpty() @@ -36,7 +36,7 @@ class AbsentOrWrongFileLicenseSpec { """ /* WRONG LICENSE */ package cases - """ + """.trimIndent() ) assertThat(findings).hasSize(1) @@ -47,7 +47,7 @@ class AbsentOrWrongFileLicenseSpec { val findings = checkLicence( """ package cases - """ + """.trimIndent() ) assertThat(findings).hasSize(1) diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivateMethodSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivateMethodSpec.kt index 3351286f9be..35732d501fa 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivateMethodSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivateMethodSpec.kt @@ -16,7 +16,7 @@ class CommentOverPrivateMethodSpec { */ private fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -27,7 +27,7 @@ class CommentOverPrivateMethodSpec { * asdf */ fun f() {} - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -40,7 +40,7 @@ class CommentOverPrivateMethodSpec { */ fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivatePropertiesSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivatePropertiesSpec.kt index ebbe04c800d..25a505741ec 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivatePropertiesSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/CommentOverPrivatePropertiesSpec.kt @@ -14,7 +14,7 @@ class CommentOverPrivatePropertiesSpec { * asdf */ private val v = 1 - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -25,7 +25,7 @@ class CommentOverPrivatePropertiesSpec { * asdf */ val v = 1 - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -38,7 +38,7 @@ class CommentOverPrivatePropertiesSpec { */ private val v = 1 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -51,7 +51,7 @@ class CommentOverPrivatePropertiesSpec { */ val v = 1 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/DeprecatedBlockTagSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/DeprecatedBlockTagSpec.kt index 68e48e4c99c..ed4ee1d757d 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/DeprecatedBlockTagSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/DeprecatedBlockTagSpec.kt @@ -17,7 +17,7 @@ class DeprecatedBlockTagSpec { * Nothing to see here... */ val v = 2 - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(0) } @@ -30,7 +30,7 @@ class DeprecatedBlockTagSpec { * @deprecated oh no, this should not be here */ fun ohNo() { } - """ + """.trimIndent() @Test fun `has found something`() { @@ -58,7 +58,7 @@ class DeprecatedBlockTagSpec { * @deprecated This thing is deprecated */ class Thing { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -73,7 +73,7 @@ class DeprecatedBlockTagSpec { */ val doNotUseMe = 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -86,7 +86,7 @@ class DeprecatedBlockTagSpec { * @deprecated Do not use that */ annotation class Thing() - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -101,7 +101,7 @@ class DeprecatedBlockTagSpec { */ constructor(something: String) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -118,7 +118,7 @@ class DeprecatedBlockTagSpec { */ set(value) { println(value) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -135,7 +135,7 @@ class DeprecatedBlockTagSpec { get() = 10 set(value) { println(value) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -148,7 +148,7 @@ class DeprecatedBlockTagSpec { * @deprecated Do not use this typealias */ typealias VeryString = String - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } } diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt index 8c1c6010954..9bd93405884 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt @@ -13,7 +13,7 @@ class EndOfSentenceFormatSpec { /** Some doc */ class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -23,7 +23,7 @@ class EndOfSentenceFormatSpec { /** Some doc */ fun f(x: Int, y: Int, z: Int) = if (x == 0) y + z else x + y - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -34,7 +34,7 @@ class EndOfSentenceFormatSpec { /** Some doc */ val test = 3 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -43,7 +43,7 @@ class EndOfSentenceFormatSpec { val code = """ /** Some doc */ fun test() = 3 - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -54,7 +54,7 @@ class EndOfSentenceFormatSpec { /** Some doc */ fun test() = 3 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -65,7 +65,7 @@ class EndOfSentenceFormatSpec { /** Some doc-- */ fun test() = 3 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -77,7 +77,7 @@ class EndOfSentenceFormatSpec { */ class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -91,7 +91,7 @@ class EndOfSentenceFormatSpec { */ class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -102,7 +102,7 @@ class EndOfSentenceFormatSpec { */ class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -116,7 +116,7 @@ class EndOfSentenceFormatSpec { */ class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -136,7 +136,7 @@ class EndOfSentenceFormatSpec { */ class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -148,7 +148,7 @@ class EndOfSentenceFormatSpec { */ class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -160,7 +160,7 @@ class EndOfSentenceFormatSpec { */ class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -172,7 +172,7 @@ class EndOfSentenceFormatSpec { */ class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -184,7 +184,7 @@ class EndOfSentenceFormatSpec { */ class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -199,7 +199,7 @@ class EndOfSentenceFormatSpec { http://google.com */ class Test2 { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocReferencesNonPublicPropertySpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocReferencesNonPublicPropertySpec.kt index 27d13aceafd..f33f36c337e 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocReferencesNonPublicPropertySpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocReferencesNonPublicPropertySpec.kt @@ -9,7 +9,7 @@ class KDocReferencesNonPublicPropertySpec { @Test fun `reports referenced non-public properties`() { - val code = """ + val code = """ /** * Comment * [prop1] - non-public property @@ -26,7 +26,7 @@ class KDocReferencesNonPublicPropertySpec { @Test fun `reports referenced non-public properties in private class`() { - val code = """ + val code = """ /** * Comment * [prop1] - non-public property @@ -43,7 +43,7 @@ class KDocReferencesNonPublicPropertySpec { @Test fun `reports referenced non-public properties in nested objects`() { - val code = """ + val code = """ /** * Comment * [prop1] - non-public property @@ -72,7 +72,7 @@ class KDocReferencesNonPublicPropertySpec { @Test fun `does not report properties with no KDoc`() { - val code = """ + val code = """ class Test { private val prop1 = 0 val prop2 = 0 @@ -109,7 +109,7 @@ class KDocReferencesNonPublicPropertySpec { @Test fun `does not report referenced public properties in nested objects`() { - val code = """ + val code = """ /** * Comment * [prop1] - public property diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocStyleSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocStyleSpec.kt deleted file mode 100644 index 70d7d13d33f..00000000000 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/KDocStyleSpec.kt +++ /dev/null @@ -1,19 +0,0 @@ -package io.gitlab.arturbosch.detekt.rules.documentation - -import io.gitlab.arturbosch.detekt.test.compileAndLint -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class KDocStyleSpec { - val subject = KDocStyle() - - @Test - fun `check referenced multi rule to only lint errors once per case does only lint once`() { - val code = """ - /** Some doc */ - class Test { - } - """ - assertThat(subject.compileAndLint(code)).hasSize(1) - } -} diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt index 8a496de44e7..25c75478d01 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt @@ -15,7 +15,7 @@ class OutdatedDocumentationSpec { fun `should not report when doc is missing`() { val withoutDoc = """ class MyClass(someParam: String, val someProp: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(withoutDoc)).isEmpty() } @@ -26,7 +26,7 @@ class OutdatedDocumentationSpec { * Some class description without referring to tags or properties */ class MyClass(someParam: String, val someProp: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(docWithoutParamAndPropertyTags)).isEmpty() } } @@ -40,7 +40,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ class MyClass(someParam: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(correctParam)).isEmpty() } @@ -51,7 +51,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ class MyClass(otherParam: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectParamName)).hasSize(1) } @@ -63,7 +63,7 @@ class OutdatedDocumentationSpec { * @param someSecondParam Description of param */ class MyClass(someParam: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectListOfParams)).hasSize(1) } @@ -75,7 +75,7 @@ class OutdatedDocumentationSpec { * @param otherParam Description of param */ class MyClass(otherParam: String, someParam: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectParamOrder)).hasSize(1) } @@ -87,7 +87,7 @@ class OutdatedDocumentationSpec { * @property someProp Description of property */ class MyClass(someParam: String, val someProp: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(correctParamAndProp)).isEmpty() } @@ -99,7 +99,7 @@ class OutdatedDocumentationSpec { * @property someProp Description of property */ class MyClass(someParam: String, val otherProp: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(correctParamIncorrectProp)).hasSize(1) } @@ -111,7 +111,7 @@ class OutdatedDocumentationSpec { * @property someProp Description of property */ class MyClass(otherParam: String, val someProp: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectParamCorrectProp)).hasSize(1) } @@ -124,7 +124,7 @@ class OutdatedDocumentationSpec { */ constructor(otherParam: String) } - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectConstructorDoc)).hasSize(1) } @@ -136,7 +136,7 @@ class OutdatedDocumentationSpec { * @param someProp Description of property */ class MyClass(someParam: String, val someProp: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(propertyAsParam)).hasSize(1) } @@ -148,7 +148,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ class MyClass(someParam: String, val someProp: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectDeclarationsOrder)).hasSize(1) } } @@ -164,7 +164,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ class MyClass(someParam: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(correctTypeParam)).isEmpty() } @@ -176,7 +176,7 @@ class OutdatedDocumentationSpec { * @param T Description of type param */ class MyClass - """ + """.trimIndent() assertThat(subject.compileAndLint(correctTypeParam)).isEmpty() } @@ -187,7 +187,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ class MyClass(someParam: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(missingTypeParam)).hasSize(1) } @@ -199,7 +199,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ class MyClass(someParam: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectTypeParamName)).hasSize(1) } @@ -211,7 +211,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ class MyClass(someParam: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectTypeParamList)).hasSize(1) } } @@ -226,7 +226,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ fun myFun(someParam: String) {} - """ + """.trimIndent() assertThat(subject.compileAndLint(correctDoc)).isEmpty() } @@ -237,7 +237,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ fun myFun(otherParam: String) {} - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectParamName)).hasSize(1) } } @@ -253,7 +253,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ fun myFun(someParam: String) {} - """ + """.trimIndent() assertThat(subject.compileAndLint(correctTypeParam)).isEmpty() } @@ -264,7 +264,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ fun myFun(someParam: String) {} - """ + """.trimIndent() assertThat(subject.compileAndLint(missingTypeParam)).hasSize(1) } @@ -276,7 +276,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ fun myFun(someParam: String) {} - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectTypeParamName)).hasSize(1) } @@ -288,7 +288,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ fun myFun(someParam: String) {} - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectTypeParamList)).hasSize(1) } @@ -301,7 +301,7 @@ class OutdatedDocumentationSpec { * @param S Description of type param */ fun myFun(someParam: String) {} - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectTypeParamsOrder)).hasSize(1) } } @@ -321,7 +321,7 @@ class OutdatedDocumentationSpec { */ fun myFun(someParam: String) {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(correctClassWithFunction)).isEmpty() } @@ -345,7 +345,7 @@ class OutdatedDocumentationSpec { */ class MyNestedClass(otherParam: String) } - """ + """.trimIndent() assertThat(subject.compileAndLint(incorrectClassWithTwoIncorrectFunctions)).hasSize(4) } } @@ -362,7 +362,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ class MyClass(someParam: String) - """ + """.trimIndent() assertThat(configuredSubject.compileAndLint(incorrectClassTypeParams)).isEmpty() } @@ -373,7 +373,7 @@ class OutdatedDocumentationSpec { * @param someParam Description of param */ fun myFun(someParam: String) {} - """ + """.trimIndent() assertThat(configuredSubject.compileAndLint(incorrectFunctionTypeParams)).isEmpty() } } @@ -391,7 +391,7 @@ class OutdatedDocumentationSpec { * @param otherParam Description of param */ class MyClass(otherParam: String, someParam: String) - """ + """.trimIndent() assertThat(configuredSubject.compileAndLint(incorrectDeclarationsOrder)).isEmpty() } @@ -405,7 +405,7 @@ class OutdatedDocumentationSpec { * @param T Description of param */ fun myFun(otherParam: String, someParam: String) {} - """ + """.trimIndent() assertThat(configuredSubject.compileAndLint(incorrectDeclarationsOrderWithType)).isEmpty() } } @@ -423,7 +423,7 @@ class OutdatedDocumentationSpec { * @param someProp Description of property */ class MyClass(someParam: String, val someProp: String) - """ + """.trimIndent() assertThat(configuredSubject.compileAndLint(propertyAsParam)).isEmpty() } @@ -435,7 +435,7 @@ class OutdatedDocumentationSpec { * @property someProp Description of property */ class MyClass(someParam: String, val someProp: String) - """ + """.trimIndent() assertThat(configuredSubject.compileAndLint(propertyAsParam)).isEmpty() } } @@ -460,7 +460,7 @@ class OutdatedDocumentationSpec { * @param someProp Description of property */ class MyClass(someParam: String, val someProp: String) - """ + """.trimIndent() assertThat(configuredSubject.compileAndLint(propertyAsParam)).isEmpty() } @@ -472,7 +472,7 @@ class OutdatedDocumentationSpec { * @property someProp Description of property */ class MyClass(someParam: String, val someProp: String) - """ + """.trimIndent() assertThat(configuredSubject.compileAndLint(propertyAsParam)).isEmpty() } } diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicClassSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicClassSpec.kt index 9cd06e0c8e8..589d87c01e3 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicClassSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicClassSpec.kt @@ -19,42 +19,42 @@ class UndocumentedPublicClassSpec { class TestInner { inner class Inner } - """ + """.trimIndent() val innerObject = """ /** Some doc */ class TestInner { object Inner } - """ + """.trimIndent() val innerInterface = """ /** Some doc */ class TestInner { interface Something } - """ + """.trimIndent() val nested = """ /** Some doc */ class TestNested { class Nested } - """ + """.trimIndent() val nestedPublic = """ /** Some doc */ class TestNested { public class Nested } - """ + """.trimIndent() val nestedPrivate = """ /** Some doc */ class TestNested { private class Nested } - """ + """.trimIndent() val privateClass = "private class TestNested {}" val internalClass = "internal class TestNested {}" @@ -141,7 +141,7 @@ class UndocumentedPublicClassSpec { class Nested inner class Inner } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -151,7 +151,7 @@ class UndocumentedPublicClassSpec { internal class Outer { interface Inner } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -161,7 +161,7 @@ class UndocumentedPublicClassSpec { internal class Outer { object Inner } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -181,7 +181,7 @@ class UndocumentedPublicClassSpec { fun main(args: Array) { } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -194,7 +194,7 @@ class UndocumentedPublicClassSpec { override fun next() = 1 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -204,7 +204,7 @@ class UndocumentedPublicClassSpec { enum class Enum { CONSTANT } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -215,7 +215,7 @@ class UndocumentedPublicClassSpec { enum class Enum { CONSTANT } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -231,7 +231,7 @@ class UndocumentedPublicClassSpec { */ fun onComplete() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -240,7 +240,7 @@ class UndocumentedPublicClassSpec { val code = """ protected class Test { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -249,7 +249,7 @@ class UndocumentedPublicClassSpec { val code = """ protected class Test { } - """ + """.trimIndent() val subject = UndocumentedPublicClass(TestConfig(mapOf(SEARCH_IN_PROTECTED_CLASS to "true"))) assertThat(subject.compileAndLint(code)).hasSize(1) } diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicFunctionSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicFunctionSpec.kt index 39f4167ff10..0c767ac406d 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicFunctionSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicFunctionSpec.kt @@ -15,7 +15,7 @@ class UndocumentedPublicFunctionSpec { fun `reports undocumented public functions`() { val code = """ fun noComment1() {} - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -25,7 +25,7 @@ class UndocumentedPublicFunctionSpec { object Test { fun noComment1() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -37,7 +37,7 @@ class UndocumentedPublicFunctionSpec { fun noComment1() {} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -50,7 +50,7 @@ class UndocumentedPublicFunctionSpec { public fun noComment2() {} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -60,7 +60,7 @@ class UndocumentedPublicFunctionSpec { interface Test { fun noComment1() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -71,7 +71,7 @@ class UndocumentedPublicFunctionSpec { * Comment */ fun commented1() {} - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -84,7 +84,7 @@ class UndocumentedPublicFunctionSpec { */ fun commented() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -95,7 +95,7 @@ class UndocumentedPublicFunctionSpec { internal fun no1(){} private fun no2(){} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -108,7 +108,7 @@ class UndocumentedPublicFunctionSpec { fun commented() { fun iDontNeedDoc() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -119,7 +119,7 @@ class UndocumentedPublicFunctionSpec { fun nope1() {} public fun nope2() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -130,7 +130,7 @@ class UndocumentedPublicFunctionSpec { fun nope1() {} public fun nope2() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -140,7 +140,7 @@ class UndocumentedPublicFunctionSpec { private object Test { fun noComment1() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -150,7 +150,7 @@ class UndocumentedPublicFunctionSpec { open class Test { protected fun noComment1() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -160,7 +160,7 @@ class UndocumentedPublicFunctionSpec { open class Test { protected fun noComment1() {} } - """ + """.trimIndent() val subject = UndocumentedPublicFunction(TestConfig(mapOf(SEARCH_PROTECTED_FUN to "true"))) assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -176,7 +176,7 @@ class UndocumentedPublicFunctionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -191,7 +191,7 @@ class UndocumentedPublicFunctionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -204,7 +204,7 @@ class UndocumentedPublicFunctionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicPropertySpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicPropertySpec.kt index 1e5fbe9bbbe..7d473dde730 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicPropertySpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/UndocumentedPublicPropertySpec.kt @@ -23,7 +23,7 @@ class UndocumentedPublicPropertySpec { object Test { val a = 1 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -35,7 +35,7 @@ class UndocumentedPublicPropertySpec { val a = 1 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -48,7 +48,7 @@ class UndocumentedPublicPropertySpec { public val b = 1 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -58,7 +58,7 @@ class UndocumentedPublicPropertySpec { interface Test { val a: Int } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -81,7 +81,7 @@ class UndocumentedPublicPropertySpec { * Comment */ val a = 1 - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -94,7 +94,7 @@ class UndocumentedPublicPropertySpec { */ val a = 1 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -111,7 +111,7 @@ class UndocumentedPublicPropertySpec { class Test : I { override val a = 1 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -122,7 +122,7 @@ class UndocumentedPublicPropertySpec { internal val a = 1 private val b = 1 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -132,7 +132,7 @@ class UndocumentedPublicPropertySpec { fun commented(x: Int) { var a = x } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -143,7 +143,7 @@ class UndocumentedPublicPropertySpec { public val a = 1 val b = 1 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -154,7 +154,7 @@ class UndocumentedPublicPropertySpec { public val a = 1 val b = 1 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -164,7 +164,7 @@ class UndocumentedPublicPropertySpec { class Test() { constructor(a: Int) : this() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -173,7 +173,7 @@ class UndocumentedPublicPropertySpec { val code = """ class Test1(internal val a: Int) class Test2(b: Int) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -202,7 +202,7 @@ class UndocumentedPublicPropertySpec { */ val e: Int ) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -212,7 +212,7 @@ class UndocumentedPublicPropertySpec { private object Test { val a = 1 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -222,7 +222,7 @@ class UndocumentedPublicPropertySpec { open class Test { protected val a = 1 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -232,7 +232,7 @@ class UndocumentedPublicPropertySpec { open class Test { protected val a = 1 } - """ + """.trimIndent() val subject = UndocumentedPublicProperty(TestConfig(mapOf(SEARCH_PROTECTED_PROPERTY to "true"))) assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -252,7 +252,7 @@ class UndocumentedPublicPropertySpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -264,7 +264,7 @@ class UndocumentedPublicPropertySpec { val i = 0 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -276,7 +276,7 @@ class UndocumentedPublicPropertySpec { val i = 0 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -288,7 +288,7 @@ class UndocumentedPublicPropertySpec { val i = 0 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -300,7 +300,7 @@ class UndocumentedPublicPropertySpec { val i = 0 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } @@ -316,7 +316,7 @@ class UndocumentedPublicPropertySpec { class InnerInner(val c: Int) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(3) } @@ -326,7 +326,7 @@ class UndocumentedPublicPropertySpec { class Outer(val a: Int) { inner class Inner(val b: Int) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -336,7 +336,7 @@ class UndocumentedPublicPropertySpec { object Outer { class Inner(val a: Int) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -346,7 +346,7 @@ class UndocumentedPublicPropertySpec { internal class Outer(val a: Int) { class Inner(val b: Int) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -356,7 +356,7 @@ class UndocumentedPublicPropertySpec { internal class Outer(val a: Int) { inner class Inner(val b: Int) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-empty/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyBlocks.kt b/detekt-rules-empty/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyBlocks.kt deleted file mode 100644 index 76eff32f101..00000000000 --- a/detekt-rules-empty/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyBlocks.kt +++ /dev/null @@ -1,139 +0,0 @@ -package io.gitlab.arturbosch.detekt.rules.empty - -import io.gitlab.arturbosch.detekt.api.Config -import io.gitlab.arturbosch.detekt.api.Rule -import io.gitlab.arturbosch.detekt.api.internal.ActiveByDefault -import org.jetbrains.kotlin.psi.KtCatchClause -import org.jetbrains.kotlin.psi.KtClassInitializer -import org.jetbrains.kotlin.psi.KtClassOrObject -import org.jetbrains.kotlin.psi.KtDoWhileExpression -import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.psi.KtFinallySection -import org.jetbrains.kotlin.psi.KtForExpression -import org.jetbrains.kotlin.psi.KtIfExpression -import org.jetbrains.kotlin.psi.KtNamedFunction -import org.jetbrains.kotlin.psi.KtPrimaryConstructor -import org.jetbrains.kotlin.psi.KtSecondaryConstructor -import org.jetbrains.kotlin.psi.KtTryExpression -import org.jetbrains.kotlin.psi.KtWhenExpression -import org.jetbrains.kotlin.psi.KtWhileExpression - -/** - * - * - * // unnecessary empty blocks should be removed - * fun unnecessaryFunction() { - * } - * - */ -@Suppress("TooManyFunctions") -@ActiveByDefault(since = "1.0.0") -class EmptyBlocks(val config: Config = Config.empty) : - @Suppress("DEPRECATION") - io.gitlab.arturbosch.detekt.api.MultiRule() { - - private val emptyCatchBlock = EmptyCatchBlock(config) - private val emptyClassBlock = EmptyClassBlock(config) - private val emptyDefaultConstructor = EmptyDefaultConstructor(config) - private val emptyDoWhileBlock = EmptyDoWhileBlock(config) - private val emptyElseBlock = EmptyElseBlock(config) - private val emptyFinallyBlock = EmptyFinallyBlock(config) - private val emptyForBlock = EmptyForBlock(config) - private val emptyFunctionBlock = EmptyFunctionBlock(config) - private val emptyIfBlock = EmptyIfBlock(config) - private val emptyInitBlock = EmptyInitBlock(config) - private val emptyKtFile = EmptyKtFile(config) - private val emptySecondaryConstructorBlock = EmptySecondaryConstructor(config) - private val emptyTryBlock = EmptyTryBlock(config) - private val emptyWhenBlock = EmptyWhenBlock(config) - private val emptyWhileBlock = EmptyWhileBlock(config) - - override val rules: List = listOf( - emptyCatchBlock, - emptyClassBlock, - emptyDefaultConstructor, - emptyDoWhileBlock, - emptyElseBlock, - emptyFinallyBlock, - emptyForBlock, - emptyFunctionBlock, - emptyIfBlock, - emptyInitBlock, - emptyKtFile, - emptySecondaryConstructorBlock, - emptyTryBlock, - emptyWhenBlock, - emptyWhileBlock - ) - - override fun visitKtFile(file: KtFile) { - emptyKtFile.runIfActive { visitFile(file) } - emptyClassBlock.runIfActive { - file.declarations.filterIsInstance().forEach { - visitClassOrObject(it) - } - } - super.visitKtFile(file) - } - - override fun visitTryExpression(expression: KtTryExpression) { - emptyTryBlock.runIfActive { visitTryExpression(expression) } - super.visitTryExpression(expression) - } - - override fun visitCatchSection(catchClause: KtCatchClause) { - emptyCatchBlock.runIfActive { visitCatchSection(catchClause) } - super.visitCatchSection(catchClause) - } - - override fun visitPrimaryConstructor(constructor: KtPrimaryConstructor) { - emptyDefaultConstructor.runIfActive { visitPrimaryConstructor(constructor) } - super.visitPrimaryConstructor(constructor) - } - - override fun visitDoWhileExpression(expression: KtDoWhileExpression) { - emptyDoWhileBlock.runIfActive { visitDoWhileExpression(expression) } - super.visitDoWhileExpression(expression) - } - - override fun visitIfExpression(expression: KtIfExpression) { - emptyIfBlock.runIfActive { visitIfExpression(expression) } - emptyElseBlock.runIfActive { visitIfExpression(expression) } - super.visitIfExpression(expression) - } - - override fun visitFinallySection(finallySection: KtFinallySection) { - emptyFinallyBlock.runIfActive { visitFinallySection(finallySection) } - super.visitFinallySection(finallySection) - } - - override fun visitForExpression(expression: KtForExpression) { - emptyForBlock.runIfActive { visitForExpression(expression) } - super.visitForExpression(expression) - } - - override fun visitNamedFunction(function: KtNamedFunction) { - emptyFunctionBlock.runIfActive { visitNamedFunction(function) } - super.visitNamedFunction(function) - } - - override fun visitClassInitializer(initializer: KtClassInitializer) { - emptyInitBlock.runIfActive { visitClassInitializer(initializer) } - super.visitClassInitializer(initializer) - } - - override fun visitSecondaryConstructor(constructor: KtSecondaryConstructor) { - emptySecondaryConstructorBlock.runIfActive { visitSecondaryConstructor(constructor) } - super.visitSecondaryConstructor(constructor) - } - - override fun visitWhenExpression(expression: KtWhenExpression) { - emptyWhenBlock.runIfActive { visitWhenExpression(expression) } - super.visitWhenExpression(expression) - } - - override fun visitWhileExpression(expression: KtWhileExpression) { - emptyWhileBlock.runIfActive { visitWhileExpression(expression) } - super.visitWhileExpression(expression) - } -} diff --git a/detekt-rules-empty/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCodeProvider.kt b/detekt-rules-empty/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCodeProvider.kt index 66149502337..ad5b8c87137 100644 --- a/detekt-rules-empty/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCodeProvider.kt +++ b/detekt-rules-empty/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCodeProvider.kt @@ -17,7 +17,21 @@ class EmptyCodeProvider : DefaultRuleSetProvider { override fun instance(config: Config): RuleSet = RuleSet( ruleSetId, listOf( - EmptyBlocks(config) + EmptyCatchBlock(config), + EmptyClassBlock(config), + EmptyDefaultConstructor(config), + EmptyDoWhileBlock(config), + EmptyElseBlock(config), + EmptyFinallyBlock(config), + EmptyForBlock(config), + EmptyFunctionBlock(config), + EmptyIfBlock(config), + EmptyInitBlock(config), + EmptyKtFile(config), + EmptySecondaryConstructor(config), + EmptyTryBlock(config), + EmptyWhenBlock(config), + EmptyWhileBlock(config), ) ) } diff --git a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyBlocksMultiRuleSpec.kt b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyBlocksMultiRuleSpec.kt deleted file mode 100644 index ee861bfc955..00000000000 --- a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyBlocksMultiRuleSpec.kt +++ /dev/null @@ -1,64 +0,0 @@ -package io.gitlab.arturbosch.detekt.rules.empty - -import io.github.detekt.test.utils.compileForTest -import io.github.detekt.test.utils.resourceAsPath -import io.gitlab.arturbosch.detekt.test.compileAndLint -import io.gitlab.arturbosch.detekt.test.lint -import io.gitlab.arturbosch.detekt.test.yamlConfig -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class EmptyBlocksMultiRuleSpec { - - private val file = compileForTest(resourceAsPath("Empty.kt")) - - private lateinit var subject: EmptyBlocks - - @BeforeEach - fun createSubject() { - subject = EmptyBlocks() - } - - @Test - fun `should report one finding per rule`() { - val findings = subject.lint(file) - // -1 because the empty kt file rule doesn't get triggered in the 'Empty' test file - val rulesSize = subject.rules.size - 1 - assertThat(findings).hasSize(rulesSize) - } - - @Test - fun `should not report any as all empty block rules are deactivated`() { - val config = yamlConfig("deactivated-empty-blocks.yml") - val ruleSet = EmptyCodeProvider().instance(config) - - @Suppress("DEPRECATION") - val findings = ruleSet.accept(file) - - assertThat(findings).isEmpty() - } - - @Test - fun `reports an empty kt file`() { - assertThat(subject.compileAndLint("")).hasSize(1) - } - - @Test - fun `reports no duplicated findings - issue #1605`() { - val findings = subject.compileAndLint( - """ - class EmptyBlocks { - class EmptyClass {} - fun exceptionHandling() { - try { - println() - } finally { - } - } - } - """ - ) - assertThat(findings).hasSize(2) - } -} diff --git a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyClassBlockSpec.kt b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyClassBlockSpec.kt index 68c2ff8427d..069f4d89066 100644 --- a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyClassBlockSpec.kt +++ b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyClassBlockSpec.kt @@ -21,7 +21,7 @@ class EmptyClassBlockSpec { class SomeClass { // Some comment to explain what this class is supposed to do } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -33,7 +33,7 @@ class EmptyClassBlockSpec { Some comment to explain what this class is supposed to do */ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -43,7 +43,7 @@ class EmptyClassBlockSpec { class SomeClass { class EmptyClass {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -63,7 +63,7 @@ class EmptyClassBlockSpec { fun f() { object : Open() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCodeSpec.kt b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCodeSpec.kt index 8cd9654493f..6ab7201bf02 100644 --- a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCodeSpec.kt +++ b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyCodeSpec.kt @@ -22,7 +22,7 @@ class EmptyCodeSpec { } catch (foo: Exception) { } } - """ + """.trimIndent() @Test fun `findsEmptyCatch`() { @@ -40,7 +40,7 @@ class EmptyCodeSpec { } } } - """ + """.trimIndent() assertThat(EmptyCatchBlock(Config.empty).compileAndLint(code)).hasSize(1) } @@ -53,7 +53,7 @@ class EmptyCodeSpec { } catch (expected: Exception) { } } - """ + """.trimIndent() assertThat(EmptyCatchBlock(Config.empty).compileAndLint(code)).isEmpty() } @@ -65,7 +65,7 @@ class EmptyCodeSpec { } catch (foo: Exception) { } } - """ + """.trimIndent() val config = TestConfig(mapOf(ALLOWED_EXCEPTION_NAME_REGEX to "foo")) assertThat(EmptyCatchBlock(config).compileAndLint(code)).isEmpty() } @@ -130,6 +130,12 @@ class EmptyCodeSpec { test { EmptySecondaryConstructor(Config.empty) } } + @Test + fun `reports an empty kt file`() { + val rule = EmptyKtFile(Config.empty) + assertThat(rule.compileAndLint("")).hasSize(1) + } + @Test fun `doesNotFailWithInvalidRegexWhenDisabled`() { val configValues = mapOf( diff --git a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyDefaultConstructorSpec.kt b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyDefaultConstructorSpec.kt index 353e3df55cd..a5dea64f37c 100644 --- a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyDefaultConstructorSpec.kt +++ b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyDefaultConstructorSpec.kt @@ -12,7 +12,7 @@ internal class EmptyDefaultConstructorSpec { fun `EmptyConstructor`() { val code = """ class EmptyConstructor() - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).compileAndLint(code)).hasSize(1) } @@ -20,7 +20,7 @@ internal class EmptyDefaultConstructorSpec { fun `EmptyPrimaryConstructor`() { val code = """ class EmptyPrimaryConstructor constructor() - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).compileAndLint(code)).hasSize(1) } @@ -28,7 +28,7 @@ internal class EmptyDefaultConstructorSpec { fun `EmptyPublicPrimaryConstructor`() { val code = """ class EmptyPublicPrimaryConstructor public constructor() - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).compileAndLint(code)).hasSize(1) } @@ -36,7 +36,7 @@ internal class EmptyDefaultConstructorSpec { fun `PrimaryConstructorWithParameter`() { val code = """ class PrimaryConstructorWithParameter constructor(x: Int) - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).compileAndLint(code)).isEmpty() } @@ -44,7 +44,7 @@ internal class EmptyDefaultConstructorSpec { fun `PrimaryConstructorWithAnnotation`() { val code = """ class PrimaryConstructorWithAnnotation @SafeVarargs constructor() - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).compileAndLint(code)).isEmpty() } @@ -52,7 +52,7 @@ internal class EmptyDefaultConstructorSpec { fun `PrivatePrimaryConstructor`() { val code = """ class PrivatePrimaryConstructor private constructor() - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).compileAndLint(code)).isEmpty() } @@ -63,7 +63,7 @@ internal class EmptyDefaultConstructorSpec { constructor(i: Int) : this() } - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).compileAndLint(code)).isEmpty() } @@ -71,7 +71,7 @@ internal class EmptyDefaultConstructorSpec { fun `should not report empty constructors for classes with expect keyword - #1362`() { val code = """ expect class NeedsConstructor() - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).lint(code)).isEmpty() } @@ -79,7 +79,7 @@ internal class EmptyDefaultConstructorSpec { fun `should not report empty constructors for classes with actual - #1362`() { val code = """ actual class NeedsConstructor actual constructor() - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).lint(code)).isEmpty() } @@ -87,7 +87,7 @@ internal class EmptyDefaultConstructorSpec { fun `should not report empty constructors for annotation classes with expect keyword - #1362`() { val code = """ expect annotation class NeedsConstructor() - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).lint(code)).isEmpty() } @@ -95,7 +95,7 @@ internal class EmptyDefaultConstructorSpec { fun `should not report empty constructors for annotation classes with actual - #1362`() { val code = """ actual annotation class NeedsConstructor actual constructor() - """ + """.trimIndent() assertThat(EmptyDefaultConstructor(Config.empty).lint(code)).isEmpty() } } diff --git a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyElseBlockSpec.kt b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyElseBlockSpec.kt index cd201e1926e..32e32a54f7a 100644 --- a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyElseBlockSpec.kt +++ b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyElseBlockSpec.kt @@ -20,7 +20,7 @@ class EmptyElseBlockSpec { } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -33,7 +33,7 @@ class EmptyElseBlockSpec { println(i) } else ; } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -48,7 +48,7 @@ class EmptyElseBlockSpec { ; i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -63,7 +63,7 @@ class EmptyElseBlockSpec { } i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -78,7 +78,7 @@ class EmptyElseBlockSpec { i++ } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -91,7 +91,7 @@ class EmptyElseBlockSpec { println(i) } else i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -104,7 +104,7 @@ class EmptyElseBlockSpec { println(i) } else i++; } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyFunctionBlockSpec.kt b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyFunctionBlockSpec.kt index 5254750568f..cc92953c965 100644 --- a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyFunctionBlockSpec.kt +++ b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyFunctionBlockSpec.kt @@ -20,7 +20,7 @@ class EmptyFunctionBlockSpec { class A { protected fun stuff() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasStartSourceLocation(2, 27) } @@ -30,7 +30,7 @@ class EmptyFunctionBlockSpec { open class A { open fun stuff() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -40,7 +40,7 @@ class EmptyFunctionBlockSpec { interface I { fun stuff() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -50,7 +50,7 @@ class EmptyFunctionBlockSpec { fun a() { fun b() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasStartSourceLocation(2, 13) } @@ -79,7 +79,7 @@ class EmptyFunctionBlockSpec { // this is necessary... } } - """ + """.trimIndent() @Test fun `should flag empty block in overridden function`() { @@ -111,7 +111,7 @@ class EmptyFunctionBlockSpec { } } - """ + """.trimIndent() @Test fun `should not flag overridden functions with commented body`() { diff --git a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyIfBlockSpec.kt b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyIfBlockSpec.kt index 6e482dd0d93..d74dfe4c082 100644 --- a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyIfBlockSpec.kt +++ b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyIfBlockSpec.kt @@ -17,7 +17,7 @@ class EmptyIfBlockSpec { if (i == 0); i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -30,7 +30,7 @@ class EmptyIfBlockSpec { ; i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -43,7 +43,7 @@ class EmptyIfBlockSpec { } i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -56,7 +56,7 @@ class EmptyIfBlockSpec { i++ } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -67,7 +67,7 @@ class EmptyIfBlockSpec { var i = 0 if (i == 0) i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -78,7 +78,7 @@ class EmptyIfBlockSpec { var i = 0 if (i == 0) i++; } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -90,7 +90,7 @@ class EmptyIfBlockSpec { if (i == 0) ; else i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -103,7 +103,7 @@ class EmptyIfBlockSpec { else if (i == 1) ; else i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-empty/src/test/resources/deactivated-empty-blocks.yml b/detekt-rules-empty/src/test/resources/deactivated-empty-blocks.yml deleted file mode 100644 index 5e96f722550..00000000000 --- a/detekt-rules-empty/src/test/resources/deactivated-empty-blocks.yml +++ /dev/null @@ -1,30 +0,0 @@ -empty-blocks: - active: true - EmptyCatchBlock: - active: false - EmptyClassBlock: - active: false - EmptyDefaultConstructor: - active: false - EmptyDoWhileBlock: - active: false - EmptyElseBlock: - active: false - EmptyFinallyBlock: - active: false - EmptyForBlock: - active: false - EmptyFunctionBlock: - active: false - EmptyIfBlock: - active: false - EmptyInitBlock: - active: false - EmptyKtFile: - active: false - EmptySecondaryConstructor: - active: false - EmptyWhenBlock: - active: false - EmptyWhileBlock: - active: false diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/CastToNullableTypeSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/CastToNullableTypeSpec.kt index 9be0ba15c30..02e832c6b45 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/CastToNullableTypeSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/CastToNullableTypeSpec.kt @@ -13,7 +13,7 @@ class CastToNullableTypeSpec { fun foo(a: Any?) { val x: String? = a as String? } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(2, 22) @@ -26,7 +26,7 @@ class CastToNullableTypeSpec { fun foo(a: Any?) { val x: String? = a as? String } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).isEmpty() } @@ -37,7 +37,7 @@ class CastToNullableTypeSpec { fun foo(a: Any?) { val x = a is String? } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).isEmpty() } @@ -48,7 +48,7 @@ class CastToNullableTypeSpec { fun foo(a: Any?) { val x = null as String? } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DeprecationSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DeprecationSpec.kt index c1ac16e9dc0..9bfe5ccb97e 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DeprecationSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DeprecationSpec.kt @@ -26,7 +26,7 @@ class DeprecationSpec(private val env: KotlinCoreEnvironment) { fun spam() { } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings.first().message).isEqualTo("Foo is deprecated.") @@ -45,7 +45,7 @@ class DeprecationSpec(private val env: KotlinCoreEnvironment) { fun baz() { } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DontDowncastCollectionTypesSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DontDowncastCollectionTypesSpec.kt index e626491f70c..539b2eddcad 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DontDowncastCollectionTypesSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DontDowncastCollectionTypesSpec.kt @@ -22,7 +22,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myList = listOf(1,2,3) val mutList = myList as MutableList } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -37,7 +37,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myList : List? = null val mutList = myList as? MutableList } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -54,7 +54,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { myList.add(4) } } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -69,7 +69,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val mySet = setOf(1,2,3) val mutSet = mySet as MutableSet } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -84,7 +84,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val mySet : Set? = null val mutSet = mySet as? MutableSet } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -101,7 +101,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { mySet.add(4) } } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -116,7 +116,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myMap = mapOf(1 to 2) val mutMap = myMap as MutableMap } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -131,7 +131,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myMap : Map? = null val mutMap = myMap as? MutableMap } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -148,7 +148,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { myMap[3] = 4 } } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -167,7 +167,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myList = mutableListOf(1,2,3) val mutList = myList as MutableList } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -179,7 +179,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val mySet = mutableSetOf(1,2,3) val mutSet = mySet as MutableSet } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -191,7 +191,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myMap = mutableMapOf(1 to 2) val mutMap = myMap as MutableMap } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -203,7 +203,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { fun main() { val params = tooltip_guide.layoutParams as LayoutParams } - """ + """.trimIndent() val result = subject.lintWithContext(env, code) assertThat(result).isEmpty() } @@ -219,7 +219,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myList = listOf(1,2,3) val mutList = myList as ArrayList } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -234,7 +234,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myList : List? = null val mutList = myList as? ArrayList } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -251,7 +251,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { myList.add(4) } } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -266,7 +266,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val mySet = setOf(1,2,3) val mutSet = mySet as LinkedHashSet } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -281,7 +281,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val mySet : Set? = null val mutSet = mySet as? LinkedHashSet } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -298,7 +298,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { mySet.add(4) } } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -313,7 +313,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val mySet = setOf(1,2,3) val mutSet = mySet as HashSet } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -328,7 +328,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val mySet : Set? = null val mutSet = mySet as? HashSet } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -345,7 +345,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { mySet.add(4) } } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -360,7 +360,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myMap = mapOf(1 to 2) val mutMap = myMap as HashMap } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -375,7 +375,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myMap : Map? = null val mutMap = myMap as? HashMap } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -392,7 +392,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { myMap[3] = 4 } } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -407,7 +407,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myMap = mapOf(1 to 2) val mutMap = myMap as LinkedHashMap } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -422,7 +422,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { val myMap : Map? = null val mutMap = myMap as? LinkedHashMap } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( @@ -439,7 +439,7 @@ class DontDowncastCollectionTypesSpec(private val env: KotlinCoreEnvironment) { myMap[3] = 4 } } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo( diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DoubleMutabilityForCollectionSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DoubleMutabilityForCollectionSpec.kt index d2c201441c7..5ae613c79a3 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DoubleMutabilityForCollectionSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DoubleMutabilityForCollectionSpec.kt @@ -27,7 +27,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myList = mutableListOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -39,7 +39,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var mySet = mutableSetOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -51,7 +51,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myMap = mutableMapOf("answer" to 42) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -63,7 +63,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myArrayList = ArrayList() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -75,7 +75,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myLinkedHashSet = LinkedHashSet() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -87,7 +87,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myHashSet = HashSet() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -99,7 +99,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myLinkedHashMap = LinkedHashMap() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -111,7 +111,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myHashMap = HashMap() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -132,7 +132,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myState = MutableState("foo") } - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(3, 5) @@ -154,7 +154,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myState = mutableStateOf("foo") } - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(4, 5) @@ -177,7 +177,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myState = remember { mutableStateOf("foo") } } - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(5, 5) @@ -193,7 +193,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val myList = mutableListOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -204,7 +204,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val mySet = mutableSetOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -215,7 +215,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val myMap = mutableMapOf("answer" to 42) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -226,7 +226,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val myArrayList = ArrayList() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -237,7 +237,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val myLinkedHashSet = LinkedHashSet() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -248,7 +248,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val myHashSet = HashSet() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -259,7 +259,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val myLinkedHashMap = LinkedHashMap() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -270,7 +270,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val myHashMap = HashMap() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -285,7 +285,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val myList = listOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -296,7 +296,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val mySet = setOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -307,7 +307,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { val myMap = mapOf("answer" to 42) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -337,7 +337,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun main() { var myState by remember { mutableStateOf("foo") } } - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -354,7 +354,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `detects var declaration with mutable list`() { val code = """ var myList = mutableListOf(1,2,3) - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(1, 1) @@ -364,7 +364,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `detects var declaration with mutable set`() { val code = """ var mySet = mutableSetOf(1,2,3) - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(1, 1) @@ -374,7 +374,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `detects var declaration with mutable map`() { val code = """ var myMap = mutableMapOf("answer" to 42) - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(1, 1) @@ -384,7 +384,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `detects var declaration with ArrayList`() { val code = """ var myArrayList = ArrayList() - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(1, 1) @@ -394,7 +394,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `detects var declaration with LinkedHashSet`() { val code = """ var myLinkedHashSet = LinkedHashSet() - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(1, 1) @@ -404,7 +404,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `detects var declaration with HashSet`() { val code = """ var myHashSet = HashSet() - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(1, 1) @@ -414,7 +414,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `detects var declaration with LinkedHashMap`() { val code = """ var myLinkedHashMap = LinkedHashMap() - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(1, 1) @@ -424,7 +424,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `detects var declaration with HashMap`() { val code = """ var myHashMap = HashMap() - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(1, 1) @@ -443,7 +443,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) val code = """ data class MutableState(var state: T) var myState = MutableState("foo") - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 1) @@ -463,7 +463,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) data class MutableState(var state: T) fun mutableStateOf(value: T): MutableState = MutableState(value) var myState = mutableStateOf("foo") - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(3, 1) @@ -484,7 +484,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun mutableStateOf(value: T): MutableState = MutableState(value) fun remember(calculation: () -> T): T = calculation() var myState = remember { mutableStateOf("foo") } - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(4, 1) @@ -498,7 +498,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect val declaration with mutable list`() { val code = """ val myList = mutableListOf(1,2,3) - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -507,7 +507,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect val declaration with mutable set`() { val code = """ val mySet = mutableSetOf(1,2,3) - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -516,7 +516,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect val declaration with mutable map`() { val code = """ val myMap = mutableMapOf("answer" to 42) - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -525,7 +525,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect val declaration with ArrayList`() { val code = """ val myArrayList = ArrayList() - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -534,7 +534,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect val declaration with LinkedHashSet`() { val code = """ val myLinkedHashSet = LinkedHashSet() - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -543,7 +543,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect val declaration with HashSet`() { val code = """ val myHashSet = HashSet() - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -552,7 +552,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect val declaration with LinkedHashMap`() { val code = """ val myLinkedHashMap = LinkedHashMap() - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -561,7 +561,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect val declaration with HashMap`() { val code = """ val myHashMap = HashMap() - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -574,7 +574,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect var declaration with immutable list`() { val code = """ val myList = listOf(1,2,3) - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -583,7 +583,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect var declaration with immutable set`() { val code = """ val mySet = setOf(1,2,3) - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -592,7 +592,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) fun `does not detect var declaration with immutable map`() { val code = """ val myMap = mapOf("answer" to 42) - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -620,7 +620,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) this.state = value } var myState by remember { mutableStateOf("foo") } - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -639,7 +639,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myOtherList = mutableListOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -651,7 +651,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var mySet = mutableSetOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -663,7 +663,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myMap = mutableMapOf("answer" to 42) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -675,7 +675,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myArrayList = ArrayList() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -687,7 +687,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myLinkedHashSet = LinkedHashSet() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -699,7 +699,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myHashSet = HashSet() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -711,7 +711,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myLinkedHashMap = LinkedHashMap() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -723,7 +723,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myHashMap = HashMap() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(2, 5) @@ -744,7 +744,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myState = MutableState("foo") } - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(3, 5) @@ -766,7 +766,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myState = mutableStateOf("foo") } - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(4, 5) @@ -789,7 +789,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myState = remember { mutableStateOf("foo") } } - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) assertThat(result).hasStartSourceLocation(5, 5) @@ -805,7 +805,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val myList = mutableListOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -816,7 +816,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val mySet = mutableSetOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -827,7 +827,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val myMap = mutableMapOf("answer" to 42) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -838,7 +838,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val myArrayList = ArrayList() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -849,7 +849,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val myLinkedHashSet = LinkedHashSet() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -860,7 +860,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val myHashSet = HashSet() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -871,7 +871,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val myLinkedHashMap = LinkedHashMap() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -882,7 +882,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val myHashMap = HashMap() } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -897,7 +897,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val myList = listOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -908,7 +908,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val mySet = setOf(1,2,3) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -919,7 +919,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { val myMap = mapOf("answer" to 42) } - """ + """.trimIndent() val result = subject.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } @@ -949,7 +949,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) class MyClass { var myState by remember { mutableStateOf("foo") } } - """ + """.trimIndent() val result = rule.compileAndLintWithContext(env, code) assertThat(result).isEmpty() } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DuplicateCaseInWhenExpressionSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DuplicateCaseInWhenExpressionSpec.kt index 14dc5ad18ed..98b945ea714 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DuplicateCaseInWhenExpressionSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DuplicateCaseInWhenExpressionSpec.kt @@ -20,7 +20,7 @@ class DuplicateCaseInWhenExpressionSpec { else -> println() } } - """ + """.trimIndent() val result = subject.compileAndLint(code) assertThat(result).hasSize(1) assertThat(result.first().message).isEqualTo("When expression has multiple case statements for 1; 1, 2.") @@ -35,7 +35,7 @@ class DuplicateCaseInWhenExpressionSpec { else -> println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ElseCaseInsteadOfExhaustiveWhenSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ElseCaseInsteadOfExhaustiveWhenSpec.kt index f503e33ae5c..d7e5f7bd44f 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ElseCaseInsteadOfExhaustiveWhenSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ElseCaseInsteadOfExhaustiveWhenSpec.kt @@ -30,7 +30,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment else -> {} } } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) } @@ -51,7 +51,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment else -> 100 } } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) } @@ -85,7 +85,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment Color.GREEN -> {} } } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } } @@ -108,7 +108,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment else -> {} } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -128,7 +128,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment else -> "other" } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -147,7 +147,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment is Variant.VariantB -> {} } } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } } @@ -170,7 +170,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment else -> {} } } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } @@ -190,7 +190,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment else -> "other" } } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } } @@ -206,7 +206,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment else -> {} } } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) } @@ -221,7 +221,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment else -> 100 } } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) } @@ -240,7 +240,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment false -> 2 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -260,7 +260,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment null -> 100 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -301,7 +301,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment else -> print("x is funny") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/EqualsAlwaysReturnsTrueOrFalseSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/EqualsAlwaysReturnsTrueOrFalseSpec.kt index 8c03ab170f3..48ff2b89f7a 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/EqualsAlwaysReturnsTrueOrFalseSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/EqualsAlwaysReturnsTrueOrFalseSpec.kt @@ -29,7 +29,7 @@ class EqualsAlwaysReturnsTrueOrFalseSpec { return true } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -42,7 +42,7 @@ class EqualsAlwaysReturnsTrueOrFalseSpec { override fun equals(other: Any?): Boolean = (other as? Item)?.text == this.text override fun hashCode(): Int = text.hashCode() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/EqualsWithHashCodeExistSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/EqualsWithHashCodeExistSpec.kt index b423c6c6520..07186677206 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/EqualsWithHashCodeExistSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/EqualsWithHashCodeExistSpec.kt @@ -18,7 +18,7 @@ class EqualsWithHashCodeExistSpec { class A { override fun hashCode(): Int { return super.hashCode() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -28,7 +28,7 @@ class EqualsWithHashCodeExistSpec { class A { override fun equals(other: Any?): Boolean { return super.equals(other) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -39,7 +39,7 @@ class EqualsWithHashCodeExistSpec { fun equals(other: Any?, i: Int): Boolean { return super.equals(other) } override fun hashCode(): Int { return super.hashCode() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -50,7 +50,7 @@ class EqualsWithHashCodeExistSpec { override fun equals(other: Any?): Boolean { return super.equals(other) } fun hashCode(i: Int): Int { return super.hashCode() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -65,7 +65,7 @@ class EqualsWithHashCodeExistSpec { override fun equals(other: Any?, i: Int): Boolean { return super.equals(other) } override fun hashCode(): Int { return super.hashCode() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -80,7 +80,7 @@ class EqualsWithHashCodeExistSpec { override fun equals(other: Any?): Boolean { return super.equals(other) } override fun hashCode(i: Int): Int { return super.hashCode() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -91,7 +91,7 @@ class EqualsWithHashCodeExistSpec { override fun equals(other: Any?): Boolean { return super.equals(other) } override fun hashCode(): Int { return super.hashCode() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -102,7 +102,7 @@ class EqualsWithHashCodeExistSpec { override fun equals(other: kotlin.Any?): Boolean { return super.equals(other) } override fun hashCode(): Int { return super.hashCode() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } @@ -118,7 +118,7 @@ class EqualsWithHashCodeExistSpec { return super.equals(other) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ExitOutsideMainSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ExitOutsideMainSpec.kt index 7ce15c8c363..dcfbeb0a599 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ExitOutsideMainSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ExitOutsideMainSpec.kt @@ -17,7 +17,7 @@ class ExitOutsideMainSpec(private val env: KotlinCoreEnvironment) { fun f() { exitProcess(0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -27,7 +27,7 @@ class ExitOutsideMainSpec(private val env: KotlinCoreEnvironment) { fun f() { System.exit(0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -38,7 +38,7 @@ class ExitOutsideMainSpec(private val env: KotlinCoreEnvironment) { fun main() { exitProcess(0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -48,7 +48,7 @@ class ExitOutsideMainSpec(private val env: KotlinCoreEnvironment) { fun main() { System.exit(0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -61,7 +61,7 @@ class ExitOutsideMainSpec(private val env: KotlinCoreEnvironment) { exitProcess(0) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -73,7 +73,7 @@ class ExitOutsideMainSpec(private val env: KotlinCoreEnvironment) { System.exit(0) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ExplicitGarbageCollectionCallSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ExplicitGarbageCollectionCallSpec.kt index 13b93625d79..131a1ec9629 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ExplicitGarbageCollectionCallSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ExplicitGarbageCollectionCallSpec.kt @@ -16,7 +16,7 @@ class ExplicitGarbageCollectionCallSpec { Runtime.getRuntime().gc() System.runFinalization() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(3) } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/HasPlatformTypeSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/HasPlatformTypeSpec.kt index 81bcb8590be..759a6b6f390 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/HasPlatformTypeSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/HasPlatformTypeSpec.kt @@ -17,7 +17,7 @@ class HasPlatformTypeSpec(private val env: KotlinCoreEnvironment) { class Person { fun apiCall() = System.getProperty("propertyName") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -27,7 +27,7 @@ class HasPlatformTypeSpec(private val env: KotlinCoreEnvironment) { class Person { private fun apiCall() = System.getProperty("propertyName") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -37,7 +37,7 @@ class HasPlatformTypeSpec(private val env: KotlinCoreEnvironment) { class Person { fun apiCall(): String = System.getProperty("propertyName") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -47,7 +47,7 @@ class HasPlatformTypeSpec(private val env: KotlinCoreEnvironment) { class Person { val name = System.getProperty("name") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -57,7 +57,7 @@ class HasPlatformTypeSpec(private val env: KotlinCoreEnvironment) { class Person { private val name = System.getProperty("name") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -67,7 +67,7 @@ class HasPlatformTypeSpec(private val env: KotlinCoreEnvironment) { class Person { val name: String = System.getProperty("name") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValueSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValueSpec.kt index f78eaeff2f0..03d2f7bf591 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValueSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValueSpec.kt @@ -22,7 +22,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun foo() { listOf("hello") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -34,7 +34,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOf("hello") return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -45,7 +45,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun foo() { listOf("hello").isEmpty().not() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -56,7 +56,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun foo() { listOf("hello");println("foo") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -67,7 +67,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun foo() { println("foo");listOf("hello") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -78,7 +78,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun foo() { listOf("hello")//foo } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -90,7 +90,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun foo(input: Int) { input.isTheAnswer() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -110,7 +110,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { var x: List x = listA() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -123,7 +123,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun foo() { noReturnValue() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -136,7 +136,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun f() { if (returnsBoolean()) {} } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -149,7 +149,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun f() { if (42 == returnsInt()) {} } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -162,7 +162,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun f() { println(returnsInt()) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -175,7 +175,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun f() { println(message = returnsInt()) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -197,12 +197,12 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello") println("foo") } - """ + """.trimIndent() val annotationClass = """ package annotation annotation class CheckReturnValue - """ + """.trimIndent() val findings = subject.lintWithContext(env, code, annotationClass) assertThat(findings).hasSize(1) @@ -224,7 +224,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello") return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(9, 5) @@ -245,7 +245,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello").isEmpty().not() return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -269,7 +269,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { .not() return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -291,7 +291,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { .listOfChecked() return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(12, 10) @@ -311,7 +311,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun foo() { listOfChecked("hello");println("foo") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(9, 5) @@ -332,7 +332,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { println("foo");listOfChecked("hello") return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(9, 20) @@ -353,7 +353,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { /* foo */listOfChecked("hello")//foo return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(9, 14) @@ -373,7 +373,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { input.isTheAnswer() return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(8, 11) @@ -395,7 +395,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { x = listOfChecked("hello") return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -414,7 +414,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { noReturnValue() return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -432,7 +432,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun f() { if (returnsBoolean()) {} } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -450,7 +450,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun f() { if (42 == returnsInt()) {} } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -468,7 +468,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun f() { println(returnsInt()) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -486,7 +486,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun f() { println(message = returnsInt()) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -506,7 +506,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { } else { returnsInt() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -527,7 +527,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { returnsInt() 2 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -549,7 +549,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { returnsInt() }.plus(1) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -572,7 +572,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { 2 }.plus(1) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -594,7 +594,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { returnsInt() } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -618,7 +618,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { .print() return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -638,7 +638,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun main() { Assertions().listOfChecked("hello") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -658,7 +658,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun main() { Assertions.listOfChecked("hello") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -680,7 +680,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun main() { Assertions().listOfChecked("hello") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -702,7 +702,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { fun main() { Parent.Child().listOfChecked("hello") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -727,7 +727,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello") return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(8, 5) @@ -748,7 +748,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello") return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -764,7 +764,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello") return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -788,7 +788,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello") return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(9, 5) @@ -804,7 +804,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello") return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(4, 5) @@ -825,7 +825,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello") return 42 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -844,7 +844,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello") return 42 } - """ + """.trimIndent() val rule = IgnoredReturnValue( TestConfig( mapOf( @@ -868,7 +868,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { listOfChecked("hello") return 42 } - """ + """.trimIndent() val rule = IgnoredReturnValue( TestConfig( mapOf( diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ImplicitDefaultLocaleSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ImplicitDefaultLocaleSpec.kt index 2c4d6864423..78529367d99 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ImplicitDefaultLocaleSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ImplicitDefaultLocaleSpec.kt @@ -17,7 +17,7 @@ class ImplicitDefaultLocaleSpec(private val env: KotlinCoreEnvironment) { fun x() { String.format("%d", 1) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -28,7 +28,7 @@ class ImplicitDefaultLocaleSpec(private val env: KotlinCoreEnvironment) { fun x() { String.format(Locale.US, "%d", 1) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -39,7 +39,7 @@ class ImplicitDefaultLocaleSpec(private val env: KotlinCoreEnvironment) { val s = "deadbeef" s.toUpperCase() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -51,7 +51,7 @@ class ImplicitDefaultLocaleSpec(private val env: KotlinCoreEnvironment) { val s = "deadbeef" s.toUpperCase(Locale.US) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -62,7 +62,7 @@ class ImplicitDefaultLocaleSpec(private val env: KotlinCoreEnvironment) { val s = "deadbeef" s.toLowerCase() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -74,7 +74,7 @@ class ImplicitDefaultLocaleSpec(private val env: KotlinCoreEnvironment) { val s = "deadbeef" s.toLowerCase(Locale.US) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -85,7 +85,7 @@ class ImplicitDefaultLocaleSpec(private val env: KotlinCoreEnvironment) { val s: String? = "deadbeef" s?.toUpperCase() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -96,7 +96,7 @@ class ImplicitDefaultLocaleSpec(private val env: KotlinCoreEnvironment) { val s: String? = "deadbeef" s?.toLowerCase() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ImplicitUnitReturnTypeSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ImplicitUnitReturnTypeSpec.kt index e033f226190..26944f273bf 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ImplicitUnitReturnTypeSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ImplicitUnitReturnTypeSpec.kt @@ -18,7 +18,7 @@ class ImplicitUnitReturnTypeSpec(private val env: KotlinCoreEnvironment) { fun errorProneUnit() = println("Hello Unit") fun errorProneUnitWithParam(param: String) = param.run { println(this) } fun String.errorProneUnitWithReceiver() = run { println(this) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) @@ -50,7 +50,7 @@ class ImplicitUnitReturnTypeSpec(private val env: KotlinCoreEnvironment) { fun blockUnitReturn() { println("Hello Unit") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) @@ -61,7 +61,7 @@ class ImplicitUnitReturnTypeSpec(private val env: KotlinCoreEnvironment) { fun `does not report for Unit expression`() { val code = """ fun foo() = Unit - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/InvalidRangeSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/InvalidRangeSpec.kt index a82a73c68ac..fafca6c9518 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/InvalidRangeSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/InvalidRangeSpec.kt @@ -22,7 +22,7 @@ class InvalidRangeSpec { for (i in 2 until 4 step 2) {} for (i in (1+1)..3) { } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -35,7 +35,7 @@ class InvalidRangeSpec { for (i in 2 until 2) { } for (i in 2 until 1 step 2) { } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(4) } @@ -47,7 +47,7 @@ class InvalidRangeSpec { for (i in 2..1) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/LateinitUsageSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/LateinitUsageSpec.kt index 851b0983b43..471c3adef70 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/LateinitUsageSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/LateinitUsageSpec.kt @@ -17,7 +17,7 @@ class LateinitUsageSpec { lateinit var v1: String @SinceKotlin("1.0.0") lateinit var v2: String } - """ + """.trimIndent() @Test fun `should report lateinit usages`() { diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MapGetWithNotNullAssertionOperatorSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MapGetWithNotNullAssertionOperatorSpec.kt index 3039a9dd5d0..8733eb0d641 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MapGetWithNotNullAssertionOperatorSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MapGetWithNotNullAssertionOperatorSpec.kt @@ -18,7 +18,7 @@ class MapGetWithNotNullAssertionOperatorSpec(private val env: KotlinCoreEnvironm val map = emptyMap() val value = map["key"]!! } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -29,7 +29,7 @@ class MapGetWithNotNullAssertionOperatorSpec(private val env: KotlinCoreEnvironm val map = emptyMap() val value = map.get("key")!! } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -40,7 +40,7 @@ class MapGetWithNotNullAssertionOperatorSpec(private val env: KotlinCoreEnvironm val map = emptyMap() map["key"] } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -51,7 +51,7 @@ class MapGetWithNotNullAssertionOperatorSpec(private val env: KotlinCoreEnvironm val map = emptyMap() map.getValue("key") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -62,7 +62,7 @@ class MapGetWithNotNullAssertionOperatorSpec(private val env: KotlinCoreEnvironm val map = emptyMap() map.getOrDefault("key", "") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -73,7 +73,7 @@ class MapGetWithNotNullAssertionOperatorSpec(private val env: KotlinCoreEnvironm val map = emptyMap() map.getOrElse("key", { "" }) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MissingPackageDeclarationSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MissingPackageDeclarationSpec.kt index 9055f94e66d..2f56ab29a81 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MissingPackageDeclarationSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MissingPackageDeclarationSpec.kt @@ -12,7 +12,7 @@ internal class MissingPackageDeclarationSpec { package foo.bar class C - """ + """.trimIndent() val findings = MissingPackageDeclaration().compileAndLint(code) assertThat(findings).isEmpty() diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MissingWhenCaseSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MissingWhenCaseSpec.kt index 1f7ab05aee4..e6fa7ec1752 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MissingWhenCaseSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/MissingWhenCaseSpec.kt @@ -33,7 +33,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { Color.GREEN -> {} } } - """ + """.trimIndent() val actual = subject.lintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().issue.id).isEqualTo("MissingWhenCase") @@ -57,7 +57,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { Color.GREEN -> {} } } - """ + """.trimIndent() val actual = subject.lintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().issue.id).isEqualTo("MissingWhenCase") @@ -82,7 +82,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { Color.RED -> {} } } - """ + """.trimIndent() val actual = subject.lintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().issue.id).isEqualTo("MissingWhenCase") @@ -108,7 +108,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { Color.RED -> {} } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -135,7 +135,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { else -> {} } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -157,7 +157,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { is Variant.VariantB -> {} } } - """ + """.trimIndent() val actual = subject.lintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().issue.id).isEqualTo("MissingWhenCase") @@ -182,7 +182,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { is Variant.VariantC -> {} } } - """ + """.trimIndent() val actual = subject.lintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().issue.id).isEqualTo("MissingWhenCase") @@ -206,7 +206,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { is Variant.VariantB -> {} } } - """ + """.trimIndent() val actual = subject.lintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().issue.id).isEqualTo("MissingWhenCase") @@ -232,7 +232,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { is Variant.VariantC -> {} } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -260,7 +260,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { is Variant.VariantC -> {} } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -301,7 +301,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { else -> print("x is funny") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -331,7 +331,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { else -> {} } } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().issue.id).isEqualTo("MissingWhenCase") @@ -355,7 +355,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { else -> {} } } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().issue.id).isEqualTo("MissingWhenCase") @@ -378,7 +378,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { Color.RED -> {} } } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).isEmpty() } @@ -402,7 +402,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { else -> {} } } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().issue.id).isEqualTo("MissingWhenCase") @@ -425,7 +425,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { is Variant.VariantC -> {} } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -443,7 +443,7 @@ class MissingWhenCaseSpec(private val env: KotlinCoreEnvironment) { else -> print("otherwise") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/NullCheckOnMutablePropertySpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/NullCheckOnMutablePropertySpec.kt index 5f8cd740627..63e1551e3a7 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/NullCheckOnMutablePropertySpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/NullCheckOnMutablePropertySpec.kt @@ -22,7 +22,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -36,7 +36,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -50,7 +50,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -64,7 +64,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -81,7 +81,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -95,7 +95,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -110,7 +110,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -124,7 +124,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -139,7 +139,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -154,7 +154,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -176,7 +176,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { return if (randInt % 2 == 0) randInt else null } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -192,7 +192,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -214,7 +214,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -230,7 +230,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -246,7 +246,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -260,7 +260,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -274,7 +274,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -289,7 +289,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -306,7 +306,7 @@ class NullCheckOnMutablePropertySpec(private val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/NullableToStringCallSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/NullableToStringCallSpec.kt index 4542f6ce73d..e501f35755b 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/NullableToStringCallSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/NullableToStringCallSpec.kt @@ -16,7 +16,7 @@ class NullableToStringCallSpec(private val env: KotlinCoreEnvironment) { fun test(a: Any?) { println(a.toString()) } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().message).isEqualTo("This call 'a.toString()' may return the string \"null\".") @@ -28,7 +28,7 @@ class NullableToStringCallSpec(private val env: KotlinCoreEnvironment) { fun test(a: Any?) { println("${'$'}a") } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().message).isEqualTo("This call '\$a' may return the string \"null\".") @@ -40,7 +40,7 @@ class NullableToStringCallSpec(private val env: KotlinCoreEnvironment) { fun test(a: Any?) { println("${'$'}{a}") } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().message).isEqualTo("This call '\${a}' may return the string \"null\".") @@ -52,7 +52,7 @@ class NullableToStringCallSpec(private val env: KotlinCoreEnvironment) { fun test(a: Any?) { println(${'"'}""${'$'}a""${'"'}) } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().message).isEqualTo("This call '\$a' may return the string \"null\".") @@ -71,7 +71,7 @@ class NullableToStringCallSpec(private val env: KotlinCoreEnvironment) { val y = foo.bar().toString() val z = baz().toString() } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(3) assertThat(actual[0].message).isEqualTo("This call 'foo.a.toString()' may return the string \"null\".") @@ -92,7 +92,7 @@ class NullableToStringCallSpec(private val env: KotlinCoreEnvironment) { val y = "${'$'}{foo.bar()}" val z = "${'$'}{baz()}" } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(3) assertThat(actual[0].message).isEqualTo("This call '\${foo.a}' may return the string \"null\".") @@ -108,7 +108,7 @@ class NullableToStringCallSpec(private val env: KotlinCoreEnvironment) { fun test(foo: Foo?) { val y = "${'$'}{foo?.a}" } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual[0].message).isEqualTo("This call '\${foo?.a}' may return the string \"null\".") @@ -155,7 +155,7 @@ class NullableToStringCallSpec(private val env: KotlinCoreEnvironment) { if (bar == null) return val y = "${'$'}{bar?.a}" } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).isEmpty() } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/RedundantElseInWhenSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/RedundantElseInWhenSpec.kt index decd8dcf3da..e33d2115488 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/RedundantElseInWhenSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/RedundantElseInWhenSpec.kt @@ -31,7 +31,7 @@ class RedundantElseInWhenSpec(private val env: KotlinCoreEnvironment) { else -> {} } } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) } @@ -53,7 +53,7 @@ class RedundantElseInWhenSpec(private val env: KotlinCoreEnvironment) { else -> 100 } } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) } @@ -80,7 +80,7 @@ class RedundantElseInWhenSpec(private val env: KotlinCoreEnvironment) { else -> 100 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -113,7 +113,7 @@ class RedundantElseInWhenSpec(private val env: KotlinCoreEnvironment) { Color.GREEN -> {} } } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } } @@ -137,7 +137,7 @@ class RedundantElseInWhenSpec(private val env: KotlinCoreEnvironment) { else -> {} } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -158,7 +158,7 @@ class RedundantElseInWhenSpec(private val env: KotlinCoreEnvironment) { else -> "other" } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -184,7 +184,7 @@ class RedundantElseInWhenSpec(private val env: KotlinCoreEnvironment) { else -> "other" } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -203,7 +203,7 @@ class RedundantElseInWhenSpec(private val env: KotlinCoreEnvironment) { is Variant.VariantB -> {} } } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } } @@ -244,7 +244,7 @@ class RedundantElseInWhenSpec(private val env: KotlinCoreEnvironment) { else -> print("x is funny") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnconditionalJumpStatementInLoopSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnconditionalJumpStatementInLoopSpec.kt index 6c5c8d7b7ab..c71b48f42da 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnconditionalJumpStatementInLoopSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnconditionalJumpStatementInLoopSpec.kt @@ -13,7 +13,7 @@ class UnconditionalJumpStatementInLoopSpec { fun f() { for (i in 1..2) return } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -23,7 +23,7 @@ class UnconditionalJumpStatementInLoopSpec { fun f() { while (true) { return } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -33,7 +33,7 @@ class UnconditionalJumpStatementInLoopSpec { fun f() { do { return } while(true) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -43,7 +43,7 @@ class UnconditionalJumpStatementInLoopSpec { fun f() { for (i in 1..2) continue } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -53,7 +53,7 @@ class UnconditionalJumpStatementInLoopSpec { fun f() { while (true) { continue } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -63,7 +63,7 @@ class UnconditionalJumpStatementInLoopSpec { fun f() { do { continue } while(true) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -73,7 +73,7 @@ class UnconditionalJumpStatementInLoopSpec { fun f() { for (i in 1..2) break } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -83,7 +83,7 @@ class UnconditionalJumpStatementInLoopSpec { fun f() { while (true) { break } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -93,7 +93,7 @@ class UnconditionalJumpStatementInLoopSpec { fun f() { do { break } while(true) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -107,7 +107,7 @@ class UnconditionalJumpStatementInLoopSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -121,7 +121,7 @@ class UnconditionalJumpStatementInLoopSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -135,7 +135,7 @@ class UnconditionalJumpStatementInLoopSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -150,7 +150,7 @@ class UnconditionalJumpStatementInLoopSpec { if (i > 1) println() else return } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -165,7 +165,7 @@ class UnconditionalJumpStatementInLoopSpec { if (i > 1) println() else continue } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -180,7 +180,7 @@ class UnconditionalJumpStatementInLoopSpec { if (i > 1) println() else break } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -192,7 +192,7 @@ class UnconditionalJumpStatementInLoopSpec { for (i in 1..5) return compute(i) ?: return } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -207,7 +207,7 @@ class UnconditionalJumpStatementInLoopSpec { } return 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -221,7 +221,7 @@ class UnconditionalJumpStatementInLoopSpec { } return 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -236,7 +236,7 @@ class UnconditionalJumpStatementInLoopSpec { } return 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -251,7 +251,7 @@ class UnconditionalJumpStatementInLoopSpec { } return 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -266,7 +266,7 @@ class UnconditionalJumpStatementInLoopSpec { } return 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -279,7 +279,7 @@ class UnconditionalJumpStatementInLoopSpec { compute(i) ?: return } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -292,7 +292,7 @@ class UnconditionalJumpStatementInLoopSpec { compute(i) ?: continue } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -305,7 +305,7 @@ class UnconditionalJumpStatementInLoopSpec { compute(i) ?: break } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -320,7 +320,7 @@ class UnconditionalJumpStatementInLoopSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -347,7 +347,7 @@ class UnconditionalJumpStatementInLoopSpec { } return 0 } - """ + """.trimIndent() ) assertThat(findings).isEmpty() diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnecessaryNotNullOperatorSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnecessaryNotNullOperatorSpec.kt index 9607e63fbb9..4d32dc532e6 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnecessaryNotNullOperatorSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnecessaryNotNullOperatorSpec.kt @@ -19,7 +19,7 @@ class UnnecessaryNotNullOperatorSpec(private val env: KotlinCoreEnvironment) { val code = """ val a = 1 val b = a!! - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasTextLocations(18 to 21) @@ -30,7 +30,7 @@ class UnnecessaryNotNullOperatorSpec(private val env: KotlinCoreEnvironment) { val code = """ val a = 1 val b = a!!.plus(42) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasTextLocations(18 to 21) @@ -41,7 +41,7 @@ class UnnecessaryNotNullOperatorSpec(private val env: KotlinCoreEnvironment) { val code = """ val a = 1 val b = a!!.plus(42)!! - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(2) assertThat(findings).hasTextLocations(18 to 21, 18 to 32) @@ -56,7 +56,7 @@ class UnnecessaryNotNullOperatorSpec(private val env: KotlinCoreEnvironment) { val code = """ val a : Int? = 1 val b = a!! - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnecessarySafeCallSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnecessarySafeCallSpec.kt index 688f61e356e..a419a92198b 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnecessarySafeCallSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnnecessarySafeCallSpec.kt @@ -22,7 +22,7 @@ class UnnecessarySafeCallSpec(private val env: KotlinCoreEnvironment) { val a = 1 val b = a?.toString() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasTextLocations(48 to 61) @@ -35,7 +35,7 @@ class UnnecessarySafeCallSpec(private val env: KotlinCoreEnvironment) { val a = 1 val b = a?.plus(42) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasTextLocations(48 to 59) @@ -48,7 +48,7 @@ class UnnecessarySafeCallSpec(private val env: KotlinCoreEnvironment) { val a = 1 val b = a?.plus(42)?.minus(24) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasTextLocations(48 to 59) @@ -65,7 +65,7 @@ class UnnecessarySafeCallSpec(private val env: KotlinCoreEnvironment) { val a : Int? = 1 val b = a?.plus(42) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -83,7 +83,7 @@ class UnnecessarySafeCallSpec(private val env: KotlinCoreEnvironment) { val a = outside() val b = a?.plus(42) } - """ + """.trimIndent() val findings = subject.lintWithContext(env, code) assertThat(findings).isEmpty() } @@ -97,7 +97,7 @@ class UnnecessarySafeCallSpec(private val env: KotlinCoreEnvironment) { val a : Int? = outside() val b = a?.plus(42) } - """ + """.trimIndent() val findings = subject.lintWithContext(env, code) assertThat(findings).isEmpty() } @@ -111,7 +111,7 @@ class UnnecessarySafeCallSpec(private val env: KotlinCoreEnvironment) { val a : Int = outside() val b = a?.plus(42) } - """ + """.trimIndent() val findings = subject.lintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasTextLocations(103 to 114) diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCatchBlockSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCatchBlockSpec.kt index a9ebdbb393d..ecaced02f25 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCatchBlockSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCatchBlockSpec.kt @@ -20,7 +20,7 @@ class UnreachableCatchBlockSpec(private val env: KotlinCoreEnvironment) { } catch (e: Exception) { } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(4, 7) @@ -35,7 +35,7 @@ class UnreachableCatchBlockSpec(private val env: KotlinCoreEnvironment) { } catch (e: Exception) { } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(4, 7) @@ -51,7 +51,7 @@ class UnreachableCatchBlockSpec(private val env: KotlinCoreEnvironment) { } catch (e: IllegalStateException) { } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(2) assertThat(findings).hasStartSourceLocations( @@ -70,7 +70,7 @@ class UnreachableCatchBlockSpec(private val env: KotlinCoreEnvironment) { } catch (e: RuntimeException) { } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCodeSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCodeSpec.kt index e6ab5a6b553..1860cee13fe 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCodeSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCodeSpec.kt @@ -20,7 +20,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -34,7 +34,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { } return false } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -50,7 +50,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { return@f 1 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -63,7 +63,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -80,7 +80,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -93,7 +93,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -106,7 +106,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { } throw IllegalArgumentException() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -120,7 +120,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { } println() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -135,7 +135,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { } return 0 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -151,7 +151,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { } return 0 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -166,7 +166,7 @@ class UnreachableCodeSpec(private val env: KotlinCoreEnvironment) { } return 0 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnsafeCallOnNullableTypeSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnsafeCallOnNullableTypeSpec.kt index 1b0ef38966e..9fa254e1f91 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnsafeCallOnNullableTypeSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnsafeCallOnNullableTypeSpec.kt @@ -16,7 +16,7 @@ class UnsafeCallOnNullableTypeSpec(private val env: KotlinCoreEnvironment) { fun test(str: String?) { println(str!!.length) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -26,7 +26,7 @@ class UnsafeCallOnNullableTypeSpec(private val env: KotlinCoreEnvironment) { import java.util.UUID val version = UUID.randomUUID()!! - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -36,7 +36,7 @@ class UnsafeCallOnNullableTypeSpec(private val env: KotlinCoreEnvironment) { fun test(str: String?) { println(str?.length) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -46,7 +46,7 @@ class UnsafeCallOnNullableTypeSpec(private val env: KotlinCoreEnvironment) { fun test(str: String?) { println(str?.length ?: 0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnsafeCastSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnsafeCastSpec.kt index f1c4bb6f755..e7c07e2c2ed 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnsafeCastSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnsafeCastSpec.kt @@ -16,7 +16,7 @@ class UnsafeCastSpec(private val env: KotlinCoreEnvironment) { fun test(s: String) { println(s as Int) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -26,7 +26,7 @@ class UnsafeCastSpec(private val env: KotlinCoreEnvironment) { fun test(s: String) { println((s as? Int) ?: 0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -36,7 +36,7 @@ class UnsafeCastSpec(private val env: KotlinCoreEnvironment) { fun test(s: Any) { println(s as Int) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -46,7 +46,7 @@ class UnsafeCastSpec(private val env: KotlinCoreEnvironment) { fun test(s: Any) { println((s as? Int) ?: 0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnusedUnaryOperatorSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnusedUnaryOperatorSpec.kt index 893b23bc3ee..764c721b9c7 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnusedUnaryOperatorSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnusedUnaryOperatorSpec.kt @@ -17,7 +17,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { val x = 1 + 2 + 3 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(3, 9) @@ -31,7 +31,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { val x = 1 + 2 - 3 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(3, 9) @@ -45,7 +45,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { val x = 1 + 2 + 3 + 4 + 5 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0]).hasMessage("This '+ 3 + 4 + 5' is not used") @@ -58,7 +58,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { val x = (1 + 2 + 3 + 4 + 5) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -69,7 +69,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { fun test() { val x = -1 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -80,7 +80,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { fun test(): Int { return -1 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -92,7 +92,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { fun test() { foo(x = -1) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -103,7 +103,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { annotation class Ann(val x: Int) @Ann(x = -1) val y = 2 - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -118,7 +118,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { val p = Foo(1) + Foo(2) - Foo(3) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -134,7 +134,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { 1 } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UselessPostfixExpressionSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UselessPostfixExpressionSpec.kt index 7fe48a5e875..b14e6c23e07 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UselessPostfixExpressionSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UselessPostfixExpressionSpec.kt @@ -20,7 +20,7 @@ class UselessPostfixExpressionSpec { i = 1 + i++ // invalid i = i++ + 1 // invalid } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(3) } @@ -32,7 +32,7 @@ class UselessPostfixExpressionSpec { var j = 0 j = i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -45,7 +45,7 @@ class UselessPostfixExpressionSpec { if (i == 0) return 1 + j++ return i++ } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -69,7 +69,7 @@ class UselessPostfixExpressionSpec { return i++ } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -91,7 +91,7 @@ class UselessPostfixExpressionSpec { return i++ } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } } @@ -111,7 +111,7 @@ class UselessPostfixExpressionSpec { fun f2(): Int { return str!!.count() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -122,7 +122,7 @@ class UselessPostfixExpressionSpec { val str: String? = "" str!! } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/WrongEqualsTypeParameterSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/WrongEqualsTypeParameterSpec.kt index cc0a0acca68..e749c0e59cf 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/WrongEqualsTypeParameterSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/WrongEqualsTypeParameterSpec.kt @@ -16,7 +16,7 @@ class WrongEqualsTypeParameterSpec { return super.equals(other) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -28,7 +28,7 @@ class WrongEqualsTypeParameterSpec { return super.equals(other) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -40,7 +40,7 @@ class WrongEqualsTypeParameterSpec { return super.equals(other) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -59,7 +59,7 @@ class WrongEqualsTypeParameterSpec { override fun equals() = true } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -69,7 +69,7 @@ class WrongEqualsTypeParameterSpec { interface I { fun equals(other: String) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -78,7 +78,7 @@ class WrongEqualsTypeParameterSpec { val code = """ fun equals(other: String) {} fun equals(other: Any?) {} - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ExceptionRaisedInUnexpectedLocationSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ExceptionRaisedInUnexpectedLocationSpec.kt index fd6b9f82c97..edf1ae3c272 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ExceptionRaisedInUnexpectedLocationSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ExceptionRaisedInUnexpectedLocationSpec.kt @@ -30,7 +30,7 @@ class ExceptionRaisedInUnexpectedLocationSpec { fun toDo() { throw IllegalStateException() } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) } @@ -43,7 +43,7 @@ class ExceptionRaisedInUnexpectedLocationSpec { fun toDo() { throw IllegalStateException() } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) } diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/InstanceOfCheckForExceptionSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/InstanceOfCheckForExceptionSpec.kt index a9bf4dc029d..786ec570bcb 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/InstanceOfCheckForExceptionSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/InstanceOfCheckForExceptionSpec.kt @@ -21,7 +21,7 @@ class InstanceOfCheckForExceptionSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -36,7 +36,7 @@ class InstanceOfCheckForExceptionSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -53,7 +53,7 @@ class InstanceOfCheckForExceptionSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -69,7 +69,7 @@ class InstanceOfCheckForExceptionSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/NotImplementedDeclarationSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/NotImplementedDeclarationSpec.kt index 1cb09a0646b..e67ecd28042 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/NotImplementedDeclarationSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/NotImplementedDeclarationSpec.kt @@ -14,7 +14,7 @@ class NotImplementedDeclarationSpec { if (1 == 1) throw NotImplementedError() throw NotImplementedError() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -25,7 +25,7 @@ class NotImplementedDeclarationSpec { TODO("not implemented") TODO() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -35,7 +35,7 @@ class NotImplementedDeclarationSpec { fun f() { // TODO } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ObjectExtendsThrowableSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ObjectExtendsThrowableSpec.kt index 4a6a7747927..45f0105d0b9 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ObjectExtendsThrowableSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ObjectExtendsThrowableSpec.kt @@ -18,7 +18,7 @@ class ObjectExtendsThrowableSpec(val env: KotlinCoreEnvironment) { object AuthException : RuntimeException() object ReportedException : Exception() object FatalException : Error() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(4) } @@ -30,7 +30,7 @@ class ObjectExtendsThrowableSpec(val env: KotlinCoreEnvironment) { class Exception2 : DomainException() object Exception3 : DomainException() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -40,7 +40,7 @@ class ObjectExtendsThrowableSpec(val env: KotlinCoreEnvironment) { object ObjectCustomException : CustomException("singleton custom exception") open class CustomException(message: String) : RuntimeException(message) - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -70,7 +70,7 @@ class ObjectExtendsThrowableSpec(val env: KotlinCoreEnvironment) { const val NAME = "Test 4" } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(4) } @@ -87,7 +87,7 @@ class ObjectExtendsThrowableSpec(val env: KotlinCoreEnvironment) { } open class CustomException(message: String) - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -105,7 +105,7 @@ class ObjectExtendsThrowableSpec(val env: KotlinCoreEnvironment) { const val NAME = "Test 3" } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -125,7 +125,7 @@ class ObjectExtendsThrowableSpec(val env: KotlinCoreEnvironment) { } open class CustomException(message: String) - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -135,7 +135,7 @@ class ObjectExtendsThrowableSpec(val env: KotlinCoreEnvironment) { val exception = object : AbstractCustomException() {} abstract class AbstractCustomException : RuntimeException() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/PrintStackTraceSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/PrintStackTraceSpec.kt index 1b69cc52508..bad4649c062 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/PrintStackTraceSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/PrintStackTraceSpec.kt @@ -20,7 +20,7 @@ class PrintStackTraceSpec { e.printStackTrace() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -36,7 +36,7 @@ class PrintStackTraceSpec { printStackTrace() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } @@ -53,7 +53,7 @@ class PrintStackTraceSpec { fun dumpStack() {} dumpStack() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } } diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/RethrowCaughtExceptionSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/RethrowCaughtExceptionSpec.kt index 3d971d7fcbf..c99aa8086ce 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/RethrowCaughtExceptionSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/RethrowCaughtExceptionSpec.kt @@ -16,7 +16,7 @@ class RethrowCaughtExceptionSpec { throw e } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -32,7 +32,7 @@ class RethrowCaughtExceptionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -46,7 +46,7 @@ class RethrowCaughtExceptionSpec { print("log") } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -62,7 +62,7 @@ class RethrowCaughtExceptionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -75,7 +75,7 @@ class RethrowCaughtExceptionSpec { throw IllegalArgumentException(e) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -90,7 +90,7 @@ class RethrowCaughtExceptionSpec { throw IllegalArgumentException("msg", f) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -106,7 +106,7 @@ class RethrowCaughtExceptionSpec { throw IllegalArgumentException("msg", f) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -125,7 +125,7 @@ class RethrowCaughtExceptionSpec { throw e } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -140,7 +140,7 @@ class RethrowCaughtExceptionSpec { print(e) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -156,7 +156,7 @@ class RethrowCaughtExceptionSpec { throw e } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -168,7 +168,7 @@ class RethrowCaughtExceptionSpec { } finally { } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -183,7 +183,7 @@ class RethrowCaughtExceptionSpec { throw e } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -199,7 +199,7 @@ class RethrowCaughtExceptionSpec { throw e } } - """ + """.trimIndent() val result = subject.compileAndLint(code) assertThat(result).hasSize(2) // ensure correct violation order diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ReturnFromFinallySpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ReturnFromFinallySpec.kt index d66894ae092..40c9fe266ad 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ReturnFromFinallySpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ReturnFromFinallySpec.kt @@ -21,7 +21,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { return } } - """ + """.trimIndent() @Test fun `should report`() { @@ -38,7 +38,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { } finally { } } - """ + """.trimIndent() @Test fun `should not report`() { @@ -58,7 +58,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() @Test fun `should report`() { @@ -79,7 +79,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { y() } } - """ + """.trimIndent() @Test fun `should not report`() { @@ -99,7 +99,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() @Test fun `should report when ignoreLabeled is false`() { @@ -127,7 +127,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { } finally { "finally" } - """ + """.trimIndent() val finding = subject.compileAndLintWithContext(env, code) @@ -147,7 +147,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { } finally { "finally" } - """ + """.trimIndent() val finding = subject.compileAndLintWithContext(env, code) @@ -169,7 +169,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { } fun compute(): String = "value" - """ + """.trimIndent() val finding = subject.compileAndLintWithContext(env, code) @@ -187,7 +187,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { } catch (e: Exception) { "exception" } - """ + """.trimIndent() val finding = subject.compileAndLintWithContext(env, code) @@ -206,7 +206,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { } catch (e: Exception) { "exception" } - """ + """.trimIndent() val finding = subject.compileAndLintWithContext(env, code) @@ -228,7 +228,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { "finally" } } - """ + """.trimIndent() val finding = subject.compileAndLintWithContext(env, code) @@ -248,7 +248,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { } finally { println("finally") } - """ + """.trimIndent() val finding = subject.compileAndLintWithContext(env, code) @@ -270,7 +270,7 @@ class ReturnFromFinallySpec(val env: KotlinCoreEnvironment) { println("finally") property } - """ + """.trimIndent() val finding = subject.compileAndLintWithContext(env, code) diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/SwallowedExceptionSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/SwallowedExceptionSpec.kt index e1b985a6b46..cd6dfbf02e8 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/SwallowedExceptionSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/SwallowedExceptionSpec.kt @@ -20,7 +20,7 @@ class SwallowedExceptionSpec { throw IllegalArgumentException() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -35,7 +35,7 @@ class SwallowedExceptionSpec { throw Exception(IllegalArgumentException(f.toString())) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -52,7 +52,7 @@ class SwallowedExceptionSpec { throw Exception(IllegalArgumentException(message)) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -73,7 +73,7 @@ class SwallowedExceptionSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -90,7 +90,7 @@ class SwallowedExceptionSpec { throw IllegalArgumentException(e) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -107,7 +107,7 @@ class SwallowedExceptionSpec { throw IllegalArgumentException(e.message) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -125,7 +125,7 @@ class SwallowedExceptionSpec { throw IllegalArgumentException(e) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -138,7 +138,7 @@ class SwallowedExceptionSpec { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -159,7 +159,7 @@ class SwallowedExceptionSpec { } catch (e: IllegalArgumentException) { } } - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).isEmpty() } @@ -171,7 +171,7 @@ class SwallowedExceptionSpec { } catch (e: Exception) { } } - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).hasSize(1) } } @@ -193,7 +193,7 @@ class SwallowedExceptionSpec { } catch (e: IllegalArgumentException) { } } - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).isEmpty() } @@ -205,7 +205,7 @@ class SwallowedExceptionSpec { } catch (e: Exception) { } } - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).hasSize(1) } } @@ -224,7 +224,7 @@ class SwallowedExceptionSpec { } catch (myIgnore: IllegalArgumentException) { } } - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).isEmpty() } @@ -236,7 +236,7 @@ class SwallowedExceptionSpec { } catch (e: IllegalArgumentException) { } } - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).hasSize(1) } } @@ -252,7 +252,7 @@ class SwallowedExceptionSpec { throw IllegalArgumentException(e) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -267,7 +267,7 @@ class SwallowedExceptionSpec { print(e.message) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -284,7 +284,7 @@ class SwallowedExceptionSpec { throw Exception() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -307,7 +307,7 @@ class SwallowedExceptionSpec { throw $exceptionInstantiation } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionFromFinallySpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionFromFinallySpec.kt index 9d648bb096f..05d74c863d5 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionFromFinallySpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionFromFinallySpec.kt @@ -18,7 +18,7 @@ class ThrowingExceptionFromFinallySpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -31,7 +31,7 @@ class ThrowingExceptionFromFinallySpec { throw IllegalArgumentException() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -44,7 +44,7 @@ class ThrowingExceptionFromFinallySpec { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionInMainSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionInMainSpec.kt index 7300329b18e..4e611dc3f9c 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionInMainSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionInMainSpec.kt @@ -14,7 +14,7 @@ class ThrowingExceptionInMainSpec { fun main(args: Array) { throw IllegalArgumentException() } fun main(vararg args: String) { throw IllegalArgumentException() } fun main() { throw IllegalArgumentException() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(3) } @@ -39,7 +39,7 @@ class ThrowingExceptionInMainSpec { @JvmStatic fun main(args: Array) { throw IllegalArgumentException() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(3) } @@ -51,7 +51,7 @@ class ThrowingExceptionInMainSpec { fun mai() { throw IllegalArgumentException() } fun main(args: String) { throw IllegalArgumentException() } fun main(args: Array, i: Int) { throw IllegalArgumentException() } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -62,7 +62,7 @@ class ThrowingExceptionInMainSpec { fun main() { } fun mai() { } fun main(args: String) { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -71,7 +71,7 @@ class ThrowingExceptionInMainSpec { val code = """ fun main(args: Array) = "" fun main() = Unit - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -85,7 +85,7 @@ class ThrowingExceptionInMainSpec { fun main(args: Array) { throw IllegalArgumentException() } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionsWithoutMessageOrCauseSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionsWithoutMessageOrCauseSpec.kt index 43c7f1ca0a8..aa6b84c4c4d 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionsWithoutMessageOrCauseSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingExceptionsWithoutMessageOrCauseSpec.kt @@ -21,7 +21,7 @@ class ThrowingExceptionsWithoutMessageOrCauseSpec { IllegalArgumentException("foo") throw IllegalArgumentException() } - """ + """.trimIndent() @Test fun `reports calls to the default constructor`() { @@ -45,7 +45,7 @@ class ThrowingExceptionsWithoutMessageOrCauseSpec { fun test() { org.assertj.core.api.Assertions.assertThatIllegalArgumentException().isThrownBy { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingNewInstanceOfSameExceptionSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingNewInstanceOfSameExceptionSpec.kt index 2df376892ec..00c8b1c8feb 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingNewInstanceOfSameExceptionSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/ThrowingNewInstanceOfSameExceptionSpec.kt @@ -18,7 +18,7 @@ class ThrowingNewInstanceOfSameExceptionSpec { throw IllegalStateException(e) } } - """ + """.trimIndent() @Test fun `should report`() { @@ -36,7 +36,7 @@ class ThrowingNewInstanceOfSameExceptionSpec { throw IllegalArgumentException(e) } } - """ + """.trimIndent() @Test fun `should not report`() { @@ -57,7 +57,7 @@ class ThrowingNewInstanceOfSameExceptionSpec { throw IllegalStateException() } } - """ + """.trimIndent() @Test fun `should not report`() { diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionCaughtSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionCaughtSpec.kt index 25d14435ce4..931b57bee6a 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionCaughtSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionCaughtSpec.kt @@ -40,7 +40,7 @@ class TooGenericExceptionCaughtSpec { throw Error() } } - """ + """.trimIndent() @Test fun `should not report an ignored catch blocks because of its exception name`() { diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionSpec.kt index 8b354f6ccc1..6cc22ded71a 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionSpec.kt @@ -20,7 +20,7 @@ class TooGenericExceptionSpec { } } -const val tooGenericExceptionCode = """ +val tooGenericExceptionCode = """ fun main() { try { throw Throwable() @@ -39,4 +39,4 @@ const val tooGenericExceptionCode = """ } } -""" +""".trimIndent() diff --git a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionThrownSpec.kt b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionThrownSpec.kt index 8d913557e21..d298e21ee49 100644 --- a/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionThrownSpec.kt +++ b/detekt-rules-exceptions/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/exceptions/TooGenericExceptionThrownSpec.kt @@ -45,7 +45,7 @@ class TooGenericExceptionThrownSpec { throw Error() } } - """ + """.trimIndent() val findings = rule.compileAndLint(code) assertThat(findings).isEmpty() diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyNamingSpec.kt index 02da1f4bd87..feefd0690d5 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/BooleanPropertyNamingSpec.kt @@ -31,7 +31,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: Boolean) : Test - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -45,7 +45,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: Boolean) : Test - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to false)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -60,7 +60,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: Boolean) : Test - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to true)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -83,7 +83,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: Boolean?) : Test - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -97,7 +97,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: Boolean?) : Test - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to false)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -112,7 +112,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: Boolean?) : Test - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to true)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -135,7 +135,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: Boolean = false) : Test - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -149,7 +149,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: Boolean = false) : Test - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to false)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -164,7 +164,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: Boolean = false) : Test - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to true)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -187,7 +187,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: java.lang.Boolean) : Test - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -203,7 +203,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override val default: java.lang.Boolean = java.lang.Boolean(true) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -217,7 +217,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: java.lang.Boolean) : Test - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to false)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -232,7 +232,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { } data class TestImpl (override var default: java.lang.Boolean) : Test - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to true)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -264,7 +264,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class Test { var default: Boolean = true } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -280,7 +280,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: Boolean = true } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -292,7 +292,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { object Test { const val CONSTANT_VAL_BOOLEAN = true } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(0) @@ -308,7 +308,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: Boolean = true } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to false)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -325,7 +325,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: Boolean = true } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to true)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -338,7 +338,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class Test { var default: Boolean? = null } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -354,7 +354,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: Boolean? = null } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -370,7 +370,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: Boolean? = null } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to false)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -387,7 +387,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: Boolean? = null } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to true)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -400,7 +400,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class Test { var default: Boolean = false } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -416,7 +416,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: Boolean = false } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -432,7 +432,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: Boolean = false } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to false)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -449,7 +449,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: Boolean = false } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to true)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -462,7 +462,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class Test { var default = true } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -478,7 +478,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default = true } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -494,7 +494,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default = true } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to false)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -511,7 +511,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default = true } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to true)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -524,7 +524,23 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class Test { var default: java.lang.Boolean = java.lang.Boolean(true) } - """ + """.trimIndent() + val findings = subject.compileAndLintWithContext(env, code) + + assertThat(findings).hasSize(1) + } + + @Test + fun `should not warn about Java Boolean override by default`() { + val code = """ + interface Test { + val default: java.lang.Boolean + } + + class TestImpl : Test { + override var default: java.lang.Boolean = java.lang.Boolean(true) + } + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -540,7 +556,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: java.lang.Boolean = java.lang.Boolean(true) } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to false)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -557,7 +573,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class TestImpl : Test { override var default: java.lang.Boolean = java.lang.Boolean(true) } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to true)) val findings = BooleanPropertyNaming(config).compileAndLintWithContext(env, code) @@ -570,7 +586,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class Test { var count: Int = 0 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -583,7 +599,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { var isEnabled: Boolean = true var hasDefault: Boolean = true } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -595,7 +611,7 @@ class BooleanPropertyNamingSpec(val env: KotlinCoreEnvironment) { class Test { var needReload: Boolean = true } - """ + """.trimIndent() val config = TestConfig(mapOf(ALLOWED_PATTERN to "^(is|has|are|need)")) assertThat(BooleanPropertyNaming(config).compileAndLint(code)) diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ClassNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ClassNamingSpec.kt index e7ff3e9808f..aa3a971bb3b 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ClassNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ClassNamingSpec.kt @@ -14,7 +14,7 @@ class ClassNamingSpec { ClassNaming(config).compileAndLint( """ class aBbD{} - """ + """.trimIndent() ) ).isEmpty() } @@ -23,7 +23,7 @@ class ClassNamingSpec { fun `should detect no violations class with numbers`() { val code = """ class MyClassWithNumbers5 - """ + """.trimIndent() assertThat(ClassNaming().compileAndLint(code)).isEmpty() } @@ -33,7 +33,7 @@ class ClassNamingSpec { val code = """ class NamingConventions { } - """ + """.trimIndent() assertThat(ClassNaming().compileAndLint(code)).isEmpty() } @@ -42,7 +42,7 @@ class ClassNamingSpec { fun `should detect no violations with class using backticks`() { val code = """ class `NamingConventions` - """ + """.trimIndent() assertThat(ClassNaming().compileAndLint(code)).isEmpty() } @@ -51,7 +51,7 @@ class ClassNamingSpec { fun `should detect because it have a _`() { val code = """ class _NamingConventions - """ + """.trimIndent() assertThat(ClassNaming().compileAndLint(code)) .hasSize(1) @@ -62,7 +62,7 @@ class ClassNamingSpec { fun `should detect because it have starts with lowercase`() { val code = """ class namingConventions {} - """ + """.trimIndent() assertThat(ClassNaming().compileAndLint(code)) .hasSize(1) @@ -74,7 +74,19 @@ class ClassNamingSpec { val code = """ @Suppress("ClassName") class namingConventions {} - """ + """.trimIndent() + assertThat(ClassNaming().compileAndLint(code)).isEmpty() + } + + @Test + fun `should not detect any`() { + val code = """ + data class D(val i: Int, val j: Int) + fun doStuff() { + val (_, HOLY_GRAIL) = D(5, 4) + } + """.trimIndent() + assertThat(ClassNaming().compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ConstructorParameterNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ConstructorParameterNamingSpec.kt index 758e898a1c3..08cdae2acf5 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ConstructorParameterNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ConstructorParameterNamingSpec.kt @@ -16,7 +16,7 @@ class ConstructorParameterNamingSpec { constructor(param: String) {} constructor(param: String, privateParam: String) {} } - """ + """.trimIndent() assertThat(ConstructorParameterNaming().compileAndLint(code)).isEmpty() } @@ -29,7 +29,7 @@ class ConstructorParameterNamingSpec { constructor(PARAM: String) {} constructor(PARAM: String, PRIVATE_PARAM: String) {} } - """ + """.trimIndent() assertThat(ConstructorParameterNaming().compileAndLint(code)).hasSize(5) } @@ -37,7 +37,7 @@ class ConstructorParameterNamingSpec { fun `should find a violation in the correct text location`() { val code = """ class C(val PARAM: String) - """ + """.trimIndent() assertThat(ConstructorParameterNaming().compileAndLint(code)).hasTextLocations(8 to 25) } @@ -47,7 +47,7 @@ class ConstructorParameterNamingSpec { class C(override val PARAM: String) : I interface I { val PARAM: String } - """ + """.trimIndent() assertThat(ConstructorParameterNaming().compileAndLint(code)).isEmpty() } @@ -57,7 +57,7 @@ class ConstructorParameterNamingSpec { class C(override val PARAM: String) : I interface I { val PARAM: String } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to "false")) assertThat(ConstructorParameterNaming(config).compileAndLint(code)).hasTextLocations(8 to 34) } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/EnumNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/EnumNamingSpec.kt index c8e10790211..3c82f6faa37 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/EnumNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/EnumNamingSpec.kt @@ -16,7 +16,7 @@ class EnumNamingSpec { enum class aBbD { enum1, enum2 } - """ + """.trimIndent() ) ).isEmpty() } @@ -28,7 +28,7 @@ class EnumNamingSpec { enum class WorkFlow { ACTIVE, NOT_ACTIVE, Unknown, Number1 } - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -39,7 +39,7 @@ class EnumNamingSpec { enum class WorkFlow { default } - """ + """.trimIndent() assertThat(EnumNaming().compileAndLint(code)).hasSize(1) } @@ -49,7 +49,7 @@ class EnumNamingSpec { enum class WorkFlow { _Default } - """ + """.trimIndent() assertThat(EnumNaming().compileAndLint(code)).hasSize(1) } @@ -59,7 +59,7 @@ class EnumNamingSpec { enum class WorkFlow { @Suppress("EnumNaming") _Default } - """ + """.trimIndent() assertThat(EnumNaming().compileAndLint(code)).isEmpty() } @@ -69,7 +69,7 @@ class EnumNamingSpec { enum class WorkFlow { _Default, } - """ + """.trimIndent() val findings = EnumNaming().compileAndLint(code) assertThat(findings).hasTextLocations(26 to 34) } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ForbiddenClassNameSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ForbiddenClassNameSpec.kt index 8ab8c2e9aa1..ab860ae5f6a 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ForbiddenClassNameSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ForbiddenClassNameSpec.kt @@ -15,7 +15,7 @@ class ForbiddenClassNameSpec { class TestManager {} // violation class TestProvider {} // violation class TestHolder - """ + """.trimIndent() assertThat( ForbiddenClassName(TestConfig(mapOf(FORBIDDEN_NAME to listOf("Manager", "Provider")))) .compileAndLint(code) @@ -39,7 +39,7 @@ class ForbiddenClassNameSpec { class TestManager {} // violation class TestProvider {} // violation class TestHolder - """ + """.trimIndent() assertThat( ForbiddenClassName(TestConfig(mapOf(FORBIDDEN_NAME to "Manager, Provider"))) .compileAndLint(code) @@ -53,7 +53,7 @@ class ForbiddenClassNameSpec { class TestManager {} // violation class TestProvider {} // violation class TestHolder - """ + """.trimIndent() assertThat( ForbiddenClassName(TestConfig(mapOf(FORBIDDEN_NAME to "*Manager*, *Provider*"))) .compileAndLint(code) @@ -65,7 +65,7 @@ class ForbiddenClassNameSpec { fun `should report all forbidden names in message`() { val code = """ class TestManager {} - """ + """.trimIndent() val actual = ForbiddenClassName(TestConfig(mapOf(FORBIDDEN_NAME to "Test, Manager, Provider"))) .compileAndLint(code) assertThat(actual.first().message) diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionNamingSpec.kt index 41744ff4501..74ed8abd2db 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionNamingSpec.kt @@ -16,7 +16,7 @@ class FunctionNamingSpec { val code = """ @Suppress("FunctionName") fun MY_FUN() {} - """ + """.trimIndent() assertThat(FunctionNaming().compileAndLint(code)).isEmpty() } @@ -26,7 +26,7 @@ class FunctionNamingSpec { val f: (Int) -> Int = fun(i: Int): Int { return i + i } - """ + """.trimIndent() assertThat(FunctionNaming().compileAndLint(code)).isEmpty() } @@ -36,7 +36,7 @@ class FunctionNamingSpec { class WhateverTest { fun SHOULD_NOT_BE_FLAGGED() {} } - """ + """.trimIndent() val config = TestConfig(mapOf(FunctionNaming.EXCLUDE_CLASS_PATTERN to ".*Test$")) assertThat(FunctionNaming(config).compileAndLint(code)).isEmpty() } @@ -50,7 +50,7 @@ class FunctionNamingSpec { } } interface I { fun shouldNotBeFlagged() } - """ + """.trimIndent() assertThat(FunctionNaming().compileAndLint(code)).hasStartSourceLocation(3, 13) } @@ -61,7 +61,7 @@ class FunctionNamingSpec { override fun SHOULD_NOT_BE_FLAGGED() {} } interface I { @Suppress("FunctionNaming") fun SHOULD_NOT_BE_FLAGGED() } - """ + """.trimIndent() assertThat(FunctionNaming().compileAndLint(code)).isEmpty() } @@ -72,7 +72,7 @@ class FunctionNamingSpec { private class FooImpl : Foo fun Foo(): Foo = FooImpl() - """ + """.trimIndent() val config = TestConfig(mapOf(FunctionNaming.IGNORE_OVERRIDDEN to "false")) assertThat(FunctionNaming(config).compileAndLint(code)).isEmpty() } @@ -86,7 +86,7 @@ class FunctionNamingSpec { } } interface I { @Suppress("FunctionNaming") fun SHOULD_BE_FLAGGED() } - """ + """.trimIndent() assertThat(FunctionNaming().compileAndLint(code)).hasStartSourceLocation(3, 13) } @@ -97,7 +97,7 @@ class FunctionNamingSpec { override fun SHOULD_BE_FLAGGED() {} } interface I { fun SHOULD_BE_FLAGGED() } - """ + """.trimIndent() val config = TestConfig(mapOf(FunctionNaming.IGNORE_OVERRIDDEN to "false")) assertThat(FunctionNaming(config).compileAndLint(code)).hasStartSourceLocations( SourceLocation(2, 18), @@ -109,7 +109,7 @@ class FunctionNamingSpec { fun `doesn't allow functions with backtick`() { val code = """ fun `7his is a function name _`() = Unit - """ + """.trimIndent() assertThat(FunctionNaming().compileAndLint(code)).hasStartSourceLocations(SourceLocation(1, 5)) } @@ -124,7 +124,7 @@ class FunctionNamingSpec { } } - """ + """.trimIndent() ) ).isEmpty() } @@ -139,7 +139,7 @@ class FunctionNamingSpec { object Foo { fun MYFun() {} } - """ + """.trimIndent() val config = TestConfig(mapOf(FunctionNaming.EXCLUDE_CLASS_PATTERN to "Foo|Bar")) assertThat(FunctionNaming(config).compileAndLint(code)).isEmpty() } @@ -162,7 +162,15 @@ class FunctionNamingSpec { object Foo { fun MYFun() {} } - """ + """.trimIndent() + + @Test + fun shouldFailWithInvalidRegexFunctionNaming() { + val config = TestConfig(mapOf(FunctionNaming.EXCLUDE_CLASS_PATTERN to "*Foo")) + assertThatExceptionOfType(PatternSyntaxException::class.java).isThrownBy { + FunctionNaming(config).compileAndLint(excludeClassPatternFunctionRegexCode) + } + } @Test fun shouldNotFailWithInvalidRegexWhenDisabledFunctionNaming() { @@ -173,13 +181,16 @@ class FunctionNamingSpec { val config = TestConfig(configRules) assertThat(FunctionNaming(config).compileAndLint(excludeClassPatternFunctionRegexCode)).isEmpty() } + } - @Test - fun shouldFailWithInvalidRegexFunctionNaming() { - val config = TestConfig(mapOf(FunctionNaming.EXCLUDE_CLASS_PATTERN to "*Foo")) - assertThatExceptionOfType(PatternSyntaxException::class.java).isThrownBy { - FunctionNaming(config).compileAndLint(excludeClassPatternFunctionRegexCode) + @Test + fun `should not detect any`() { + val code = """ + data class D(val i: Int, val j: Int) + fun doStuff() { + val (_, HOLY_GRAIL) = D(5, 4) } - } + """.trimIndent() + assertThat(FunctionNaming().compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionParameterNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionParameterNamingSpec.kt index fd8fbb450bf..36d86fabd18 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionParameterNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionParameterNamingSpec.kt @@ -20,7 +20,7 @@ class FunctionParameterNamingSpec { class C { fun someStuff(param: String) {} } - """ + """.trimIndent() assertThat(FunctionParameterNaming().compileAndLint(code)).isEmpty() } @@ -31,7 +31,7 @@ class FunctionParameterNamingSpec { override fun someStuff(`object`: String) {} } interface I { fun someStuff(@Suppress("FunctionParameterNaming") `object`: String) } - """ + """.trimIndent() assertThat(FunctionParameterNaming().compileAndLint(code)).isEmpty() } @@ -42,7 +42,7 @@ class FunctionParameterNamingSpec { override fun someStuff(`object`: String) {} } interface I { fun someStuff(`object`: String) } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to "false")) assertThat(FunctionParameterNaming(config).compileAndLint(code)).hasSize(2) } @@ -53,7 +53,7 @@ class FunctionParameterNamingSpec { class C { fun someStuff(PARAM: String) {} } - """ + """.trimIndent() assertThat(FunctionParameterNaming().compileAndLint(code)).hasSize(1) } } @@ -69,7 +69,7 @@ class FunctionParameterNamingSpec { class Excluded { fun f(PARAM: Int) {} } - """ + """.trimIndent() assertThat(FunctionParameterNaming(config).compileAndLint(code)).isEmpty() } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/InvalidPackageDeclarationSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/InvalidPackageDeclarationSpec.kt index 230b8c24fda..ce35687075c 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/InvalidPackageDeclarationSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/InvalidPackageDeclarationSpec.kt @@ -20,7 +20,7 @@ class InvalidPackageDeclarationSpec { package foo.bar class C - """ + """.trimIndent() val ktFile = compileContentForTest(source, createPath("project/src/foo/bar/File.kt")) val findings = InvalidPackageDeclaration().lint(ktFile) @@ -50,7 +50,7 @@ class InvalidPackageDeclarationSpec { package com.example class C - """ + """.trimIndent() val ktFile = compileContentForTest(source, createPath("src/File.kt")) val findings = InvalidPackageDeclaration(config).lint(ktFile) @@ -64,7 +64,7 @@ class InvalidPackageDeclarationSpec { package com.example.foo.bar class C - """ + """.trimIndent() val ktFile = compileContentForTest(source, createPath("src/foo/bar/File.kt")) val findings = InvalidPackageDeclaration(config).lint(ktFile) @@ -78,7 +78,7 @@ class InvalidPackageDeclarationSpec { package com.example.foo.bar class C - """ + """.trimIndent() val ktFile = compileContentForTest(source, createPath("src/com/example/foo/bar/File.kt")) val findings = InvalidPackageDeclaration(config).lint(ktFile) @@ -92,7 +92,7 @@ class InvalidPackageDeclarationSpec { package com.example.foo.baz class C - """ + """.trimIndent() val ktFile = compileContentForTest(source, createPath("src/foo/bar/File.kt")) val findings = InvalidPackageDeclaration(config).lint(ktFile) @@ -106,7 +106,7 @@ class InvalidPackageDeclarationSpec { package io.foo.bar class C - """ + """.trimIndent() val ktFile = compileContentForTest(source, createPath("src/com/example/File.kt")) val findings = InvalidPackageDeclaration(config).lint(ktFile) @@ -126,7 +126,7 @@ class InvalidPackageDeclarationSpec { package com.example.foo.bar class C - """ + """.trimIndent() val ktFileWithRelativePath = compileContentForTest(source, createPath("src/foo/bar/File.kt")) val findingsForRelativePath = InvalidPackageDeclaration(config).lint(ktFileWithRelativePath) @@ -145,7 +145,7 @@ class InvalidPackageDeclarationSpec { package foo.bar class C - """ + """.trimIndent() val ktFile = compileContentForTest(source, createPath("src/foo/bar/File.kt")) val findings = InvalidPackageDeclaration(config).lint(ktFile) diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/LambdaParameterNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/LambdaParameterNamingSpec.kt index 04bab26f4ae..10ff869bcdf 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/LambdaParameterNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/LambdaParameterNamingSpec.kt @@ -10,7 +10,7 @@ class LambdaParameterNamingSpec { fun `Reports no supported parameter names`() { val code = """ val a: (String) -> Unit = { HELLO_THERE -> Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .hasSize(1) .hasTextLocations("HELLO_THERE") @@ -20,7 +20,7 @@ class LambdaParameterNamingSpec { fun `Reports no supported parameter names when there are multiple`() { val code = """ val a: (String, Int) -> Unit = { HI, HELLO_THERE -> Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .hasSize(2) .hasTextLocations("HI", "HELLO_THERE") @@ -30,7 +30,7 @@ class LambdaParameterNamingSpec { fun `Doesn't report a valid parameter`() { val code = """ val a: (String) -> Unit = { helloThere -> Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .isEmpty() } @@ -39,7 +39,7 @@ class LambdaParameterNamingSpec { fun `Doesn't report a valid parameter when define type`() { val code = """ val a = { helloThere: String -> Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .isEmpty() } @@ -48,7 +48,7 @@ class LambdaParameterNamingSpec { fun `Doesn't report _`() { val code = """ val a: (String) -> Unit = { _ -> Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .isEmpty() } @@ -57,7 +57,7 @@ class LambdaParameterNamingSpec { fun `Doesn't report by using implicit name`() { val code = """ val a: (String) -> Unit = { Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .isEmpty() } @@ -66,7 +66,7 @@ class LambdaParameterNamingSpec { fun `Doesn't report if there aren't parameters`() { val code = """ val a: () -> Unit = { Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .isEmpty() } @@ -76,7 +76,7 @@ class LambdaParameterNamingSpec { val code = """ data class Bar(val a: String) val a: (Bar) -> Unit = { (HELLO_THERE) -> Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .hasSize(1) .hasTextLocations("HELLO_THERE") @@ -87,7 +87,7 @@ class LambdaParameterNamingSpec { val code = """ data class Bar(val a: String, val b: String) val a: (Bar) -> Unit = { (HI, HELLO_THERE) -> Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .hasSize(2) .hasTextLocations("HI", "HELLO_THERE") @@ -98,7 +98,7 @@ class LambdaParameterNamingSpec { val code = """ data class Bar(val a: String, val b: String) val a: (Bar) -> Unit = { (a, b) -> Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .isEmpty() } @@ -108,7 +108,7 @@ class LambdaParameterNamingSpec { val code = """ data class Bar(val a: String, val b: String) val a: (Bar) -> Unit = { (a: String, b) -> Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .isEmpty() } @@ -118,7 +118,7 @@ class LambdaParameterNamingSpec { val code = """ data class Bar(val a: String, val b: String) val a: (Bar) -> Unit = { (_, b) -> Unit } - """ + """.trimIndent() assertThat(LambdaParameterNaming().compileAndLint(code)) .isEmpty() } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MatchingDeclarationNameSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MatchingDeclarationNameSpec.kt index 0b7eaa749a9..701b1747a79 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MatchingDeclarationNameSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MatchingDeclarationNameSpec.kt @@ -50,7 +50,7 @@ class MatchingDeclarationNameSpec { enum class E { ONE, TWO, THREE } - """, + """.trimIndent(), filename = "E.kt" ) val findings = MatchingDeclarationName().lint(ktFile) @@ -64,7 +64,7 @@ class MatchingDeclarationNameSpec { class C object O fun a() = 5 - """, + """.trimIndent(), filename = "MultiDeclarations.kt" ) val findings = MatchingDeclarationName().lint(ktFile) @@ -78,7 +78,7 @@ class MatchingDeclarationNameSpec { class C fun a() = 5 fun C.b() = 5 - """, + """.trimIndent(), filename = "C.kt" ) val findings = MatchingDeclarationName().lint(ktFile) @@ -92,7 +92,7 @@ class MatchingDeclarationNameSpec { fun a() = 5 fun C.b() = 5 class C - """, + """.trimIndent(), filename = "Classes.kt" ) val findings = MatchingDeclarationName().lint(ktFile) @@ -105,7 +105,7 @@ class MatchingDeclarationNameSpec { """ private class C fun a() = 5 - """, + """.trimIndent(), filename = "b.kt" ) val findings = MatchingDeclarationName().lint(ktFile) @@ -118,7 +118,7 @@ class MatchingDeclarationNameSpec { typealias Foo = FooImpl class FooImpl {} - """ + """.trimIndent() val ktFile = compileContentForTest(code, filename = "Foo.kt") val findings = MatchingDeclarationName().lint(ktFile) assertThat(findings).isEmpty() @@ -192,7 +192,7 @@ class MatchingDeclarationNameSpec { val code = """ class FooImpl {} typealias Bar = FooImpl - """ + """.trimIndent() val ktFile = compileContentForTest(code, filename = "Foo.kt") val findings = MatchingDeclarationName().lint(ktFile) assertThat(findings).hasSize(1) diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MemberNameEqualsClassNameSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MemberNameEqualsClassNameSpec.kt index 598fafb3d90..50813a66c9e 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MemberNameEqualsClassNameSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MemberNameEqualsClassNameSpec.kt @@ -35,7 +35,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { fun MethodNameNotEqualsClassName() {} } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -47,7 +47,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { fun MethodNameNotEqualsClassName() {} } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -59,7 +59,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { fun A() {} } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -73,7 +73,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { class MethodNameEqualsClassName { fun methodNameEqualsClassName() {} } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).hasSize(1) } @@ -83,7 +83,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { object MethodNameEqualsObjectName { fun MethodNameEqualsObjectName() {} } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).hasSize(1) } @@ -93,7 +93,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { class PropertyNameEqualsClassName { val propertyNameEqualsClassName = 0 } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).hasSize(1) } @@ -103,7 +103,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { object PropertyNameEqualsObjectName { val propertyNameEqualsObjectName = 0 } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).hasSize(1) } @@ -115,7 +115,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { fun StaticMethodNameEqualsClassName() {} } } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).hasSize(1) } @@ -127,7 +127,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { fun MethodNameEqualsNestedClassName() {} } } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).hasSize(1) } @@ -140,7 +140,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { abstract class BaseClassForMethodNameEqualsClassName { abstract fun AbstractMethodNameEqualsClassName() } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).isEmpty() } @@ -150,7 +150,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { interface MethodNameEqualsInterfaceName { fun MethodNameEqualsInterfaceName() {} } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).isEmpty() } @@ -163,7 +163,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { abstract class BaseClassForMethodNameEqualsClassName { abstract fun AbstractMethodNameEqualsClassName() } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName(noIgnoreOverridden).compileAndLint(code)).hasSize(1) } @@ -176,7 +176,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { abstract class BaseClassForMethodNameEqualsClassName { abstract val AbstractMethodNameEqualsClassName: String } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).isEmpty() } @@ -189,7 +189,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { abstract class BaseClassForMethodNameEqualsClassName { abstract val AbstractMethodNameEqualsClassName: String } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName(noIgnoreOverridden).compileAndLint(code)).hasSize(1) } } @@ -206,7 +206,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { fun wrongFactoryClass1() {} } } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).hasSize(1) } @@ -221,7 +221,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLint(code)).hasSize(1) } @@ -234,7 +234,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { fun wrongFactoryClass3() = 0 } } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLintWithContext(env, code)).hasSize(1) } @@ -252,7 +252,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { class B: A() class C: A() - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLintWithContext(env, code)).isEmpty() } @@ -269,7 +269,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(MemberNameEqualsClassName().compileAndLintWithContext(env, code)).isEmpty() } @@ -286,7 +286,7 @@ class MemberNameEqualsClassNameSpec(val env: KotlinCoreEnvironment) { class B: A() class C: A() - """ + """.trimIndent() @Test fun `with type solving`() { diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NoNameShadowingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NoNameShadowingSpec.kt index ed16f59845b..22c6ecff6ba 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NoNameShadowingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NoNameShadowingSpec.kt @@ -16,7 +16,7 @@ class NoNameShadowingSpec(val env: KotlinCoreEnvironment) { fun test(i: Int) { val i = 1 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(2, 9) @@ -29,7 +29,7 @@ class NoNameShadowingSpec(val env: KotlinCoreEnvironment) { fun test(j: Int) { val (j, _) = 1 to 2 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0]).hasMessage("Name shadowed: j") @@ -42,7 +42,7 @@ class NoNameShadowingSpec(val env: KotlinCoreEnvironment) { listOf(1).map { k -> } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0]).hasMessage("Name shadowed: k") @@ -57,7 +57,7 @@ class NoNameShadowingSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0]).hasMessage("Name shadowed: it") @@ -72,7 +72,7 @@ class NoNameShadowingSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -83,7 +83,7 @@ class NoNameShadowingSpec(val env: KotlinCoreEnvironment) { fun test(i: Int) { val j = i } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -106,7 +106,7 @@ class NoNameShadowingSpec(val env: KotlinCoreEnvironment) { list.map { it + "x" } } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NonBooleanPropertyWithPrefixIsSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NonBooleanPropertyWithPrefixIsSpec.kt index e37ff5c174d..c8b619cd96b 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NonBooleanPropertyWithPrefixIsSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NonBooleanPropertyWithPrefixIsSpec.kt @@ -60,7 +60,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { data class O (var isDefault: Inner) { class Inner } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -91,7 +91,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class O { var isDefault = false } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -107,7 +107,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { isDefault = true } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -119,7 +119,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class O { var isDefault: Boolean? = null } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -131,7 +131,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class O { var isDefault: java.lang.Boolean = java.lang.Boolean(false) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -147,7 +147,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { isDefault = java.lang.Boolean(false) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -159,7 +159,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class O { var isDefault: java.lang.Boolean? = null } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -171,7 +171,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class O { var isDefault: Int = 0 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -183,7 +183,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class O { var isDefault = 0 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -195,7 +195,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class O { var isDefault = listOf(1, 2, 3) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -209,7 +209,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class Inner } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -221,7 +221,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class O { var `is`: Int = 0 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -233,7 +233,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class O { var isengardTowerHeightInFeet: Int = 500 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -245,7 +245,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { fun f() { var isDefault: Int = 0 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -260,7 +260,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { class Test { val isDebuggable get() = BuildConfig.DEBUG } - """ + """.trimIndent() // BuildConfig is missing in this test so we can't compile it val findings = subject.lintWithContext(env, code) @@ -275,7 +275,7 @@ class NonBooleanPropertyWithPrefixIsSpec(val env: KotlinCoreEnvironment) { fun trueFun() = true val isReferenceBoolean = ::trueFun - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ObjectPropertyNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ObjectPropertyNamingSpec.kt index 2c8dc13eb3b..c0cc7c0ba48 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ObjectPropertyNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ObjectPropertyNamingSpec.kt @@ -23,7 +23,7 @@ class ObjectPropertyNamingSpec { object O { ${PublicConst.negative} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -33,7 +33,7 @@ class ObjectPropertyNamingSpec { object O { ${PublicConst.positive} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -43,7 +43,7 @@ class ObjectPropertyNamingSpec { object O { ${PrivateConst.negative} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -53,7 +53,7 @@ class ObjectPropertyNamingSpec { object O { ${PrivateConst.positive} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -63,7 +63,7 @@ class ObjectPropertyNamingSpec { object O { ${PublicConst.positive} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasStartSourceLocation(2, 15) } } @@ -81,7 +81,7 @@ class ObjectPropertyNamingSpec { ${PublicConst.negative} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -93,7 +93,7 @@ class ObjectPropertyNamingSpec { ${PublicConst.positive} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -105,7 +105,7 @@ class ObjectPropertyNamingSpec { ${PrivateConst.negative} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -117,7 +117,7 @@ class ObjectPropertyNamingSpec { ${PrivateConst.positive} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -129,7 +129,7 @@ class ObjectPropertyNamingSpec { ${PublicConst.positive} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasStartSourceLocation(3, 19) } } @@ -145,7 +145,7 @@ class ObjectPropertyNamingSpec { object O { ${PublicVal.negative} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -155,7 +155,7 @@ class ObjectPropertyNamingSpec { object O { ${PublicVal.positive} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -165,7 +165,7 @@ class ObjectPropertyNamingSpec { object O { ${PrivateVal.negative} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -175,7 +175,7 @@ class ObjectPropertyNamingSpec { object O { private val __NAME = "Artur" } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } } @@ -199,7 +199,7 @@ class ObjectPropertyNamingSpec { const val _NAME = "Artur" const val _name = "Artur" } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -210,7 +210,7 @@ class ObjectPropertyNamingSpec { private val __NAME = "Artur" private val _1234 = "Artur" } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } @@ -232,7 +232,7 @@ class ObjectPropertyNamingSpec { val somethingElse = 1 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -249,7 +249,7 @@ abstract class NamingSnippet(private val isPrivate: Boolean, private val isConst ${visibility()}${const()}val name = "Artur" ${visibility()}${const()}val nAme = "Artur" ${visibility()}${const()}val serialVersionUID = 42L - """ + """.trimIndent() val positive = """${visibility()}${const()}val _nAme = "Artur"""" private fun visibility() = if (isPrivate) "private " else "" diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/PackageNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/PackageNamingSpec.kt index e98f20cde34..ab00ac81b8a 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/PackageNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/PackageNamingSpec.kt @@ -20,7 +20,7 @@ class PackageNamingSpec { """ @file:Suppress("PackageDirectoryMismatch") package FOO.BAR - """ + """.trimIndent() ) ).isEmpty() } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/TopLevelPropertyNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/TopLevelPropertyNamingSpec.kt index 23640414f7e..3d238104ba6 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/TopLevelPropertyNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/TopLevelPropertyNamingSpec.kt @@ -21,7 +21,7 @@ class TopLevelPropertyNamingSpec { const val lowerCaseConst = "" } } - """ + """.trimIndent() ) ).isEmpty() } @@ -34,7 +34,7 @@ class TopLevelPropertyNamingSpec { val code = """ const val MY_NAME_8 = "Artur" const val MYNAME = "Artur" - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -46,7 +46,7 @@ class TopLevelPropertyNamingSpec { const val nAme = "Artur" private const val _nAme = "Artur" const val serialVersionUID = 42L - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(5) } } @@ -67,7 +67,7 @@ class TopLevelPropertyNamingSpec { private val NAME = "Artur" val s_d_d_1 = listOf("") private val INTERNAL_VERSION = "1.0.0" - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -75,7 +75,7 @@ class TopLevelPropertyNamingSpec { fun `should report non private top level property using underscore`() { val code = """ val _nAme = "Artur" - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -83,7 +83,7 @@ class TopLevelPropertyNamingSpec { fun `should report private top level property using two underscores`() { val code = """ private val __NAME = "Artur" - """ + """.trimIndent() io.gitlab.arturbosch.detekt.test.assertThat(subject.lint(code)).hasSize(1) } } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableMaxLengthSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableMaxLengthSpec.kt index 54ae548d3b4..07c93bc655d 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableMaxLengthSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableMaxLengthSpec.kt @@ -13,7 +13,7 @@ class VariableMaxLengthSpec { fun function() { val (_, status) = getResult() } - """ + """.trimIndent() assertThat(VariableMaxLength().compileAndLint(code)).isEmpty() } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableMinLengthSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableMinLengthSpec.kt index 65c9f4dcbd6..e99cda86cd7 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableMinLengthSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableMinLengthSpec.kt @@ -26,7 +26,7 @@ class VariableMinLengthSpec { class C { val prop: (Int) -> Unit = { _ -> Unit } } - """ + """.trimIndent() assertThat(variableMinLength.compileAndLint(code)).isEmpty() } } @@ -50,7 +50,7 @@ class VariableMinLengthSpec { fun function() { val (_, status) = getResult() } - """ + """.trimIndent() assertThat(VariableMinLength().compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableNamingSpec.kt index 12af91a2dbd..ff825b8909a 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableNamingSpec.kt @@ -22,7 +22,7 @@ class VariableNamingSpec { object Foo { val MYVar = 3 } - """ + """.trimIndent() @Test fun shouldNotFailWithInvalidRegexWhenDisabledVariableNaming() { @@ -53,7 +53,7 @@ class VariableNamingSpec { object Foo { val MYVar = 3 } - """ + """.trimIndent() val config = TestConfig(mapOf(VariableNaming.EXCLUDE_CLASS_PATTERN to "Foo|Bar")) assertThat(VariableNaming(config).compileAndLint(code)).isEmpty() } @@ -66,7 +66,7 @@ class VariableNamingSpec { val FIELD get() = _FIELD val camel_Case_Property = 5 } - """ + """.trimIndent() assertThat(VariableNaming().compileAndLint(code)) .hasStartSourceLocations( SourceLocation(2, 17), @@ -83,7 +83,7 @@ class VariableNamingSpec { val field get() = _field val camelCaseProperty = 5 } - """ + """.trimIndent() assertThat(VariableNaming().compileAndLint(code)).isEmpty() } @@ -99,7 +99,7 @@ class VariableNamingSpec { interface I2 { @Suppress("VariableNaming") val SHOULD_NOT_BE_FLAGGED: String } - """ + """.trimIndent() assertThat(VariableNaming().compileAndLint(code)).isEmpty() } @@ -112,7 +112,7 @@ class VariableNamingSpec { fun bar() { listOf>().flatMap { (right, _) -> listOf(right) } } - """ + """.trimIndent() assertThat(VariableNaming().compileAndLint(code)).isEmpty() } @@ -128,7 +128,7 @@ class VariableNamingSpec { interface I2 { @Suppress("VariableNaming") val SHOULD_BE_FLAGGED: String } - """ + """.trimIndent() val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to "false")) assertThat(VariableNaming(config).compileAndLint(code)) .hasStartSourceLocations( @@ -136,6 +136,17 @@ class VariableNamingSpec { SourceLocation(5, 18) ) } + + @Test + fun `should not detect any`() { + val code = """ + data class D(val i: Int, val j: Int) + fun doStuff() { + val (_, HOLY_GRAIL) = D(5, 4) + } + """.trimIndent() + assertThat(VariableNaming().compileAndLint(code)).isEmpty() + } } private const val IGNORE_OVERRIDDEN = "ignoreOverridden" diff --git a/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/CouldBeSequenceSpec.kt b/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/CouldBeSequenceSpec.kt index 1deab2c4678..3105e18d979 100644 --- a/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/CouldBeSequenceSpec.kt +++ b/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/CouldBeSequenceSpec.kt @@ -22,7 +22,7 @@ class CouldBeSequenceSpec(val env: KotlinCoreEnvironment) { }.filter { it > 5 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -33,7 +33,7 @@ class CouldBeSequenceSpec(val env: KotlinCoreEnvironment) { val processed = myCollection.filter { it % 2 == 0 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -48,7 +48,7 @@ class CouldBeSequenceSpec(val env: KotlinCoreEnvironment) { }.filter { it > 5 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -63,7 +63,7 @@ class CouldBeSequenceSpec(val env: KotlinCoreEnvironment) { }.filter { it > 5 }.toList() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/ForEachOnRangeSpec.kt b/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/ForEachOnRangeSpec.kt index 1de91df460a..fdcd22cb62f 100644 --- a/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/ForEachOnRangeSpec.kt +++ b/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/ForEachOnRangeSpec.kt @@ -26,7 +26,7 @@ class ForEachOnRangeSpec { println(it) } } - """ + """.trimIndent() @Test fun `should report the forEach usage`() { @@ -41,7 +41,7 @@ class ForEachOnRangeSpec { fun test() { (1..10).isEmpty() } - """ + """.trimIndent() @Test fun `should not report any issues`() { @@ -58,7 +58,7 @@ class ForEachOnRangeSpec { println(it) } } - """ + """.trimIndent() @Test fun `should not report any issues`() { diff --git a/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/SpreadOperatorSpec.kt b/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/SpreadOperatorSpec.kt index 993de8d6189..880fd39c756 100644 --- a/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/SpreadOperatorSpec.kt +++ b/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/SpreadOperatorSpec.kt @@ -30,7 +30,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val xsArray = intArrayOf(1) fun foo(vararg xs: Int) {} val testVal = foo(xs = *xsArray) - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().message).isEqualTo(typeResolutionEnabledMessage) @@ -42,7 +42,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val xsArray = intArrayOf(1) fun foo(vararg xs: Int) {} val testVal = foo(*xsArray) - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) assertThat(actual.first().message).isEqualTo(typeResolutionEnabledMessage) @@ -53,7 +53,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val code = """ fun foo(vararg xs: Int) {} val testVal = foo(xs = *intArrayOf(1)) - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -62,7 +62,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val code = """ fun asList(vararg ts: T, stringValue: String): List = listOf(1,2,3) val list = asList(-1, 0, *arrayOf(1, 2, 3), 4, stringValue = "5") - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -71,7 +71,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val code = """ fun asList(vararg ts: T, stringValue: String): List = listOf(1,2,3) val list = asList(-1, 0, 1, 2, 3, 4, stringValue = "5") - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -85,7 +85,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { fun test(strs: Array) { strs.forEach { println(it) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -99,7 +99,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { fun test(test : Int) { println(test) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -110,7 +110,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { fun a(vararg bla: Int) { b(*bla) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -123,7 +123,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val bla = arrayOf("") b(*bla) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } @@ -140,7 +140,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val xsArray = intArrayOf(1) fun foo(vararg xs: Int) {} val testVal = foo(xs = *xsArray) - """ + """.trimIndent() val actual = subject.compileAndLint(code) assertThat(actual).hasSize(1) assertThat(actual.first().message).isEqualTo(typeResolutionDisabledMessage) @@ -152,7 +152,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val xsArray = intArrayOf(1) fun foo(vararg xs: Int) {} val testVal = foo(*xsArray) - """ + """.trimIndent() val actual = subject.compileAndLint(code) assertThat(actual).hasSize(1) assertThat(actual.first().message).isEqualTo(typeResolutionDisabledMessage) @@ -163,7 +163,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val code = """ fun foo(vararg xs: Int) {} val testVal = foo(xs = *intArrayOf(1)) - """ + """.trimIndent() val actual = subject.compileAndLint(code) assertThat(actual).hasSize(1) assertThat(actual.first().message).isEqualTo(typeResolutionDisabledMessage) @@ -174,7 +174,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val code = """ fun asList(vararg ts: T, stringValue: String): List = listOf(1,2,3) val list = asList(-1, 0, *arrayOf(1, 2, 3), 4, stringValue = "5") - """ + """.trimIndent() val actual = subject.compileAndLint(code) assertThat(actual).hasSize(1) assertThat(actual.first().message).isEqualTo(typeResolutionDisabledMessage) @@ -185,7 +185,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val code = """ fun asList(vararg ts: T, stringValue: String): List = listOf(1,2,3) val list = asList(-1, 0, 1, 2, 3, 4, stringValue = "5") - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -199,7 +199,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { fun test(strs: Array) { strs.forEach { println(it) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -213,7 +213,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { fun test(test : Int) { println(test) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -224,7 +224,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { fun a(vararg bla: Int) { b(*bla) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -237,7 +237,7 @@ class SpreadOperatorSpec(val env: KotlinCoreEnvironment) { val bla = arrayOf("") b(*bla) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClass.kt b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClass.kt index 84487eb3929..95851efd42d 100644 --- a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClass.kt +++ b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClass.kt @@ -54,9 +54,7 @@ class UnnecessaryAbstractClass(config: Config = Config.empty) : Rule(config) { Issue( "UnnecessaryAbstractClass", Severity.Style, - "An abstract class is unnecessary and can be refactored. " + - "An abstract class should have both abstract and concrete properties or functions. " + - noConcreteMember + " " + noAbstractMember, + "An abstract class is unnecessary. May be refactored to an interface or to a concrete class.", Debt.FIVE_MINS ) diff --git a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryLet.kt b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryLet.kt index b6698e4e6af..51ef26576aa 100644 --- a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryLet.kt +++ b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryLet.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.psi.KtSafeQualifiedExpression import org.jetbrains.kotlin.psi.KtSimpleNameExpression import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.calls.util.getResolvedCall /** * `let` expressions are used extensively in our code for null-checking and chaining functions, @@ -124,7 +123,7 @@ private fun KtBlockExpression.hasOnlyOneStatement() = this.children.size == 1 private fun PsiElement.countVarRefs(parameter: CallableDescriptor, context: BindingContext): Int = collectDescendantsOfType { - it.getResolvedCall(context)?.resultingDescriptor == parameter + context[BindingContext.REFERENCE_TARGET, it] == parameter }.count() private fun KtLambdaExpression.countReferences(context: BindingContext): Int { diff --git a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMember.kt b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMember.kt index 9180de718ad..eaf21701784 100644 --- a/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMember.kt +++ b/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMember.kt @@ -258,7 +258,7 @@ private class UnusedParameterVisitor(allowedNames: Regex) : UnusedMemberVisitor( } override fun visitReferenceExpression(expression: KtReferenceExpression) { - parameters.remove(expression.text) + parameters.remove(expression.text.removeSurrounding("`")) super.visitReferenceExpression(expression) } }) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt index 4b20456b0b4..ee3503d893b 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CanBeNonNullableSpec.kt @@ -22,7 +22,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { a = 6 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -46,7 +46,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { return b } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -77,7 +77,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -90,7 +90,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { fun fileFoo() { fileB = 6 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -123,7 +123,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { return if (bizz % 2 == 0) null else bizz } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -133,7 +133,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { class A(private var aDelegate: Int?) { private var a: Int? by this::aDelegate } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -155,7 +155,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { fileA = null } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -169,7 +169,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { a = 6 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -183,7 +183,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { a = null } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -196,7 +196,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { a = 6 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -210,7 +210,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { a = 6 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -222,7 +222,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { a = 6 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -242,7 +242,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { c = cVal } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(3) } @@ -254,7 +254,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { 5 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -262,7 +262,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { fun `reports when file-level vals are set to non-nullable values`() { val code = """ val fileA: Int? = 5 - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -281,7 +281,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { c = cVal } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -296,7 +296,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { if (randVal % 2 == 0) randVal else null } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -304,7 +304,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { fun `does not report when file-level vals are assigned a nullable value`() { val code = """ val fileA: Int? = null - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -314,7 +314,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { class A { val a: Int = 5 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -322,7 +322,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { fun `does not report when vals are declared in the constructor`() { val code = """ class A(private val a: Int?) - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -343,7 +343,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { return 5 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(3) } @@ -367,7 +367,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { return if (randInt % 2 == 0) randInt else null } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -452,7 +452,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { open val a: Int? = 5 open var b: Int? = 5 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -463,7 +463,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { abstract val a: Int? abstract var b: Int? } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -477,7 +477,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { // as non-null in Kotlin code. private var a: String? = e.localizedMessage } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -488,7 +488,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { val a: Int? var b: Int? } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -579,7 +579,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { inner class `in a non-return statement` { @Test fun `does report when the safe-qualified expression is the only expression of the function`() { - val code = """ + val code = """ class A(val foo: String) fun foo(a: A?) { @@ -899,7 +899,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { @Test fun `does report null-check returning unit type`() { - val code = """ + val code = """ fun foo(a: Int?) { if (a == null) return println(a) @@ -910,7 +910,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { @Test fun `does report null-check returning unit type in block`() { - val code = """ + val code = """ fun foo(a: Int?) { if (a == null) { return } println(a) @@ -921,7 +921,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { @Test fun `does not report guard statement with side effect ahead`() { - val code = """ + val code = """ fun foo(a: Int?) { println("side effect") if (a == null) return @@ -933,7 +933,7 @@ class CanBeNonNullableSpec(val env: KotlinCoreEnvironment) { @Test fun `does not report null-check returning non-unit type`() { - val code = """ + val code = """ fun foo(a: Int?): Int { if (a == null) return 0 println(a) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CascadingCallWrappingSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CascadingCallWrappingSpec.kt index a9c141253c9..165c1129153 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CascadingCallWrappingSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CascadingCallWrappingSpec.kt @@ -15,7 +15,7 @@ class CascadingCallWrappingSpec { val code = """ val a = 0 .plus(0).plus(0).plus(0) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)) .hasSize(1) @@ -28,7 +28,7 @@ class CascadingCallWrappingSpec { fun `does not report when chained calls are on a single line`() { val code = """ val a = 0.plus(0).plus(0) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -39,7 +39,7 @@ class CascadingCallWrappingSpec { val a = 0 .plus(0) .plus(0) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -50,7 +50,7 @@ class CascadingCallWrappingSpec { val a = 0.plus(0).plus(0) .plus(0) .plus(0) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -60,7 +60,7 @@ class CascadingCallWrappingSpec { val code = """ val a = 0 ?.plus(0)?.plus(0) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -70,7 +70,7 @@ class CascadingCallWrappingSpec { val code = """ val a = 0!! .plus(0)!!.plus(0) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -83,7 +83,7 @@ class CascadingCallWrappingSpec { val b = "" .length.plus(0) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -100,7 +100,7 @@ class CascadingCallWrappingSpec { .let { 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -117,7 +117,7 @@ class CascadingCallWrappingSpec { }.plus( 0 ) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -130,7 +130,7 @@ class CascadingCallWrappingSpec { ).let { 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -141,7 +141,7 @@ class CascadingCallWrappingSpec { val a = 0.plus( 0 ) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -158,7 +158,7 @@ class CascadingCallWrappingSpec { val a = 0 .plus(0) ?: 0 - """ + """.trimIndent() assertThat(subjectIncludingElvis.compileAndLint(code)).isEmpty() assertThat(subjectExcludingElvis.compileAndLint(code)).isEmpty() @@ -169,7 +169,7 @@ class CascadingCallWrappingSpec { val code = """ val a = 0 .plus(0) ?: 0 - """ + """.trimIndent() assertThat(subjectIncludingElvis.compileAndLint(code)).hasSize(1) assertThat(subjectExcludingElvis.compileAndLint(code)).isEmpty() diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ClassOrderingSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ClassOrderingSpec.kt index ebd96ce817d..902147806a0 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ClassOrderingSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ClassOrderingSpec.kt @@ -26,7 +26,7 @@ class ClassOrderingSpec { const val IMPORTANT_VALUE = 3 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -49,7 +49,7 @@ class ClassOrderingSpec { const val IMPORTANT_VALUE = 3 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -72,7 +72,7 @@ class ClassOrderingSpec { const val IMPORTANT_VALUE = 3 } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) @@ -99,7 +99,7 @@ class ClassOrderingSpec { const val IMPORTANT_VALUE = 3 } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(2) @@ -129,7 +129,7 @@ class ClassOrderingSpec { const val IMPORTANT_VALUE = 3 } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(3) @@ -159,7 +159,7 @@ class ClassOrderingSpec { fun returnX() = x } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) @@ -184,7 +184,7 @@ class ClassOrderingSpec { fun returnX() = x } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(0) } @@ -207,7 +207,7 @@ class ClassOrderingSpec { fun returnX() = x } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(0) } @@ -232,7 +232,7 @@ class ClassOrderingSpec { val y = x } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(3) @@ -258,7 +258,7 @@ class ClassOrderingSpec { val y = x } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(3) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CollapsibleIfStatementsSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CollapsibleIfStatementsSpec.kt index d8193d2c7a6..69464cbcf97 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CollapsibleIfStatementsSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/CollapsibleIfStatementsSpec.kt @@ -17,7 +17,7 @@ class CollapsibleIfStatementsSpec { // a comment } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -32,7 +32,7 @@ class CollapsibleIfStatementsSpec { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -45,7 +45,7 @@ class CollapsibleIfStatementsSpec { if (true) {} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -57,7 +57,7 @@ class CollapsibleIfStatementsSpec { if (1 == 1) {} } else {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -70,7 +70,7 @@ class CollapsibleIfStatementsSpec { } else if (false) {} else {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -83,7 +83,7 @@ class CollapsibleIfStatementsSpec { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -96,7 +96,7 @@ class CollapsibleIfStatementsSpec { } else {} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -109,7 +109,7 @@ class CollapsibleIfStatementsSpec { } else if (2 == 2) {} } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/DataClassContainsFunctionsSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/DataClassContainsFunctionsSpec.kt index cdf1fb497d9..e92db270b27 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/DataClassContainsFunctionsSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/DataClassContainsFunctionsSpec.kt @@ -21,7 +21,7 @@ class DataClassContainsFunctionsSpec { fun toConversion() = C(i.toString()) } } - """ + """.trimIndent() @Test fun `reports valid data class with conversion function`() { @@ -55,7 +55,7 @@ class DataClassContainsFunctionsSpec { class C { fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -76,7 +76,7 @@ class DataClassContainsFunctionsSpec { return super.toString() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/DataClassShouldBeImmutableSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/DataClassShouldBeImmutableSpec.kt index 06da33906d5..08dae552bc2 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/DataClassShouldBeImmutableSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/DataClassShouldBeImmutableSpec.kt @@ -19,7 +19,7 @@ class DataClassShouldBeImmutableSpec { data class C(val i: Int) { var s: String? = null } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -30,7 +30,7 @@ class DataClassShouldBeImmutableSpec { var s: String = "" private set } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -40,7 +40,7 @@ class DataClassShouldBeImmutableSpec { data class C(val i: Int) { lateinit var s: String } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -56,7 +56,7 @@ class DataClassShouldBeImmutableSpec { data class C(val i: Int) { val s: String? = null } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -66,7 +66,7 @@ class DataClassShouldBeImmutableSpec { data class C(val i: Int) { val s: String by lazy { "" } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -76,7 +76,7 @@ class DataClassShouldBeImmutableSpec { class C(var i: Int) { val s: String by lazy { "" } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/EqualsNullCallSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/EqualsNullCallSpec.kt index 67a42ffdecf..3499a15653f 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/EqualsNullCallSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/EqualsNullCallSpec.kt @@ -14,7 +14,7 @@ class EqualsNullCallSpec { fun x(a: String) { a.equals(null) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code).size).isEqualTo(1) } @@ -24,7 +24,7 @@ class EqualsNullCallSpec { fun x(a: String, b: String) { a.equals(b.equals(null)) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code).size).isEqualTo(1) } @@ -34,7 +34,7 @@ class EqualsNullCallSpec { fun x(a: String, b: String) { a.equals(b) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code).size).isEqualTo(0) } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/EqualsOnSignatureLineSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/EqualsOnSignatureLineSpec.kt index 6fce96b1cf0..1839add57e2 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/EqualsOnSignatureLineSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/EqualsOnSignatureLineSpec.kt @@ -17,7 +17,7 @@ class EqualsOnSignatureLineSpec { """ fun foo() = 1 - """ + """.trimIndent() ) assertThat(findings).hasSize(1) } @@ -30,7 +30,7 @@ class EqualsOnSignatureLineSpec { fun bar() = 2 - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -54,7 +54,7 @@ class EqualsOnSignatureLineSpec { foo: String ): Int = 3 - """ + """.trimIndent() ) assertThat(findings).hasSize(3) } @@ -91,7 +91,7 @@ class EqualsOnSignatureLineSpec { : Int = 6 - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -116,7 +116,7 @@ class EqualsOnSignatureLineSpec { ): Int where V : Number = 3 - """ + """.trimIndent() ) assertThat(findings).hasSize(3) } @@ -132,7 +132,7 @@ class EqualsOnSignatureLineSpec { where V : Number = 2 - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -154,7 +154,7 @@ class EqualsOnSignatureLineSpec { Unit { } - """ + """.trimIndent() ) assertThat(findings).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitCollectionElementAccessMethodSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitCollectionElementAccessMethodSpec.kt index 2456dce4646..61fec2b0cca 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitCollectionElementAccessMethodSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitCollectionElementAccessMethodSpec.kt @@ -26,7 +26,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = mapOf() val value = map.get("key") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -37,7 +37,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = mapOf() val value = map?.get("key") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -48,7 +48,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = mutableMapOf() map.set("key", "value") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -59,7 +59,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = mutableMapOf() map.put("key", "val") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -70,7 +70,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = mutableMapOf() val oldValue = map.put("key", "val") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -81,7 +81,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = mutableMapOf() return map.put("key", "val") == null } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -92,7 +92,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = hashMapOf() val value = map.get("key") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -103,7 +103,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = hashMapOf() map.put("key", "value") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -115,7 +115,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = mapOf() val value = map["key"] } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -127,7 +127,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = mutableMapOf() map["key"] = "value" } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -138,7 +138,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = mapOf() val value = listOf("1", "2").associateBy { it }.get("1") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -149,7 +149,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = linkedMapOf() val value = map.get("key") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -160,7 +160,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = mapOf() with(map) { get("a") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0) } } @@ -174,7 +174,7 @@ class ExplicitCollectionElementAccessMethodSpec { val list = listOf() val value = list.get(0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -185,7 +185,7 @@ class ExplicitCollectionElementAccessMethodSpec { val list = mutableListOf() val value = list.get(0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -197,7 +197,7 @@ class ExplicitCollectionElementAccessMethodSpec { val list = listOf() val value = list[0] } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -208,7 +208,7 @@ class ExplicitCollectionElementAccessMethodSpec { val list = arrayListOf() val value = list.get(0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -219,7 +219,7 @@ class ExplicitCollectionElementAccessMethodSpec { val list = listOf() val value = with(list) { get(0) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0) } } @@ -234,7 +234,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = java.util.HashMap() val value = map.get("key") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -245,7 +245,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = java.util.HashMap() map.set("key", "val") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -256,7 +256,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = java.util.HashMap() map.put("key", "val") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -268,7 +268,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = java.util.HashMap() val value = map["key"] } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -280,7 +280,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = java.util.HashMap() map["key"] = "value" } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -291,7 +291,7 @@ class ExplicitCollectionElementAccessMethodSpec { val map = java.util.HashMap() val value = listOf("1", "2").associateBy { it }.get("1") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } @@ -305,7 +305,7 @@ class ExplicitCollectionElementAccessMethodSpec { val buffer = java.nio.ByteBuffer() buffer.get(byteArrayOf(0x42)) } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } @@ -315,7 +315,7 @@ class ExplicitCollectionElementAccessMethodSpec { fun f(field: java.lang.reflect.Field) { val value = field.get(null) // access static field } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } } @@ -331,7 +331,7 @@ class ExplicitCollectionElementAccessMethodSpec { val custom = Custom() val value = custom.get(0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -343,7 +343,7 @@ class ExplicitCollectionElementAccessMethodSpec { val custom = Custom() val value = custom.get(0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -355,7 +355,7 @@ class ExplicitCollectionElementAccessMethodSpec { val custom = Custom() custom.set("key", "value") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -367,7 +367,7 @@ class ExplicitCollectionElementAccessMethodSpec { val custom = Custom() custom.set("key", "value") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -380,7 +380,7 @@ class ExplicitCollectionElementAccessMethodSpec { fun test(c: C) { c.get("key") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -395,7 +395,7 @@ class ExplicitCollectionElementAccessMethodSpec { val list = java.util.ArrayList() val value = list.get(0) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -407,7 +407,7 @@ class ExplicitCollectionElementAccessMethodSpec { val list = java.util.ArrayList() val value = list[0] } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -422,7 +422,7 @@ class ExplicitCollectionElementAccessMethodSpec { val i: Int get() = 1 + 2 val c: Char? get() = "".first() ?: throw IllegalArgumentException("getter") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -431,7 +431,7 @@ class ExplicitCollectionElementAccessMethodSpec { val code = """ val string = "" .toString() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -442,7 +442,7 @@ class ExplicitCollectionElementAccessMethodSpec { val unknownType = UnknownType() val value = unknownType.put("answer", 42) } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } @@ -453,7 +453,7 @@ class ExplicitCollectionElementAccessMethodSpec { fun f() { put() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -472,7 +472,7 @@ class ExplicitCollectionElementAccessMethodSpec { rect.set(0, 1) rect.set(0, 1, 2) } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitItLambdaParameterSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitItLambdaParameterSpec.kt index ab3bc04bc41..7737e1f6388 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitItLambdaParameterSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExplicitItLambdaParameterSpec.kt @@ -18,7 +18,7 @@ class ExplicitItLambdaParameterSpec { fun f() { val digits = 1234.let { it -> listOf(it) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) } @@ -30,7 +30,7 @@ class ExplicitItLambdaParameterSpec { fun f() { val lambda = { it: Int -> it.toString() } } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) } @@ -47,7 +47,7 @@ class ExplicitItLambdaParameterSpec { val digits = 1234.let { lambda(it) }.toList() val flat = listOf(listOf(1), listOf(2)).flatMap { it } } - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -62,7 +62,7 @@ class ExplicitItLambdaParameterSpec { fun f() { val flat = listOf(listOf(1), listOf(2)).mapIndexed { index, it -> it + index } } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) } @@ -74,7 +74,7 @@ class ExplicitItLambdaParameterSpec { fun f() { val lambda = { it: Int, that: String -> it.toString() + that } } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExpressionBodySyntaxSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExpressionBodySyntaxSpec.kt index 27564a265ab..52ae89f1397 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExpressionBodySyntaxSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ExpressionBodySyntaxSpec.kt @@ -23,7 +23,7 @@ class ExpressionBodySyntaxSpec { fun stuff(): Int { return 5 } - """ + """.trimIndent() ) ).hasSize(1) } @@ -36,7 +36,7 @@ class ExpressionBodySyntaxSpec { fun stuff(): String { return StringBuilder().append(0).toString() } - """ + """.trimIndent() ) ).hasSize(1) } @@ -52,7 +52,7 @@ class ExpressionBodySyntaxSpec { fun stuff(): Int { return try { return 5 } catch (e: Exception) { return 3 } } - """ + """.trimIndent() ) ).hasSize(2) } @@ -66,7 +66,7 @@ class ExpressionBodySyntaxSpec { if (true) return true return false } - """ + """.trimIndent() ) ).isEmpty() } @@ -81,7 +81,7 @@ class ExpressionBodySyntaxSpec { } fun callee(a: String): String = "" - """ + """.trimIndent() ) ).isEmpty() } @@ -96,7 +96,7 @@ class ExpressionBodySyntaxSpec { .append(1) .toString() } - """ + """.trimIndent() @Test fun `does not report with the default configuration`() { @@ -120,7 +120,7 @@ class ExpressionBodySyntaxSpec { else -> 1 } } - """ + """.trimIndent() @Test fun `does not report with the default configuration`() { @@ -142,7 +142,7 @@ class ExpressionBodySyntaxSpec { return if (arg == 0) 0 else 1 } - """ + """.trimIndent() @Test fun `does not report with the default configuration`() { diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenCommentSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenCommentSpec.kt index c1c1b7e0f55..e8728c3f630 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenCommentSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenCommentSpec.kt @@ -70,7 +70,7 @@ class ForbiddenCommentSpec { /* TODO: I need to fix this. */ - """ + """.trimIndent() val findings = ForbiddenComment().compileAndLint(code) assertThat(findings).hasSize(1) } @@ -86,7 +86,7 @@ class ForbiddenCommentSpec { * TODO: I need to fix this. */ } - """ + """.trimIndent() val findings = ForbiddenComment().compileAndLint(code) assertThat(findings).hasSize(2) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenImportSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenImportSpec.kt index 18370f8a807..6631f7caedd 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenImportSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenImportSpec.kt @@ -21,7 +21,7 @@ class ForbiddenImportSpec { import com.example.R.string import net.example.R.dimen import net.example.R.dimension - """ + """.trimIndent() @Test fun `should report nothing by default`() { diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenMethodCallSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenMethodCallSpec.kt index 854e9d2d165..dadc3f2d679 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenMethodCallSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenMethodCallSpec.kt @@ -21,7 +21,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { print("3") println("4") } - """ + """.trimIndent() val findings = ForbiddenMethodCall(TestConfig()).compileAndLintWithContext(env, code) assertThat(findings) @@ -44,7 +44,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun main() { System.out.println("hello") } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf(" "))) ).compileAndLintWithContext(env, code) @@ -58,7 +58,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun main() { System.out.println("hello") } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("java.lang.System.gc"))) ).compileAndLintWithContext(env, code) @@ -71,7 +71,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun main() { java.lang.System.out.println("hello") } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("java.io.PrintStream.println"))) ).compileAndLintWithContext(env, code) @@ -86,7 +86,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun main() { out.println("hello") } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("java.io.PrintStream.println"))) ).compileAndLintWithContext(env, code) @@ -102,7 +102,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { System.out.println("hello") System.gc() } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig( mapOf( @@ -123,7 +123,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun main() { java.math.BigDecimal(5.5) == java.math.BigDecimal(5.5) } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("java.math.BigDecimal.equals"))) ).compileAndLintWithContext(env, code) @@ -137,7 +137,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { var i = 1 ++i } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("kotlin.Int.inc"))) ).compileAndLintWithContext(env, code) @@ -151,7 +151,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { var i = 1 i-- } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("kotlin.Int.dec"))) ).compileAndLintWithContext(env, code) @@ -168,7 +168,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { val date = LocalDate.now() val date2 = LocalDate.now(clock) } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("java.time.LocalDate.now"))) ).compileAndLintWithContext(env, code) @@ -185,7 +185,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { val date = LocalDate.now() val date2 = LocalDate.now(clock) } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("java.time.LocalDate.now()"))) ).compileAndLintWithContext(env, code) @@ -204,7 +204,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { val date = LocalDate.now() val date2 = LocalDate.now(clock) } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("java.time.LocalDate.now(java.time.Clock)"))) ).compileAndLintWithContext(env, code) @@ -219,7 +219,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun test() { val date = LocalDate.of(2020, 1, 1) } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("java.time.LocalDate.of(kotlin.Int, kotlin.Int, kotlin.Int)"))) ).compileAndLintWithContext(env, code) @@ -234,7 +234,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun test() { val date = LocalDate.of(2020, 1, 1) } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("java.time.LocalDate.of(kotlin.Int,kotlin.Int,kotlin.Int)"))) ).compileAndLintWithContext(env, code) @@ -252,7 +252,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun test() { val s = `some, test`() } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("io.gitlab.arturbosch.detekt.rules.style.`some, test`()"))) ).compileAndLintWithContext(env, code) @@ -270,7 +270,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun test() { val s = defaultParamsMethod("test") } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig( mapOf( @@ -300,7 +300,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { i.f() c.f() } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("org.example.com.I.f"))) ).compileAndLintWithContext(env, code) @@ -317,7 +317,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun foo() { bar { "" } } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("org.example.bar((kotlin.String) -> kotlin.String)"))) ).compileAndLintWithContext(env, code) @@ -334,7 +334,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun foo() { "".bar() } - """ + """.trimIndent() val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("org.example.bar(kotlin.String)"))) ).compileAndLintWithContext(env, code) @@ -351,7 +351,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun foo() { bar(1, "", "") } - """ + """.trimIndent() @Test fun `raise the issue`() { @@ -380,7 +380,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { fun foo() { 1.bar("") } - """ + """.trimIndent() @Test fun `raise the issue`() { @@ -410,7 +410,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { runCatching {} } } - """ + """.trimIndent() @Test fun `forbid the one without receiver`() { @@ -445,7 +445,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { val calendar = Calendar.getInstance() val day = calendar.getFirstDayOfWeek() } - """ + """.trimIndent() val findings = ForbiddenMethodCall(TestConfig(mapOf(METHODS to listOf("java.util.Calendar.getFirstDayOfWeek")))).compileAndLintWithContext( env, @@ -463,7 +463,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { val calendar = Calendar.getInstance() val day = calendar.firstDayOfWeek } - """ + """.trimIndent() val findings = ForbiddenMethodCall(TestConfig(mapOf(METHODS to listOf("java.util.Calendar.getFirstDayOfWeek")))).compileAndLintWithContext( env, @@ -482,7 +482,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { val calendar = Calendar.getInstance() calendar.firstDayOfWeek = 1 } - """ + """.trimIndent() val findings = ForbiddenMethodCall(TestConfig(mapOf(METHODS to listOf("java.util.Calendar.setFirstDayOfWeek")))).compileAndLintWithContext( env, @@ -500,7 +500,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { val calendar = Calendar.getInstance() calendar.let(calendar::compareTo) } - """ + """.trimIndent() val findings = ForbiddenMethodCall(TestConfig(mapOf(METHODS to listOf("java.util.Calendar.compareTo")))).compileAndLintWithContext( env, diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenPublicDataClassSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenPublicDataClassSpec.kt index 08a54f92025..8900bd700bc 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenPublicDataClassSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenPublicDataClassSpec.kt @@ -13,7 +13,7 @@ class ForbiddenPublicDataClassSpec { fun `public data class should pass without explicit filters set`() { val code = """ data class C(val a: String) - """ + """.trimIndent() assertThat(ForbiddenPublicDataClass(TestConfig(Config.EXCLUDES_KEY to "**")).compileAndLint(code)).isEmpty() } @@ -22,7 +22,7 @@ class ForbiddenPublicDataClassSpec { fun `public data class should fail`() { val code = """ data class C(val a: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -31,7 +31,7 @@ class ForbiddenPublicDataClassSpec { fun `private data class should pass`() { val code = """ private data class C(val a: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -40,7 +40,7 @@ class ForbiddenPublicDataClassSpec { fun `internal data class should pass`() { val code = """ internal data class C(val a: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -49,7 +49,7 @@ class ForbiddenPublicDataClassSpec { fun `public class should pass`() { val code = """ class C(val a: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -60,7 +60,7 @@ class ForbiddenPublicDataClassSpec { class C { private data class D(val a: String) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -71,7 +71,7 @@ class ForbiddenPublicDataClassSpec { class C { data class D(val a: String) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -82,7 +82,7 @@ class ForbiddenPublicDataClassSpec { open class C { protected data class D(val a: String) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -93,7 +93,7 @@ class ForbiddenPublicDataClassSpec { internal class C { data class D(val a: String) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -104,7 +104,7 @@ class ForbiddenPublicDataClassSpec { package com.example.internal data class C(val a: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -115,7 +115,7 @@ class ForbiddenPublicDataClassSpec { package com.example.internal.other data class C(val a: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -126,7 +126,7 @@ class ForbiddenPublicDataClassSpec { package com.example.internalise data class C(val a: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -137,7 +137,7 @@ class ForbiddenPublicDataClassSpec { package com.random data class C(val a: String) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -148,7 +148,7 @@ class ForbiddenPublicDataClassSpec { package com.example data class C(val a: String) - """ + """.trimIndent() val config = TestConfig("ignorePackages" to listOf("*.hello", "com.example")) assertThat(ForbiddenPublicDataClass(config).compileAndLint(code)).isEmpty() @@ -160,7 +160,7 @@ class ForbiddenPublicDataClassSpec { package org.example data class C(val a: String) - """ + """.trimIndent() val config = TestConfig("ignorePackages" to "*.hello,org.example") assertThat(ForbiddenPublicDataClass(config).compileAndLint(code)).isEmpty() diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenSuppressSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenSuppressSpec.kt index 3fd6714e5c4..f3e47b2cbf4 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenSuppressSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenSuppressSpec.kt @@ -21,7 +21,7 @@ internal class ForbiddenSuppressSpec { @SuppressWarnings("ARule") class Foo - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(3, 1) @@ -35,7 +35,7 @@ internal class ForbiddenSuppressSpec { val code = """ @file:Suppress("ARule") package config - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(1, 1) @@ -51,7 +51,7 @@ internal class ForbiddenSuppressSpec { @Suppress("ARule") fun foo() { } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(3, 1) @@ -69,7 +69,7 @@ internal class ForbiddenSuppressSpec { @Suppress("ARule") println("bar") } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(4, 5) @@ -85,7 +85,7 @@ internal class ForbiddenSuppressSpec { @Suppress("UNCHECKED_CAST") fun foo() { } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).isEmpty() } @@ -97,7 +97,7 @@ internal class ForbiddenSuppressSpec { @Suppress("UNCHECKED_CAST", "ARule") fun foo() { } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings.first()).hasMessage( @@ -113,7 +113,7 @@ internal class ForbiddenSuppressSpec { @Suppress fun foo() { } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(0) } @@ -130,7 +130,7 @@ internal class ForbiddenSuppressSpec { val code = """ @file:Suppress("ARule", "BRule") package config - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(1, 1) @@ -147,7 +147,7 @@ internal class ForbiddenSuppressSpec { @Suppress("BRule") fun foo() { } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(3, 1) @@ -168,7 +168,7 @@ internal class ForbiddenSuppressSpec { val code = """ @file:Suppress("ForbiddenSuppress") package config - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(0) } @@ -178,7 +178,7 @@ internal class ForbiddenSuppressSpec { val code = """ @file:Suppress("ForbiddenSuppress", "ARule") package config - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(0) } @@ -193,7 +193,7 @@ internal class ForbiddenSuppressSpec { val code = """ @file:Suppress("ARule") package config - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(0) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenVoidSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenVoidSpec.kt index 096cd1e0acd..38fbae8ba5a 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenVoidSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenVoidSpec.kt @@ -26,7 +26,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { val a: Void? = null val b: Void = null!! } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(4) } @@ -36,7 +36,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { val code = """ val clazz = java.lang.Void::class val klass = Void::class - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -55,7 +55,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { fun myFun2(): E = E.Void abstract fun myFun(): Void } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -78,7 +78,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { throw IllegalStateException() } } - """ + """.trimIndent() val findings = ForbiddenVoid(config).compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -99,7 +99,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { throw IllegalStateException() } } - """ + """.trimIndent() val findings = ForbiddenVoid(config).compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -117,7 +117,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { val a: Void? = null } } - """ + """.trimIndent() val findings = ForbiddenVoid(config).compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -129,7 +129,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { fun method(param: Void) : Void { return param } - """ + """.trimIndent() val findings = ForbiddenVoid(config).compileAndLintWithContext(env, code) assertThat(findings).hasSize(2) @@ -157,7 +157,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { } class D : A - """ + """.trimIndent() val findings = ForbiddenVoid(config).compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -169,7 +169,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { interface A interface B class C : A> - """ + """.trimIndent() val findings = ForbiddenVoid(config).compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -179,7 +179,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { fun `should not report Void in definition with multiple generic parameters`() { val code = """ val foo = mutableMapOf() - """ + """.trimIndent() val findings = ForbiddenVoid(config).compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -194,7 +194,7 @@ class ForbiddenVoidSpec(val env: KotlinCoreEnvironment) { val a: Void? = null val b: Void = null!! } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(4) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/FunctionOnlyReturningConstantSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/FunctionOnlyReturningConstantSpec.kt index 8724eee44c8..1ce564554f0 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/FunctionOnlyReturningConstantSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/FunctionOnlyReturningConstantSpec.kt @@ -26,7 +26,7 @@ class FunctionOnlyReturningConstantSpec { actual class ActualFunctionReturningConstant { actual fun f() = 1 } - """ + """.trimIndent() val code = """ import kotlin.SinceKotlin @@ -36,7 +36,7 @@ class FunctionOnlyReturningConstantSpec { return "I am a constant" } } - """ + """.trimIndent() @Test fun `reports functions which return constants`() { diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/LibraryCodeMustSpecifyReturnTypeSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/LibraryCodeMustSpecifyReturnTypeSpec.kt index 44267b2056e..fd580d16d27 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/LibraryCodeMustSpecifyReturnTypeSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/LibraryCodeMustSpecifyReturnTypeSpec.kt @@ -26,7 +26,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { fun b() = 2 val c = 2 } - """ + """.trimIndent() ) ).isEmpty() } @@ -42,7 +42,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { env, """ fun foo() = 5 - """ + """.trimIndent() ) ).hasSize(1) } @@ -54,7 +54,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { env, """ val foo = 5 - """ + """.trimIndent() ) ).hasSize(1) } @@ -69,7 +69,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { val foo = 5 fun bar() = 5 } - """ + """.trimIndent() ) ).hasSize(2) } @@ -84,7 +84,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { protected val foo = 5 protected fun bar() = 5 } - """ + """.trimIndent() ) ).hasSize(2) } @@ -101,7 +101,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { env, """ fun foo(): Int = 5 - """ + """.trimIndent() ) ).isEmpty() } @@ -113,7 +113,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { env, """ fun foo() {} - """ + """.trimIndent() ) ).isEmpty() } @@ -125,7 +125,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { env, """ val foo: Int = 5 - """ + """.trimIndent() ) ).isEmpty() } @@ -140,7 +140,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { val foo: Int = 5 fun bar(): Int = 5 } - """ + """.trimIndent() ) ).isEmpty() } @@ -158,7 +158,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { """ internal fun bar() = 5 private fun foo() = 5 - """ + """.trimIndent() ) ).isEmpty() } @@ -170,7 +170,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { env, """ internal val foo = 5 - """ + """.trimIndent() ) ).isEmpty() } @@ -188,7 +188,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { val a = 5 } } - """ + """.trimIndent() ) ).isEmpty() } @@ -203,7 +203,7 @@ class LibraryCodeMustSpecifyReturnTypeSpec(val env: KotlinCoreEnvironment) { fun baz() = 5 val qux = 5 } - """ + """.trimIndent() ) ).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/LibraryEntitiesShouldNotBePublicSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/LibraryEntitiesShouldNotBePublicSpec.kt index 0d2860f7171..7cd20e4a41e 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/LibraryEntitiesShouldNotBePublicSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/LibraryEntitiesShouldNotBePublicSpec.kt @@ -16,7 +16,7 @@ class LibraryEntitiesShouldNotBePublicSpec { subject.compileAndLint( """ class A - """ + """.trimIndent() ) ).isEmpty() } @@ -31,7 +31,7 @@ class LibraryEntitiesShouldNotBePublicSpec { subject.compileAndLint( """ class A - """ + """.trimIndent() ) ).hasSize(1) } @@ -46,7 +46,7 @@ class LibraryEntitiesShouldNotBePublicSpec { return 1 } } - """ + """.trimIndent() ) ).hasSize(1) } @@ -57,7 +57,7 @@ class LibraryEntitiesShouldNotBePublicSpec { subject.compileAndLint( """ typealias A = List - """ + """.trimIndent() ) ).hasSize(1) } @@ -69,7 +69,7 @@ class LibraryEntitiesShouldNotBePublicSpec { """ typealias A = List fun foo() = Unit - """ + """.trimIndent() ) ).hasSize(2) } @@ -80,7 +80,7 @@ class LibraryEntitiesShouldNotBePublicSpec { subject.compileAndLint( """ fun foo() = Unit - """ + """.trimIndent() ) ).hasSize(1) } @@ -100,7 +100,7 @@ class LibraryEntitiesShouldNotBePublicSpec { return 1 } } - """ + """.trimIndent() ) ).isEmpty() } @@ -111,7 +111,7 @@ class LibraryEntitiesShouldNotBePublicSpec { subject.compileAndLint( """ internal class A - """ + """.trimIndent() ) ).isEmpty() } @@ -122,7 +122,7 @@ class LibraryEntitiesShouldNotBePublicSpec { subject.compileAndLint( """ internal typealias A = List - """ + """.trimIndent() ) ).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MagicNumberSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MagicNumberSpec.kt index ea9d7c09b4b..566e7eca0d9 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MagicNumberSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MagicNumberSpec.kt @@ -340,7 +340,7 @@ class MagicNumberSpec { 3 -> return 3 } } - """ + """.trimIndent() @Test fun `should be reported`() { @@ -362,7 +362,7 @@ class MagicNumberSpec { fun test(x: Int) { val i = 5 } - """ + """.trimIndent() @Test fun `should be reported`() { @@ -377,7 +377,7 @@ class MagicNumberSpec { fun test() : Boolean { return true; } - """ + """.trimIndent() @Test fun `should not be reported`() { @@ -469,7 +469,7 @@ class MagicNumberSpec { } data class Color(val color: Int) - """ + """.trimIndent() @Test fun `should report all without ignore flags`() { @@ -526,7 +526,7 @@ class MagicNumberSpec { const val anotherBoringConstant = 93872 } } - """ + """.trimIndent() @Test fun `should not report any issues by default`() { @@ -645,7 +645,7 @@ class MagicNumberSpec { ) var model = Model(someVal = $numberString) - """ + """.trimIndent() @Test fun `should not ignore int`() { @@ -687,7 +687,7 @@ class MagicNumberSpec { abstract class A(n: Int) object B : A(n = 5) - """ + """.trimIndent() assertThat(MagicNumber().compileAndLint(code)).isEmpty() } @@ -709,7 +709,7 @@ class MagicNumberSpec { ) var model = Model($numberString) - """ + """.trimIndent() @Test fun `should detect the argument by default`() { @@ -723,7 +723,7 @@ class MagicNumberSpec { fun tested(someVal: Int, other: String = "default") val t = tested(someVal = $number) - """ + """.trimIndent() @Test fun `should ignore int by default`() { @@ -753,7 +753,7 @@ class MagicNumberSpec { SMALL(1), EXTRA_LARGE(5) } - """ + """.trimIndent() @Test fun `should be reported by default`() { @@ -774,7 +774,7 @@ class MagicNumberSpec { SMALL(id = 1), EXTRA_LARGE(id = 5) } - """ + """.trimIndent() @Test fun `should be reported`() { @@ -805,7 +805,7 @@ class MagicNumberSpec { val code = """ fun x() = 9 fun y(): Int { return 9 } - """ + """.trimIndent() assertThat(MagicNumber().compileAndLint(code)).isEmpty() } @@ -814,7 +814,7 @@ class MagicNumberSpec { val code = """ fun x() = 9 + 1 fun y(): Int { return 9 + 1 } - """ + """.trimIndent() assertThat(MagicNumber().compileAndLint(code)).hasSize(2) } } @@ -851,7 +851,7 @@ class MagicNumberSpec { class SomeClassWithDefault { constructor(val defaultValue: Int = 10) { } } - """ + """.trimIndent() assertThat(MagicNumber().lint(code)).isEmpty() } @@ -861,7 +861,7 @@ class MagicNumberSpec { class SomeClassWithDefault { constructor(val defaultValue: Duration = 10.toDuration(DurationUnit.MILLISECONDS)) { } } - """ + """.trimIndent() assertThat(MagicNumber().lint(code)).isEmpty() } } @@ -994,7 +994,7 @@ class MagicNumberSpec { fun Int.dp() = this + 1 val a = 500.dp() - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).isEmpty() } @@ -1006,7 +1006,7 @@ class MagicNumberSpec { get() = this + 1 val a = 500.dp - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).isEmpty() } @@ -1017,7 +1017,7 @@ class MagicNumberSpec { fun Int.dp(a: Int) = this + a val a = 500.dp(400) - """ + """.trimIndent() assertThat(rule.compileAndLint(code)).hasSize(1) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxChainedCallsOnSameLineSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxChainedCallsOnSameLineSpec.kt index f1240d13bfb..41cee426c1a 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxChainedCallsOnSameLineSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxChainedCallsOnSameLineSpec.kt @@ -67,7 +67,7 @@ class MaxChainedCallsOnSameLineSpec(private val env: KotlinCoreEnvironment) { .plus(0) .plus(0) .plus(0) - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).isEmpty() } @@ -79,7 +79,7 @@ class MaxChainedCallsOnSameLineSpec(private val env: KotlinCoreEnvironment) { val a = 0.plus(0).plus(0) .plus(0).plus(0).plus(0) .plus(0).plus(0).plus(0) - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).isEmpty() } @@ -91,7 +91,7 @@ class MaxChainedCallsOnSameLineSpec(private val env: KotlinCoreEnvironment) { val a = 0.plus(0).plus(0).plus(0) .plus(0) .plus(0) - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).hasSize(1) } @@ -104,7 +104,7 @@ class MaxChainedCallsOnSameLineSpec(private val env: KotlinCoreEnvironment) { .plus(0) .plus(0).plus(0).plus(0).plus(0) .plus(0) - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).hasSize(1) } @@ -130,7 +130,7 @@ class MaxChainedCallsOnSameLineSpec(private val env: KotlinCoreEnvironment) { val rule = MaxChainedCallsOnSameLine(TestConfig(mapOf("maxChainedCalls" to 3))) val code = """ val x = kotlin.math.floor(1.0).plus(1).plus(1) - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).isEmpty() } @@ -139,7 +139,7 @@ class MaxChainedCallsOnSameLineSpec(private val env: KotlinCoreEnvironment) { val rule = MaxChainedCallsOnSameLine(TestConfig(mapOf("maxChainedCalls" to 3))) val code = """ val x = kotlin.run { 1 }.plus(1).plus(1) - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxLineLengthSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxLineLengthSpec.kt index d6c52a7986a..8410e704919 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxLineLengthSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxLineLengthSpec.kt @@ -77,7 +77,7 @@ class MaxLineLengthSpec { class Test { } - """ + """.trimIndent() private val file = compileContentForTest(code) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MayBeConstSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MayBeConstSpec.kt index 97dd7c3da6f..a599b0428d9 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MayBeConstSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MayBeConstSpec.kt @@ -19,7 +19,7 @@ class MayBeConstSpec { object Something { const val X = 42 } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -30,7 +30,7 @@ class MayBeConstSpec { object Test { const val TEST = "Test" } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -43,7 +43,7 @@ class MayBeConstSpec { const val B = 1 } } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -60,7 +60,7 @@ class MayBeConstSpec { const val B = Something.A + 1 } } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -73,7 +73,7 @@ class MayBeConstSpec { } val p = Pair(Something.a, Something.a + Something.a) val p2 = emptyList().plus(Something.a) - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -85,7 +85,7 @@ class MayBeConstSpec { fun `is a simple val`() { val code = """ val x = 1 - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(1, 5) @@ -96,7 +96,7 @@ class MayBeConstSpec { fun `is a simple JvmField val`() { val code = """ @JvmField val x = 1 - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(1, 15) @@ -109,7 +109,7 @@ class MayBeConstSpec { object Test { @JvmField val test = "Test" } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(2, 19) @@ -124,7 +124,7 @@ class MayBeConstSpec { val b = 1 } } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 13) @@ -141,7 +141,7 @@ class MayBeConstSpec { const val one = 1 val two = one * 2 } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 9) @@ -157,7 +157,7 @@ class MayBeConstSpec { val two = one * 2 } } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(4, 13) @@ -171,7 +171,7 @@ class MayBeConstSpec { const val one = 1 val two = one * 2 + 1 } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 9) @@ -185,7 +185,7 @@ class MayBeConstSpec { const val one = 1 val two = one * (2 + 1) } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 9) @@ -201,7 +201,7 @@ class MayBeConstSpec { @JvmField val b = a + 1 } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(5, 9) @@ -215,7 +215,7 @@ class MayBeConstSpec { private const val A = "a" private val B = A + "b" } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 17) @@ -259,7 +259,7 @@ class MayBeConstSpec { class Test { @JvmField val a = 3 } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -270,7 +270,7 @@ class MayBeConstSpec { annotation class A @A val a = 55 - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -285,7 +285,7 @@ class MayBeConstSpec { object Derived : Base { override val property = 1 } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -314,7 +314,7 @@ class MayBeConstSpec { } var test_var = "test" var code = $innerCode - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -328,7 +328,7 @@ class MayBeConstSpec { val prop = "" } } - """ + """.trimIndent() ) assertThat(subject.findings).isEmpty() @@ -361,7 +361,7 @@ class MayBeConstSpec { val ACONST = ROOT_CONST + 1 } } - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(3).hasStartSourceLocations( SourceLocation(4, 13), diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ModifierOrderSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ModifierOrderSpec.kt index af049d6a8df..6728ae1ab8f 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ModifierOrderSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ModifierOrderSpec.kt @@ -68,7 +68,7 @@ class ModifierOrderSpec { abstract class Test : A() { override open fun test() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -81,7 +81,7 @@ class ModifierOrderSpec { abstract class Test : A() { override fun test() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } @@ -95,7 +95,7 @@ class ModifierOrderSpec { public class A { tailrec private fun foo(x: Double = 1.0): Double = 1.0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -105,7 +105,7 @@ class ModifierOrderSpec { public class A { private tailrec fun foo(x: Double = 1.0): Double = 1.0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } @@ -135,7 +135,7 @@ class ModifierOrderSpec { private fun interface LoadMoreCallback { fun loadMore(): Boolean } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } @@ -148,7 +148,7 @@ class ModifierOrderSpec { val code = """ @JvmInline private value class Foo(val bar: Int) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MultilineLambdaItParameterSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MultilineLambdaItParameterSpec.kt index 9d9a5b5dda4..f60ad833601 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MultilineLambdaItParameterSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MultilineLambdaItParameterSpec.kt @@ -23,7 +23,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { println(it) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -37,7 +37,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { println(it) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -51,7 +51,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { println(param) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -68,7 +68,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { println(it) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -84,7 +84,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { listOf(it) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -97,7 +97,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { listOf(it) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -110,7 +110,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { listOf(param) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -124,7 +124,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { fun f() { val digits = 1234.let { listOf(it) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -135,7 +135,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { fun f() { val digits = 1234.let { listOf(it) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -146,7 +146,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { fun f() { val digits = 1234.let { it -> listOf(it) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -157,7 +157,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { fun f() { val digits = 1234.let { param -> listOf(param) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -174,7 +174,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { it + index } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -188,7 +188,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { item.toString() + that } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -205,7 +205,7 @@ class MultilineLambdaItParameterSpec(val env: KotlinCoreEnvironment) { append("b") } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MultilineRawStringIndentationSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MultilineRawStringIndentationSpec.kt index c309c54af73..b799c910e94 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MultilineRawStringIndentationSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MultilineRawStringIndentationSpec.kt @@ -17,7 +17,7 @@ class MultilineRawStringIndentationSpec { val a = $TQ Hello world! $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(1) @@ -33,7 +33,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(2) @@ -47,7 +47,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(1) @@ -63,7 +63,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(1) @@ -79,7 +79,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .isEmpty() @@ -93,7 +93,7 @@ class MultilineRawStringIndentationSpec { How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .isEmpty() @@ -107,7 +107,7 @@ class MultilineRawStringIndentationSpec { How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .isEmpty() @@ -120,7 +120,7 @@ class MultilineRawStringIndentationSpec { Hello world! $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(1) @@ -135,7 +135,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(1) @@ -153,7 +153,7 @@ class MultilineRawStringIndentationSpec { $TQ Hello world! $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(1) @@ -169,7 +169,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(2) @@ -183,7 +183,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(1) @@ -199,7 +199,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(1) @@ -216,7 +216,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .isEmpty() @@ -230,7 +230,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .isEmpty() @@ -244,7 +244,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(1) @@ -260,7 +260,7 @@ class MultilineRawStringIndentationSpec { Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .hasSize(1) @@ -277,7 +277,7 @@ class MultilineRawStringIndentationSpec { val a = $TQ Hello world! $TQ - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -286,7 +286,7 @@ class MultilineRawStringIndentationSpec { fun `don't raise one line raw strings`() { val code = """ val a = ${TQ}Hello world!$TQ - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -295,7 +295,7 @@ class MultilineRawStringIndentationSpec { fun `doesn't raise if it is not a raw string`() { val code = """ val a = "Hello world!" - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -306,7 +306,7 @@ class MultilineRawStringIndentationSpec { val a = ${TQ}Hello world! How are you? $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .isEmpty() @@ -318,7 +318,7 @@ class MultilineRawStringIndentationSpec { val a = $TQ Hello world! How are you?$TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .isEmpty() @@ -329,7 +329,7 @@ class MultilineRawStringIndentationSpec { val code = """ val a = $TQ $TQ.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings) .isEmpty() diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NestedClassesVisibilitySpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NestedClassesVisibilitySpec.kt index 792b0628a97..2d1a466741a 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NestedClassesVisibilitySpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NestedClassesVisibilitySpec.kt @@ -15,7 +15,7 @@ class NestedClassesVisibilitySpec { public object B public class C } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(3) } @@ -26,7 +26,7 @@ class NestedClassesVisibilitySpec { A; public class C } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -39,7 +39,7 @@ class NestedClassesVisibilitySpec { enum class E { One } internal interface I } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -49,7 +49,7 @@ class NestedClassesVisibilitySpec { internal class Outer { private class A } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -59,7 +59,7 @@ class NestedClassesVisibilitySpec { internal class Outer { public enum class E { E1; } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -69,7 +69,7 @@ class NestedClassesVisibilitySpec { internal class Outer { public companion object C } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -79,7 +79,7 @@ class NestedClassesVisibilitySpec { internal class Outer { companion object C } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -89,7 +89,7 @@ class NestedClassesVisibilitySpec { private class Outer { class A } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -99,7 +99,7 @@ class NestedClassesVisibilitySpec { internal interface Outer { class A } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -111,7 +111,7 @@ class NestedClassesVisibilitySpec { public class C2 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NullableBooleanCheckSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NullableBooleanCheckSpec.kt index e7c9799731a..c18468cf5a4 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NullableBooleanCheckSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NullableBooleanCheckSpec.kt @@ -32,7 +32,7 @@ class NullableBooleanCheckSpec(val env: KotlinCoreEnvironment) { fun foo(): Boolean { return nullableBoolean() ?: $bool } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -48,7 +48,7 @@ class NullableBooleanCheckSpec(val env: KotlinCoreEnvironment) { fun foo(): Boolean { return nullableBoolean() ?: $bool } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -69,7 +69,7 @@ class NullableBooleanCheckSpec(val env: KotlinCoreEnvironment) { fun foo() { if (nullableBoolean() ?: $bool) println("foo") } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -89,7 +89,7 @@ class NullableBooleanCheckSpec(val env: KotlinCoreEnvironment) { fun foo(): Boolean { return nullableBoolean() ?: Random.nextBoolean() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -105,7 +105,7 @@ class NullableBooleanCheckSpec(val env: KotlinCoreEnvironment) { fun foo(): Any { return nullableAny() ?: $bool } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -120,7 +120,7 @@ class NullableBooleanCheckSpec(val env: KotlinCoreEnvironment) { fun foo(): Int { return nullableInt() ?: 0 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -133,7 +133,7 @@ class NullableBooleanCheckSpec(val env: KotlinCoreEnvironment) { fun foo(): Boolean { return Random.nextBoolean() || false } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ObjectLiteralToLambdaSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ObjectLiteralToLambdaSpec.kt index ca0b3e89673..6b39f2e1621 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ObjectLiteralToLambdaSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ObjectLiteralToLambdaSpec.kt @@ -29,7 +29,7 @@ class ObjectLiteralToLambdaSpec { override fun foo() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -48,7 +48,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -69,7 +69,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -87,7 +87,7 @@ class ObjectLiteralToLambdaSpec { return 1 } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -105,7 +105,7 @@ class ObjectLiteralToLambdaSpec { override fun foo() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -126,7 +126,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -142,7 +142,7 @@ class ObjectLiteralToLambdaSpec { val a = object : Sam { override fun foo() = 3 } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -162,7 +162,7 @@ class ObjectLiteralToLambdaSpec { override fun foo() { } } - """ + """.trimIndent() subject.compileAndLint(code).assert().isEmpty() } @@ -171,7 +171,7 @@ class ObjectLiteralToLambdaSpec { val code = """ interface Sam val a = object : Sam {} - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -183,7 +183,7 @@ class ObjectLiteralToLambdaSpec { fun foo() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -196,7 +196,7 @@ class ObjectLiteralToLambdaSpec { val a = object : Sam { override val foo = 1 } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -207,7 +207,7 @@ class ObjectLiteralToLambdaSpec { val a = object : Sam { val b = 1 } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -221,7 +221,7 @@ class ObjectLiteralToLambdaSpec { override fun foo() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -235,7 +235,7 @@ class ObjectLiteralToLambdaSpec { override fun foo() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -251,7 +251,7 @@ class ObjectLiteralToLambdaSpec { override fun foo() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -269,7 +269,7 @@ class ObjectLiteralToLambdaSpec { override fun foo() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } } @@ -288,7 +288,7 @@ class ObjectLiteralToLambdaSpec { fun bar() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -303,7 +303,7 @@ class ObjectLiteralToLambdaSpec { override fun foo() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -319,7 +319,7 @@ class ObjectLiteralToLambdaSpec { override fun foo() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } } @@ -333,7 +333,7 @@ class ObjectLiteralToLambdaSpec { override fun run(){ } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -349,7 +349,7 @@ class ObjectLiteralToLambdaSpec { return 1 } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -364,7 +364,7 @@ class ObjectLiteralToLambdaSpec { fun foo() { } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -381,7 +381,7 @@ class ObjectLiteralToLambdaSpec { return 1 } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } } @@ -402,7 +402,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -422,7 +422,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -440,7 +440,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } @@ -462,7 +462,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -485,7 +485,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -506,7 +506,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.compileAndLintWithContext(env, code).assert().isEmpty() } } @@ -530,7 +530,7 @@ class ObjectLiteralToLambdaSpec { val a = newObject() === newObject() // false val b = lambda() === lambda() // true - """ + """.trimIndent() subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) @@ -555,7 +555,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.lintWithContext(env, code).assert().hasSize(1) } @@ -569,7 +569,7 @@ class ObjectLiteralToLambdaSpec { val x = object : OnlyDefaultMethods { } } - """ + """.trimIndent() subject.lintWithContext(env, code).assert().isEmpty() } @@ -585,7 +585,7 @@ class ObjectLiteralToLambdaSpec { } } } - """ + """.trimIndent() subject.lintWithContext(env, code).assert().isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalAbstractKeywordSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalAbstractKeywordSpec.kt index aa07be11e84..e7248e06adc 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalAbstractKeywordSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalAbstractKeywordSpec.kt @@ -36,7 +36,7 @@ class OptionalAbstractKeywordSpec { abstract fun x() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -54,7 +54,7 @@ class OptionalAbstractKeywordSpec { abstract fun dependency() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalWhenBracesSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalWhenBracesSpec.kt index 72171b78680..281969010d6 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalWhenBracesSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalWhenBracesSpec.kt @@ -25,7 +25,7 @@ class OptionalWhenBracesSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -38,7 +38,7 @@ class OptionalWhenBracesSpec { else -> println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -63,7 +63,7 @@ class OptionalWhenBracesSpec { false -> println("false") } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)) .hasSize(2) .hasStartSourceLocations(SourceLocation(7, 17), SourceLocation(10, 17)) @@ -84,7 +84,7 @@ class OptionalWhenBracesSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)) .hasSize(1) .hasStartSourceLocations(SourceLocation(3, 9)) @@ -101,7 +101,7 @@ class OptionalWhenBracesSpec { false -> { { it + 200 } } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -114,7 +114,7 @@ class OptionalWhenBracesSpec { false -> { { i -> i + 200 } } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ProtectedMemberInFinalClassSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ProtectedMemberInFinalClassSpec.kt index b1e473ff260..565bfadaa93 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ProtectedMemberInFinalClassSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ProtectedMemberInFinalClassSpec.kt @@ -19,7 +19,7 @@ class ProtectedMemberInFinalClassSpec { class Foo { protected var i1 = 0 } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(2, 5) @@ -34,7 +34,7 @@ class ProtectedMemberInFinalClassSpec { this.i1 = i1 } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(3, 5) @@ -46,7 +46,7 @@ class ProtectedMemberInFinalClassSpec { class Foo { protected fun function() {} } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(2, 5) @@ -60,7 +60,7 @@ class ProtectedMemberInFinalClassSpec { protected val i = 0 } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(3, 9) @@ -74,7 +74,7 @@ class ProtectedMemberInFinalClassSpec { protected val i = 0 } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(2) assertThat(findings).hasStartSourceLocations( @@ -93,7 +93,7 @@ class ProtectedMemberInFinalClassSpec { } } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(3) assertThat(findings).hasStartSourceLocations( @@ -113,7 +113,7 @@ class ProtectedMemberInFinalClassSpec { } } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(4, 13) @@ -127,7 +127,7 @@ class ProtectedMemberInFinalClassSpec { protected val i = 0 } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(3, 9) @@ -137,7 +137,7 @@ class ProtectedMemberInFinalClassSpec { fun `reports a protected primary constructor in a final class`() { val code = """ class FinalClassWithProtectedConstructor protected constructor() - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(1, 42) @@ -154,7 +154,7 @@ class ProtectedMemberInFinalClassSpec { class Foo : BaseClass() { private val i = 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -168,7 +168,7 @@ class ProtectedMemberInFinalClassSpec { // should not report protected = private visibility protected override val abstractProp = 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -183,7 +183,7 @@ class ProtectedMemberInFinalClassSpec { protected override fun abstractFunction() { } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -196,7 +196,7 @@ class ProtectedMemberInFinalClassSpec { protected object InnerObject } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -206,7 +206,7 @@ class ProtectedMemberInFinalClassSpec { sealed class SealedClass { protected fun a() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -217,7 +217,7 @@ class ProtectedMemberInFinalClassSpec { ; protected fun foo() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantExplicitTypeSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantExplicitTypeSpec.kt index 5efcd83d052..d993b79ba04 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantExplicitTypeSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantExplicitTypeSpec.kt @@ -17,7 +17,7 @@ class RedundantExplicitTypeSpec(val env: KotlinCoreEnvironment) { fun function() { val x: Boolean = true } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -27,7 +27,7 @@ class RedundantExplicitTypeSpec(val env: KotlinCoreEnvironment) { fun function() { val x: Int = 3 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -37,7 +37,7 @@ class RedundantExplicitTypeSpec(val env: KotlinCoreEnvironment) { fun function() { val x: Long = 3L } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -47,7 +47,7 @@ class RedundantExplicitTypeSpec(val env: KotlinCoreEnvironment) { fun function() { val x: Float = 3.0f } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -57,7 +57,7 @@ class RedundantExplicitTypeSpec(val env: KotlinCoreEnvironment) { fun function() { val x: Double = 3.0 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -67,7 +67,7 @@ class RedundantExplicitTypeSpec(val env: KotlinCoreEnvironment) { fun function() { val x: Char = 'f' } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -79,7 +79,7 @@ class RedundantExplicitTypeSpec(val env: KotlinCoreEnvironment) { val x = 3 val y: String = "$substitute" } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -91,7 +91,7 @@ class RedundantExplicitTypeSpec(val env: KotlinCoreEnvironment) { fun foo() { val o: Test = Test } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -107,7 +107,7 @@ class RedundantExplicitTypeSpec(val env: KotlinCoreEnvironment) { fun tallPerson() { val t: TallPerson = TallPerson("first", 3) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -123,7 +123,7 @@ class RedundantExplicitTypeSpec(val env: KotlinCoreEnvironment) { fun tallPerson() { val t: Person = TallPerson("first", 3) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantHigherOrderMapUsageSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantHigherOrderMapUsageSpec.kt index 6d562f0f2e1..63e72ebd354 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantHigherOrderMapUsageSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantHigherOrderMapUsageSpec.kt @@ -21,7 +21,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { .filter { it > 1 } .map { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(4, 10) @@ -41,7 +41,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { } .filter { it > 1 } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(5, 10) @@ -54,7 +54,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { fun test() { listOf(1, 2, 3).map { foo -> foo } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -65,7 +65,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { fun test() { listOf(1).map({ it }) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -80,7 +80,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -97,7 +97,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -113,7 +113,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { }.joinToString("") + s } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -124,7 +124,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { fun List.test() { map { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -135,7 +135,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { fun List.test() { this.map { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -146,7 +146,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { fun test() { mutableListOf(1).map { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -157,7 +157,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { fun test() { val x:Sequence = sequenceOf(1).map { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -168,7 +168,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { fun test() { setOf(1).map { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0]).hasMessage("This 'map' call can be replaced with 'toList'.") @@ -185,7 +185,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { .filter { it > 1 } .map { it + 1 } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -199,7 +199,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -210,7 +210,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { fun test() { listOf(1 to 2).map { (a, b) -> a } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -221,7 +221,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { fun test() { val x: List> = mapOf(1 to "a").map { it } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantVisibilityModifierRuleSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantVisibilityModifierRuleSpec.kt index db47e1bcd10..ba27ed3eea1 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantVisibilityModifierRuleSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantVisibilityModifierRuleSpec.kt @@ -26,7 +26,7 @@ class RedundantVisibilityModifierRuleSpec { class Test : A() { override public fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -40,7 +40,7 @@ class RedundantVisibilityModifierRuleSpec { class Test : A() { override fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -54,7 +54,7 @@ class RedundantVisibilityModifierRuleSpec { class Test : A { override public fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -65,7 +65,7 @@ class RedundantVisibilityModifierRuleSpec { @Suppress("RedundantVisibilityModifier") public fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -75,7 +75,7 @@ class RedundantVisibilityModifierRuleSpec { class Test { public fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -85,7 +85,7 @@ class RedundantVisibilityModifierRuleSpec { class Test { fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -95,7 +95,7 @@ class RedundantVisibilityModifierRuleSpec { public class Test { fun f() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -105,7 +105,7 @@ class RedundantVisibilityModifierRuleSpec { public interface Test { public fun f() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -115,7 +115,7 @@ class RedundantVisibilityModifierRuleSpec { class Test { public val str : String = "test" } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -125,7 +125,7 @@ class RedundantVisibilityModifierRuleSpec { class Test { val str : String = "test" } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -139,7 +139,7 @@ class RedundantVisibilityModifierRuleSpec { class B : A() { override val test: String = "valid" } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -153,7 +153,7 @@ class RedundantVisibilityModifierRuleSpec { class B : A() { override public val test: String = "valid" } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -163,7 +163,7 @@ class RedundantVisibilityModifierRuleSpec { private object A { internal class InternalClass } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -173,7 +173,7 @@ class RedundantVisibilityModifierRuleSpec { private object A { internal fun internalFunction() {} } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -186,7 +186,7 @@ class RedundantVisibilityModifierRuleSpec { public class A() { fun f() } - """ + """.trimIndent() ) val rule = RedundantVisibilityModifierRule() diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCountSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCountSpec.kt index 4b6bc3936c3..a0966fc9154 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCountSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ReturnCountSpec.kt @@ -20,7 +20,7 @@ class ReturnCountSpec { inner class `a function without a body` { val code = """ fun func() = Unit - """ + """.trimIndent() @Test fun `does not report violation by default`() { @@ -32,7 +32,7 @@ class ReturnCountSpec { inner class `a function with an empty body` { val code = """ fun func() {} - """ + """.trimIndent() @Test fun `does not report violation by default`() { @@ -51,7 +51,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should not get flagged for if condition guard clauses`() { @@ -75,7 +75,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should not get flagged for if condition guard clauses`() { @@ -110,7 +110,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should report a too-complicated if statement for being a guard clause, with EXCLUDE_GUARD_CLAUSES on`() { @@ -131,7 +131,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should not get flagged for ELVIS operator guard clauses`() { @@ -152,7 +152,7 @@ class ReturnCountSpec { if (x < 4) return 0 return 6 } - """ + """.trimIndent() @Test fun `should get flagged for an if condition guard clause which is not the first statement`() { @@ -173,7 +173,7 @@ class ReturnCountSpec { val y = x ?: return 0 return 6 } - """ + """.trimIndent() @Test fun `should get flagged for an ELVIS guard clause which is not the first statement`() { @@ -197,7 +197,7 @@ class ReturnCountSpec { return } - """ + """.trimIndent() @Test fun `should not count all four guard clauses`() { @@ -231,7 +231,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should get flagged by default`() { @@ -262,7 +262,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should not get flagged by default`() { @@ -294,7 +294,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should not get flagged`() { @@ -339,7 +339,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should flag none of the ignored functions`() { @@ -387,7 +387,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should not get flag when returns is in inner object`() { @@ -424,7 +424,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should not get flag when returns is in inner object`() { @@ -463,7 +463,7 @@ class ReturnCountSpec { } return 6 } - """ + """.trimIndent() @Test fun `should get flagged when returns is in inner object`() { @@ -483,7 +483,7 @@ class ReturnCountSpec { return@flatMap Flowable.just(it[0]) } } - """ + """.trimIndent() @Test fun `should not count labeled returns from lambda by default`() { diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SafeCastSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SafeCastSpec.kt index d0e707bd513..fdb603d2f8b 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SafeCastSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SafeCastSpec.kt @@ -17,7 +17,7 @@ class SafeCastSpec { element } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -31,7 +31,7 @@ class SafeCastSpec { null } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -46,7 +46,7 @@ class SafeCastSpec { null } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -60,7 +60,7 @@ class SafeCastSpec { String() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SerialVersionUIDInSerializableClassSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SerialVersionUIDInSerializableClassSpec.kt index 11709ca0e33..878b482c2ef 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SerialVersionUIDInSerializableClassSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SerialVersionUIDInSerializableClassSpec.kt @@ -14,7 +14,7 @@ class SerialVersionUIDInSerializableClassSpec { import java.io.Serializable class C : Serializable - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -28,7 +28,7 @@ class SerialVersionUIDInSerializableClassSpec { const val serialVersionUID = 1 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -42,7 +42,7 @@ class SerialVersionUIDInSerializableClassSpec { const val serialVersionUID: Int = 1 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -60,7 +60,7 @@ class SerialVersionUIDInSerializableClassSpec { val serialVersionUUID = 1L } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(2) } @@ -76,7 +76,7 @@ class SerialVersionUIDInSerializableClassSpec { import java.io.Serializable interface I : Serializable - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -90,7 +90,7 @@ class SerialVersionUIDInSerializableClassSpec { const val serialVersionUID = 1L } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -104,7 +104,7 @@ class SerialVersionUIDInSerializableClassSpec { const val serialVersionUID = -1L } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -118,7 +118,7 @@ class SerialVersionUIDInSerializableClassSpec { const val serialVersionUID: Long = 1 } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SpacingBetweenPackageAndImportsSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SpacingBetweenPackageAndImportsSpec.kt index 21221a2d03c..2358f202bc4 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SpacingBetweenPackageAndImportsSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/SpacingBetweenPackageAndImportsSpec.kt @@ -110,7 +110,7 @@ class SpacingBetweenPackageAndImportsSpec { import kotlin.collections.Set class A { } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -121,7 +121,7 @@ class SpacingBetweenPackageAndImportsSpec { import kotlin.collections.List import kotlin.collections.Set - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ThrowsCountSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ThrowsCountSpec.kt index 26e4a7314a0..4fe211fe362 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ThrowsCountSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ThrowsCountSpec.kt @@ -16,7 +16,7 @@ class ThrowsCountSpec { inner class `a function with an empty body` { val code = """ fun func() {} - """ + """.trimIndent() @Test fun `does not report violation by default`() { @@ -28,7 +28,7 @@ class ThrowsCountSpec { inner class `a function without a body` { val code = """ fun func() = Unit - """ + """.trimIndent() @Test fun `does not report violation by default`() { @@ -45,7 +45,7 @@ class ThrowsCountSpec { 2 -> throw IOException() } } - """ + """.trimIndent() val subject = ThrowsCount(Config.empty) @Test @@ -64,7 +64,7 @@ class ThrowsCountSpec { 3 -> throw IOException() } } - """ + """.trimIndent() val subject = ThrowsCount(Config.empty) @Test @@ -83,7 +83,7 @@ class ThrowsCountSpec { 3 -> throw IOException() } } - """ + """.trimIndent() val subject = ThrowsCount(Config.empty) @Test @@ -107,7 +107,7 @@ class ThrowsCountSpec { } return bar(x) } - """ + """.trimIndent() val subject = ThrowsCount(Config.empty) @Test @@ -126,7 +126,7 @@ class ThrowsCountSpec { val int = x?.toInt() ?: throw IOException() val double = x?.toDouble() ?: throw IOException() } - """ + """.trimIndent() @Test fun `does not report when max parameter is 3`() { @@ -154,7 +154,7 @@ class ThrowsCountSpec { } throw Exception() } - """ + """.trimIndent() @Test fun `should not report violation with EXCLUDE_GUARD_CLAUSES as true`() { @@ -182,7 +182,7 @@ class ThrowsCountSpec { } throw Exception() } - """ + """.trimIndent() @Test fun `should not report violation with EXCLUDE_GUARD_CLAUSES as true`() { @@ -217,7 +217,7 @@ class ThrowsCountSpec { } throw Exception() } - """ + """.trimIndent() @Test fun `should report violation even with EXCLUDE_GUARD_CLAUSES as true`() { @@ -238,7 +238,7 @@ class ThrowsCountSpec { if (x < 4) throw Exception() throw Exception() } - """ + """.trimIndent() @Test fun `should report the violation even with EXCLUDE_GUARD_CLAUSES as true`() { @@ -259,7 +259,7 @@ class ThrowsCountSpec { val y = x ?: throw Exception() throw Exception() } - """ + """.trimIndent() @Test fun `should report the violation even with EXCLUDE_GUARD_CLAUSES as true`() { @@ -283,7 +283,7 @@ class ThrowsCountSpec { throw Exception() } - """ + """.trimIndent() @Test fun `should not report violation with EXCLUDE_GUARD_CLAUSES as true`() { diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/TrailingWhitespaceSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/TrailingWhitespaceSpec.kt index 27f14e6c0ab..a6fe9900137 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/TrailingWhitespaceSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/TrailingWhitespaceSpec.kt @@ -78,7 +78,7 @@ class TrailingWhitespaceSpec { Should ignore indent on the previous line ""${'"'} - """.trim() + """.trimIndent() val findings = compileAndLintWithoutTrim(code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/TrimMultilineRawStringSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/TrimMultilineRawStringSpec.kt index d09235756ac..8c3618a1fe1 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/TrimMultilineRawStringSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/TrimMultilineRawStringSpec.kt @@ -16,7 +16,7 @@ class TrimMultilineRawStringSpec { val a = ${TQ} Hello world! ${TQ} - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1) } @@ -27,7 +27,7 @@ class TrimMultilineRawStringSpec { val a = ${TQ} Hello world! ${TQ}.length - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).hasSize(1) } @@ -38,7 +38,7 @@ class TrimMultilineRawStringSpec { val a = ${TQ} Hello world! ${TQ}.trimIndent() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -49,7 +49,7 @@ class TrimMultilineRawStringSpec { val a = ${TQ} |Hello world! ${TQ}.trimMargin() - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -60,7 +60,7 @@ class TrimMultilineRawStringSpec { val a = ${TQ} >Hello world! ${TQ}.trimMargin(">") - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -69,7 +69,7 @@ class TrimMultilineRawStringSpec { fun `don't raise one line raw strings`() { val code = """ val a = ${TQ}Hello world!${TQ} - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } @@ -78,7 +78,7 @@ class TrimMultilineRawStringSpec { fun `doesn't raise if it is not a raw string`() { val code = """ val a = "Hello world!" - """ + """.trimIndent() subject.compileAndLint(code) assertThat(subject.findings).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnderscoresInNumericLiteralsSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnderscoresInNumericLiteralsSpec.kt index 912f2bfdb20..71fbc18623d 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnderscoresInNumericLiteralsSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnderscoresInNumericLiteralsSpec.kt @@ -260,7 +260,7 @@ class UnderscoresInNumericLiteralsSpec { object TestSerializable : Serializable { private val serialVersionUID = 314159L } - """ + """.trimIndent() @Test fun `should not be reported`() { @@ -275,7 +275,7 @@ class UnderscoresInNumericLiteralsSpec { object TestSerializable { private val serialVersionUID = 314159L } - """ + """.trimIndent() @Test fun `should be reported by default`() { @@ -290,7 +290,7 @@ class UnderscoresInNumericLiteralsSpec { object TestSerializable { private val serialVersionUID = 314_159L } - """ + """.trimIndent() @Test fun `should not be reported`() { @@ -312,7 +312,7 @@ class UnderscoresInNumericLiteralsSpec { private const val serialVersionUID = -43857148126114372L } } - """ + """.trimIndent() val findings = UnderscoresInNumericLiterals().compileAndLint(code) assertThat(findings).hasSize(0) } @@ -327,7 +327,7 @@ class UnderscoresInNumericLiteralsSpec { private const val serialVersionUID = 43857148126114372L } } - """ + """.trimIndent() val findings = UnderscoresInNumericLiterals().compileAndLint(code) assertThat(findings).hasSize(0) } @@ -344,7 +344,7 @@ class UnderscoresInNumericLiteralsSpec { class Test : Serializable { private val serialVersionUID = -43857148126114372L } - """ + """.trimIndent() val findings = UnderscoresInNumericLiterals().compileAndLint(code) assertThat(findings).hasSize(0) } @@ -357,7 +357,7 @@ class UnderscoresInNumericLiteralsSpec { class Test : Serializable { private val serialVersionUID = 43857148126114372L } - """ + """.trimIndent() val findings = UnderscoresInNumericLiterals().compileAndLint(code) assertThat(findings).hasSize(0) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClassSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClassSpec.kt index b6b2066444c..67eb6425b6b 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClassSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClassSpec.kt @@ -28,7 +28,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { abstract fun f() public abstract fun f2() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertFindingMessage(findings, message) assertThat(findings).hasStartSourceLocation(1, 16) @@ -72,7 +72,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { val i: Int } abstract class B : A - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertFindingMessage(findings, message) } @@ -85,7 +85,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { abstract val i: Int } abstract class B : A() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -99,7 +99,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { abstract val i: Int } abstract class B: A(), I - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -114,7 +114,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { abstract val i: Int } abstract class B: I, A() - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -131,7 +131,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { abstract class B : A() { abstract fun g() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -141,7 +141,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { abstract class A { internal abstract fun f() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -151,7 +151,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { abstract class A { protected abstract fun f() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -168,7 +168,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { val i: Int = 0 fun f() {} } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertFindingMessage(findings, message) } @@ -181,7 +181,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { fun f() {} } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertFindingMessage(findings, message) } @@ -194,7 +194,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { fun f() {} } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertFindingMessage(findings, message) } @@ -239,7 +239,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { fun g() {} } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertFindingMessage(findings, message) } @@ -259,7 +259,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { abstract class B : A() { fun g() {} } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -273,7 +273,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { abstract class B : A(0) { fun g() {} } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -287,7 +287,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { interface Interface { fun f() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -303,7 +303,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { abstract class B { abstract fun f() } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -314,7 +314,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { fun test(): Int } abstract class Test(val x: Int) : I - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAnnotationUseSiteTargetSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAnnotationUseSiteTargetSpec.kt index e489a159d8a..ec78bb7be5d 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAnnotationUseSiteTargetSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAnnotationUseSiteTargetSpec.kt @@ -14,7 +14,7 @@ class UnnecessaryAnnotationUseSiteTargetSpec { class C(@param:Asdf private val foo: String) annotation class Asdf - """ + """.trimIndent() assertThat(UnnecessaryAnnotationUseSiteTarget().compileAndLint(code)).hasTextLocations("param:") } @@ -25,7 +25,7 @@ class UnnecessaryAnnotationUseSiteTargetSpec { class C(@param:Asdf foo: String) annotation class Asdf - """ + """.trimIndent() assertThat(UnnecessaryAnnotationUseSiteTarget().compileAndLint(code)).hasTextLocations("param:") } @@ -36,7 +36,7 @@ class UnnecessaryAnnotationUseSiteTargetSpec { class C(@get:Asdf private val foo: String) annotation class Asdf - """ + """.trimIndent() assertThat(UnnecessaryAnnotationUseSiteTarget().compileAndLint(code)).isEmpty() } @@ -47,7 +47,7 @@ class UnnecessaryAnnotationUseSiteTargetSpec { class C(@property:Asdf private val foo: String) annotation class Asdf - """ + """.trimIndent() assertThat(UnnecessaryAnnotationUseSiteTarget().compileAndLint(code)).isEmpty() } @@ -60,7 +60,7 @@ class UnnecessaryAnnotationUseSiteTargetSpec { } annotation class Asdf - """ + """.trimIndent() assertThat(UnnecessaryAnnotationUseSiteTarget().compileAndLint(code)).hasTextLocations("property:") } @@ -71,7 +71,7 @@ class UnnecessaryAnnotationUseSiteTargetSpec { @property:Asdf private val foo: String = "bar" annotation class Asdf - """ + """.trimIndent() assertThat(UnnecessaryAnnotationUseSiteTarget().compileAndLint(code)).hasTextLocations("property:") } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryApplySpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryApplySpec.kt index b9f6ce081ea..7679a925839 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryApplySpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryApplySpec.kt @@ -28,7 +28,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { plus(1) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) assertThat(findings.first().message).isEqualTo("apply expression can be omitted") @@ -47,7 +47,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { plus(1) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) assertThat(findings.first().message).isEqualTo("apply can be replaced with let or an if") @@ -67,7 +67,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { b() } } - """ + """.trimIndent() ) ).hasSize(1) } @@ -84,7 +84,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { plus(1) }) } - """ + """.trimIndent() ) ).isEmpty() } @@ -103,7 +103,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { toString() }) } - """ + """.trimIndent() ) ).isEmpty() } @@ -130,7 +130,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { } ) } - """ + """.trimIndent() ) ).isEmpty() } @@ -144,7 +144,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { val a = listOf(mutableListOf("")) .map { it.apply { add("") } } } - """ + """.trimIndent() ) ).isEmpty() } @@ -172,7 +172,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { plus(2) }) } - """ + """.trimIndent() ) ).isEmpty() } @@ -193,7 +193,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { class Bar { fun bar() {} } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) } @@ -214,7 +214,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { class Bar { fun bar() {} } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) } @@ -229,7 +229,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { this } } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) } @@ -253,7 +253,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { prop = 1 } } - """ + """.trimIndent() ) ).hasSize(1) } @@ -273,7 +273,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { prop = 1 } } - """ + """.trimIndent() ) ).isEmpty() } @@ -293,7 +293,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { } val a = C().apply { f() } - """ + """.trimIndent() ) ).isEmpty() } @@ -307,7 +307,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { class C(var prop: Int) fun Int.f() = C(5).apply { prop = 10 } - """ + """.trimIndent() ) ).isEmpty() } @@ -323,7 +323,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { C(1).apply { prop = 3 } } } - """ + """.trimIndent() ) ).isEmpty() } @@ -337,7 +337,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { class C(var prop: Int) fun f() = (C(5)).apply { prop = 10 } - """ + """.trimIndent() ) ).isEmpty() } @@ -354,7 +354,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { ?.apply { if (true) 4 } ?: listOf(0) } - """ + """.trimIndent() ) ).isEmpty() } @@ -380,7 +380,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() ) ).isEmpty() } @@ -404,7 +404,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { this.prop } } - """ + """.trimIndent() ) ).hasSize(2) } @@ -430,7 +430,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { C() } } - """ + """.trimIndent() ) ).isEmpty() } @@ -455,7 +455,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { C().apply { f() } } } - """ + """.trimIndent() ) ).isEmpty() } @@ -484,7 +484,7 @@ class UnnecessaryApplySpec(val env: KotlinCoreEnvironment) { var baz = 1 } - """ + """.trimIndent() ) ).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilterSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilterSpec.kt index 983b9c44526..aa8d7739f21 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilterSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryFilterSpec.kt @@ -20,7 +20,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { val x = listOf(1, 2, 3) .filter { it > 1 } .size - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -33,7 +33,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { val x = listOf(1, 2, 3) .filter { it > 1 } .count() - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -47,7 +47,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { .map { it * 2 } .filter { it > 1 } .count() - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -59,7 +59,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { val x = listOf(1, 2, 3) .filter { it > 2 } .isEmpty() - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -71,7 +71,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { val x = listOf(1, 2, 3) .filter { it > 2 } .isNotEmpty() - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -89,7 +89,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { val x = listOf().count() val y = listOf().filter { it > 0 }.count() - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -104,7 +104,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { val x = listOf().asSequence().count() val y = listOf().asSequence().filter { it > 0 }.count() - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -118,7 +118,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { } val x = filter().size - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -129,7 +129,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { val code = """ val x = listOf(1, 2, 3) .count { it > 2 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -140,7 +140,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { val code = """ val x = listOf(1, 2, 3) .none { it > 2 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -151,7 +151,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { val code = """ val x = listOf(1, 2, 3) .any { it > 2 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -164,7 +164,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { .asSequence() .map { it * 2 } .count { it > 1 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() @@ -182,7 +182,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { println("more than two") } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -198,7 +198,7 @@ class UnnecessaryFilterSpec(val env: KotlinCoreEnvironment) { b.isEmpty() c.isNotEmpty() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryInheritanceSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryInheritanceSpec.kt index 1c90c41279f..071ea3179e7 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryInheritanceSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryInheritanceSpec.kt @@ -14,7 +14,7 @@ class UnnecessaryInheritanceSpec { """ class A : Any() class B : Object() - """ + """.trimIndent() ) assertThat(findings).hasSize(2) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryLetSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryLetSpec.kt index 918177ef0a2..090adf8d2e9 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryLetSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryLetSpec.kt @@ -22,7 +22,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { a.let { it.plus(1) } a.let { that -> that.plus(1) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(2) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -38,7 +38,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { a?.let { it.plus(1) } a?.let { that -> that.plus(1) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(2) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -54,7 +54,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { a?.let { it?.plus(1) } a?.let { that -> that?.plus(1) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(2) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -69,7 +69,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { val a: Int? = null a?.let { that -> that.plus(1) }?.let { it.plus(1) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(2) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -85,7 +85,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { a.let { 1.plus(1) } a.let { that -> 1.plus(1) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(2) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -101,7 +101,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { val x = a.let { 1.plus(1) } val y = a.let { that -> 1.plus(1) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(2) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -117,7 +117,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { a?.let { 1.plus(1) } a?.let { that -> 1.plus(1) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(2) assertThat(findings).allMatch { it.message == MESSAGE_USE_IF } @@ -133,7 +133,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { a.let { print(it) } a.let { that -> print(that) } } - """ + """.trimIndent() ) assertThat(findings).hasSize(2) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -149,7 +149,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { val a: Int? = null a.let(f) } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -165,7 +165,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { a?.let { print(it) } a?.let { that -> 1.plus(that) } } - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -179,7 +179,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { val a: Int? = null a?.let { that -> 1.plus(that) }?.let { print(it) } } - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -194,7 +194,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { val x = a?.let { 1.plus(1) } val y = a?.let { that -> 1.plus(1) } } - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -208,7 +208,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { val a = listOf?>(listOf("")) .map { list -> list?.let { it + it } } } - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -223,7 +223,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { val a: Int? = null a?.let(f) } - """ + """.trimIndent() ) assertThat(findings).hasSize(0) } @@ -260,7 +260,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { it.plus(2) } } - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -278,7 +278,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { a?.let { foo -> foo.plus(foo) } b.let { foo -> foo.plus(foo) } } - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -293,7 +293,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { fun test(foo: Foo) { foo.let { (a, b) -> a + b } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, content) assertThat(findings).isEmpty() } @@ -306,7 +306,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { fun test(foo: Foo) { foo.let { (a, _) -> a + a } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, content) assertThat(findings).isEmpty() } @@ -319,7 +319,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { fun test(foo: Foo) { foo.let { (a: Int, b: Int) -> a + b } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, content) assertThat(findings).isEmpty() } @@ -332,7 +332,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { fun test(foo: Foo) { foo.let { (a, _) -> a } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, content) assertThat(findings).hasSize(1) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -346,7 +346,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { fun test(foo: Foo?) { foo?.let { (_, b) -> b.plus(1) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, content) assertThat(findings).hasSize(1) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -360,7 +360,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { fun test(foo: Foo) { foo.let { (_, _) -> 0 } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, content) assertThat(findings).hasSize(1) assertThat(findings).allMatch { it.message == MESSAGE_OMIT_LET } @@ -374,7 +374,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { fun test(foo: Foo?) { foo?.let { (_, _) -> 0 } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, content) assertThat(findings).hasSize(1) assertThat(findings).allMatch { it.message == MESSAGE_USE_IF } @@ -389,7 +389,7 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { listOf(1).map { it } } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, content) assertThat(findings).hasSize(1) assertThat(findings).allMatch { it.message == MESSAGE_USE_IF } @@ -409,10 +409,25 @@ class UnnecessaryLetSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, content) assertThat(findings).isEmpty() } + + @Test + fun `does not report lets with invoke operator calls`() { + val findings = subject.compileAndLintWithContext( + env, + """ + fun f(callback: ((Int) -> Int)?) { + callback?.let { that -> + that(42) + } + } + """.trimIndent() + ) + assertThat(findings).isEmpty() + } } private const val MESSAGE_OMIT_LET = "let expression can be omitted" diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryParenthesesSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryParenthesesSpec.kt index 5711bc21000..86882a5471b 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryParenthesesSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryParenthesesSpec.kt @@ -43,7 +43,7 @@ class UnnecessaryParenthesesSpec { println("Test") } } - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).hasSize(1) } @@ -59,7 +59,7 @@ class UnnecessaryParenthesesSpec { fun test() { function({ input -> println(input) }) } - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -75,7 +75,7 @@ class UnnecessaryParenthesesSpec { fun test() { function(1, { input -> println(input) }) } - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -87,7 +87,7 @@ class UnnecessaryParenthesesSpec { fun f() { instance.copy(value = { false }) } - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -101,7 +101,7 @@ class UnnecessaryParenthesesSpec { println("Test") } } - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -116,7 +116,7 @@ class UnnecessaryParenthesesSpec { } } }) - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -131,7 +131,7 @@ class UnnecessaryParenthesesSpec { } } }) - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -145,7 +145,7 @@ class UnnecessaryParenthesesSpec { ) { constructor() : this({ first, second -> true }) } - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -164,7 +164,7 @@ class UnnecessaryParenthesesSpec { test({ println(it) }) { println(it) } } } - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -183,7 +183,7 @@ class UnnecessaryParenthesesSpec { test({ println(it) }, { println(it) }) } } - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -204,7 +204,7 @@ class UnnecessaryParenthesesSpec { test("hello", { println(it) }) { println(it) } } } - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -214,7 +214,7 @@ class UnnecessaryParenthesesSpec { fun `should not report interface delegation with parenthesis - #3851`(testCase: RuleTestCase) { val code = """ class Clazz: Comparable by ("hello".filter { it != 'l' }) - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).isEmpty() } @@ -232,7 +232,7 @@ class UnnecessaryParenthesesSpec { val b3 = 3 + (1 % 2) val c = (4 + 5) * 3 // parens required - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).hasSize(if (testCase.allowForUnclearPrecedence) 0 else 6) } @@ -246,7 +246,7 @@ class UnnecessaryParenthesesSpec { val a3 = (1 + 2 * 3) val b1 = (1 + 2) + 3 val b2 = (1 * 2) * 3 - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).hasSize(5) } @@ -259,7 +259,7 @@ class UnnecessaryParenthesesSpec { val a2 = (true && false) || (false && true) // 2 warnings when disallowed val b = false || (true && false) val c = (true || false) && false // parens required - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).hasSize(if (testCase.allowForUnclearPrecedence) 0 else 4) } @@ -273,7 +273,7 @@ class UnnecessaryParenthesesSpec { val a3 = (true && false || false) val b1 = (true && false) && false val b2 = (true || false) || false - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).hasSize(5) } @@ -284,7 +284,7 @@ class UnnecessaryParenthesesSpec { val code = """ val d = (true and false) or false val e = false or (true and false) // parens required - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).hasSize(if (testCase.allowForUnclearPrecedence) 0 else 1) } @@ -304,7 +304,7 @@ class UnnecessaryParenthesesSpec { val d1 = null ?: (1 in 2) // parens required val d2 = (null ?: 1) in 2 - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).hasSize(if (testCase.allowForUnclearPrecedence) 0 else 4) } @@ -317,7 +317,7 @@ class UnnecessaryParenthesesSpec { val b = (1 / 2)..(3 * 4) val c = (1 ?: 2)..(3 ?: 4) // parens required val d = (1 to 2)..(3 to 4) // parens required - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).hasSize(if (testCase.allowForUnclearPrecedence) 0 else 4) } @@ -327,7 +327,7 @@ class UnnecessaryParenthesesSpec { fun `multiple wrapping parentheses`(testCase: RuleTestCase) { val code = """ val a = ((false || (((true && false))))) - """ + """.trimIndent() assertThat(testCase.rule.lint(code)).hasSize(if (testCase.allowForUnclearPrecedence) 4 else 5) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UntilInsteadOfRangeToSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UntilInsteadOfRangeToSpec.kt index 9dd2adfbd02..5cd730b5f24 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UntilInsteadOfRangeToSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UntilInsteadOfRangeToSpec.kt @@ -16,7 +16,7 @@ class UntilInsteadOfRangeToSpec { fun f() { for (i in 0 .. 10 - 1) {} } - """ + """.trimIndent() val findings = subject.lint(code) assertThat(findings).hasSize(1) assertThat(findings[0]).hasMessage("'..' call can be replaced with 'until'") @@ -29,7 +29,7 @@ class UntilInsteadOfRangeToSpec { for (i in 0 until 10 - 1) {} for (i in 10 downTo 2 - 1) {} } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -39,7 +39,7 @@ class UntilInsteadOfRangeToSpec { fun f() { for (i in 0 .. 10) {} } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -50,7 +50,7 @@ class UntilInsteadOfRangeToSpec { for (i in 0 .. 10 + 1) {} for (i in 0 .. 10 - 2) {} } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedImportsSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedImportsSpec.kt index ca6fbf5ca67..a578620f271 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedImportsSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedImportsSpec.kt @@ -23,12 +23,12 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { } success { } } - """ + """.trimIndent() val additional = """ package tasks infix fun Int.success(f: () -> Unit) {} - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).isEmpty() } @@ -52,14 +52,14 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() val additional = """ package tasks infix fun Int.success(f: () -> Unit) {} infix fun Int.failure(f: () -> Unit) {} infix fun Int.undefined(f: () -> Unit) {} - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).isEmpty() } @@ -80,14 +80,14 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { } success { } } - """ + """.trimIndent() val additional = """ package tasks infix fun Int.success(f: () -> Unit) {} infix fun Int.failure(f: () -> Unit) {} infix fun Int.undefined(f: () -> Unit) {} - """ + """.trimIndent() val lint = subject.lintWithContext(env, main, additional) with(lint) { assertThat(this).hasSize(1) @@ -102,12 +102,12 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { import test.SomeClass val a: SomeClass? = null - """ + """.trimIndent() val additional = """ package test class SomeClass - """ + """.trimIndent() val lint = subject.lintWithContext(env, main, additional) with(lint) { assertThat(this).hasSize(1) @@ -130,14 +130,14 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { TODO() } } - """ + """.trimIndent() val additional = """ package android.text class TextWatcher { fun beforeTextChanged() {} } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).isEmpty() } @@ -162,7 +162,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { } fun fn(s: String) {} - """ + """.trimIndent() val p = """ package p @@ -173,20 +173,20 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { fun call() {} } class D - """ + """.trimIndent() val p2 = """ package p2 object B { const val NAME = "" } - """ + """.trimIndent() val escaped = """ package escaped fun `when`() {} fun `foo`() {} - """ + """.trimIndent() val lint = subject.lintWithContext(env, main, p, p2, escaped) with(lint) { assertThat(this).hasSize(3) @@ -206,14 +206,14 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { open class Something class Foo : Something() - """ + """.trimIndent() val additional = """ package test class Outer { class Inner } - """ + """.trimIndent() val lint = subject.lintWithContext(env, main, additional) with(lint) { assertThat(this).isEmpty() @@ -230,12 +230,12 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { * @see success */ fun doSomething() - """ + """.trimIndent() val additional = """ package tasks fun success() {} - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).isEmpty() } @@ -249,12 +249,12 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { * @see success something */ fun doSomething() {} - """ + """.trimIndent() val additional = """ package tasks fun success() {} - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).isEmpty() } @@ -268,12 +268,12 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { * @see something */ fun doSomething() {} - """ + """.trimIndent() val additional = """ package tasks fun success() {} - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).hasSize(1) } @@ -287,12 +287,12 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { * @see something success */ fun doSomething() {} - """ + """.trimIndent() val additional = """ package tasks fun success() {} - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).hasSize(1) } @@ -310,13 +310,13 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { * @sample success when ... */ fun doSomething() {} - """ + """.trimIndent() val additional = """ package tasks fun success() {} fun undefined() {} - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).isEmpty() } @@ -325,11 +325,11 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { val main = """ import test.forEach as foreach fun foo() = listOf().iterator().foreach {} - """ + """.trimIndent() val additional = """ package test fun Iterator.forEach(f: () -> Unit) {} - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).isEmpty() } @@ -344,15 +344,15 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { fun f(): Boolean { return myFoo() == otherFoo() } - """ + """.trimIndent() val additional1 = """ package com.example fun foo() = 1 - """ + """.trimIndent() val additional2 = """ package com.example.other fun foo() = 1 - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional1, additional2)).isEmpty() } @@ -365,7 +365,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { class DumpVersionProperties { private val dumpVersionProperties by Foo() } - """ + """.trimIndent() val additional = """ package org.gradle.kotlin.dsl @@ -377,7 +377,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { thisRef: T, prop: KProperty<*> ) = lazy { "" } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).isEmpty() } @@ -391,11 +391,11 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { fun test() { val (a, b) = MyClass(1, 2) } - """ + """.trimIndent() val additional = """ package com.example data class MyClass(val a: Int, val b: Int) - """ + """.trimIndent() assertThat(subject.lintWithContext(env, main, additional)).isEmpty() } @@ -411,17 +411,17 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { fun test() { println("Testing") } - """ + """.trimIndent() val additional1 = """ package com.example class TestComponent fun components() {} fun component1AndSomethingElse() {} - """ + """.trimIndent() val additional2 = """ package com.example.component1 class Unused - """ + """.trimIndent() val lint = subject.lintWithContext(env, main, additional1, additional2) with(lint) { @@ -441,15 +441,15 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { fun main() { test(1) } - """ + """.trimIndent() val additionalFile1 = """ package foo fun test(i: Int) {} - """ + """.trimIndent() val additionalFile2 = """ package bar fun test(s: String) {} - """ + """.trimIndent() val findings = subject.lintWithContext(env, mainFile, additionalFile1, additionalFile2) assertThat(findings).hasSize(1) assertThat(findings[0].entity.signature).endsWith("import bar.test") @@ -462,7 +462,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { fun doesNothing(thing: HashMap) { } - """ + """.trimIndent() val findings = subject.lintWithContext(env, code) assertThat(findings).isEmpty() } @@ -477,7 +477,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { @Ann(HashMap::class) fun foo() {} - """ + """.trimIndent() val findings = subject.lintWithContext(env, code) assertThat(findings).isEmpty() } @@ -488,12 +488,12 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { import x.y.z.Foo val foo = Foo() - """ + """.trimIndent() val additionalFile = """ package x.y.z class Foo - """ + """.trimIndent() val findings = subject.lintWithContext(env, mainFile, additionalFile) assertThat(findings).isEmpty() } @@ -505,12 +505,12 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { @Ann fun foo() {} - """ + """.trimIndent() val additionalFile = """ package x.y.z annotation class Ann - """ + """.trimIndent() val findings = subject.lintWithContext(env, mainFile, additionalFile) assertThat(findings).isEmpty() } @@ -521,14 +521,14 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { import x.y.z.Foo val x = Foo - """ + """.trimIndent() val additionalFile = """ package x.y.z class Foo { companion object } - """ + """.trimIndent() val findings = subject.lintWithContext(env, mainFile, additionalFile) assertThat(findings).isEmpty() } @@ -539,7 +539,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { import x.y.z.Foo val x = Foo.create() - """ + """.trimIndent() val additionalFile = """ package x.y.z @@ -548,7 +548,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { fun create(): Foo = Foo() } } - """ + """.trimIndent() val findings = subject.lintWithContext(env, mainFile, additionalFile) assertThat(findings).isEmpty() } @@ -559,7 +559,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { import x.y.z.Foo val x = Foo.BAR - """ + """.trimIndent() val additionalFile = """ package x.y.z @@ -568,7 +568,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { const val BAR = 1 } } - """ + """.trimIndent() val findings = subject.lintWithContext(env, mainFile, additionalFile) assertThat(findings).isEmpty() } @@ -579,14 +579,14 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { import x.y.z.FetchType val x = FetchType.LAZY - """ + """.trimIndent() val additionalFile = """ package x.y.z enum class FetchType { LAZY } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, mainFile, additionalFile)).isEmpty() } @@ -600,13 +600,13 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { @AnnotationB(attribute = AnnotationA()) val someProp: Int = 42 } - """ + """.trimIndent() val additionalFile = """ package x.y.z annotation class AnnotationA annotation class AnnotationB(val attribute: AnnotationA) - """ + """.trimIndent() assertThat(subject.lintWithContext(env, mainFile, additionalFile)).isEmpty() } @@ -624,13 +624,13 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { * @property someVal Someval for [SomeClass] */ data class StyleClass(val someVal: String) - """ + """.trimIndent() val additionalFile = """ package x.y.z class SomeClass - """ + """.trimIndent() assertThat(subject.lintWithContext(env, mainFile, additionalFile)).isEmpty() } @@ -648,7 +648,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { Bar().baz() } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, mainFile)).isEmpty() } @@ -662,7 +662,7 @@ class UnusedImportsSpec(val env: KotlinCoreEnvironment) { fun test() { 2 + 3 } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, mainFile)).hasSize(2) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateClassSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateClassSpec.kt index ff7a305e5d1..cf66490f80b 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateClassSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateClassSpec.kt @@ -18,7 +18,7 @@ class UnusedPrivateClassSpec { val code = """ private interface Foo class Bar - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -34,7 +34,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo class Bar - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -47,7 +47,7 @@ class UnusedPrivateClassSpec { val code = """ private open class Foo private class Bar : Foo() - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -66,7 +66,7 @@ class UnusedPrivateClassSpec { data class FooOne(val b: Bar) : Foo { override fun invoke(b: Bar): Unit = Unit } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -81,7 +81,7 @@ class UnusedPrivateClassSpec { fun something() { val foo: Foo = Foo() } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -95,7 +95,7 @@ class UnusedPrivateClassSpec { private object Bar { fun bar(foo: Foo) = Unit } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -107,7 +107,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo private val a: Foo? = null - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -119,7 +119,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo private lateinit var a: Foo - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -131,7 +131,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo private lateinit var foos: List - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -143,7 +143,7 @@ class UnusedPrivateClassSpec { val code = """ private val elements = listOf(42).filterIsInstance>() private class Item - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -155,7 +155,7 @@ class UnusedPrivateClassSpec { val code = """ private val elements = listOf(42).filterIsInstance>() private abstract class Something: Collection - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -171,7 +171,7 @@ class UnusedPrivateClassSpec { fun bar(): T { throw Exception() } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -183,7 +183,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo private lateinit var foos: List> - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -195,7 +195,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo private lateinit var foos: Foo - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -207,7 +207,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo private var foos: Foo? = Foo() - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -219,7 +219,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo private val a = Foo() - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -231,7 +231,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo(val a: String) private val a = Foo("test") - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -245,7 +245,7 @@ class UnusedPrivateClassSpec { private object Bar { fun foo(): Foo? = null } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -257,7 +257,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo private val lambda: ((Foo) -> Unit)? = null - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -269,7 +269,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo private val lambda: (() -> Foo)? = null - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -281,7 +281,7 @@ class UnusedPrivateClassSpec { val code = """ private class Foo private val lambda: (() -> List)? = null - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -300,7 +300,7 @@ class UnusedPrivateClassSpec { override fun bar() = Unit } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -318,7 +318,7 @@ class UnusedPrivateClassSpec { private class Foo fun bar(clazz: KClass<*>) = Unit - """ + """.trimIndent() val findings = UnusedPrivateClass().compileAndLint(code) @@ -338,7 +338,7 @@ class UnusedPrivateClassSpec { B("B"), C("C") } - """ + """.trimIndent() val findings = UnusedPrivateClass().compileAndLint(code) @@ -363,7 +363,7 @@ class UnusedPrivateClassSpec { fun getSomeObject(): ((String) -> Any) = ::InternalClass private class InternalClass(val param: String) } - """ + """.trimIndent() val findings = UnusedPrivateClass().compileAndLint(code) @@ -382,7 +382,7 @@ class UnusedPrivateClassSpec { @Test3 val property = "" @Test4 fun function() {} } - """ + """.trimIndent() val findings = UnusedPrivateClass().compileAndLint(code) @@ -407,7 +407,7 @@ class UnusedPrivateClassSpec { E3 } } - """ + """.trimIndent() val findings = UnusedPrivateClass().lint(code) assertThat(findings).isEmpty() } @@ -432,7 +432,7 @@ class UnusedPrivateClassSpec { EFG1 } } - """ + """.trimIndent() val findings = UnusedPrivateClass().lint(code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(10, 5) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt index f7e39e0cb5d..fec8431b2d9 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt @@ -30,7 +30,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println(used) } } - """ + """.trimIndent() @Nested inner class `interface functions` { @@ -42,7 +42,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun plug(application: Application) fun unplug() } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -57,7 +57,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun bar(i: Int) fun baz(i: Int, s: String) } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -68,7 +68,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun bar(i: Int) fun baz(i: Int, s: String) } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -77,7 +77,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { val code = """ expect fun bar(i: Int) expect fun baz(i: Int, s: String) - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -86,7 +86,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { val code = """ expect class Foo1(private val bar: String) {} expect class Foo2(bar: String) {} - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -101,7 +101,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { actual fun bar(i: Int) {} actual fun baz(i: Int, s: String) {} } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -109,7 +109,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `should not report unused parameters in actual constructors`() { val code = """ actual class Foo actual constructor(bar: String) {} - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -117,7 +117,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `should not report unused actual fields defined as parameters of primary constructors`() { val code = """ actual class Foo actual constructor(actual val bar: String) {} - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -125,7 +125,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `reports unused private fields defined as parameters of primary constructors`() { val code = """ actual class Foo actual constructor(private val bar: String) {} - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } } @@ -152,7 +152,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun notify(error: String) } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -184,7 +184,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { } }) } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -206,7 +206,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { return 1 } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -217,7 +217,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `should not report internal classes`() { val code = """ internal class IC // unused but internal - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -238,7 +238,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { .subscribe() } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -256,7 +256,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println("This is not using a property") } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -270,7 +270,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println("This is not using a property") } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -284,7 +284,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println(used) } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -299,7 +299,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println(used) } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -336,7 +336,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { val unusedLocal = 5 } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(5) } @@ -351,7 +351,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println(used) } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -366,7 +366,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println(text) } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -403,7 +403,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private fun doubleColonObjectReferenced() {} } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -443,7 +443,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println(used) } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } } @@ -464,7 +464,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private val unusedNestedVal = 1 } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(4) } @@ -478,7 +478,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private object PO { // private, but constants may be used const val TEXT = "text" } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -493,7 +493,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { val defaultRuleSetIds = listOf("comments", "complexity", "empty-blocks", "exceptions", "potential-bugs", "performance", "style") - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -507,7 +507,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -520,7 +520,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -535,7 +535,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -549,7 +549,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(2) } @@ -565,7 +565,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -584,7 +584,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println(text) } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -598,7 +598,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { val test = unused } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -610,7 +610,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `reports top-level unused functions`() { val code = """ private fun unusedTopLevelFunction() = 5 - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -622,7 +622,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun main(args: Array) { calledFromMain() } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -635,7 +635,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private val usedTopLevelVal = 1 private const val unusedTopLevelConst = 1 private val unusedTopLevelVal = usedTopLevelVal - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(2) } @@ -662,7 +662,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println(stuff.next()) calledFromMain() } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -679,7 +679,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { return 5 } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -692,7 +692,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { return 5 } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -706,7 +706,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { } } private fun doSomethingElse() {} - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -727,7 +727,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println("Never used") } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -742,7 +742,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { class Test { private val ignored = "" } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -752,7 +752,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { class Test { private fun ignored(ignored: Int) {} } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -768,7 +768,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private val unused = 1 } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -781,7 +781,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun someFunction() = used } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -792,7 +792,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `reports unused private property`() { val code = """ class Test(private val unused: Any) - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -800,7 +800,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `does not report public property`() { val code = """ class Test(val unused: Any) - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -810,7 +810,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { class Test(private val used: Any) { init { used.toString() } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -822,7 +822,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { used.toString() } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -833,7 +833,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `are specific for function parameters`() { val code = """ fun foo(unused: Int){} - """ + """.trimIndent() val lint = subject.lint(code) @@ -844,7 +844,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `are specific for local variables`() { val code = """ fun foo(){ val unused = 1 } - """ + """.trimIndent() val lint = subject.lint(code) @@ -859,7 +859,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { return 5 } } - """ + """.trimIndent() val lint = subject.lint(code) @@ -873,7 +873,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `does not report annotated private constructor properties`() { val code = """ class Test(@Suppress("unused") private val foo: String) {} - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -885,7 +885,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { @Suppress("unused") private val foo: String, private val bar: String ) {} - """ + """.trimIndent() val lint = subject.lint(code) @@ -901,7 +901,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private val foo: String, private val bar: String ) {} - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -918,7 +918,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private val baz: String ) {} } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -936,7 +936,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private val baz: String ) {} } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -947,7 +947,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { class Test { @Suppress("unused") private val foo: String } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -959,7 +959,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { @Suppress("unused") private val foo: String private val bar: String } - """ + """.trimIndent() val lint = subject.lint(code) @@ -975,7 +975,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private val foo: String private val bar: String } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -992,7 +992,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private val baz: String } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -1010,7 +1010,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private val baz: String } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -1023,7 +1023,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { val code = """ @Suppress("unused") private fun foo(): String = "" - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -1032,7 +1032,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun `reports private functions without annotation`() { val code = """ private fun foo(): String = "" - """ + """.trimIndent() val findings = subject.lint(code) @@ -1047,7 +1047,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { class Test { private fun foo(): String = "" } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -1064,7 +1064,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private fun baz(): String = "" } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -1081,7 +1081,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private fun baz(): String = "" } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -1100,7 +1100,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { println("b") } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -1110,7 +1110,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun main(args: Array) { println("b") } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -1128,7 +1128,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun Date.plus(diff: Long): Date = Date(this.time + diff) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -1142,7 +1142,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun Date.plus(diff: Long): Date = Date(this.time + diff) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -1156,7 +1156,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { } val answer = Test.answer() - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -1178,7 +1178,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun Int?.div(other: Int) = 4 private operator fun Int?.rem(other: Int) = 5 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -1192,7 +1192,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { return any { it.matches(a) } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -1206,7 +1206,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { return any { it.matches(a) } } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -1219,7 +1219,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun Date.minus(diff: Long): Date = Date(this.time - diff) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } @@ -1241,7 +1241,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { return 5 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -1263,7 +1263,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { return num.toInt() } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -1285,7 +1285,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { return toInt() } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } } @@ -1303,7 +1303,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun double(): Foo = this + this } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0) } @@ -1318,7 +1318,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun double(): Foo = this + this } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 30) @@ -1353,7 +1353,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { aInstance.someMethod(setOf(B(), B()), false) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0) } } @@ -1377,7 +1377,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { error("setValue") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0) } @@ -1395,7 +1395,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) { } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0) } @@ -1413,7 +1413,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { error("setValue") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } } @@ -1427,7 +1427,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { fun main() { val `in` = "foo" } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -1439,7 +1439,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { val expected = "foo" println(expected == `in`) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -1451,7 +1451,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { val expected = "foo" println(expected == `actual`) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -1463,7 +1463,18 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { val expected = "foo" println(expected == actual) } - """ + """.trimIndent() + assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() + } + } + + @Nested + inner class `backtick identifiers - #5251` { + @Test + fun `does not report used backtick parameters`() { + val code = """ + fun test(`foo bar`: Int) = `foo bar` + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -1481,7 +1492,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun List.get(s: String) = this.firstOrNull { it.s == s } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -1500,7 +1511,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun List.get(s: String) = this.firstOrNull { it.s == s } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0) } @@ -1519,7 +1530,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun List.get(a: String, b: String) = this.firstOrNull { it.s == b } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0) } @@ -1538,7 +1549,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun List.get(s: String) = this.firstOrNull { it.s == s } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0) } @@ -1551,7 +1562,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun List.get(s: String) = this.firstOrNull { it.s == s } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).hasSize(1) } @@ -1570,7 +1581,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun List.get(s: String) = this.firstOrNull { it.s == s } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).hasSize(0) } @@ -1589,7 +1600,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private operator fun List.get(s: String) = this.firstOrNull { it.s == s } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).hasSize(0) } } @@ -1605,7 +1616,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { */ private fun foo() = 1 } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1).hasStartSourceLocation(5, 17) } @@ -1618,7 +1629,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { */ private val foo = 1 } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1).hasStartSourceLocation(5, 17) } @@ -1633,7 +1644,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { x: Int ) = 1 } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1).hasStartSourceLocation(6, 9) } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateParameterSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateParameterSpec.kt index 15c626f1341..7fac644c54d 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateParameterSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateParameterSpec.kt @@ -20,7 +20,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun function(unusedParameter: Int): Int { return 5 } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -31,7 +31,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun function(used: Int): Int { return used } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -42,7 +42,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun function(used: Int) { println(used) } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -53,7 +53,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun function(unusedParameter: Int, usedParameter: Int): Int { return usedParameter } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -64,7 +64,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun function(unusedParameter: Int, usedParameter: Int) { println(usedParameter) } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -79,7 +79,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { return 5 } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -99,7 +99,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { return 5 } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(2) } @@ -114,7 +114,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { return used } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -129,7 +129,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { println(used) } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -144,7 +144,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { return usedParameter } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -159,7 +159,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { println(usedParameter) } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -171,7 +171,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun `reports unused parameter`() { val code = """ class Test(unused: Any) - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } @@ -180,7 +180,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { val code = """ class Parent(val ignored: Any) class Test(used: Any) : Parent(used) - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -192,7 +192,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { used.toString() } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -202,7 +202,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { class Test(used: Any) { val usedString = used.toString() } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } @@ -220,7 +220,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { // this is actually unused, but clashes with the other constructor constructor(used: Any) } - """ + """.trimIndent() assertThat(subject.lint(code)).hasSize(1) } } @@ -231,7 +231,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun `does not report annotated parameters`() { val code = """ fun foo(@Suppress("UNUSED_PARAMETER") unused: String){} - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -240,7 +240,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun `reports parameters without annotation`() { val code = """ fun foo(@Suppress("UNUSED_PARAMETER") unused: String, unusedWithoutAnnotation: String){} - """ + """.trimIndent() val lint = subject.lint(code) @@ -253,7 +253,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { val code = """ @Suppress("UNUSED_PARAMETER") fun foo(unused: String, otherUnused: String){} - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -266,7 +266,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun foo(unused: String, otherUnused: String){} fun bar(unused: String){} } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -278,7 +278,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { object Test { fun foo(unused: String){} } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -294,7 +294,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun bar(unused: String){} } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -311,7 +311,7 @@ class UnusedPrivateParameterSpec(val env: KotlinCoreEnvironment) { fun bar(unused: String){} } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseArrayLiteralsInAnnotationsSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseArrayLiteralsInAnnotationsSpec.kt index a06a1469df7..a43b625b5fb 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseArrayLiteralsInAnnotationsSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseArrayLiteralsInAnnotationsSpec.kt @@ -16,7 +16,7 @@ class UseArrayLiteralsInAnnotationsSpec { annotation class Test(val values: Array) @Test(arrayOf("value")) fun test() = Unit - """ + """.trimIndent() ) assertThat(findings).hasSize(1) @@ -30,7 +30,7 @@ class UseArrayLiteralsInAnnotationsSpec { annotation class Test(val values: Array) @Test(["value"]) fun test() = Unit - """ + """.trimIndent() ) assertThat(findings).isEmpty() diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckNotNullSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckNotNullSpec.kt index 460aee82f9e..d5503041fd1 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckNotNullSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckNotNullSpec.kt @@ -16,7 +16,7 @@ class UseCheckNotNullSpec(val env: KotlinCoreEnvironment) { fun test(i: Int?) { check(i != null) } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) } @@ -27,7 +27,7 @@ class UseCheckNotNullSpec(val env: KotlinCoreEnvironment) { fun test(i: Int?) { check(null != i) } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) } @@ -38,7 +38,7 @@ class UseCheckNotNullSpec(val env: KotlinCoreEnvironment) { fun test(i: Int) { check(i > 0) } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckOrErrorSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckOrErrorSpec.kt index 6178cb24e54..d178d952632 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckOrErrorSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckOrErrorSpec.kt @@ -21,7 +21,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { doSomething() if (a < 0) throw IllegalStateException() } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(3, 16) } @@ -34,7 +34,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { throw IllegalStateException() } } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(4, 9) } @@ -45,7 +45,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { doSomething() if (a < 0) throw IllegalStateException("More details") } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(3, 16) } @@ -57,7 +57,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { 1 -> doSomething() else -> throw IllegalStateException() } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(4, 17) } @@ -68,7 +68,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { doSomething() if (a < 0) throw java.lang.IllegalStateException() } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(3, 16) } @@ -79,7 +79,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { doSomething() if (a < 0) throw kotlin.IllegalStateException() } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(3, 16) } @@ -90,7 +90,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { doSomething() if (a < 0) throw SomeBusinessException() } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -102,7 +102,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { throw IllegalStateException("message", cause) } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -112,7 +112,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { fun unsafeRunSync(): A = unsafeRunTimed(Duration.INFINITE) .fold({ throw IllegalStateException("message") }, ::identity) - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -137,7 +137,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { else -> throw IllegalStateException(throwable) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -150,7 +150,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { else -> throw IllegalStateException("b", throwable) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -163,7 +163,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { else -> throw IllegalStateException(throwable.toString()) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -179,7 +179,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { else -> throw IllegalStateException(throwable) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -192,7 +192,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { else -> throw IllegalStateException("b", throwable) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -205,7 +205,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { else -> throw IllegalStateException(throwable.toString()) } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -218,7 +218,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { else -> throw IllegalStateException("b") } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseDataClassSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseDataClassSpec.kt index 5996b55864a..4547d276cd9 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseDataClassSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseDataClassSpec.kt @@ -31,7 +31,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { } object Obj } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -43,7 +43,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -51,7 +51,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { fun `does not report a candidate class with a private constructor`() { val code = """ class NoDataClassCandidateWithOnlyPrivateCtor1 private constructor(val i: Int) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -61,7 +61,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class NoDataClassCandidateWithOnlyPrivateCtor2 { private constructor(i: Int) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -72,7 +72,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { data class Success(val any: Any) : NoDataClassBecauseItsSealed() data class Error(val error: Throwable) : NoDataClassBecauseItsSealed() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -82,7 +82,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { enum class EnumNoDataClass(val i: Int) { FIRST(1), SECOND(2); } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -90,7 +90,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { fun `does not report a candidate annotation class`() { val code = """ annotation class AnnotationNoDataClass(val i: Int) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -104,7 +104,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class NotDataClassBecauseItsImplementingInterfaceWithMethods(val i : Int): SomeInterface { override fun foo() = i } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -117,7 +117,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { } data class DataClass(override val i: Int): SimpleInterface - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -132,7 +132,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { open class BaseClass(open val j: Int) class DataClass(override val i: Int, override val j: Int): SimpleInterface, BaseClass(j) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -143,7 +143,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { interface I class B() : I class A(val b: B) : I by b - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -156,7 +156,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { fun `does report a data class candidate`() { val code = """ class DataClassCandidate1(val i: Int) - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -166,7 +166,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class DataClassCandidateWithProperties(val i: Int) { val i2: Int = 0 } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -176,7 +176,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class DataClassCandidate2(val s: String) { private constructor(i: Int) : this(i.toString()) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -186,7 +186,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class DataClassCandidate3 private constructor(val s: String) { constructor(i: Int) : this(i.toString()) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -204,7 +204,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { return super.toString() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -213,7 +213,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { val code = """ interface SimpleInterface class DataClass(val i: Int): SimpleInterface - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -226,7 +226,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { } class DataClass(override val i: Int): SimpleInterface - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -241,7 +241,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class D(val a: Int, val b: String) { fun copy(a: Int, b: String): D = D(a, b) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -251,7 +251,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class D(val a: Int, val b: String) { fun copy(a: Int, b: String) = D(a, b) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -261,7 +261,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class D(val a: Int, val b: String) { fun copy(): D = D(0, "") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -271,7 +271,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class D(val a: Int, val b: String) { fun copy(a: Int, b: String, c: String): D = D(a, b + c) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -281,7 +281,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class D(val a: Int, val b: String) { fun copy(a: Int, b: Int): D = D(a, b.toString()) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -291,7 +291,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class D(val a: Int, val b: String) { fun copy(a: Int, b: String?): D = D(a, b.toString()) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -302,7 +302,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { fun copy(a: Int, b: String) { } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } @@ -323,7 +323,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class DataClassCandidateWithProperties(var i: Int) { var i2: Int = 0 } - """ + """.trimIndent() val config = TestConfig(mapOf(ALLOW_VARS to "true")) assertThat(UseDataClass(config).compileAndLint(code)).isEmpty() } @@ -334,7 +334,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class DataClassCandidateWithMixedProperties(val i: Int) { var i2: Int = 0 } - """ + """.trimIndent() val config = TestConfig(mapOf(ALLOW_VARS to "true")) assertThat(UseDataClass(config).compileAndLint(code)).isEmpty() } @@ -345,7 +345,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { class DataClassCandidateWithMixedProperties(var i: Int) { val i2: Int = 0 } - """ + """.trimIndent() val config = TestConfig(mapOf(ALLOW_VARS to "true")) assertThat(UseDataClass(config).compileAndLint(code)).isEmpty() } @@ -372,7 +372,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { @SinceKotlin("1.0.0") class AnnotatedClass(val i: Int) {} - """ + """.trimIndent() val config = TestConfig(mapOf(EXCLUDE_ANNOTATED_CLASSES to "kotlin.*")) assertThat(UseDataClass(config).compileAndLint(code)).isEmpty() } @@ -386,7 +386,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { prop, old, new -> println("") } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -401,7 +401,7 @@ class UseDataClassSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseEmptyCounterpartSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseEmptyCounterpartSpec.kt index bcdfc2d4780..9ac865001be 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseEmptyCounterpartSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseEmptyCounterpartSpec.kt @@ -20,7 +20,7 @@ class UseEmptyCounterpartSpec(val env: KotlinCoreEnvironment) { val map = mapOf() val sequence = sequenceOf() val set = setOf() - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).hasSize(6) } @@ -33,7 +33,7 @@ class UseEmptyCounterpartSpec(val env: KotlinCoreEnvironment) { val map: Map = mapOf() val sequence: Sequence = sequenceOf() val set: Set = setOf() - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).hasSize(6) } @@ -45,7 +45,7 @@ class UseEmptyCounterpartSpec(val env: KotlinCoreEnvironment) { val map = emptyMap() val sequence = emptySequence() val set = emptySet() - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).isEmpty() } @@ -58,7 +58,7 @@ class UseEmptyCounterpartSpec(val env: KotlinCoreEnvironment) { val map = mapOf(0 to 0) val sequence = sequenceOf(0) val set = setOf(0) - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).isEmpty() } @@ -78,7 +78,7 @@ class UseEmptyCounterpartSpec(val env: KotlinCoreEnvironment) { val map = mapOf() val sequence = sequenceOf() val set = setOf() - """ + """.trimIndent() assertThat(rule.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfEmptyOrIfBlankSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfEmptyOrIfBlankSpec.kt index 6955ff5e479..8b7cb640611 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfEmptyOrIfBlankSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfEmptyOrIfBlankSpec.kt @@ -23,7 +23,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { fun test(api: Api) { val name = if (api.name.isBlank()) "John" else api.name } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(4, 29) @@ -42,7 +42,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { else "John" } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(4, 29) @@ -58,7 +58,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { fun test(api: Api) { val name = if (api.name.isEmpty()) "John" else api.name } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(4, 29) @@ -77,7 +77,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { else "John" } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(4, 29) @@ -95,7 +95,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { list } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -111,7 +111,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { listOf(1) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -127,7 +127,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { set } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -143,7 +143,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { setOf(1) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -159,7 +159,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { map } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -175,7 +175,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { mapOf(1 to 2) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -191,7 +191,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { collection } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -207,7 +207,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { listOf(1) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -222,7 +222,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { this } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -238,7 +238,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { list } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -253,7 +253,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { listOf(1) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0]).hasMessage("This 'isEmpty' call can be replaced with 'ifEmpty'") @@ -269,7 +269,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { list } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0]).hasMessage("This 'isNotEmpty' call can be replaced with 'ifEmpty'") @@ -287,7 +287,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { fun test(api: Api) { val name = if (api.name.isNullOrBlank()) "John" else api.name } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -303,7 +303,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { list } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -319,7 +319,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { arr } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -335,7 +335,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { arrayOf("a") } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -351,7 +351,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { arr } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -367,7 +367,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { intArrayOf(1) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -384,7 +384,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { list } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -397,7 +397,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { listOf(1) } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -412,7 +412,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { list + list } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -428,7 +428,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { list } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -443,7 +443,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { list } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfInsteadOfWhenSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfInsteadOfWhenSpec.kt index 05d9a2a4861..6b090121e03 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfInsteadOfWhenSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfInsteadOfWhenSpec.kt @@ -18,7 +18,7 @@ class UseIfInsteadOfWhenSpec { else -> return false } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).hasSize(1) } @@ -31,7 +31,7 @@ class UseIfInsteadOfWhenSpec { else -> return false } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -46,7 +46,7 @@ class UseIfInsteadOfWhenSpec { else -> return false } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -61,7 +61,7 @@ class UseIfInsteadOfWhenSpec { } return false } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIsNullOrEmptySpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIsNullOrEmptySpec.kt index b7a6f6844ca..5a994e566e5 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIsNullOrEmptySpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIsNullOrEmptySpec.kt @@ -21,7 +21,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(2, 9) @@ -36,7 +36,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { if (x == null || x.count() == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -47,7 +47,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { if (x == null || x.size == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -58,7 +58,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { if (null == x || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -69,7 +69,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { if (x == null || 0 == x.count()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -80,7 +80,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { if (x == null || 0 == x.size) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -94,7 +94,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Set?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -105,7 +105,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Set?) { if (x == null || x.count() == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -116,7 +116,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Set?) { if (x == null || x.size == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -130,7 +130,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Collection?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -141,7 +141,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Collection?) { if (x == null || x.count() == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -152,7 +152,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Collection?) { if (x == null || x.size == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -166,7 +166,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Map?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -177,7 +177,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Map?) { if (x == null || x.count() == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -188,7 +188,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Map?) { if (x == null || x.size == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -202,7 +202,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Array?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -213,7 +213,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Array?) { if (x == null || x.count() == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -224,7 +224,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Array?) { if (x == null || x.size == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -238,7 +238,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: String?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -249,7 +249,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: String?) { if (x == null || x.count() == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -260,7 +260,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: String?) { if (x == null || x.length == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -271,7 +271,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: String?) { if (x == null || x == "") return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -285,7 +285,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: MutableList?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -299,7 +299,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: MutableSet?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -313,7 +313,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: MutableCollection?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -327,7 +327,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: MutableMap?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -344,7 +344,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: IntArray?) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -355,7 +355,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: IntArray?) { if (x == null || x.count() == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -366,7 +366,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: IntArray?) { if (x == null || x.size == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -380,7 +380,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Sequence?) { if (x == null || x.count() == 0) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -392,7 +392,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?, y: List) { if (x == null || y.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -403,7 +403,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { if (x != null && x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -414,7 +414,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { if (x == null || x.count() == 1) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -425,7 +425,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List) { if (x == null || x.isEmpty()) return } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -440,7 +440,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { if (x == null || x?.count() == 0) return } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseOrEmptySpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseOrEmptySpec.kt index 09d1466dcd2..a3a664c91f3 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseOrEmptySpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseOrEmptySpec.kt @@ -19,7 +19,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { val a = x ?: emptyList() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings).hasStartSourceLocation(2, 13) @@ -32,7 +32,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Set?) { val a = x ?: emptySet() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -43,7 +43,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Map?) { val a = x ?: emptyMap() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -54,7 +54,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Sequence?) { val a = x ?: emptySequence() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -65,7 +65,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Array?) { val a = x ?: emptyArray() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -76,7 +76,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { val a = x ?: listOf() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -87,7 +87,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Set?) { val a = x ?: setOf() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -98,7 +98,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Map?) { val a = x ?: mapOf() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -109,7 +109,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Sequence?) { val a = x ?: sequenceOf() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -120,7 +120,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: Array?) { val a = x ?: arrayOf() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -131,7 +131,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: String?) { val a = x ?: "" } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -142,7 +142,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: MutableList?) { val a = x ?: emptyList() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -156,7 +156,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(c: C) { c["key"] ?: emptyList() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -170,7 +170,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List) { val a = x ?: emptyList() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -181,7 +181,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: List?) { val a = x ?: listOf(1) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -195,7 +195,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(c: Any?) { val x = c ?: emptyList() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -206,7 +206,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: MutableList?) { val a = x ?: mutableListOf() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -217,7 +217,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { fun test(x: IntArray?) { val a = x ?: intArrayOf() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -233,7 +233,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { val y: List = c["key"] ?: emptyList() val z = (c["key"]) ?: emptyList() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireNotNullSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireNotNullSpec.kt index 910c31ba78c..20ce58c849b 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireNotNullSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireNotNullSpec.kt @@ -16,7 +16,7 @@ class UseRequireNotNullSpec(val env: KotlinCoreEnvironment) { fun test(i: Int?) { require(i != null) } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) } @@ -27,7 +27,7 @@ class UseRequireNotNullSpec(val env: KotlinCoreEnvironment) { fun test(i: Int?) { require(null != i) } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).hasSize(1) } @@ -38,7 +38,7 @@ class UseRequireNotNullSpec(val env: KotlinCoreEnvironment) { fun test(i: Int) { require(i > 0) } - """ + """.trimIndent() val actual = subject.compileAndLintWithContext(env, code) assertThat(actual).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireSpec.kt index f7306b45420..ac62f3bc1c6 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireSpec.kt @@ -21,7 +21,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { if (a < 0) throw IllegalArgumentException() doSomething() } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(2, 16) } @@ -34,7 +34,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { } doSomething() } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(3, 9) } @@ -46,7 +46,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { if (a < 0) throw IllegalArgumentException("More details") doSomething() } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(2, 16) } @@ -57,7 +57,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { if (a < 0) throw java.lang.IllegalArgumentException() doSomething() } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(2, 16) } @@ -68,7 +68,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { if (a < 0) throw kotlin.IllegalArgumentException() doSomething() } - """ + """.trimIndent() assertThat(subject.lint(code)).hasStartSourceLocation(2, 16) } @@ -79,7 +79,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { if (a < 0) throw SomeBusinessException() doSomething() } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -90,7 +90,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { doSomething() throw IllegalArgumentException("message", cause) } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -104,7 +104,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { } doSomething() } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -114,7 +114,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { val code = """ fun unsafeRunSync(): A = foo.fold({ throw IllegalArgumentException("message") }, ::identity) - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -136,7 +136,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { fun test(throwable: Throwable) { if (throwable !is NumberFormatException) throw IllegalArgumentException(throwable) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -146,7 +146,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { fun test(throwable: Throwable) { if (throwable !is NumberFormatException) throw IllegalArgumentException("a", throwable) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -157,7 +157,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { val s = "" if (throwable !is NumberFormatException) throw IllegalArgumentException(s) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -170,7 +170,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { fun test(throwable: Throwable) { if (throwable !is NumberFormatException) throw IllegalArgumentException(throwable) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -180,7 +180,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { fun test(throwable: Throwable) { if (throwable !is NumberFormatException) throw IllegalArgumentException("a", throwable) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -191,7 +191,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { val s = "" if (throwable !is NumberFormatException) throw IllegalArgumentException(s) } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -201,7 +201,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { fun test(throwable: Throwable) { if (throwable !is NumberFormatException) throw IllegalArgumentException("a") } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } } @@ -217,7 +217,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { is LinkedList<*> -> 2 else -> throw IllegalArgumentException("Not supported List type") } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -233,7 +233,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { } throw IllegalArgumentException("Test was too big") } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } @@ -245,7 +245,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { ?: throw IllegalArgumentException("List is not a LinkedList") return subclass } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UselessCallOnNotNullSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UselessCallOnNotNullSpec.kt index e9f950749ae..5854d7094e6 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UselessCallOnNotNullSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UselessCallOnNotNullSpec.kt @@ -49,7 +49,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val code = """ val testList: List? = listOf("string") val nonNullableTestList = testList.orEmpty() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -66,7 +66,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val code = """ val testString: String? = "" val nonNullableTestString = testString.isNullOrBlank() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -89,7 +89,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val code = """ val testString: String? = "" val nonNullableTestString = testString.isNullOrEmpty() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -106,7 +106,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val code = """ val testString: String? = "" val nonNullableTestString = testString.orEmpty() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -123,7 +123,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val code = """ val testSequence: Sequence? = listOf(1).asSequence() val nonNullableTestSequence = testSequence.orEmpty() - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -134,7 +134,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val noList = "str".orEmpty() val list = listOf(1, 2, 3).orEmpty() - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0].message).isEqualTo("Remove redundant call to orEmpty") @@ -144,7 +144,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { fun `reports when calling listOfNotNull on all non-nullable arguments`() { val code = """ val strings = listOfNotNull("string") - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0].message).isEqualTo("Replace listOfNotNull with listOf") @@ -154,7 +154,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { fun `reports when calling listOfNotNull with no arguments`() { val code = """ val strings = listOfNotNull() - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0].message).isEqualTo("Replace listOfNotNull with listOf") @@ -164,7 +164,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { fun `does not report when calling listOfNotNull on at least one nullable argument`() { val code = """ val strings = listOfNotNull("string", null) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -174,7 +174,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val code = """ val nullableArray = arrayOf("string", null) val strings = listOfNotNull(*nullableArray) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -184,7 +184,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val code = """ val nonNullableArray = arrayOf("string", "bar") val strings = listOfNotNull(*nonNullableArray) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0].message).isEqualTo("Replace listOfNotNull with listOf") @@ -196,7 +196,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val nullableArray = arrayOf("string", null) val nonNullableArray = arrayOf("string", "bar") val strings = listOfNotNull("string", *nonNullableArray, "foo", *nullableArray) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -206,7 +206,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val code = """ val nonNullableArray = arrayOf("string", "bar") val strings = listOfNotNull("string", *nonNullableArray, null) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -217,7 +217,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { val nonNullableArray = arrayOf("string", "bar") val otherNonNullableArray = arrayOf("foobar") val strings = listOfNotNull("string", *nonNullableArray, "foo", *otherNonNullableArray) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0].message).isEqualTo("Replace listOfNotNull with listOf") @@ -229,7 +229,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { fun listOfNotNull(vararg elements: T?): List = TODO() val strings = listOfNotNull("string", null) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -266,7 +266,7 @@ class UselessCallOnNotNullSpec(val env: KotlinCoreEnvironment) { fun test(list: List) { list.isNullOrEmpty() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0].message).isEqualTo("Replace isNullOrEmpty with isEmpty") diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UtilityClassWithPublicConstructorSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UtilityClassWithPublicConstructorSpec.kt index c2dfceaaee5..59ac91c65da 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UtilityClassWithPublicConstructorSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UtilityClassWithPublicConstructorSpec.kt @@ -63,7 +63,7 @@ class UtilityClassWithPublicConstructorSpec { const val FEMALE = "female" } } - """ + """.trimIndent() assertThat(subject.lint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/VarCouldBeValSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/VarCouldBeValSpec.kt index e20de06b217..63dd79c5741 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/VarCouldBeValSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/VarCouldBeValSpec.kt @@ -47,7 +47,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { fun foo() { a = 2 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -62,7 +62,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { a = 2 } } - """ + """.trimIndent() assertThat(subject.lintWithContext(env, code)).isEmpty() } @@ -80,7 +80,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { a = 2 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -167,7 +167,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { var a = 1 a = 2 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -178,7 +178,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { var a = 1 a += 2 } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -189,7 +189,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { var a = 1 a++ } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -200,7 +200,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { var a = 1 --a } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -213,7 +213,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { a = 2 } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -224,7 +224,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { var a = 1 val b = a + 2 } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -238,7 +238,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { var a = 1 println(a) } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) @@ -255,7 +255,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { shadowed = 3 } } - """ + """.trimIndent() val lint = subject.compileAndLintWithContext(env, code) assertThat(lint).hasSize(1) @@ -277,7 +277,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { var myVar = value } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(2) } @@ -290,7 +290,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { this.myVar = value } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -304,7 +304,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { this.myVar = value } } - """ + """.trimIndent() with(subject.compileAndLintWithContext(env, code)[0]) { assertThat(entity.ktElement?.text).isEqualTo("var myVar = value") } @@ -321,7 +321,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { var test: Boolean = true } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).hasSize(1) } @@ -334,7 +334,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { } wrapper.test = false } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -349,7 +349,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { override var optionEnabled: Boolean = false } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -367,7 +367,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { } o.optionEnabled = false } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -385,7 +385,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { } return o } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -405,7 +405,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { } return o } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -422,7 +422,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { } return o } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -443,7 +443,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { } return o } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -458,7 +458,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { override var optionEnabled: Boolean = false } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -477,7 +477,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { null } } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -490,7 +490,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { fun test() = object: I { override var optionEnabled: Boolean = false } - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -505,7 +505,7 @@ class VarCouldBeValSpec(val env: KotlinCoreEnvironment) { override var optionEnabled: Boolean = false } } else null - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/WildcardImportSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/WildcardImportSpec.kt index d70d51de5d7..bbe69354c89 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/WildcardImportSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/WildcardImportSpec.kt @@ -20,7 +20,7 @@ class WildcardImportSpec { class Test { } - """ + """.trimIndent() @Test fun `should not report anything when the rule is turned off`() { @@ -84,7 +84,7 @@ class WildcardImportSpec { fun `ignores the default values`() { val code2 = """ import java.util.* - """ + """.trimIndent() val findings = WildcardImport().lint(code2) assertThat(findings).isEmpty() @@ -100,7 +100,7 @@ class WildcardImportSpec { class Test { } - """ + """.trimIndent() @Test fun `should not report any issues`() { diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/MandatoryBracesIfStatementsSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/MandatoryBracesIfStatementsSpec.kt index 0b07afee7e4..eac743c8ce0 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/MandatoryBracesIfStatementsSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/MandatoryBracesIfStatementsSpec.kt @@ -20,7 +20,7 @@ class MandatoryBracesIfStatementsSpec { if (true) println() } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) @@ -35,7 +35,7 @@ class MandatoryBracesIfStatementsSpec { if (true) 50 .toString() } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) @@ -50,7 +50,7 @@ class MandatoryBracesIfStatementsSpec { .toString() else 50 .toString() } - """ + """.trimIndent() ) assertThat(findings).hasSize(2) @@ -66,7 +66,7 @@ class MandatoryBracesIfStatementsSpec { else println() } - """ + """.trimIndent() ) assertThat(findings).hasSize(2) @@ -85,7 +85,7 @@ class MandatoryBracesIfStatementsSpec { else println() } - """ + """.trimIndent() ) assertThat(findings).hasSize(3) @@ -102,7 +102,7 @@ class MandatoryBracesIfStatementsSpec { } else println() } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) @@ -120,7 +120,7 @@ class MandatoryBracesIfStatementsSpec { println() } } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) @@ -135,7 +135,7 @@ class MandatoryBracesIfStatementsSpec { if (true) println() else println() } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) @@ -150,7 +150,7 @@ class MandatoryBracesIfStatementsSpec { if (true) println() else println() } - """ + """.trimIndent() ) assertThat(findings).hasSize(1) @@ -174,7 +174,7 @@ class MandatoryBracesIfStatementsSpec { } if (true) { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } @@ -190,7 +190,7 @@ class MandatoryBracesIfStatementsSpec { if (true) println() else println() if (true) println() else if (false) println() else println() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } @@ -209,7 +209,7 @@ class MandatoryBracesIfStatementsSpec { else -> println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/MandatoryBracesLoopsSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/MandatoryBracesLoopsSpec.kt index d36178071a0..c0f7e6812f8 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/MandatoryBracesLoopsSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/MandatoryBracesLoopsSpec.kt @@ -20,7 +20,7 @@ class MandatoryBracesLoopsSpec { println(i) } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -31,7 +31,7 @@ class MandatoryBracesLoopsSpec { fun test() { for (i in 0..10) println(i) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -42,7 +42,7 @@ class MandatoryBracesLoopsSpec { fun test() { for (i in 0..10) println(i); print(' ') } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -54,7 +54,7 @@ class MandatoryBracesLoopsSpec { for (i in 0..10) println(i) } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -71,7 +71,7 @@ class MandatoryBracesLoopsSpec { for (i in 0..10) println(i) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -86,7 +86,7 @@ class MandatoryBracesLoopsSpec { } } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -97,7 +97,7 @@ class MandatoryBracesLoopsSpec { fun test() { for (i in 0..10) for (j in 0..10) println() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -111,7 +111,7 @@ class MandatoryBracesLoopsSpec { println() } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -129,7 +129,7 @@ class MandatoryBracesLoopsSpec { println() } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -145,7 +145,7 @@ class MandatoryBracesLoopsSpec { for (j in 0..10) println() } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -169,7 +169,7 @@ class MandatoryBracesLoopsSpec { println("Odd") } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -191,7 +191,7 @@ class MandatoryBracesLoopsSpec { println("Odd") } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -212,7 +212,7 @@ class MandatoryBracesLoopsSpec { println() } } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -223,7 +223,7 @@ class MandatoryBracesLoopsSpec { fun test() { while(true) println() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -235,7 +235,7 @@ class MandatoryBracesLoopsSpec { while (true) println() } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -252,7 +252,7 @@ class MandatoryBracesLoopsSpec { while(true) println() } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -266,7 +266,7 @@ class MandatoryBracesLoopsSpec { println() } } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -286,7 +286,7 @@ class MandatoryBracesLoopsSpec { println() } while(true) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -297,7 +297,7 @@ class MandatoryBracesLoopsSpec { fun test() { do println() while(true) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -310,7 +310,7 @@ class MandatoryBracesLoopsSpec { println() while (true) } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -328,7 +328,7 @@ class MandatoryBracesLoopsSpec { println() while(true) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -343,7 +343,7 @@ class MandatoryBracesLoopsSpec { } } while (true) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -355,7 +355,7 @@ class MandatoryBracesLoopsSpec { var i = 0 do do i += 1 while(i < 5) while (i < 5) } - """ + """.trimIndent() assertThat(subject.compileAndLint(code)).isEmpty() } @@ -370,7 +370,7 @@ class MandatoryBracesLoopsSpec { } while (true) while (true) } - """ + """.trimIndent() val findings = subject.compileAndLint(code) @@ -389,7 +389,7 @@ class MandatoryBracesLoopsSpec { while(true) } while (true) } - """ + """.trimIndent() val findings = subject.compileAndLint(code) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/OptionalUnitSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/OptionalUnitSpec.kt index e097381adf8..ae83b144629 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/OptionalUnitSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/OptionalUnitSpec.kt @@ -46,7 +46,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { } fun returnsUnit2() = Unit - """ + """.trimIndent() lateinit var findings: List @BeforeEach @@ -81,7 +81,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { class C : I { override fun returnsUnit() = Unit } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).isEmpty() } @@ -104,7 +104,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { Unit } } - """ + """.trimIndent() lateinit var findings: List @BeforeEach @@ -139,7 +139,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { Unit.equals(null) val i: (Int) -> Unit = { _ -> } } - """ + """.trimIndent() ) assertThat(findings).isEmpty() } @@ -153,7 +153,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { interface Foo { fun method(i: Int) = Unit } - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) } @@ -175,7 +175,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { } } } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -196,7 +196,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { } }.foo() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -223,7 +223,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { } }.foo() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -248,7 +248,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { } }.foo() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -277,7 +277,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { } }.foo() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -303,7 +303,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { } }.foo() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -329,7 +329,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { } }.foo() } - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) } @@ -352,7 +352,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { fun `should not report when function initializer is Nothing`() { val code = """ fun test(): Unit = throw UnsupportedOperationException() - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).isEmpty() } @@ -376,7 +376,7 @@ class OptionalUnitSpec(val env: KotlinCoreEnvironment) { fun `should report on function initializers when there is no context`() { val code = """ fun test(): Unit = throw UnsupportedOperationException() - """ + """.trimIndent() val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/PreferToOverPairSyntaxSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/PreferToOverPairSyntaxSpec.kt index 50aaf676d75..a88c48ef324 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/PreferToOverPairSyntaxSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/optional/PreferToOverPairSyntaxSpec.kt @@ -17,7 +17,7 @@ class PreferToOverPairSyntaxSpec(val env: KotlinCoreEnvironment) { val pair1 = Pair(1, 2) val pair2: Pair = Pair(1, 2) val pair3 = Pair(Pair(1, 2), Pair(3, 4)) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(5) @@ -29,7 +29,7 @@ class PreferToOverPairSyntaxSpec(val env: KotlinCoreEnvironment) { val code = """ val pair = createPair() fun createPair() = Pair(1, 2) - """ + """.trimIndent() val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) assertThat(findings[0].message).endsWith("`1 to 2`.") @@ -49,7 +49,7 @@ class PreferToOverPairSyntaxSpec(val env: KotlinCoreEnvironment) { val pair3 = Pair(Pair(1, 2), Pair(3, 4)) data class Pair(val int1: T, val int2: Z) - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } @@ -58,7 +58,7 @@ class PreferToOverPairSyntaxSpec(val env: KotlinCoreEnvironment) { val code = """ val pair = createPair() fun createPair() = 1 to 2 - """ + """.trimIndent() assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } } diff --git a/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/TooManyFunctionsSpec.kt b/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/TooManyFunctionsSpec.kt index af476641755..ec83cd9640b 100644 --- a/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/TooManyFunctionsSpec.kt +++ b/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/TooManyFunctionsSpec.kt @@ -17,7 +17,7 @@ class TooManyFunctionsSpec { } } -private const val code: String = """ +private val code: String = """ class TooManyFunctions : Rule("TooManyFunctions") { override fun visitUserType(type: KtUserType) { @@ -85,4 +85,4 @@ private const val code: String = """ } } -""" +""".trimIndent() diff --git a/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/processors/NumberOfLoopsProcessorSpec.kt b/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/processors/NumberOfLoopsProcessorSpec.kt index 47834d993ad..fd9c9a13e2f 100644 --- a/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/processors/NumberOfLoopsProcessorSpec.kt +++ b/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/processors/NumberOfLoopsProcessorSpec.kt @@ -18,7 +18,7 @@ class NumberOfLoopsProcessorSpec { } } } - """ + """.trimIndent() val ktFile = compileContentForTest(code) ktFile.accept(DetektVisitor()) diff --git a/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/processors/QualifiedNameProcessorSpec.kt b/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/processors/QualifiedNameProcessorSpec.kt index a59a66a6fb6..c36d839e35c 100644 --- a/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/processors/QualifiedNameProcessorSpec.kt +++ b/detekt-sample-extensions/src/test/kotlin/io/gitlab/arturbosch/detekt/sample/extensions/processors/QualifiedNameProcessorSpec.kt @@ -51,10 +51,10 @@ private val result = object : Detektion { } } -private const val code = """ +private val code = """ package io.gitlab.arturbosch.detekt.sample class Foo {} object Bar {} interface Bla {} -""" +""".trimIndent() diff --git a/detekt-test-utils/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/KotlinEnvironmentTestSetup.kt b/detekt-test-utils/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/KotlinEnvironmentTestSetup.kt index 97f59ef5e36..fda626909a4 100644 --- a/detekt-test-utils/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/KotlinEnvironmentTestSetup.kt +++ b/detekt-test-utils/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/KotlinEnvironmentTestSetup.kt @@ -12,6 +12,7 @@ import org.spekframework.spek2.dsl.Root import org.spekframework.spek2.lifecycle.CachingMode import java.io.File import java.nio.file.Path +import kotlin.script.experimental.jvm.util.classpathFromClassloader @Deprecated( "This is specific to Spek and will be removed in a future release. Documentation has been updated to " + @@ -48,7 +49,12 @@ internal class KotlinEnvironmentResolver : ParameterResolver { override fun resolveParameter(parameterContext: ParameterContext, extensionContext: ExtensionContext): Any { val closeableWrapper = extensionContext.wrapper ?: CloseableWrapper( - createEnvironment(additionalJavaSourceRootPaths = extensionContext.additionalJavaSourcePaths()) + createEnvironment( + additionalRootPaths = checkNotNull( + classpathFromClassloader(Thread.currentThread().contextClassLoader) + ) { "We should always have a classpath" }, + additionalJavaSourceRootPaths = extensionContext.additionalJavaSourcePaths(), + ) ).also { extensionContext.wrapper = it } return closeableWrapper.wrapper.env } diff --git a/detekt-test/src/main/kotlin/io/gitlab/arturbosch/detekt/test/RuleExtensions.kt b/detekt-test/src/main/kotlin/io/gitlab/arturbosch/detekt/test/RuleExtensions.kt index a3bd72373da..90dd131e8d2 100644 --- a/detekt-test/src/main/kotlin/io/gitlab/arturbosch/detekt/test/RuleExtensions.kt +++ b/detekt-test/src/main/kotlin/io/gitlab/arturbosch/detekt/test/RuleExtensions.kt @@ -25,7 +25,7 @@ fun BaseRule.compileAndLint(@Language("kotlin") content: String): List } fun BaseRule.lint(@Language("kotlin") content: String): List { - val ktFile = compileContentForTest(content.trimIndent()) + val ktFile = compileContentForTest(content) return findingsAfterVisit(ktFile) } @@ -39,9 +39,9 @@ fun BaseRule.lintWithContext( @Language("kotlin") content: String, @Language("kotlin") vararg additionalContents: String, ): List { - val ktFile = compileContentForTest(content.trimIndent()) + val ktFile = compileContentForTest(content) val additionalKtFiles = additionalContents.mapIndexed { index, additionalContent -> - compileContentForTest(additionalContent.trimIndent(), "AdditionalTest$index.kt") + compileContentForTest(additionalContent, "AdditionalTest$index.kt") } val bindingContext = environment.getContextForPaths(listOf(ktFile) + additionalKtFiles) val languageVersionSettings = environment.configuration.languageVersionSettings diff --git a/detekt-tooling/api/detekt-tooling.api b/detekt-tooling/api/detekt-tooling.api index fbabfcc9532..4155a325ada 100644 --- a/detekt-tooling/api/detekt-tooling.api +++ b/detekt-tooling/api/detekt-tooling.api @@ -7,6 +7,25 @@ public final class io/github/detekt/tooling/api/AnalysisResultKt { public static final fun exitCode (Lio/github/detekt/tooling/api/AnalysisResult;)I } +public abstract interface class io/github/detekt/tooling/api/Baseline { + public abstract fun contains (Ljava/lang/String;)Z + public abstract fun getCurrentIssues ()Ljava/util/Set; + public abstract fun getManuallySuppressedIssues ()Ljava/util/Set; +} + +public abstract interface class io/github/detekt/tooling/api/BaselineProvider { + public static final field Companion Lio/github/detekt/tooling/api/BaselineProvider$Companion; + public abstract fun id (Lio/gitlab/arturbosch/detekt/api/Finding;)Ljava/lang/String; + public abstract fun of (Ljava/util/Set;Ljava/util/Set;)Lio/github/detekt/tooling/api/Baseline; + public abstract fun read (Ljava/nio/file/Path;)Lio/github/detekt/tooling/api/Baseline; + public abstract fun write (Ljava/nio/file/Path;Lio/github/detekt/tooling/api/Baseline;)V +} + +public final class io/github/detekt/tooling/api/BaselineProvider$Companion { + public final fun load (Ljava/lang/ClassLoader;)Lio/github/detekt/tooling/api/BaselineProvider; + public static synthetic fun load$default (Lio/github/detekt/tooling/api/BaselineProvider$Companion;Ljava/lang/ClassLoader;ILjava/lang/Object;)Lio/github/detekt/tooling/api/BaselineProvider; +} + public abstract interface class io/github/detekt/tooling/api/DefaultConfigurationProvider { public static final field Companion Lio/github/detekt/tooling/api/DefaultConfigurationProvider$Companion; public abstract fun copy (Ljava/nio/file/Path;)V diff --git a/detekt-tooling/src/main/kotlin/io/github/detekt/tooling/api/BaselineProvider.kt b/detekt-tooling/src/main/kotlin/io/github/detekt/tooling/api/BaselineProvider.kt new file mode 100644 index 00000000000..b6b23cce58f --- /dev/null +++ b/detekt-tooling/src/main/kotlin/io/github/detekt/tooling/api/BaselineProvider.kt @@ -0,0 +1,31 @@ +package io.github.detekt.tooling.api + +import io.gitlab.arturbosch.detekt.api.Finding +import java.nio.file.Path +import java.util.ServiceLoader + +interface BaselineProvider { + + fun id(finding: Finding): FindingId + fun of(manuallySuppressedIssues: FindingsIdList, currentIssues: FindingsIdList): Baseline + fun read(sourcePath: Path): Baseline + fun write(targetPath: Path, baseline: Baseline) + + companion object { + + fun load( + classLoader: ClassLoader = BaselineProvider::class.java.classLoader, + ): BaselineProvider = ServiceLoader.load(BaselineProvider::class.java, classLoader).first() + } +} + +typealias FindingsIdList = Set +typealias FindingId = String + +interface Baseline { + + val manuallySuppressedIssues: FindingsIdList + val currentIssues: FindingsIdList + + fun contains(id: FindingId): Boolean +} diff --git a/detekt-utils/src/test/kotlin/io/github/detekt/utils/YamlSpec.kt b/detekt-utils/src/test/kotlin/io/github/detekt/utils/YamlSpec.kt index fcae48f37e3..7617df44702 100644 --- a/detekt-utils/src/test/kotlin/io/github/detekt/utils/YamlSpec.kt +++ b/detekt-utils/src/test/kotlin/io/github/detekt/utils/YamlSpec.kt @@ -10,7 +10,7 @@ class YamlSpec { inner class KeyValue { @Test fun `renders key and value as provided`() { - val result = yaml { keyValue() { "key" to "value" } } + val result = yaml { keyValue { "key" to "value" } } assertThat(result).isEqualTo("key: value") } } @@ -30,7 +30,8 @@ class YamlSpec { fun `renders single element`() { val given = listOf("value") val result = yaml { list("key", given) } - val expected = """key: + val expected = """ + |key: | - 'value' """.trimMargin() assertThat(result).isEqualTo(expected) @@ -40,7 +41,8 @@ class YamlSpec { fun `renders multiple elements`() { val given = listOf("value 1", "value 2") val result = yaml { list("key", given) } - val expected = """key: + val expected = """ + |key: | - 'value 1' | - 'value 2' """.trimMargin() @@ -51,7 +53,8 @@ class YamlSpec { fun `quotes a value containing special characters`() { val given = listOf("val*ue1", "val|ue2", "val\$ue3") val result = yaml { list("key", given) } - val expected = """key: + val expected = """ + |key: | - 'val*ue1' | - 'val|ue2' | - 'val${"$"}ue3' @@ -63,7 +66,8 @@ class YamlSpec { fun `quotes a blank value`() { val given = listOf(" ") val result = yaml { list("key", given) } - val expected = """key: + val expected = """ + |key: | - ' ' """.trimMargin() assertThat(result).isEqualTo(expected) @@ -73,7 +77,8 @@ class YamlSpec { fun `does not add quotes when value is already enclosed in quotes`() { val given = listOf("'val*ue1'", "\"val|ue2\"", "\"\"", "''") val result = yaml { list("key", given) } - val expected = """key: + val expected = """ + |key: | - 'val*ue1' | - "val|ue2" | - "" @@ -106,7 +111,8 @@ class YamlSpec { fun `renders single map with single element`() { val given = listOf(mapOf("name" to "value")) val result = yaml { listOfMaps("key", given) } - val expected = """key: + val expected = """ + |key: | - name: 'value' """.trimMargin() assertThat(result).isEqualTo(expected) @@ -122,7 +128,8 @@ class YamlSpec { ) ) val result = yaml { listOfMaps("key", given) } - val expected = """key: + val expected = """ + |key: | - name1: 'value 1' | name2: 'value 2' | name3: 'value 3' @@ -147,7 +154,8 @@ class YamlSpec { ) ) val result = yaml { listOfMaps("key", given) } - val expected = """key: + val expected = """ + |key: | - name1: 'value 1' | name2: 'value 2' | - name3: 'value 3' @@ -168,7 +176,8 @@ class YamlSpec { ), ) val result = yaml { listOfMaps("key", given) } - val expected = """key: + val expected = """ + |key: | - a: 'value' | b: 'value' | x: 'value' @@ -187,7 +196,8 @@ class YamlSpec { ), ) val result = yaml { listOfMaps("key", given) } - val expected = """key: + val expected = """ + |key: | - a: 'value' | c: 'value' """.trimMargin() @@ -204,7 +214,8 @@ class YamlSpec { ) ) val result = yaml { listOfMaps("key", given) } - val expected = """key: + val expected = """ + |key: | - name1: 'already quoted' | name2: "also quoted" | name3: 'should be quoted' diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bb7ad8b42a4..0478385ce6f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -28,7 +28,7 @@ ktlint-rulesetStandard = { module = "com.pinterest.ktlint:ktlint-ruleset-standar ktlint-rulesetExperimental = { module = "com.pinterest.ktlint:ktlint-ruleset-experimental", version.ref = "ktlint" } slf4j-nop = { module = "org.slf4j:slf4j-nop", version = "1.7.36" } -spek-dsl = { module = "org.spekframework.spek2:spek-dsl-jvm", version = "2.0.18" } +spek-dsl = { module = "org.spekframework.spek2:spek-dsl-jvm", version = "2.0.19" } junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" } @@ -36,7 +36,7 @@ sarif4k = "io.github.detekt.sarif4k:sarif4k:0.0.1" assertj = "org.assertj:assertj-core:3.23.1" reflections = "org.reflections:reflections:0.10.2" mockk = "io.mockk:mockk:1.12.5" -snakeyaml = "org.yaml:snakeyaml:1.30" +snakeyaml = "org.yaml:snakeyaml:1.31" jcommander = "com.beust:jcommander:1.82" contester-breakpoint = { module = "io.github.davidburstrom.contester:contester-breakpoint", version.ref = "contester" } contester-driver = { module = "io.github.davidburstrom.contester:contester-driver", version.ref = "contester" } diff --git a/scripts/github-milestone-report.main.kts b/scripts/github-milestone-report.main.kts index 5be16bdfec2..8f1ccc35961 100755 --- a/scripts/github-milestone-report.main.kts +++ b/scripts/github-milestone-report.main.kts @@ -9,7 +9,7 @@ // for the exec line @file:Suppress("detekt.CommentSpacing") -@file:DependsOn("org.kohsuke:github-api:1.307") +@file:DependsOn("org.kohsuke:github-api:1.308") @file:DependsOn("com.github.ajalt:clikt:2.8.0") import com.github.ajalt.clikt.core.CliktCommand @@ -51,7 +51,7 @@ class GithubMilestoneReport : CliktCommand() { var ghIssues: List = ghRepository.getIssues(GHIssueState.CLOSED, ghMilestone) if (filterExisting) { - val changeLogContent = File("./website/docs/introduction/changelog 1.x.x.md").readText() + val changeLogContent = File("./website/docs/introduction/changelog.md").readText() ghIssues = ghIssues.filter { "[#${it.number}]" !in changeLogContent } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 4abb8253fdc..d25b8c2356a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -41,10 +41,8 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") // build scan plugin can only be applied in settings file plugins { - // check https://gradle.com/enterprise/releases with new versions. GE plugin version should not lag behind Gradle version - id("com.gradle.enterprise") version "3.10.3" - id("com.gradle.common-custom-user-data-gradle-plugin") version "1.7.2" - id("com.gradle.enterprise.test-distribution") version "2.3.5" + id("com.gradle.enterprise") version "3.11.1" + id("com.gradle.common-custom-user-data-gradle-plugin") version "1.8" } val isCiBuild = System.getenv("CI") != null diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 661b56f79ff..bf71d44e0b1 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -45,8 +45,10 @@ const config = { '@docusaurus/plugin-client-redirects', { redirects: [ - { to: '/docs/introduction/changelog', from: '/changelog.html' }, - { to: '/docs/introduction/changelog-rc', from: '/changelog-rc.html' }, + { to: '/changelog', from: '/docs/introduction/changelog' }, + { to: '/changelog-rc', from: '/docs/introduction/changelog-rc' }, + { to: '/changelog', from: '/changelog.html' }, + { to: '/changelog-rc', from: '/changelog-rc.html' }, { to: '/docs/introduction/configurations', from: '/configurations.html' }, { to: '/docs/introduction/reporting', from: '/reporting.html' }, { to: '/docs/introduction/suppressing-rules', from: '/suppressing-rules.html' }, @@ -112,7 +114,7 @@ const config = { dropdownActiveClassDisabled: true, dropdownItemsAfter: [ { - to: "/docs/introduction/changelog", + to: "/changelog", label: "All changelogs", }, ], diff --git a/website/package.json b/website/package.json index ddd1fdad7a3..ed5d81c1c83 100644 --- a/website/package.json +++ b/website/package.json @@ -16,9 +16,9 @@ "generate-and-build": "../gradlew -p .. :detekt-generator:generateDocumentation && docusaurus build" }, "dependencies": { - "@docusaurus/core": "2.0.1", - "@docusaurus/plugin-client-redirects": "2.0.1", - "@docusaurus/preset-classic": "2.0.1", + "@docusaurus/core": "2.1.0", + "@docusaurus/plugin-client-redirects": "2.1.0", + "@docusaurus/preset-classic": "2.1.0", "@mdx-js/react": "1.6.22", "clsx": "1.2.1", "prism-react-renderer": "1.3.5", diff --git a/website/sidebars.js b/website/sidebars.js index 1617d000ea6..454a1922045 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -14,7 +14,28 @@ /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ const sidebars = { // By default, Docusaurus generates a sidebar from the docs folder structure - defaultSidebar: [{type: 'autogenerated', dirName: '.'}], + defaultSidebar: [ + { + type: "autogenerated", + dirName: ".", + }, + { + type: "category", + label: "Changelogs", + items: [ + { + type: "link", + label: "1.x Changelog", + href: "/changelog", + }, + { + type: "link", + label: "0.x Changelog", + href: "/changelog-pre-stable", + }, + ], + }, + ], // But you can create a sidebar manually /* diff --git a/website/docs/introduction/changelog.md b/website/src/pages/changelog-rc.md similarity index 99% rename from website/docs/introduction/changelog.md rename to website/src/pages/changelog-rc.md index c3b9b295c9d..d886634cad5 100644 --- a/website/docs/introduction/changelog.md +++ b/website/src/pages/changelog-rc.md @@ -2,13 +2,9 @@ id: changelog-rc title: Changelog and Migration Guide - Pre 1.0.0 keywords: [changelog, release-notes, migration] -sidebar_position: 2 --- - +# Changelog and Migration Guide - Pre 1.0.0 #### RC16 diff --git a/website/docs/introduction/changelog 1.x.x.md b/website/src/pages/changelog.md similarity index 99% rename from website/docs/introduction/changelog 1.x.x.md rename to website/src/pages/changelog.md index f521075a790..54b43a59a77 100644 --- a/website/docs/introduction/changelog 1.x.x.md +++ b/website/src/pages/changelog.md @@ -2,9 +2,10 @@ id: changelog title: Changelog and Migration Guide keywords: [changelog, release-notes, migration] -sidebar_position: 1 --- +# Changelog and Migration Guide + #### 1.21.0 - 2022-07-16 We're delighted to announce the next upcoming stable release of Detekt: `1.21.0` 🎉 diff --git a/website/src/remark/detektVersionReplace.js b/website/src/remark/detektVersionReplace.js index 8c4920e3088..e82a7287458 100644 --- a/website/src/remark/detektVersionReplace.js +++ b/website/src/remark/detektVersionReplace.js @@ -9,7 +9,7 @@ const plugin = (options) => { const transformer = async (ast) => { visit(ast, "code", (node) => { if (node.value.includes("[detekt_version]")) { - node.value = node.value.replace("[detekt_version]", detektVersion); + node.value = node.value.replaceAll("[detekt_version]", detektVersion); } }); }; diff --git a/website/versioned_docs/version-1.21.0/introduction/changelog 1.x.x.md b/website/versioned_docs/version-1.21.0/introduction/changelog 1.x.x.md deleted file mode 100644 index 60218caa68a..00000000000 --- a/website/versioned_docs/version-1.21.0/introduction/changelog 1.x.x.md +++ /dev/null @@ -1,2482 +0,0 @@ ---- -id: changelog -title: Changelog and Migration Guide -keywords: [changelog, release-notes, migration] -sidebar_position: 1 ---- - -#### 1.21.0 - 2022-07-16 - -We're delighted to announce the next upcoming stable release of Detekt: `1.21.0` 🎉 -This release is coming with 6 new rules, new API and functionalities and several stability improvements. - -We want to thank you very much [our Sponsors](https://github.com/sponsors/detekt) for the support in those last months. The work behind Detekt is all happening on a voluntary basis, and we're more than grateful for all the support we get from the Open Source Ecosystem. - -We're also excited to announce that we're now having an [Open Source Gradle Enterprise](https://ge.detekt.dev) instance. When building the Detekt projects, you'll benefit from the Gradle Remote Cache that this instance is providing! - -Finally, we want to take the opportunity to thank our contributors for testing, bug reporting and helping -us release this new version of Detekt. You're more than welcome to join our community on the [#detekt](https://kotlinlang.slack.com/archives/C88E12QH4) channel on KotlinLang's Slack (you can [get an invite here](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up)). - -##### Notable Changes - -- We enabled ~30 new rules by default which we believe are now stable enough. - [#4875](https://github.com/detekt/detekt/pull/4875) -- We added **6** new Rules to Detekt - - `NullableBooleanCheck` - [#4872](https://github.com/detekt/detekt/pull/4872) - - `CouldBeSequence` - [#4855](https://github.com/detekt/detekt/pull/4855) - - `UnnecessaryBackticks` - [#4764](https://github.com/detekt/detekt/pull/4764) - - `ForbiddenSuppress` - [#4899](https://github.com/detekt/detekt/pull/4899) - - `MaxChainedCallsOnSameLine` - [#4985](https://github.com/detekt/detekt/pull/4985) - - `CascadingCallWrapping` - [#4979](https://github.com/detekt/detekt/pull/4979) -- We added support for Markdown reports - [#4858](https://github.com/detekt/detekt/pull/4858) -- We now allow users and rule authors to specify a **reason** for every value in the config file - [#4611](https://github.com/detekt/detekt/pull/4611) -- We now report as warnings the Strings in the config file that can be converted to be an array - [#4793](https://github.com/detekt/detekt/pull/4793) -- We added a dependency on **ConTester** to help us verify concurrency scenarios for Detekt - [#4672](https://github.com/detekt/detekt/pull/4672) -- For contributors: we restructured our build setup to be use **Gradle composite build** - [#4751](https://github.com/detekt/detekt/pull/4751) - -##### Migration - -We fixed a bug related to function with KDocs and how their location in the source code was calculated (see [#4961](https://github.com/detekt/detekt/pull/4961) and [#4887](https://github.com/detekt/detekt/issues/4887)). - -Because of this, some users might have to **recreate their baseline** as the location of such functions are not matched anymore against the baseline. You can do so by deleting your old baseline and invoking the `detektBaseline` task (or the corresponding task, based on your configuration). - -##### Changelog - -- ReturnCount: Make configuration parameter more explicit - [#5062](https://github.com/detekt/detekt/pull/5062) -- Remove redundant null check - [#5061](https://github.com/detekt/detekt/pull/5061) -- Drop redundant Gradle workaround - [#5057](https://github.com/detekt/detekt/pull/5057) -- Update ktlint links from website to readme - [#5056](https://github.com/detekt/detekt/pull/5056) -- Improve extensions.doc format with admonitions - [#5055](https://github.com/detekt/detekt/pull/5055) -- Update docusaurus monorepo to v2.0.0-beta.22 - [#5050](https://github.com/detekt/detekt/pull/5050) -- Enable strict Kotlin DSL precompiled script plugins accessors generation - [#5048](https://github.com/detekt/detekt/pull/5048) -- MaxChainedCallsOnSameLine: don't count package references as chained calls - [#5036](https://github.com/detekt/detekt/pull/5036) -- Xml Report Merger now merges duplicate smells across input report files - [#5033](https://github.com/detekt/detekt/pull/5033) -- Add ending line and column to Location.kt - [#5032](https://github.com/detekt/detekt/pull/5032) -- Fix type resolution link in Contributing.md - [#5027](https://github.com/detekt/detekt/pull/5027) -- #5014 Fix MaxChainedCallsOnSameLine false positives - [#5020](https://github.com/detekt/detekt/pull/5020) -- Add endColumn/endLine to SARIF region - [#5011](https://github.com/detekt/detekt/pull/5011) -- Removed UnnecessaryAbstractClass if it inherits from a abstract class - [#5009](https://github.com/detekt/detekt/pull/5009) -- Only recommend using index accessors for Java classes that are known collections - [#4994](https://github.com/detekt/detekt/pull/4994) -- UnusedImports: fix false positive for unresolved imports - [#4882](https://github.com/detekt/detekt/pull/4882) -- Fix Signatures.kt:buildFunctionSignature - [#4961](https://github.com/detekt/detekt/pull/4961) -- Loading a specific resource from a module must use class from module - [#5008](https://github.com/detekt/detekt/pull/5008) -- Update github/codeql-action digest to 3f62b75 - [#5007](https://github.com/detekt/detekt/pull/5007) -- Show finding at declaration name instead of the whole declaration - [#5003](https://github.com/detekt/detekt/pull/5003) -- NamedArguments: don't count trailing lambda argument - [#5002](https://github.com/detekt/detekt/pull/5002) -- Address TextLocation for Wrapping - [#4998](https://github.com/detekt/detekt/pull/4998) -- Support markdown report in Gradle plugin - [#4995](https://github.com/detekt/detekt/pull/4995) -- Fix false-negative for CanBeNonNullable - [#4993](https://github.com/detekt/detekt/pull/4993) -- Give a better error message for --jvm-target - [#4978](https://github.com/detekt/detekt/pull/4978) -- Fix rule code samples to be valid Kotlin code - [#4969](https://github.com/detekt/detekt/pull/4969) -- Use plain ASCII output in standard reports - [#4968](https://github.com/detekt/detekt/pull/4968) -- UnnecessaryApply: fix false negative for assignment - [#4948](https://github.com/detekt/detekt/pull/4948) -- Support disabling config validation via tooling spec - [#4937](https://github.com/detekt/detekt/pull/4937) -- UnusedPrivateMember: highlight declaration name - [#4928](https://github.com/detekt/detekt/pull/4928) -- Provide a priority field for DetektProvider - [#4923](https://github.com/detekt/detekt/pull/4923) -- CastToNullableType: allow casting null keyword - [#4907](https://github.com/detekt/detekt/pull/4907) -- Update plugin com.gradle.common-custom-user-data-gradle-plugin to v1.7.2 - [#4897](https://github.com/detekt/detekt/pull/4897) -- Set strict dependency on tested Kotlin compiler version - [#4822](https://github.com/detekt/detekt/pull/4822) -- Simplify regular expressions - [#4893](https://github.com/detekt/detekt/pull/4893) -- Remove redundant character escape in RegExp - [#4892](https://github.com/detekt/detekt/pull/4892) -- Reformat Markdown files to comply with the spec - [#4891](https://github.com/detekt/detekt/pull/4891) -- UnnecessaryInnerClass: fix false negative with `this` references - [#4884](https://github.com/detekt/detekt/pull/4884) -- UselessCallOnNotNull: fix false positive for unresolved types - [#4880](https://github.com/detekt/detekt/pull/4880) -- Update MagicNumber rule to exclude .kts files - [#4877](https://github.com/detekt/detekt/pull/4877) -- CanBeNonNullable: fix false positives for parameterized types - [#4870](https://github.com/detekt/detekt/pull/4870) -- UnnecessaryInnerClass: fix false positives labeled expression to outer class - [#4865](https://github.com/detekt/detekt/pull/4865) -- UnnecessaryInnerClass: add test for safe qualified expressions - [#4864](https://github.com/detekt/detekt/pull/4864) -- Fix a confusing Regex in the Compose webpage - [#4852](https://github.com/detekt/detekt/pull/4852) -- Fix edit URLs for the website - [#4850](https://github.com/detekt/detekt/pull/4850) -- detektGenerateConfig adds the configuration of plugins - [#4844](https://github.com/detekt/detekt/pull/4844) -- Update dependency prism-react-renderer to v1.3.3 - [#4833](https://github.com/detekt/detekt/pull/4833) -- Search in all versions.properties, not just the first one #4830 - [#4831](https://github.com/detekt/detekt/pull/4831) -- Improve exception message - [#4823](https://github.com/detekt/detekt/pull/4823) -- Fix ValShouldBeVar false positive inside unknown type - [#4820](https://github.com/detekt/detekt/pull/4820) -- Add a recent conference talk link - [#4819](https://github.com/detekt/detekt/pull/4819) -- False positive for unused imports #4815 - [#4818](https://github.com/detekt/detekt/pull/4818) -- Revert "Display dynamic --jvm-target values when using --help flag (#4694)" - [#4816](https://github.com/detekt/detekt/pull/4816) -- UnnecessaryAbstractClass: report only the class name - [#4808](https://github.com/detekt/detekt/pull/4808) -- Fix wrong replacement suggestion for UnnecessaryFilter - [#4807](https://github.com/detekt/detekt/pull/4807) -- UseOrEmpty: fix false positive for indexing operator calls with type parameters - [#4804](https://github.com/detekt/detekt/pull/4804) -- ExplicitCollectionElementAccessMethod: fix false positive for get operators with type parameters - [#4803](https://github.com/detekt/detekt/pull/4803) -- Add tests for #4786 - [#4801](https://github.com/detekt/detekt/pull/4801) -- Add documentation link for rules in html report - [#4799](https://github.com/detekt/detekt/pull/4799) -- Improve rule documentaion and smell message of NamedArguments - [#4796](https://github.com/detekt/detekt/pull/4796) -- Improve issue description and smell message of DestructuringDeclarationWithTooManyEntries - [#4795](https://github.com/detekt/detekt/pull/4795) -- NestedScopeFunctions - Add rule for nested scope functions - [#4788](https://github.com/detekt/detekt/pull/4788) -- Partially drop redundant usage of "dry run" in Gradle plugin tests - [#4776](https://github.com/detekt/detekt/pull/4776) -- Allow additionalJavaSourceRootPaths to be defined on @KotlinCoreEnvironmentTest - [#4771](https://github.com/detekt/detekt/pull/4771) -- Report KDoc comments that refer to non-public properties of a class - [#4768](https://github.com/detekt/detekt/pull/4768) -- Self-inspect the detekt-gradle-plugin - [#4765](https://github.com/detekt/detekt/pull/4765) -- Pass args to DetektInvoker as List<String> - [#4762](https://github.com/detekt/detekt/pull/4762) -- Cleanup Gradle Plugin Publications - [#4752](https://github.com/detekt/detekt/pull/4752) -- Break a dependency between `detekt-gradle-plugin` and `detekt-utils` - [#4748](https://github.com/detekt/detekt/pull/4748) -- Remove suspend lambda rule with CoroutineScope receiver due to not de… - [#4747](https://github.com/detekt/detekt/pull/4747) -- `VarCouldBeVal`: Add configuration flag `ignoreLateinitVar` - [#4745](https://github.com/detekt/detekt/pull/4745) -- UnnecessaryInnerClass: fix false positive with references to function type variables - [#4738](https://github.com/detekt/detekt/pull/4738) -- Fix false positive on VarCouldBeVal in generic classes - [#4733](https://github.com/detekt/detekt/pull/4733) -- OutdatedDocumentation: fix false positive with no primary constructor - [#4728](https://github.com/detekt/detekt/pull/4728) -- Android Gradle: add javac intermediates to classpath - [#4723](https://github.com/detekt/detekt/pull/4723) -- OptionalWhenBraces: fix false negative when the single statement has comments inside - [#4722](https://github.com/detekt/detekt/pull/4722) -- Document pre-commit hook for staged files - [#4711](https://github.com/detekt/detekt/pull/4711) -- Enable rules by default for `1.21` - [#4643](https://github.com/detekt/detekt/issues/4643) - -##### Dependency Updates - -- Update dependency gradle to v7.5 - [#5074](https://github.com/detekt/detekt/pull/5074) -- Update plugin binaryCompatibilityValidator to v0.11.0 - [#5069](https://github.com/detekt/detekt/pull/5069) -- Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.6.3 - [#4976](https://github.com/detekt/detekt/pull/4976) -- Update dependency org.jetbrains.dokka to v1.7.0 - [#4974](https://github.com/detekt/detekt/pull/4974) -- Update plugin binaryCompatibilityValidator to v0.10.1 - [#4954](https://github.com/detekt/detekt/pull/4954) -- Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.6.2 - [#4868](https://github.com/detekt/detekt/pull/4868) -- Update dependency com.android.tools.build:gradle to v7.2.1 - [#4861](https://github.com/detekt/detekt/pull/4861) -- Update plugin binaryCompatibilityValidator to v0.10.0 - [#4837](https://github.com/detekt/detekt/pull/4837) -- Update dependency io.mockk:mockk to v1.12.4 - [#4829](https://github.com/detekt/detekt/pull/4829) -- Update dependency com.android.tools.build:gradle to v7.2.0 - [#4824](https://github.com/detekt/detekt/pull/4824) -- Add dependency-analysis plugin and implement some recommendations - [#4798](https://github.com/detekt/detekt/pull/4798) -- Add dependency on slf4j-nop to silence warning - [#4775](https://github.com/detekt/detekt/pull/4775) -- Update plugin dokka to v1.6.21 - [#4770](https://github.com/detekt/detekt/pull/4770) -- Update org.jetbrains.kotlin to v1.6.21 - [#4737](https://github.com/detekt/detekt/pull/4737) -- Update dependency com.github.breadmoirai:github-release to v2.3.7 - [#4734](https://github.com/detekt/detekt/pull/4734) -- Update plugin binaryCompatibilityValidator to v0.9.0 - [#4729](https://github.com/detekt/detekt/pull/4729) - -##### Housekeeping & Refactorings - -- Fix `ComplexMethod` debt and refactor code - [#5029](https://github.com/detekt/detekt/pull/5029) -- Fix ReturnCount debt and refactor code - [#5026](https://github.com/detekt/detekt/pull/5026) -- Add test for ForbiddenMethodCall with getters - [#5018](https://github.com/detekt/detekt/pull/5018) -- Measure flakyness on Windows CI - [#4742](https://github.com/detekt/detekt/pull/4742) -- Declare nested test classes as non-static - [#4894](https://github.com/detekt/detekt/pull/4894) -- Remove deprecated usages in gradle-plugin test - [#4889](https://github.com/detekt/detekt/pull/4889) -- Remove reference to contributor list - [#4871](https://github.com/detekt/detekt/pull/4871) -- Add missing image - [#4834](https://github.com/detekt/detekt/pull/4834) -- Upgrade to GE enterprise 3.10 - [#4802](https://github.com/detekt/detekt/pull/4802) -- Fix broken snapshot publishing - [#4783](https://github.com/detekt/detekt/pull/4783) -- Remove pending Gradle version milestones from comments - [#4777](https://github.com/detekt/detekt/pull/4777) -- Add more tests for Annotation Suppressor - [#4774](https://github.com/detekt/detekt/pull/4774) -- fix: add test case that fails if environment is not properly set up - [#4769](https://github.com/detekt/detekt/pull/4769) -- Disable UnusedImports for the Detekt project - [#4741](https://github.com/detekt/detekt/pull/4741) -- Remove Unnecesary @Nested - [#4740](https://github.com/detekt/detekt/pull/4740) -- Update the argsfile to unblock `runWithArgsFile` failing locally - [#4718](https://github.com/detekt/detekt/pull/4718) - -See all issues at: [1.21.0](https://github.com/detekt/detekt/milestone/86) - -#### 1.20.0 - 2022-04-14 - -We're extremely excited to share with you all the next upcoming stable release of Detekt: `1.20.0` 🎉 -This release is coming with 16 new rules, new API and functionalities and several stability improvements. - -First, much thanks to our sponsors ❤️ as we were able to buy a domain and move our website to [https://detekt.dev/](https://detekt.dev/). - -As for the feature shipped, we work a lot on the Reporting side: we added a new type of reporting, improved the styling of the existing one and -generally reduced the unnecessary warnings of run with type resolution. - -For rules like `ForbiddenMethod` where you can configure a signature of a method you want to use in your rule, we added a new syntax -that allows to reference generic methods & extension functions. - -We update a lot of the libraries we depend on bringing Detekt up to the ecosystem: KtLint 0.45.2, Kotlin 1.6.20 and Gradle 7.4.2 to name a few. - -Finally, we also migrated all of our tests **from Spek to JUnit**. This was a huge effort that will hopefully make easier for contributors -to be involved with Detekt. - -As always, we want to take the opportunity to thank our contributors for testing, bug reporting and helping -us release this new version of Detekt. You're more than welcome to join our community on the [#detekt](https://kotlinlang.slack.com/archives/C88E12QH4) channel on KotlinLang's Slack (you can [get an invite here](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up)). - -##### Notable Changes - -- With this Detekt versions, rule authors **can define the default configuration** for their custom rules. This default configuration will be merged together with the user configuration and can be overridden by the user if they wish. More on this here [#4315](https://github.com/detekt/detekt/pull/4315). The `formatting` ruleset provided by Detekt is updated to use this new mechanism - [#4352](https://github.com/detekt/detekt/pull/4352) -- We've added **16 new rules**: - - UnnecessaryInnerClass - [#4394](https://github.com/detekt/detekt/pull/4394) - - CanBeNonNullableProperty - [#4379](https://github.com/detekt/detekt/pull/4379) - - NullCheckOnMutableProperty - [#4353](https://github.com/detekt/detekt/pull/4353) - - SuspendFunWithCoroutineScopeReceiver - [#4616](https://github.com/detekt/detekt/pull/4616) - - ElseCaseInsteadOfExhaustiveWhen - [#4632](https://github.com/detekt/detekt/pull/4632) - - TrailingComma - From KtLint - [#4227](https://github.com/detekt/detekt/pull/4227) - - UnnecessaryParenthesesBeforeTrailingLambda - From KtLint - [#4630](https://github.com/detekt/detekt/pull/4630) - - BlockCommentInitialStarAlignment - From KtLint - [#4645](https://github.com/detekt/detekt/pull/4645) - - CommentWrapping - From KtLint - [#4645](https://github.com/detekt/detekt/pull/4645) - - DiscouragedCommentLocation - From KtLint - [#4645](https://github.com/detekt/detekt/pull/4645) - - FunKeywordSpacing - From KtLint - [#4645](https://github.com/detekt/detekt/pull/4645) - - FunctionTypeReferenceSpacing - From KtLint - [#4645](https://github.com/detekt/detekt/pull/4645) - - KdocWrapping - From KtLint - [#4645](https://github.com/detekt/detekt/pull/4645) - - ModifierListSpacing - From KtLint - [#4645](https://github.com/detekt/detekt/pull/4645) - - TypeArgumentListSpacing - From KtLint - [#4645](https://github.com/detekt/detekt/pull/4645) - - Wrapping - From KtLint - [#4645](https://github.com/detekt/detekt/pull/4645) -- We've made several improvements to the **console reporting**: - - The HTML report has now a better CSS styling - [#4447](https://github.com/detekt/detekt/pull/4447) - - The default reporting format is now `LiteFindingsReport` (which is more compact reporting and similar to other tools in the ecosystem. [You can see an example here](https://github.com/detekt/detekt/pull/4027)) - [#4449](https://github.com/detekt/detekt/pull/4449). - - We've added issue details to findings on `FindingsReport` and `FileBasedFindingsReporter` - [#4464](https://github.com/detekt/detekt/pull/4464) - - We suppressed several warnings reported when running with type resolution - [#4423](https://github.com/detekt/detekt/pull/4423) -- We fixed a **regression** introduced in `1.19.0` for users using `ignoreAnnotated` running **without type resolution** - [#4570](https://github.com/detekt/detekt/pull/4570) -- For rules like `ForbiddenMethod` where you can specify a method name in the config file, now we added support for: - - Matching functions with generics - [#4460](https://github.com/detekt/detekt/pull/4460) - - Matching extension functions - [#4459](https://github.com/detekt/detekt/pull/4459) -- We've fixed a security vulnerability related to XML parsing - [#4499](https://github.com/detekt/detekt/pull/4499) -- We've changed the behavior of the baseline task. Now the baseline is always update, even if you fixed all the issues in your codebase - [#4445](https://github.com/detekt/detekt/pull/4445) -- We now enable the naming ruleset by default also on tests. Previously they were excluded - [#4438](https://github.com/detekt/detekt/pull/4438) -- This version of Detekt is built with Gradle `v7.4.2`, AGP `7.1.3` and Kotlin `1.6.20` (see [#4530](https://github.com/detekt/detekt/pull/4530) [#4573](https://github.com/detekt/detekt/pull/4573) [#4133](https://github.com/detekt/detekt/pull/4133) [#4277](https://github.com/detekt/detekt/pull/4277) [#4665](https://github.com/detekt/detekt/pull/4665)) -- This version of Detekt is wrapping KtLint version `0.45.2` (see [#4227](https://github.com/detekt/detekt/pull/4227) [#4630](https://github.com/detekt/detekt/pull/4630) [#4645](https://github.com/detekt/detekt/pull/4645) [#4690](https://github.com/detekt/detekt/pull/4690)) -- For contributors: we migrated all our tests **from Spek to JUnit** due to better support and tooling [#4670](https://github.com/detekt/detekt/pull/4670). - -##### Changelog - -- Display dynamic --jvm-target values when using --help flag - [#4694](https://github.com/detekt/detekt/pull/4694) -- CanBeNonNullable shouldn't consider abstract properties - [#4686](https://github.com/detekt/detekt/pull/4686) -- NonBooleanPropertyPrefixedWithIs: Allow boolean function reference - [#4684](https://github.com/detekt/detekt/pull/4684) -- [VarCouldBeVal] fix overrides false positives - [#4664](https://github.com/detekt/detekt/pull/4664) -- Add ignoreOverridden support for BooleanPropertyNaming rule - [#4654](https://github.com/detekt/detekt/pull/4654) -- Fix regression generating configuration - [#4646](https://github.com/detekt/detekt/pull/4646) -- Fix concurrency issue when creating PomModel (#4609) - [#4631](https://github.com/detekt/detekt/pull/4631) -- UnnecessaryAbstractClass: fix false positive when the abstract class has properties in the primary constructor - [#4628](https://github.com/detekt/detekt/pull/4628) -- Properly set toolVersion on DetektExtension - [#4623](https://github.com/detekt/detekt/pull/4623) -- NamedArguments: Ignore when argument values are the same as the parameter name - [#4613](https://github.com/detekt/detekt/pull/4613) -- Parallel invocation of AnalysisFacade fails spuriously in 1.20.0-RC1 - [#4609](https://github.com/detekt/detekt/issues/4609) -- NoSuchElementException after updating to 1.20.0-RC1 - [#4604](https://github.com/detekt/detekt/issues/4604) -- Better error classification in Gradle Enterprise. - [#4586](https://github.com/detekt/detekt/pull/4586) -- Fix for missing /kotlin folder when running on Android projects - [#4554](https://github.com/detekt/detekt/pull/4554) -- Deprecate continuationIndentSize from the Indentation rule - [#4551](https://github.com/detekt/detekt/pull/4551) -- Fix performance issue for regexp in Reporting.kt - [#4550](https://github.com/detekt/detekt/pull/4550) -- Revert "trim values when parsing the baseline (#4335)" - [#4548](https://github.com/detekt/detekt/pull/4548) -- Fix AutoCorrection crashing with Missing extension point - [#4545](https://github.com/detekt/detekt/pull/4545) -- Make DoubleMutabilityForCollection configurable and set a DoubleMutability alias - [#4541](https://github.com/detekt/detekt/pull/4541) -- Fix `AnnotationExcluder` - [#4518](https://github.com/detekt/detekt/pull/4518) -- Fix false positive of UnnecessaryInnerClass - [#4509](https://github.com/detekt/detekt/pull/4509) -- [MaxLineLength] Fix signature in for blank characters in the Baseline - [#4504](https://github.com/detekt/detekt/pull/4504) -- Fix overridden function reporting for CanBeNonNullable rule - [#4497](https://github.com/detekt/detekt/pull/4497) -- Set the name of functions and paramenters between ` to improve the readability - [#4488](https://github.com/detekt/detekt/pull/4488) -- update InvalidPackageDeclaration to report if rootPackage is not present - [#4484](https://github.com/detekt/detekt/pull/4484) -- [VarCouldBeVal] Override vars will not be flagged if bindingContext is not set - [#4477](https://github.com/detekt/detekt/pull/4477) -- Document the overlapping rules from `formatting` - [#4473](https://github.com/detekt/detekt/pull/4473) -- Match functions signatures with lambdas on it - [#4458](https://github.com/detekt/detekt/pull/4458) -- Add option for OutdatedDocumentation to allow param in constructor pr… - [#4453](https://github.com/detekt/detekt/pull/4453) -- Ignore private operators when we don't have ContextBingding in UnusedPrivateMember - [#4441](https://github.com/detekt/detekt/pull/4441) -- Add documentation for `Suppressor`s - [#4440](https://github.com/detekt/detekt/issues/4440) -- [FunctionNaming] Don't allow the usage of ` in function names - [#4439](https://github.com/detekt/detekt/pull/4439) -- Add list of functions to skip in IgnoredReturnValue rule - [#4434](https://github.com/detekt/detekt/pull/4434) -- Extend CanBeNonNullable rule to check function params - [#4431](https://github.com/detekt/detekt/pull/4431) -- Extend VarCouldBeVal to include analysis of file- and class-level properties - [#4424](https://github.com/detekt/detekt/pull/4424) -- Formulate rule/sample-extensions descriptions consistently - [#4412](https://github.com/detekt/detekt/pull/4412) -- Fix false-positive on ExplicitCollectionElementAccessMethod - [#4400](https://github.com/detekt/detekt/pull/4400) -- Fixes false negatives in `UnnecessaryAbstractClass` - [#4399](https://github.com/detekt/detekt/pull/4399) -- Add first draft of a rule description style guide - [#4386](https://github.com/detekt/detekt/pull/4386) -- Forbid usage of java.lang.ClassLoader.getResourceAsStream - [#4381](https://github.com/detekt/detekt/pull/4381) -- Update Sponsor button to Detekt's one - [#4378](https://github.com/detekt/detekt/pull/4378) -- [OptionalUnit] Allow a function to declare a Unit return type when it uses a generic function initializer - [#4371](https://github.com/detekt/detekt/pull/4371) -- Completely-empty abstract classes will now be flagged by UnnecessaryAbstractClass - [#4370](https://github.com/detekt/detekt/pull/4370) -- Fix false positive in RethrowCaughtException for try with more than one catch (#4367) - [#4369](https://github.com/detekt/detekt/pull/4369) -- Testing and rule improvement for EmptyElseBlock - [#4349](https://github.com/detekt/detekt/pull/4349) -- UnusedPrivateMember should not report external classes/interfaces - [#4347](https://github.com/detekt/detekt/pull/4347) -- [UseDataClass] Do not report on `inner` classes - [#4344](https://github.com/detekt/detekt/pull/4344) -- Support jvmTarget 17 - [#4287](https://github.com/detekt/detekt/issues/4287) -- UnderscoresInNumericLiterals: Allow numbers with non standard groupings - [#4280](https://github.com/detekt/detekt/pull/4280) -- Introduce DefaultValue type - [#3928](https://github.com/detekt/detekt/pull/3928) - -##### Dependency Updates - -- Update plugin dokka to v1.6.20 - [#4717](https://github.com/detekt/detekt/pull/4717) -- Update dependency com.android.tools.build:gradle to v7.1.3 - [#4695](https://github.com/detekt/detekt/pull/4695) -- JaCoCo 0.8.8 - [#4680](https://github.com/detekt/detekt/pull/4680) -- Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.6.1 - [#4673](https://github.com/detekt/detekt/pull/4673) -- Update dependency gradle to v7.4.2 - [#4658](https://github.com/detekt/detekt/pull/4658) -- Update dependency org.jetbrains.kotlinx:kotlinx-html-jvm to v0.7.5 - [#4657](https://github.com/detekt/detekt/pull/4657) -- Update dependency gradle to v7.4.1 - [#4622](https://github.com/detekt/detekt/pull/4622) -- Update dependency com.android.tools.build:gradle to v7.1.2 - [#4594](https://github.com/detekt/detekt/pull/4594) -- Update dependency com.android.tools.build:gradle to v7.1.1 - [#4561](https://github.com/detekt/detekt/pull/4561) -- Update plugin pluginPublishing to v0.20.0 - [#4502](https://github.com/detekt/detekt/pull/4502) -- Update JamesIves/github-pages-deploy-action action to v4.2.1 - [#4475](https://github.com/detekt/detekt/pull/4475) -- Update JamesIves/github-pages-deploy-action action to v4.1.9 - [#4455](https://github.com/detekt/detekt/pull/4455) -- Update plugin gradleVersions to v0.41.0 - [#4454](https://github.com/detekt/detekt/pull/4454) -- Revert "Update plugin pluginPublishing to v0.19.0 (#4429)" - [#4452](https://github.com/detekt/detekt/pull/4452) -- Update plugin pluginPublishing to v0.19.0 - [#4429](https://github.com/detekt/detekt/pull/4429) -- Update dependency io.mockk:mockk to v1.12.2 - [#4427](https://github.com/detekt/detekt/pull/4427) -- Shadow 7.1.2 - [#4422](https://github.com/detekt/detekt/pull/4422) -- Update plugin dokka to v1.6.10 - autoclosed - [#4407](https://github.com/detekt/detekt/pull/4407) -- Update dependency org.jetbrains.dokka:jekyll-plugin to v1.6.10 - [#4406](https://github.com/detekt/detekt/pull/4406) -- Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.6.0 - [#4393](https://github.com/detekt/detekt/pull/4393) -- Update dependency gradle to v7.3.3 - [#4392](https://github.com/detekt/detekt/pull/4392) -- Update dependency org.yaml:snakeyaml to v1.30 - [#4375](https://github.com/detekt/detekt/pull/4375) -- Update dependency gradle to v7.3.2 - [#4374](https://github.com/detekt/detekt/pull/4374) -- Update plugin shadow to v7.1.1 - [#4373](https://github.com/detekt/detekt/pull/4373) -- Update dependency gradle to v7.3.1 - [#4350](https://github.com/detekt/detekt/pull/4350) -- Update plugin dokka to v1.6.0 - [#4328](https://github.com/detekt/detekt/pull/4328) - -##### Housekeeping & Refactorings - -- Add missing Test annotations - [#4699](https://github.com/detekt/detekt/pull/4699) -- Add failure message assertions to Gradle's "expect failure" tests - [#4693](https://github.com/detekt/detekt/pull/4693) -- Drop (most) Groovy DSL tests - [#4687](https://github.com/detekt/detekt/pull/4687) -- Check detekt-gradle-plugin functionalTest source when running detekt task - [#4681](https://github.com/detekt/detekt/pull/4681) -- Fix typo in AvoidReferentialEquality rule description - [#4644](https://github.com/detekt/detekt/pull/4644) -- Housekeep Gradle scripts - [#4589](https://github.com/detekt/detekt/pull/4589) -- Refactor config printer to improve testability - [#4580](https://github.com/detekt/detekt/pull/4580) -- avoid usage of java stream for parameterized tests - [#4579](https://github.com/detekt/detekt/pull/4579) -- split rule documentation printer to improve testability - [#4578](https://github.com/detekt/detekt/pull/4578) -- Make VERSION_CATALOGS stable - [#4577](https://github.com/detekt/detekt/pull/4577) -- Enable Gradle's configuration cache by default - [#4576](https://github.com/detekt/detekt/pull/4576) -- Migrate detekt-rules-performance tests to JUnit - [#4569](https://github.com/detekt/detekt/pull/4569) -- Migrate detekt-rules-complexity tests to JUnit - [#4566](https://github.com/detekt/detekt/pull/4566) -- Drop Groovy DSL testing in DetektTaskDslSpec - [#4563](https://github.com/detekt/detekt/pull/4563) -- Reuse `setReportOutputConventions` - [#4546](https://github.com/detekt/detekt/pull/4546) -- Code cleanups - [#4542](https://github.com/detekt/detekt/pull/4542) -- Fix MaxLineLength violation on detekt main inside IgnoredReturnValue rule - [#4539](https://github.com/detekt/detekt/pull/4539) -- Use Java 17 for all CI jobs - [#4526](https://github.com/detekt/detekt/pull/4526) -- Migrate tests in detekt-rules-errorprone to junit - [#4523](https://github.com/detekt/detekt/pull/4523) -- Drop unused dependencies - [#4506](https://github.com/detekt/detekt/pull/4506) -- Update JUnit dependencies - [#4505](https://github.com/detekt/detekt/pull/4505) -- Fixes test for LiteFindingsReport - [#4479](https://github.com/detekt/detekt/pull/4479) -- Remove outdated detekt suppression - [#4468](https://github.com/detekt/detekt/pull/4468) -- Add test cases to RedundantSuspendModifier rule - [#4430](https://github.com/detekt/detekt/pull/4430) -- Refactor MultilineLambdaItParameter rule - [#4428](https://github.com/detekt/detekt/pull/4428) -- Formulate rule/naming descriptions consistently - [#4419](https://github.com/detekt/detekt/pull/4419) -- Formulate rule/bugs descriptions consistently - [#4418](https://github.com/detekt/detekt/pull/4418) -- Formulate rule/complexity descriptions consistently - [#4417](https://github.com/detekt/detekt/pull/4417) -- Formulate rule/documentation descriptions consistently - [#4416](https://github.com/detekt/detekt/pull/4416) -- Formulate rule/coroutines descriptions consistently - [#4415](https://github.com/detekt/detekt/pull/4415) -- Formulate rule/style descriptions consistently - [#4414](https://github.com/detekt/detekt/pull/4414) -- Formulate rule/exceptions descriptions consistently - [#4413](https://github.com/detekt/detekt/pull/4413) -- Formulate rule/performance descriptions consistently - [#4411](https://github.com/detekt/detekt/pull/4411) -- Make MultiRuleCollector.kt consistent with the DoubleMutabilityForCollection rule - [#4405](https://github.com/detekt/detekt/pull/4405) -- Add test for nested SwallowedException - [#4404](https://github.com/detekt/detekt/pull/4404) -- Disable CI for Windows & JDK8 - [#4403](https://github.com/detekt/detekt/pull/4403) -- Improve test description in ForEachOnRangeSpec.kt - [#4402](https://github.com/detekt/detekt/pull/4402) -- Don't define classes on default package - [#4401](https://github.com/detekt/detekt/pull/4401) -- Config file in directory test - [#4398](https://github.com/detekt/detekt/pull/4398) -- Remove unnecessary map lambda in test code - [#4397](https://github.com/detekt/detekt/pull/4397) -- Improve `AnnotationExcluder` tests - [#4368](https://github.com/detekt/detekt/pull/4368) -- Enable UseAnyOrNoneInsteadOfFind - [#4362](https://github.com/detekt/detekt/pull/4362) -- Enable ForbiddenMethodCall - [#4334](https://github.com/detekt/detekt/pull/4334) - -See all issues at: [1.20.0](https://github.com/detekt/detekt/milestone/85) - -#### 1.19.0 - 2021-11-29 - -Please welcome the next upcoming stable release of Detekt: `1.19.0` 🎉 -This release is coming with a lot of new features, new rules, evolution in the API and stability improvements. - -Specifically, we've shipped some features that will allow you to better adapt detekt to run on codebases -that are using JetPack compose with features such as [`ignoreAnnotated` and `ignoreFunction`](/docs/introduction/suppressors). - -As always, we want to take the opportunity to thank our contributors for testing, bug reporting and helping -us release this new version of Detekt. You're more than welcome to join our community on the [#detekt](https://kotlinlang.slack.com/archives/C88E12QH4) channel on KotlinLang's Slack (you can [get an invite here](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up)). - -##### Notable Changes - -- We now offer an `ignoreAnnotated` configuration key that you can use on all your rules to suppress findings if inside an annotated block (e.g. `@Composable`) - [#4102](https://github.com/detekt/detekt/pull/4102) and [#4241](https://github.com/detekt/detekt/pull/4241) -- Similarly, we now offer also an `ignoreFunction` configuration key that you can use to suppress findings if inside a function with a given name - [#4148](https://github.com/detekt/detekt/pull/4148) -- Report configuration is changing in the Gradle plugin. The `reports` extension on the `detekt` extension has been - deprecated. See the Migration section below for steps to migrate to the new recommended configuration - [#3687](https://github.com/detekt/detekt/pull/3687) -- The `ExplicitCollectionElementAccessMethod` rule is now a type-resolution only rule - [#4201](https://github.com/detekt/detekt/pull/4201) -- The `InvalidPackageDeclaration` rule has been split to create the `MissingPackageDeclaration` rule - [#4149](https://github.com/detekt/detekt/pull/4149) -- The `ForbiddenComment` rule now offers a `customMessage` configuration key - [#4126](https://github.com/detekt/detekt/pull/4126) -- We bumped ktlint and updated the default enabled rules to mirror what ktlint is doing - [#4179](https://github.com/detekt/detekt/pull/4179) -- Added a new `LambdaParameterNaming` rule, to enforce a naming convention of parameter inside lambdas - [#4147](https://github.com/detekt/detekt/pull/4147) -- Added a new `InjectDispatcher` rule, to check if dispatchers are injectable - [#4222](https://github.com/detekt/detekt/pull/4222) -- Added a new `ConsoleReport` format - [#4027](https://github.com/detekt/detekt/pull/4027) -- Gradle: We added the `--auto-correct` cmdline option to gradle tasks - [#4202](https://github.com/detekt/detekt/pull/4202) -- Gradle: We removed the `afterEvaluate` wrapper from the Android and KMM plugin - [#4159](https://github.com/detekt/detekt/pull/4159) and [#4271](https://github.com/detekt/detekt/pull/4271) -- We now test against Java 17 and stopped testing against Java 16 - [#4136](https://github.com/detekt/detekt/pull/4136) -- Remove library specific configurations like Jetpack Compose and Dagger from the default config - [#4101](https://github.com/detekt/detekt/pull/4101) -- Remove detekt-bom module - [#4043](https://github.com/detekt/detekt/pull/4043) -- Use reference in fallback property delegate - [#3982](https://github.com/detekt/detekt/pull/3982) - -##### Migration - -Configuring reports in the Gradle plugin should be done at the task level instead of at the extension (or global) level. -The previous recommendation resulted in the report output for multiple tasks overwriting each other when multiple detekt -tasks were executed in the same Gradle run. - -Before this release the recommended way to configure reports was using the `detekt` extension: -```kotlin -detekt { - reports { - xml { - enabled = true - destination = file("build/reports/detekt/detekt.xml") - } - } -} -``` - -This meant all detekt tasks would output the report to the same destination. From this detekt release you should enable -and disable reports for all tasks using the `withType` Gradle method: - -```kotlin -// Kotlin DSL -tasks.withType().configureEach { - reports { - xml.required.set(true) - } -} -``` - -```groovy -// Groovy DSL -tasks.withType(Detekt).configureEach { - reports { - xml.required.set(true) - } -} -``` - -To customize the report output location configure the task individually: -```kotlin -tasks.detektMain { - reports { - xml { - outputLocation.set(file("build/reports/detekt/customPath.xml")) - required.set(true) // reports can also be enabled and disabled at the task level as needed - } - } -} -``` - -##### Changelog - -- trim values when parsing the baseline - [#4335](https://github.com/detekt/detekt/pull/4335) -- Fix #4332 by widening the scope to all JDKs - [#4333](https://github.com/detekt/detekt/pull/4333) -- Bugfix provided by #4225 needs wider scope - [#4332](https://github.com/detekt/detekt/issues/4332) -- Avoid false positives in MemberNameEqualsClassName - [#4329](https://github.com/detekt/detekt/pull/4329) -- Add two new config steps for Compose - [#4322](https://github.com/detekt/detekt/pull/4322) -- Set DetektJvm task source with SourceDirectorySet instead of file list - [#4151](https://github.com/detekt/detekt/pull/4151) -- Add documentation about how to configure Baseline task with type resolution - [#4285](https://github.com/detekt/detekt/pull/4285) -- Remove kotlin-gradle-plugin-api from runtime classpath - [#4275](https://github.com/detekt/detekt/pull/4275) -- Use appropriate annotations on source properties in Gradle tasks - [#4264](https://github.com/detekt/detekt/pull/4264) -- Replace usage of deprecated ConfigureUtil - [#4263](https://github.com/detekt/detekt/pull/4263) -- Fix test failure of ReportMergeSpec - [#4262](https://github.com/detekt/detekt/pull/4262) -- Revert "Remove afterEvaluate wrapper (#4159)" - [#4259](https://github.com/detekt/detekt/pull/4259) -- ExplicitCollectionElementAccessMethodSpec: does not report methods that is called on implicit receiver - [#4256](https://github.com/detekt/detekt/pull/4256) -- UnusedPrivateMember: fix false positive with operator `in` - [#4249](https://github.com/detekt/detekt/pull/4249) -- Introduce UseAnyOrNoneInsteadOfFind rule - [#4247](https://github.com/detekt/detekt/pull/4247) -- OptionalWhenBraces: fix false negative for nested when - [#4246](https://github.com/detekt/detekt/pull/4246) -- Handle MultiRules in Suppressors - [#4239](https://github.com/detekt/detekt/pull/4239) -- Fix UselessCallOnNotNull rule - [#4237](https://github.com/detekt/detekt/pull/4237) -- Make detekt a bit less noisy when mixing java and kotlin files - [#4231](https://github.com/detekt/detekt/pull/4231) -- Workaround for JDK 8 instability when reading config - [#4225](https://github.com/detekt/detekt/pull/4225) -- Define FunctionSignature - [#4176](https://github.com/detekt/detekt/pull/4176) -- ForbiddenMethodCall: report overriding method calls - [#4205](https://github.com/detekt/detekt/pull/4205) -- ObjectLiteralToLambda: fix false positive when using Java interfaces with default methods - [#4203](https://github.com/detekt/detekt/pull/4203) -- Unit tests for TooGenericExceptionThrown - [#4198](https://github.com/detekt/detekt/pull/4198) -- Display correct --jvm-target values when using --help flag - [#4195](https://github.com/detekt/detekt/pull/4195) -- Improved `MaximumLineLength` documentation - [#4188](https://github.com/detekt/detekt/pull/4188) -- Report NewLineAtEndOfFile source location at end of file - [#4187](https://github.com/detekt/detekt/pull/4187) -- #4169 OutdatedDocumentation rule - [#4185](https://github.com/detekt/detekt/pull/4185) -- Don't report on platform types in NullableToStringCall - [#4180](https://github.com/detekt/detekt/pull/4180) -- Fix #4140: Allow Bazel based tests to run with string test input - [#4170](https://github.com/detekt/detekt/pull/4170) -- Improve ForbiddenMethodCall documentation - [#4166](https://github.com/detekt/detekt/pull/4166) -- Report SwallowedException on catchParameter - [#4158](https://github.com/detekt/detekt/pull/4158) -- Enable binary compatibility validator for detekt-test and detekt-test-api - [#4157](https://github.com/detekt/detekt/pull/4157) -- Fix issues with Elvis operator in UnconditionalJumpStatementInLoop - [#4150](https://github.com/detekt/detekt/pull/4150) -- Improve documentation for naming rules - [#4146](https://github.com/detekt/detekt/pull/4146) -- Disable `UnsafeCallOnNullableType` on tests - [#4123](https://github.com/detekt/detekt/pull/4123) -- Remove annotations from LateinitUsage noncompliant block - [#4100](https://github.com/detekt/detekt/pull/4100) -- UnnecessaryAbstractClass: false positive when the abstract class has internal/protected abstract members - [#4099](https://github.com/detekt/detekt/pull/4099) -- Deprecate DefaultContext - [#4098](https://github.com/detekt/detekt/pull/4098) -- Fix confusing message when breaking the MultilineLambdaItParameter rule - [#4089](https://github.com/detekt/detekt/pull/4089) -- Remove deprecated KotlinExtension - [#4063](https://github.com/detekt/detekt/pull/4063) -- Add an alias for FunctionMinLength/FunctionMaxLength rules to be more descriptive - [#4050](https://github.com/detekt/detekt/pull/4050) -- fix report path, default path is reports/detekt/... - [#4034](https://github.com/detekt/detekt/pull/4034) -- Fix TextLocation of Indentation rule - [#4030](https://github.com/detekt/detekt/pull/4030) -- detekt-bom is going away after 1.18.0 - [#3988](https://github.com/detekt/detekt/issues/3988) -- UnderscoresInNumericLiterals acceptableDecimalLength is off by one - [#3972](https://github.com/detekt/detekt/pull/3972) -- Create rule set configurations in a safe way - [#3964](https://github.com/detekt/detekt/pull/3964) -- Remove UnnecessarySafeCall safeguard against ErrorType - [#3439](https://github.com/detekt/detekt/pull/3439) - -##### Dependency Updates - -- Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.5.2 - [#4302](https://github.com/detekt/detekt/pull/4302) -- Update dependency io.mockk:mockk to v1.12.1 - [#4297](https://github.com/detekt/detekt/pull/4297) -- Update dependency com.android.tools.build:gradle to v4.2.2 - [#4296](https://github.com/detekt/detekt/pull/4296) -- Gradle Publishing Plugin 0.17.0 - [#4270](https://github.com/detekt/detekt/pull/4270) -- Shadow 7.1.0 - [#4269](https://github.com/detekt/detekt/pull/4269) -- Dokka 1.5.31 - [#4268](https://github.com/detekt/detekt/pull/4268) -- Binary Compatibility Validator 0.8.0 - [#4267](https://github.com/detekt/detekt/pull/4267) -- Reflections 0.10.2 - [#4266](https://github.com/detekt/detekt/pull/4266) -- Upgrade to Gradle 7.3 - [#4254](https://github.com/detekt/detekt/pull/4254) -- Dokka 1.5.30 - [#4114](https://github.com/detekt/detekt/pull/4114) -- Kotlin 1.5.31 - [#4113](https://github.com/detekt/detekt/pull/4113) -- Update dependencies - [#4065](https://github.com/detekt/detekt/pull/4065) - -##### Housekeeping & Refactorings - -- Simplify YamlConfig - [#4316](https://github.com/detekt/detekt/pull/4316) -- Move tests to the correct module - [#4314](https://github.com/detekt/detekt/pull/4314) -- Don't hide null issues - [#4313](https://github.com/detekt/detekt/pull/4313) -- Add functional test for type resolution for JVM - [#4307](https://github.com/detekt/detekt/pull/4307) -- Minor typo fix and code refactoring - [#4284](https://github.com/detekt/detekt/pull/4284) -- Improve Tests of UnnecesaryLet - [#4282](https://github.com/detekt/detekt/pull/4282) -- Fix typo in UnnecessaryLet - [#4281](https://github.com/detekt/detekt/pull/4281) -- Fix typo in Gradle lib definition - [#4255](https://github.com/detekt/detekt/pull/4255) -- Rename DoubleMutabilityInCollectionSpec to DoubleMutabilityForCollectionSpec - [#4251](https://github.com/detekt/detekt/pull/4251) -- Simplify conditional checks to improve coverage - [#4221](https://github.com/detekt/detekt/pull/4221) -- Refactor NoTabs to remove DetektVisitor - [#4220](https://github.com/detekt/detekt/pull/4220) -- Fix typos and grammar in rule descriptions - [#4219](https://github.com/detekt/detekt/pull/4219) -- Use Kotlin's ArrayDeque implementation - [#4218](https://github.com/detekt/detekt/pull/4218) -- Update Kotlin docs URL - [#4217](https://github.com/detekt/detekt/pull/4217) -- Report UntilInsteadOfRangeTo for 'rangeTo' calls - [#4212](https://github.com/detekt/detekt/pull/4212) -- Add tests for merging reports - [#4199](https://github.com/detekt/detekt/pull/4199) -- Setup Gradle functional tests - [#4074](https://github.com/detekt/detekt/pull/4074) -- GitHub Actions cache fixes - [#3723](https://github.com/detekt/detekt/pull/3723) -- Simplify where casts used unnecessarily - [#4213](https://github.com/detekt/detekt/pull/4213) -- Don't specify Gradle Enterprise Gradle Plugin version - [#4210](https://github.com/detekt/detekt/pull/4210) -- Fix baserule import in tests - [#4189](https://github.com/detekt/detekt/pull/4189) -- Run CLI sanity checks with Gradle - [#4186](https://github.com/detekt/detekt/pull/4186) -- Use Codecov GitHub Action to upload coverage - [#4184](https://github.com/detekt/detekt/pull/4184) -- Enable ParameterListWrapping rule on detekt codebase - [#4178](https://github.com/detekt/detekt/pull/4178) -- Add test cases for MagicNumber - [#4152](https://github.com/detekt/detekt/pull/4152) -- Fix FunctionParameterNamingSpec - [#4145](https://github.com/detekt/detekt/pull/4145) -- Address feedback on #4139 - [#4143](https://github.com/detekt/detekt/pull/4143) -- Don't skip tests that now pass - [#4142](https://github.com/detekt/detekt/pull/4142) -- Fixes for Kotlin 1.6.0-M1 - [#4139](https://github.com/detekt/detekt/pull/4139) -- Don't unnecessarily propogate opt-in requirement - [#4116](https://github.com/detekt/detekt/pull/4116) -- Drop junit-platform-launcher dependency - [#4115](https://github.com/detekt/detekt/pull/4115) -- Ensure detekt-tooling public API is stable - [#4112](https://github.com/detekt/detekt/pull/4112) -- Fix globing typo - [#4107](https://github.com/detekt/detekt/pull/4107) -- Rename and split ValidateConfig files - [#4105](https://github.com/detekt/detekt/pull/4105) -- Dynamic deprecation - [#4104](https://github.com/detekt/detekt/pull/4104) -- Fix indent issues with continuation indent - [#4103](https://github.com/detekt/detekt/pull/4103) -- Refactor so detekt-gradle-plugin can be added as an included build - [#4094](https://github.com/detekt/detekt/pull/4094) -- Migrate buildSrc to composite build - [#4090](https://github.com/detekt/detekt/pull/4090) -- Fix broken `applySelfAnalysisVersion` task - [#4082](https://github.com/detekt/detekt/pull/4082) -- Convert DetektJvmSpec to use ProjectBuilder - [#4075](https://github.com/detekt/detekt/pull/4075) -- Upscale JVM settings - [#4057](https://github.com/detekt/detekt/pull/4057) -- Gradle 7.2 - [#4056](https://github.com/detekt/detekt/pull/4056) -- Verify at compile time that issue id matches rule name - [#4047](https://github.com/detekt/detekt/pull/4047) - -See all issues at: [1.19.0](https://github.com/detekt/detekt/milestone/83) - -#### 1.18.1 - 2021-08-30 - -This is a point release for Detekt `1.18.0` containing bugfixes for problems that got discovered just after the release. - -##### Notable Changes - -- MultiRule should pass correctly the BindingContext - [#4071](https://github.com/detekt/detekt/pull/4071) -- Allow active, excludes and includes in the rule-set configuration - [#4045](https://github.com/detekt/detekt/pull/4045) -- Remove Error from ThrowingExceptionsWithoutMessageOrCause because is a common name - [#4046](https://github.com/detekt/detekt/pull/4046) -- Fix issue IDs for ReferentialEquality and DoubleMutability - [#4040](https://github.com/detekt/detekt/pull/4040) - -See all issues at: [1.18.1](https://github.com/detekt/detekt/milestone/84) - -#### 1.18.0 - 2021-08-12 - -We're more than excited to introduce you a next stable release of Detekt: `1.18.0` 🎉 -This release is coming with a lot of changes, new rules, evolution in the API and stability improvements. - -We want to take the opportunity to thank our contributors for testing, bug reporting and helping -us release this new version of Detekt. - -##### Notable Changes - -- We've added two new rules: `AvoidReferentialEquality` and `BooleanPropertyNaming` (see [#3924](https://github.com/detekt/detekt/pull/3924) and [#3795](https://github.com/detekt/detekt/pull/3795)) -- This version of Detekt ships with Kotlin `1.5.21`, and we're compiling with `apiVersion` set to `1.4` - [#3956](https://github.com/detekt/detekt/pull/3956) and [#3852](https://github.com/detekt/detekt/pull/3852) -- The minimum version of Gradle to use Detekt Gradle Plugin is now `6.1` - [#3830](https://github.com/detekt/detekt/pull/3830) -- This version of Detekt has been tested against Java 16 - [#3698](https://github.com/detekt/detekt/pull/3698) -- We fixed a long-standing bug related to parallel execution (#3248) - [#3799](https://github.com/detekt/detekt/pull/3799) and [#3822](https://github.com/detekt/detekt/pull/3822) -- We now use multi-line format for list options in the default detekt config file - [#3827](https://github.com/detekt/detekt/pull/3827) -- The rule `VarCouldBeVal` has been updated and now works only with type resolution to provide more precise findings - [#3880](https://github.com/detekt/detekt/pull/3880) -- We removed all the references to `Extensions.getRootArea` that is now deprecated from our codebase. This was affecting users with sporadic crashes. - [#3848](https://github.com/detekt/detekt/pull/3848) -- For _detekt_ rule authors: We created a Github Template that you can use to bootstrap your custom rule project: [detekt-custom-rule-template](https://github.com/detekt/detekt-custom-rule-template). You can use JitPack to host it and share your rule easily with other members of the community. -- For _detekt_ rule authors: We finished the rework to use the annotations instead of kdoc tags in rules. Specifically configurations must be configured using `@Configuration` while auto-correction capability should be specified with the `@AutoCorrectable` annotation [#3820](https://github.com/detekt/detekt/pull/3820). - -##### Migration - -- We renamed the `input` property inside the `detekt{}` extension of the Gradle plugin to `source`. The `input` property has been deprecated, and we invite you to migrate to the new property (see [#3951](https://github.com/detekt/detekt/pull/3951)) - -``` -// BEFORE -detekt { - input = files(...) -} - -// AFTER -detekt { - source = files(...) -} -``` - -- For all rule authors: When accessing a config value within a rule, using `valueOrDefault` and `valueOrDefaultCommaSeparated` is no longer recommended. While both will remain part of the public api, they should be replaced by one of the config delegates (see [#3891](https://github.com/detekt/detekt/pull/3891)). The key that is used to lookup the configured value is derived from the property name. -```kotlin -/* simple property */ -// BEFORE -val ignoreDataClasses = valueOrDefault("ignoreDataClasses", true) -// AFTER -val ignoreDataClasses: Boolean by config(true) - -/* transformed simple property */ -// BEFORE -val ignoredName = valueOrDefault("ignoredName", "").trim() -// AFTER -val ignoredName: String by config("", String::trim) - -/* transformed list property */ -// BEFORE -val ignoreAnnotated = valueOrDefaultCommaSeparated("ignoreAnnotated", listOf("Inject", "Value")) - .map(String::trim) -// AFTER -val ignoreAnnotated: List by config(listOf("Inject", "Value")) { list -> - list.map(String::trim) -} -``` - -- For all rule authors: The types `ThresholdRule` and `LazyRegex` have been marked as deprecated and will be removed in a future release. Please migrate to config delegates. -```kotlin -/* ThresholdRule */ -// BEFORE -class MyRule(config: Config, threshold: Int = 10) : ThresholdRule(config, threshold) { - // ... -} -// AFTER -class MyRule(config: Config) : Rule(config) { - private val threshold: Int by config(10) - // ... -} - -/* LazyRegex */ -// BEFORE -private val allowedPattern: Regex by LazyRegex("allowedPatterns", "") -// AFTER -private val allowedPattern: Regex by config("", String::toRegex) -``` - -- For custom rule authors: This will be the last version of detekt where we publish the `detekt-bom` artifact. This change should not affect anyone. If it affects you, [please let us know](https://github.com/detekt/detekt/issues/3988). - -##### Changelog - -- [KMP] Fix resolution of Android test classpaths - [#4026](https://github.com/detekt/detekt/pull/4026) -- Sort config lists - [#4014](https://github.com/detekt/detekt/pull/4014) -- Multiplatform tasks should not depend on check - [#4025](https://github.com/detekt/detekt/pull/4025) -- mark configWithFallback as unstable - [#4028](https://github.com/detekt/detekt/pull/4028) -- UseDataClass: fix false positive on value classes - [#4016](https://github.com/detekt/detekt/pull/4016) -- ImplicitUnitReturnType: don't report when expression body is 'Unit' - [#4011](https://github.com/detekt/detekt/pull/4011) -- Fix false positive with UnusedPrivateMember on parameter of a protected function - [#4007](https://github.com/detekt/detekt/pull/4007) -- ClassNaming: Don't treat Kotlin syntax ` as part of class name - [#3977](https://github.com/detekt/detekt/pull/3977) -- IgnoredReturnValue: fix false negative when annotation is on the class - [#3979](https://github.com/detekt/detekt/pull/3979) -- NoNameShadowing: fix false positive with nested lambda has implicit parameter - [#3991](https://github.com/detekt/detekt/pull/3991) -- UnusedPrivateMember - added handling of overloaded array get operator - [#3666](https://github.com/detekt/detekt/pull/3666) -- Publish bundled/Shadow JAR artifact to Maven repos - [#3986](https://github.com/detekt/detekt/pull/3986) -- EmptyDefaultConstructor false positive with expect and actual classes - [#3970](https://github.com/detekt/detekt/pull/3970) -- FunctionNaming - Allow factory function names - fix #1639 - [#3973](https://github.com/detekt/detekt/pull/3973) -- EndOfSentenceFormat - Fix #3893 by only calling super.visit once - [#3904](https://github.com/detekt/detekt/pull/3904) -- UndocumentedPublicFunction: don't report when nested class is inside not public class [#3962](https://github.com/detekt/detekt/pull/3962) -- Fail with a meaningful error message for invalid boolean - [#3931](https://github.com/detekt/detekt/pull/3931) -- UndocumentedPublicProperty and UndocumentedPublicFunction should include objects - [#3940](https://github.com/detekt/detekt/pull/3940) -- Fix exclusion pattern for InvalidPackageDeclaration - [#3907](https://github.com/detekt/detekt/pull/3907) -- Allow else when {...} in MandatoryBracesIfStatements rule - [#3905](https://github.com/detekt/detekt/pull/3905) -- Remove unnecessary constant declaration - [#3903](https://github.com/detekt/detekt/pull/3903) -- Check bindingContext only once in MemberNameEqualsClassName - [#3899](https://github.com/detekt/detekt/pull/3899) -- LongMethod: add 'ignoreAnnotated' configuration option - [#3892](https://github.com/detekt/detekt/pull/3892) -- Fix Deprecation rule message - [#3885](https://github.com/detekt/detekt/pull/3885) -- Improve LongParameterList rule by supporting ignoring annotated parameters - [#3879](https://github.com/detekt/detekt/pull/3879) -- OptionalUnit: fix false positive when function initializer is Nothing type - [#3876](https://github.com/detekt/detekt/pull/3876) -- UnnecessaryParentheses: fix false positive for delegated expressions - [#3858](https://github.com/detekt/detekt/pull/3858) -- Fix UnnecessaryLet false positive in inner lambdas - [#3841](https://github.com/detekt/detekt/pull/3841) -- Fix false positive for UnusedPrivateMember - Backtick identifiers - [#3828](https://github.com/detekt/detekt/pull/3828) -- Properly apply test excludes for comments - [#3815](https://github.com/detekt/detekt/pull/3815) -- Fix generation issues around (deprecated) list properties - [#3813](https://github.com/detekt/detekt/pull/3813) -- Update the implementation of ClassOrdering to handle false negatives - [#3810](https://github.com/detekt/detekt/pull/3810) -- [comments] Do not exclude tests globally - [#3801](https://github.com/detekt/detekt/pull/3801) -- UnnecessaryLet: report when implicit parameter isn't used - [#3794](https://github.com/detekt/detekt/pull/3794) -- NoNameShadowing: don't report when implicit 'it' parameter isn't used - [#3793](https://github.com/detekt/detekt/pull/3793) -- Fix ModifierOrder to support value class - [#3719](https://github.com/detekt/detekt/pull/3719) -- Remove inline value class to stay compatible with Kotlin 1.4 API - [#3871](https://github.com/detekt/detekt/pull/3871) -- [FunctionNaming] Revert annotations that are ignored by default - [#3948](https://github.com/detekt/detekt/pull/3948) -- Android: add javac intermediates to classpath - [#3867]((https://github.com/detekt/detekt/pull/3867) -- Revert "Android: add javac intermediates to classpath (#3867)" - [#3958]((https://github.com/detekt/detekt/pull/3958) -- Use annotations to configure rules in detekt-rules-exceptions - [#3798](https://github.com/detekt/detekt/pull/3798) -- Use @Configuration in detekt-rules-style - [#3774](https://github.com/detekt/detekt/pull/3774) -- Use annotations to configure rules in custom-checks - [#3773](https://github.com/detekt/detekt/pull/3773) -- Use @Configuration for rules-errorprone - [#3772](https://github.com/detekt/detekt/pull/3772) -- Use annotation to configure rules in rules-empty - [#3771](https://github.com/detekt/detekt/pull/3771) -- Use annotation to configure rules in rules-documentation - [#3770](https://github.com/detekt/detekt/pull/3770) -- Use annotations to configure rules in rules-naming - [#3769](https://github.com/detekt/detekt/pull/3769) -- Use annotations to configure rules in rules-complexity - [#3768](https://github.com/detekt/detekt/pull/3768) -- Move formatting rules to @Configuration - [#3847](https://github.com/detekt/detekt/pull/3847) - -##### Dependency Updates - -- Bump Kotlin to 1.5.21 - [#3956](https://github.com/detekt/detekt/pull/3956) -- Revert "Bump Kotlin to v1.5.20" - [#3941](https://github.com/detekt/detekt/pull/3941) -- Bump Kotlin to v1.5.20 - [#3921](https://github.com/detekt/detekt/pull/3921) -- Kotlin 1.5.10 - [#3826](https://github.com/detekt/detekt/pull/3826) -- Update assertj to v3.20.2 - [#3912](https://github.com/detekt/detekt/pull/3912) -- Update snakeyaml to v1.29 - [#3911](https://github.com/detekt/detekt/pull/3911) -- Bump byte-buddy from 1.11.2 to 1.11.5 - [#3886](https://github.com/detekt/detekt/pull/3886) -- Bump byte-buddy from 1.11.1 to 1.11.2 - [#3872](https://github.com/detekt/detekt/pull/3872) -- Bump byte-buddy from 1.11.0 to 1.11.1 - [#3861](https://github.com/detekt/detekt/pull/3861) -- Update mockk to 1.12.0 - [#3937](https://github.com/detekt/detekt/pull/3937) - -##### Housekeeping & Refactorings - -- Enable UnnecessaryLet rule for detekt code base - [#4024](https://github.com/detekt/detekt/pull/4024) -- enable PreferToOverPairSyntax rule for detekt code base - [#4023](https://github.com/detekt/detekt/pull/4023) -- Add IllegalArgumentException and IllegalStateException to ThrowingExceptionsWithoutMessageOrCause - [#4013](https://github.com/detekt/detekt/pull/4013) -- enable more potential-bugs rules for detekt code base - [#3997](https://github.com/detekt/detekt/pull/3997) -- enable more exception rules for detekt code base - [#3995](https://github.com/detekt/detekt/pull/3995) -- Enable UseOrEmpty for detekt code base - [#3999](https://github.com/detekt/detekt/pull/3999) -- enable those rules from the style rule set that have not violation or obvious fixes - [#3998](https://github.com/detekt/detekt/pull/3998) -- Enable more rules from naming rule set for detekt code base - [#3996](https://github.com/detekt/detekt/pull/3996) -- Enable UseEmptyCounterpart for detekt code base - [#4000](https://github.com/detekt/detekt/pull/4000) -- enable coroutine rules for detekt code base - [#3994](https://github.com/detekt/detekt/pull/3994) -- Remove "plugin" suffix from version catalog aliases - [#3987](https://github.com/detekt/detekt/pull/3987) -- Fix ClassCastException in test on java 11 openjdk9 - [#3984](https://github.com/detekt/detekt/pull/3984) -- Activate IgnoredReturnValue on detekt code base - [#3974](https://github.com/detekt/detekt/pull/3974) -- Add missing test in FunctionNaming - [#3976](https://github.com/detekt/detekt/pull/3976) -- Fix trunk compilation - [#3968](https://github.com/detekt/detekt/pull/3968) -- Reformat internal detekt.yml using multi line lists - [#3936](https://github.com/detekt/detekt/pull/3936) -- Increase memory available to gradle integration test daemon - [#3938](https://github.com/detekt/detekt/pull/3938) -- Avoid empty lines when running detekt with type resolution - [#3909](https://github.com/detekt/detekt/pull/3909) -- Fix java.lang.ClassCastException is reading default yaml config - [#3920](https://github.com/detekt/detekt/pull/3920) -- Refactor + rename util function inside MandatoryBracesIfStatement rule - [#3908](https://github.com/detekt/detekt/pull/3908) -- Rename Tests to Spec - [#3906](https://github.com/detekt/detekt/pull/3906) -- verify that no rule is configured with kdoc tags - [#3870](https://github.com/detekt/detekt/pull/3870) -- Setup FOSSA - [#3836](https://github.com/detekt/detekt/pull/3836) -- jvmTarget can't be null - [#3818](https://github.com/detekt/detekt/pull/3818) -- Add test for ruleset provider configuration - [#3814](https://github.com/detekt/detekt/pull/3814) -- Merge JaCoCo coverage reports the "right" way - [#3650](https://github.com/detekt/detekt/pull/3650) -- Update outdated Gradle plugin documentation regarding source files - [#3883](https://github.com/detekt/detekt/pull/3883) -- Make documentation more precise about how rules are enabled - [#3889](https://github.com/detekt/detekt/pull/3889) -- Rename MapGetWithNotNullAsserSpec to follow test convention - [#3878](https://github.com/detekt/detekt/pull/3878) -- Remove custom assertions that check kdoc of rules - [#3859](https://github.com/detekt/detekt/pull/3859) -- Avoid overlapping outputs - [#3790](https://github.com/detekt/detekt/pull/3790) -- Revert "Avoid overlapping outputs" - [#3943](https://github.com/detekt/detekt/pull/3943) - -See all issues at: [1.18.0](https://github.com/detekt/detekt/milestone/82) - -#### 1.17.1 - 2021-05-19 - -##### Notable Changes - -This is a patch release for Detekt `1.17.0` including fixes that we considered worth a point release. - -Specifically, we're reverting a change on our Gradle Plugin. The original change [#3655](https://github.com/detekt/detekt/pull/3655) resulted in several false positives when using rules with Type Resolution on Java/Kotlin mixed codebases. - -Moreover we included a couple of false positive fixes for `NoNameShadowing` and `UnnecessaryLet` - -##### Changelog - -- Revert "Noisy gradle (#3655)" - [#3792](https://github.com/detekt/detekt/pull/3792) -- NoNameShadowing: don't report when implicit 'it' parameter isn't used - [#3793](https://github.com/detekt/detekt/pull/3793) -- UnnecessaryLet: report when implicit parameter isn't used - [#3794](https://github.com/detekt/detekt/pull/3794) - -#### 1.17.0 - 2021-05-15 - -##### Notable Changes - -- We're introducing our new Project logo :). See [#3726](https://github.com/detekt/detekt/pull/3726) -- This release allows you to replace your `jcenter()` dependencies with `mavenCentral()` given that our dependency on `kotlinx.html` migrated to Maven Central - See [#3455](https://github.com/detekt/detekt/pull/3455) -- We now introduced the `src/test/java` and `src/test/kotlin` by default for the plain `detekt` Gradle task. If you use that task, you might notice rule reports in your test sourceset. See [#3649](https://github.com/detekt/detekt/pull/3649) -- We now default the baseline file to `detekt-baseline.xml` so you don't have to specify it manually. You can revert the previous behavior by setting the baseline to `null` - See [#3619](https://github.com/detekt/detekt/pull/3619) and [#3745](https://github.com/detekt/detekt/pull/3745) -- We enabled the SARIF output format by default - See [#3543](https://github.com/detekt/detekt/pull/3543) -- We're introducing annotations to provide metadata to rules, such as `@ActiveByDefault`, `@Configuration` and `@RequiresTypeResolution` - See [#3637](https://github.com/detekt/detekt/pull/3637) [#3592](https://github.com/detekt/detekt/pull/3592) and [#3579](https://github.com/detekt/detekt/pull/3579) - -##### Changelog - -- Fix crash for DontDowncastCollectionTypes on Synthetic types - [#3776](https://github.com/detekt/detekt/pull/3776) -- We don't need to talk about jcenter anymore at our docs - [#3755](https://github.com/detekt/detekt/pull/3755) -- Skip publishing for detekt-cli shadowRuntimeElements variant - [#3747](https://github.com/detekt/detekt/pull/3747) -- Set the org.gradle.dependency.bundling attribute to external - [#3738](https://github.com/detekt/detekt/pull/3738) -- Support triple quoted strings in default value of config delegate - [#3733](https://github.com/detekt/detekt/pull/3733) -- Properly populate versions.properties - [#3730](https://github.com/detekt/detekt/pull/3730) -- We have a logo :) - [#3726](https://github.com/detekt/detekt/pull/3726) -- [UndocumentedPublicProperty] Allow inline comments for properties in primary constructor as documentation - [#3722](https://github.com/detekt/detekt/pull/3722) -- MultilineLambdaItParameter: don't report when lambda has no implicit parameter references - [#3696](https://github.com/detekt/detekt/pull/3696) -- Fix false positives for UnnecessaryFilter - [#3695](https://github.com/detekt/detekt/pull/3695) -- Add support for transformer function in config property delegate - [#3676](https://github.com/detekt/detekt/pull/3676) -- Add support for fallback property - [#3675](https://github.com/detekt/detekt/pull/3675) -- Ignore actual members in UnusedPrivateMember - [#3669](https://github.com/detekt/detekt/pull/3669) -- NamedArguments rule: fix false positive with trailing lambda - [#3661](https://github.com/detekt/detekt/pull/3661) -- Add DeprecatedBlockTag rule - [#3660](https://github.com/detekt/detekt/pull/3660) -- Noisy gradle - [#3655](https://github.com/detekt/detekt/pull/3655) -- Drop support to Gradle 5 - [#3647](https://github.com/detekt/detekt/pull/3647) -- Add MayBeConstant as alias for MayBeConst - [#3644](https://github.com/detekt/detekt/pull/3644) -- [ThrowingExceptionInMain] [ExitOutsideMainfix] fix for KtNamedFunction.isMainFunction() - [#3641](https://github.com/detekt/detekt/pull/3641) -- Fixing IllegalArgumentException in ForbiddenMethodCall rule for Intersection type parameters - [#3626](https://github.com/detekt/detekt/pull/3626) -- Replace getJetTypeFqName with fqNameOrNull extension - [#3613](https://github.com/detekt/detekt/pull/3613) -- New Rule: ObjectLiteralToLambda - [#3599](https://github.com/detekt/detekt/pull/3599) -- [MemberNameEqualsClassName] Support factory exemption for generic classes - [#3595](https://github.com/detekt/detekt/pull/3595) -- Refactor Analyzer so that RuleSetProvider.instance is only called once - [#3585](https://github.com/detekt/detekt/pull/3585) -- SarifOutputReportSpec: Correctly detect Windows root directory on local development machine - [#3584](https://github.com/detekt/detekt/pull/3584) -- Replace @since KDoc tag with @SinceDetekt - [#3582](https://github.com/detekt/detekt/pull/3582) -- Simplify code in RedundantSuspendModifier rule - [#3580](https://github.com/detekt/detekt/pull/3580) -- Revert "Refactor Analyzer so that RuleSetProvider.instance is only called once" - [#3578](https://github.com/detekt/detekt/pull/3578) -- fix error message -> buildUponDefaultConfig instead of buildOnDefaultConfig - [#3572](https://github.com/detekt/detekt/pull/3572) -- UnnecessaryApply: fix false positive when lambda has multiple member references - [#3564](https://github.com/detekt/detekt/pull/3564) -- Switch SARIF report off jackson - [#3557](https://github.com/detekt/detekt/pull/3557) -- Fix rules not appearing in the sarif output - [#3556](https://github.com/detekt/detekt/pull/3556) -- Refactor Analyzer so that RuleSetProvider.instance is only called once - [#3555](https://github.com/detekt/detekt/pull/3555) -- New Rule: DoubleMutabilityForCollection - [#3553](https://github.com/detekt/detekt/pull/3553) -- Adds a ForbiddenSingleExpressionSyntax rule - [#3550](https://github.com/detekt/detekt/pull/3550) - -##### Dependency Updates - -- Update to Gradle 7.0.1 - [#3760](https://github.com/detekt/detekt/pull/3760) -- Update Shadow plugin to 7.0.0 - [#3759](https://github.com/detekt/detekt/pull/3759) -- Upgrade to AGP 4.2.0 - [#3744](https://github.com/detekt/detekt/pull/3744) -- JaCoCo 0.8.7 - [#3739](https://github.com/detekt/detekt/pull/3739) -- Upgrade to GitHub-native Dependabot - [#3716](https://github.com/detekt/detekt/pull/3716) -- Upgrade to Gradle 7 - [#3689](https://github.com/detekt/detekt/pull/3689) -- Bump com.gradle.plugin-publish from 0.13.0 to 0.14.0 - [#3654](https://github.com/detekt/detekt/pull/3654) -- Bump kotlin-reflect from 1.4.0 to 1.4.32 - [#3627](https://github.com/detekt/detekt/pull/3627) -- Upgrade to ktlint 0.41.0 - [#3624](https://github.com/detekt/detekt/pull/3624) -- Update to Kotlin 1.4.32 - [#3606](https://github.com/detekt/detekt/pull/3606) -- Bump AGP from 4.1.2 to 4.1.3 - [#3589](https://github.com/detekt/detekt/pull/3589) -- Bump mockk from 1.10.6 to 1.11.0 - [#3588](https://github.com/detekt/detekt/pull/3588) - -##### Housekeeping & Refactorings - -- Fix document - [#3765](https://github.com/detekt/detekt/pull/3765) -- Fix kdoc link on blog navigation - [#3761](https://github.com/detekt/detekt/pull/3761) -- Upload any heap dumps produced during CI build - [#3758](https://github.com/detekt/detekt/pull/3758) -- Always run warningsAsErrors on CI - [#3754](https://github.com/detekt/detekt/pull/3754) -- Clean ci - [#3753](https://github.com/detekt/detekt/pull/3753) -- Revert "Set the org.gradle.dependency.bundling attribute to external" - [#3750](https://github.com/detekt/detekt/pull/3750) -- Enable Gradle's type-safe project accessors - [#3742](https://github.com/detekt/detekt/pull/3742) -- Enable Gradle's version catalogs - [#3741](https://github.com/detekt/detekt/pull/3741) -- Ignore gradle plugin in codecov - [#3740](https://github.com/detekt/detekt/pull/3740) -- Update config file due to invalid argument - [#3735](https://github.com/detekt/detekt/pull/3735) -- Skip Multiplatform iOS tests if XCode is not configured - [#3734](https://github.com/detekt/detekt/pull/3734) -- Specify Java language level in module plugin - [#3732](https://github.com/detekt/detekt/pull/3732) -- Don't run unnecesary tasks - [#3725](https://github.com/detekt/detekt/pull/3725) -- Remove --stacktrace now that we have scan - [#3724](https://github.com/detekt/detekt/pull/3724) -- Drop JCenter usage from detekt's own build - [#3711](https://github.com/detekt/detekt/pull/3711) -- Publish build scans for all CI builds - [#3710](https://github.com/detekt/detekt/pull/3710) -- Remove deprecated kotlin-dsl Gradle config option - [#3709](https://github.com/detekt/detekt/pull/3709) -- Update to setup-java@v2 - [#3704](https://github.com/detekt/detekt/pull/3704) -- (Try to) improve CI build reliability - [#3703](https://github.com/detekt/detekt/pull/3703) -- Simplify UpdateVersionInFileTask - [#3693](https://github.com/detekt/detekt/pull/3693) -- Fix compilation issue in `:detekt-rules-style:compileTestKotlin` - [#3691](https://github.com/detekt/detekt/pull/3691) -- Fix detekt failure in CI - [#3674](https://github.com/detekt/detekt/pull/3674) -- Refactor UnusedPrivateMemberSpec - [#3667](https://github.com/detekt/detekt/pull/3667) -- Warnings as errors - [#3646](https://github.com/detekt/detekt/pull/3646) -- Skip ios tests if no ci - [#3635](https://github.com/detekt/detekt/pull/3635) -- Fix tests - [#3634](https://github.com/detekt/detekt/pull/3634) -- Include detekt-rules on CLI runtime classpath - [#3625](https://github.com/detekt/detekt/pull/3625) -- Improve tests from :detekt-gradle-plugin - [#3623](https://github.com/detekt/detekt/pull/3623) -- Improve generator test coverage - [#3622](https://github.com/detekt/detekt/pull/3622) -- Improve tests - [#3618](https://github.com/detekt/detekt/pull/3618) -- Apply more formatting rules to our code - [#3615](https://github.com/detekt/detekt/pull/3615) -- Add negative test case for `requiresTypeResolution` - [#3614](https://github.com/detekt/detekt/pull/3614) -- Simplify Gradle config - [#3612](https://github.com/detekt/detekt/pull/3612) -- Decouple Gradle projects - [#3611](https://github.com/detekt/detekt/pull/3611) -- Add --stacktrace to help triage CI flakiness - [#3604](https://github.com/detekt/detekt/pull/3604) -- Fix CI failure for deploy-snapshot - [#3598](https://github.com/detekt/detekt/pull/3598) -- Improve Deprecation and Documentation for allRules - [#3596](https://github.com/detekt/detekt/pull/3596) -- Update files to support `main` branch in order to remove oppressive language - [#3586](https://github.com/detekt/detekt/pull/3586) -- Format test code for RedundantSuspendModifierSpec - [#3581](https://github.com/detekt/detekt/pull/3581) -- Gradle tweaks - [#3575](https://github.com/detekt/detekt/pull/3575) -- Support Gradle config cache in detekt's build - [#3574](https://github.com/detekt/detekt/pull/3574) -- Show information from @active in the website - [#3569](https://github.com/detekt/detekt/pull/3569) -- Update rule doc for SwallowedException config - [#3547](https://github.com/detekt/detekt/pull/3547) -- Markdown: Reintroduce double-backticks for inline code rendering - [#3545](https://github.com/detekt/detekt/pull/3545) - -See all issues at: [1.17.0](https://github.com/detekt/detekt/milestone/81) - -#### 1.16.0 - 2021-03-10 - -##### Changelog - -- Bump jcommander from 1.78 to 1.81 - [#3530](https://github.com/detekt/detekt/pull/3530) -- Swallow exception fixes - [#3525](https://github.com/detekt/detekt/pull/3525) -- Merge SARIF reports - [#3522](https://github.com/detekt/detekt/pull/3522) -- Revert Update Kotlin to version 1.4.31 - [#3521](https://github.com/detekt/detekt/pull/3521) -- Fix not being able to override `insertFinalNewLine` - [#3515](https://github.com/detekt/detekt/pull/3515) -- Allow opt-out configuring detekt android and multiplatform - [#3511](https://github.com/detekt/detekt/pull/3511) -- Gradle Plugin tests should access also Maven Local - [#3510](https://github.com/detekt/detekt/pull/3510) -- Update Kotlin to version 1.4.31 - [#3509](https://github.com/detekt/detekt/pull/3509) -- Fix SARIF validation failure - [#3507](https://github.com/detekt/detekt/pull/3507) -- Remove off importing android util - [#3506](https://github.com/detekt/detekt/pull/3506) -- Adding support for full method signatures in ForbiddenMethodCall - [#3505](https://github.com/detekt/detekt/pull/3505) -- Add UnusedUnaryOperator rule - [#3499](https://github.com/detekt/detekt/pull/3499) -- New rule: disallow to cast to nullable type - [#3497](https://github.com/detekt/detekt/pull/3497) -- Merge XML report output - [#3491](https://github.com/detekt/detekt/pull/3491) -- Allow using regular expressions when defining license header templates - [#3486](https://github.com/detekt/detekt/pull/3486) -- Add UnreachableCatchBlock rule - [#3478](https://github.com/detekt/detekt/pull/3478) -- Add NoNameShadowing rule - [#3477](https://github.com/detekt/detekt/pull/3477) -- Fix false negative "UselessCallOnNotNull" with `list.isNullOrEmpty()` - [#3475](https://github.com/detekt/detekt/pull/3475) -- Add UseOrEmpty rule - [#3470](https://github.com/detekt/detekt/pull/3470) -- Add UseIsNullOrEmpty rule - [#3469](https://github.com/detekt/detekt/pull/3469) -- Add support to Kotlin Multiplatform Projects - [#3453](https://github.com/detekt/detekt/pull/3453) -- Fix false positives for MultilineLambdaItParameter.kt - [#3451](https://github.com/detekt/detekt/pull/3451) -- Dont generate baseline if empty - [#3450](https://github.com/detekt/detekt/pull/3450) -- Silence IndexOutOfBoundsException in getLineAndColumnInPsiFile() - [#3446](https://github.com/detekt/detekt/pull/3446) -- Add new ObjectExtendsThrowable rule - [#3443](https://github.com/detekt/detekt/pull/3443) -- Add allRules and deprecate failFast in gradle tasks - [#3431](https://github.com/detekt/detekt/pull/3431) -- Add two missing ktlint rules - [#3430](https://github.com/detekt/detekt/pull/3430) -- Don't fail if baseline doesn't exist in PlainDetekt - [#3429](https://github.com/detekt/detekt/pull/3429) -- Fix False Positive on `UnnecessarySafeCall` - [#3419](https://github.com/detekt/detekt/pull/3419) -- Fix false positive for `UnusedPrivateMember` with expect on objects - [#3417](https://github.com/detekt/detekt/pull/3417) -- Fix code samples for `UnnecessarySafeCall` - [#3416](https://github.com/detekt/detekt/pull/3416) -- New rule: DontDowncastCollectionTypes - [#3413](https://github.com/detekt/detekt/pull/3413) -- Fix documentation in UnnecessarySafeCall - [#3412](https://github.com/detekt/detekt/pull/3412) -- Bump gradle from 4.1.1 to 4.1.2 - [#3405](https://github.com/detekt/detekt/pull/3405) -- Introduce --max-issues flag for cli - #2267 - [#3391](https://github.com/detekt/detekt/pull/3391) -- Ignore actual functions in FunctionOnlyReturningConstant (#3388) - [#3390](https://github.com/detekt/detekt/pull/3390) -- Fix hyperlink for elements of the type 'KtFile' - [#3386](https://github.com/detekt/detekt/pull/3386) -- Update gradle doc to show table of contents correctly - [#3383](https://github.com/detekt/detekt/pull/3383) -- Update cli doc to show table of contents correctly - [#3382](https://github.com/detekt/detekt/pull/3382) -- Fix EmptyConfig making all rules active in production - [#3380](https://github.com/detekt/detekt/pull/3380) -- Empty custom config enables rules disabled by default - [#3379](https://github.com/detekt/detekt/issues/3379) -- Add `setup-detekt` action to README - [#3373](https://github.com/detekt/detekt/pull/3373) -- GlobalClassLoaderCache: move call to getFiles out of synchronized block - [#3370](https://github.com/detekt/detekt/pull/3370) -- Check for === instead of == - [#3363](https://github.com/detekt/detekt/issues/3363) -- Filter existing files in classpath - [#3361](https://github.com/detekt/detekt/pull/3361) -- Suppress RedundantVisibilityModifierRule if explicit API mode enabled - [#3358](https://github.com/detekt/detekt/pull/3358) -- Add the final new line in the baseline again - [#3351](https://github.com/detekt/detekt/pull/3351) -- [Security] Bump nokogiri from 1.10.10 to 1.11.1 in /docs - [#3348](https://github.com/detekt/detekt/pull/3348) -- Remove trailing newline after ending IndentingXMLStreamWriter - [#3347](https://github.com/detekt/detekt/pull/3347) -- [Security] Bump nokogiri from 1.10.10 to 1.11.0 in /docs - [#3343](https://github.com/detekt/detekt/pull/3343) -- Add UnnecessaryFilter rule - [#3341](https://github.com/detekt/detekt/pull/3341) -- Reorganize docs for the configuration file - [#3337](https://github.com/detekt/detekt/pull/3337) -- Add new rule SleepInsteadOfDelay - [#3335](https://github.com/detekt/detekt/pull/3335) -- Update Android Gradle Plugin to 4.1.1 - [#3328](https://github.com/detekt/detekt/pull/3328) -- Support relative output paths - [#3319](https://github.com/detekt/detekt/pull/3319) -- Fix `runLastOnRoot` being empty in KtLintMultiRule - [#3318](https://github.com/detekt/detekt/pull/3318) -- Ensure binary-compatibility with previous versrions - [#3315](https://github.com/detekt/detekt/issues/3315) -- Fix reports not propagated to detekt task with type resolution - [#3313](https://github.com/detekt/detekt/pull/3313) -- Support configurable severity per ruleset/rule in XML and Sarif output - [#3310](https://github.com/detekt/detekt/pull/3310) -- Configure default excludes for InvalidPackageDeclaration - [#3305](https://github.com/detekt/detekt/pull/3305) -- Remove exceptions of Library rules - [#3304](https://github.com/detekt/detekt/pull/3304) -- Move the questions to discussions - [#3300](https://github.com/detekt/detekt/pull/3300) -- Magic number extension functions - [#3299](https://github.com/detekt/detekt/pull/3299) -- NamedArguments: fix false positive with varargs - [#3294](https://github.com/detekt/detekt/pull/3294) -- NamedArguments rule: false positive with varargs - [#3291](https://github.com/detekt/detekt/issues/3291) -- NamedArguments with java code false positive - [#3289](https://github.com/detekt/detekt/issues/3289) -- Upgrade ktlint to 0.40.0 - [#3281](https://github.com/detekt/detekt/pull/3281) -- False positive "Unconditional loop jump" - [#3280](https://github.com/detekt/detekt/issues/3280) -- ForbiddenComments don't report TODO: in KDoc - [#3273](https://github.com/detekt/detekt/issues/3273) -- Add MultilineLambdaItParameter rule - [#3259](https://github.com/detekt/detekt/pull/3259) -- Update Kotlin to 1.4.21 - [#3254](https://github.com/detekt/detekt/pull/3254) -- Introduce --all-rules flag - [#3253](https://github.com/detekt/detekt/pull/3253) -- Enable more rules by default - [#3229](https://github.com/detekt/detekt/pull/3229) -- Running multiple Detekt tasks concurrently may cause deadlock - [#3047](https://github.com/detekt/detekt/issues/3047) -- detektMain is noisy "Ignoring a file detekt cannot handle" - [#3019](https://github.com/detekt/detekt/issues/3019) -- Configure default excludes for InvalidPackageDeclaration - [#2539](https://github.com/detekt/detekt/issues/2539) -- Hyperlink to error inside Android studio - [#2340](https://github.com/detekt/detekt/issues/2340) -- Align cli flags and defaults with other analysis tools - [#2267](https://github.com/detekt/detekt/issues/2267) - -##### Housekeeping & Refactorings - -- SwallowedException: Slightly improve the documentation - [#3527](https://github.com/detekt/detekt/pull/3527) -- Fix Markdown rendering of multiple default values - [#3526](https://github.com/detekt/detekt/pull/3526) -- Move gradle testkit test back to test/ - [#3504](https://github.com/detekt/detekt/pull/3504) -- Add documentation on suppressing formatting rules - [#3503](https://github.com/detekt/detekt/pull/3503) -- Change DetektMultiplatform from unit test to gradle testkit integrati… - [#3500](https://github.com/detekt/detekt/pull/3500) -- Bump com.gradle.plugin-publish from 0.12.0 to 0.13.0 - [#3494](https://github.com/detekt/detekt/pull/3494) -- Refactor Gradle integration tests - [#3489](https://github.com/detekt/detekt/pull/3489) -- Refactor gradle integration test - [#3487](https://github.com/detekt/detekt/pull/3487) -- Prepare Detekt 1.16.0-RC2 - [#3485](https://github.com/detekt/detekt/pull/3485) -- Bump mockk from 1.10.5 to 1.10.6 - [#3473](https://github.com/detekt/detekt/pull/3473) -- Upgrade to Gradle 6.8.2 - [#3468](https://github.com/detekt/detekt/pull/3468) -- Correct `maxIssues` documentation - [#3456](https://github.com/detekt/detekt/pull/3456) -- Bump junit-platform-launcher from 1.7.0 to 1.7.1 - [#3454](https://github.com/detekt/detekt/pull/3454) -- Don't use deprecated functions - [#3452](https://github.com/detekt/detekt/pull/3452) -- Bump github-pages from 210 to 211 in /docs - [#3434](https://github.com/detekt/detekt/pull/3434) -- Add documentation for SARIF, severity and relative path - [#3433](https://github.com/detekt/detekt/pull/3433) -- Refactor uploading SARIF to report without overriding the previous step - [#3432](https://github.com/detekt/detekt/pull/3432) -- Fix `githubRelease` skipping assets - [#3427](https://github.com/detekt/detekt/pull/3427) -- Prompt bug reporters to attach gradle scan - [#3422](https://github.com/detekt/detekt/pull/3422) -- Fix invalid link in detekt html report - [#3421](https://github.com/detekt/detekt/pull/3421) -- Prepare 1.16.0-rc1 release - [#3411](https://github.com/detekt/detekt/pull/3411) -- Add full qualified name in documentation - [#3410](https://github.com/detekt/detekt/pull/3410) -- Bump kotlinx-coroutines-core from 1.3.8 to 1.4.1 - [#3407](https://github.com/detekt/detekt/pull/3407) -- Fix deploy website on master - [#3406](https://github.com/detekt/detekt/pull/3406) -- Bump mockk from 1.10.4 to 1.10.5 - [#3404](https://github.com/detekt/detekt/pull/3404) -- Bump assertj-core from 3.18.1 to 3.19.0 - [#3403](https://github.com/detekt/detekt/pull/3403) -- Bump github-pages from 209 to 210 in /docs - [#3401](https://github.com/detekt/detekt/pull/3401) -- Update dangling URLs pointing to the old website - [#3400](https://github.com/detekt/detekt/pull/3400) -- Auto generate CLI options in docs - [#3399](https://github.com/detekt/detekt/pull/3399) -- Update documentations on snapshots - [#3393](https://github.com/detekt/detekt/pull/3393) -- Fix maven publish - [#3392](https://github.com/detekt/detekt/pull/3392) -- Fix build script to avoid jvm plugin applied - [#3389](https://github.com/detekt/detekt/pull/3389) -- Disable parallel test discovery; we already use Grade workers for max parallelism - [#3387](https://github.com/detekt/detekt/pull/3387) -- Use more fluent assertions - [#3381](https://github.com/detekt/detekt/pull/3381) -- Refactor orders of repositories - [#3376](https://github.com/detekt/detekt/pull/3376) -- Add a test for UndocumentedPublicClass and fun interfaces - [#3374](https://github.com/detekt/detekt/pull/3374) -- Refactor build.gradle.kts in detekt-gradle-plugin - [#3371](https://github.com/detekt/detekt/pull/3371) -- Gradle to 6.8 - [#3362](https://github.com/detekt/detekt/pull/3362) -- Integrate SARIF report with Github code scanning - [#3359](https://github.com/detekt/detekt/pull/3359) -- Refactor integration test for detekt-gradle-plugin - [#3356](https://github.com/detekt/detekt/pull/3356) -- Improve gradle plugin - [#3354](https://github.com/detekt/detekt/pull/3354) -- Remove checkNotNull - [#3352](https://github.com/detekt/detekt/pull/3352) -- Generate API validation for `detekt-psi-utils` - [#3338](https://github.com/detekt/detekt/pull/3338) -- recover binary compatibility with 1.15.0 - [#3336](https://github.com/detekt/detekt/pull/3336) -- Refactor tests in detekt-gradle-plugin - [#3333](https://github.com/detekt/detekt/pull/3333) -- Fix failing website deployment on master - [#3332](https://github.com/detekt/detekt/pull/3332) -- The output of updateVersion should not depend on the OS that executes it - [#3330](https://github.com/detekt/detekt/pull/3330) -- Reduce visibility - [#3326](https://github.com/detekt/detekt/pull/3326) -- Refactor XmlOutputFormatSpec - [#3325](https://github.com/detekt/detekt/pull/3325) -- Simplify our buildSrc - [#3322](https://github.com/detekt/detekt/pull/3322) -- Apply binary compatibility plugin to Detekt - [#3320](https://github.com/detekt/detekt/pull/3320) -- Add KDoc for convoluted PathFilters.isIgnored - [#3312](https://github.com/detekt/detekt/pull/3312) -- Don't mix kotlin 1.3 and 1.4 - [#3309](https://github.com/detekt/detekt/pull/3309) -- Allow to overwrite in the task moveJarForIntegrationTest - [#3308](https://github.com/detekt/detekt/pull/3308) -- Remove unnecessary .trimIndent() - housekeeping - [#3307](https://github.com/detekt/detekt/pull/3307) -- Fix typo - [#3301](https://github.com/detekt/detekt/pull/3301) -- General housekeeping - [#3298](https://github.com/detekt/detekt/pull/3298) -- Inline UnconditionalJumpStatementInLoop case files - [#3296](https://github.com/detekt/detekt/pull/3296) - -See all issues at: [1.16.0](https://github.com/detekt/detekt/milestone/80) - -#### 1.15.0 - 2020-12-18 - -##### Notable Changes - -detekt 1.15.0 bundles Kotlin 1.4.10. -You may experience some known issues when your project already uses 1.4.20 -- [#3248](https://github.com/detekt/detekt/issues/3248) and [#3282](https://github.com/detekt/detekt/issues/3282). - -In addition to many rule improvements, there are also new ones: - -- RedundantHigherOrderMapUsage -- UseIfEmptyOrIfBlank - -We added documentation on how to configure [type resolution](/docs/gettingstarted/type-resolution). -Only the rules marked with `Requires Type Resolution` (on the website documentation or `@requiresTypeResolution` in code) are executed (see [here for example](/docs/rules/style#forbiddenmethodcall)). - -detekt now supports [SARIF](https://sarifweb.azurewebsites.net/) as an output format. In the future you will be able to -upload this format to GitHub and see detekt issues right in your pull requests. - -##### Migration - -We removed implementations of the `Config` interface from the public api. -It was first deprecated and then moved to `internal` package earlier this year. -Rule authors can use `TestConfig(Map)` or `yamlConfig(String)` from `detekt-test` to test their rules. - -- Move internal config api to core module - [#3163](https://github.com/detekt/detekt/pull/3163) - -##### Changelog - -- NamedArguments: fix false positive with java method call - [#3290](https://github.com/detekt/detekt/pull/3290) -- Prepare 1.15.0 rc2 - [#3286](https://github.com/detekt/detekt/pull/3286) -- UnconditionalJumpStatementInLoop: don't report a return after a conditional jump - [#3285](https://github.com/detekt/detekt/pull/3285) -- Add MuseDev to the list of integrations - [#3284](https://github.com/detekt/detekt/pull/3284) -- Fix ForbiddenComment rule not checking for KDoc - [#3275](https://github.com/detekt/detekt/pull/3275) -- ForbiddenComments don't report TODO: in KDoc - [#3273](https://github.com/detekt/detekt/issues/3273) -- Add IntelliJ platform plugin template integration to readme - [#3270](https://github.com/detekt/detekt/pull/3270) -- Bundle new sarif output format by default - [#3268](https://github.com/detekt/detekt/pull/3268) -- Add a test for UnusedImports with annotations used as attributes #3246 - [#3255](https://github.com/detekt/detekt/pull/3255) -- Add documentation page on type resolution - [#3225](https://github.com/detekt/detekt/pull/3225) -- ThrowsCount rule: fix false positive with nested function - [#3223](https://github.com/detekt/detekt/pull/3223) -- False positive in ThrowsCount rule - [#3222](https://github.com/detekt/detekt/issues/3222) -- Refactor UnsafeCallOnNullableType rule - [#3221](https://github.com/detekt/detekt/pull/3221) -- Fix false negatives in UnreachableCode rule - [#3220](https://github.com/detekt/detekt/pull/3220) -- False negatives in UnreachableCode rule - [#3219](https://github.com/detekt/detekt/issues/3219) -- Refactor RedundantElseInWhen to use compiler warning - [#3214](https://github.com/detekt/detekt/pull/3214) -- NullableToStringCall: fix false negative with safe qualified expression - [#3213](https://github.com/detekt/detekt/pull/3213) -- False negative in NullableToStringCall - [#3211](https://github.com/detekt/detekt/issues/3211) -- NullableToStringCall: fix false negatives with qualified expression - [#3198](https://github.com/detekt/detekt/pull/3198) -- False negatives in NullableToStringCall - [#3196](https://github.com/detekt/detekt/issues/3196) -- Check for presence of null case in MissingWhenCase rule - [#3194](https://github.com/detekt/detekt/pull/3194) -- Throw error instead of logging as error in analysis phase - [#3193](https://github.com/detekt/detekt/pull/3193) -- Make kotlinc adapted rule comments internal - [#3190](https://github.com/detekt/detekt/issues/3190) -- MissingWhenCase false negative with nulls - [#3189](https://github.com/detekt/detekt/issues/3189) -- Check for static imports in unused imports rule - [#3188](https://github.com/detekt/detekt/pull/3188) -- Add allowElseExpression configuration for MissingWhenCase rule - [#3187](https://github.com/detekt/detekt/pull/3187) -- Add UseIfEmptyOrIfBlank rule - [#3186](https://github.com/detekt/detekt/pull/3186) -- Fix detektBaseline task filtering .java files - [#3185](https://github.com/detekt/detekt/pull/3185) -- Internal exception should fail the gradle task - [#3183](https://github.com/detekt/detekt/issues/3183) -- Add RedundantHigherOrderMapUsage rule - [#3182](https://github.com/detekt/detekt/pull/3182) -- Fix false negative in IgnoredReturnValue - [#3179](https://github.com/detekt/detekt/pull/3179) -- Fix false positive when `to` is used to create a pair within a function - [#3178](https://github.com/detekt/detekt/pull/3178) -- False Positive PreferToOverPairSyntax - [#3177](https://github.com/detekt/detekt/issues/3177) -- Suppress RedundantVisibilityModifierRule if explicit API mode enabled - [#3175](https://github.com/detekt/detekt/pull/3175) -- Hardcode default values - [#3171](https://github.com/detekt/detekt/pull/3171) -- False negative in IgnoredReturnValue - [#3170](https://github.com/detekt/detekt/issues/3170) -- Fix false positive in IgnoredReturnValue - [#3169](https://github.com/detekt/detekt/pull/3169) -- Duplicate deprecated KtLint methods - [#3168](https://github.com/detekt/detekt/pull/3168) -- Introduce NamedArguments rule - [#3167](https://github.com/detekt/detekt/pull/3167) -- Add JSON Schema documentation - [#3166](https://github.com/detekt/detekt/pull/3166) -- Fix MaxLineLengthSuppressed ignoring @Suppress annotation on class - [#3164](https://github.com/detekt/detekt/pull/3164) -- Use the properties syntax in Gradle docs - #3158 - [#3161](https://github.com/detekt/detekt/pull/3161) -- Fix rule LibraryCodeMustSpecifyReturnType - [#3155](https://github.com/detekt/detekt/pull/3155) -- Update README to mention config auto-complete - [#3143](https://github.com/detekt/detekt/issues/3143) -- @Suppress("MaxLineLength") not working for simple block comment inside class - [#3136](https://github.com/detekt/detekt/issues/3136) -- Support sarif as a report type - #3045 - [#3132](https://github.com/detekt/detekt/pull/3132) -- UnusedImports false positive for enums in annotation attributes (with type resolution) - [#3131](https://github.com/detekt/detekt/issues/3131) -- Unable to generate detektMain baseline for UnsafeCallOnNullableType violations in Android (mixed Kotlin + Java) modules - [#3130](https://github.com/detekt/detekt/issues/3130) -- Suppress RedundantVisibilityModifierRule if explicit API mode enabled - [#3125](https://github.com/detekt/detekt/issues/3125) -- SARIF export support - [#3045](https://github.com/detekt/detekt/issues/3045) -- IgnoredReturnValue false positives - [#3043](https://github.com/detekt/detekt/issues/3043) -- Offset calculation in KtLint deprecated/made private - [#3021](https://github.com/detekt/detekt/issues/3021) -- Map { it } must return an error - [#2975](https://github.com/detekt/detekt/issues/2975) -- Upload detekt-formatting plugin to Github releases next to precompiled cli binary - [#2927](https://github.com/detekt/detekt/issues/2927) -- Add a rule to flag places where `ifBlank` and `ifEmpty` can be used - [#2840](https://github.com/detekt/detekt/issues/2840) -- Remove hardcoded default values from rules - [#2597](https://github.com/detekt/detekt/issues/2597) -- Doc: type and symbol solving - [#2259](https://github.com/detekt/detekt/issues/2259) -- Suggestion: LongParameterList rule but on method call if named argument is not used - [#1007](https://github.com/detekt/detekt/issues/1007) - -##### Housekeeping & Refactorings - -- Standardize "active" constant - [#3292](https://github.com/detekt/detekt/pull/3292) -- Update Spek to v2.0.15 - [#3287](https://github.com/detekt/detekt/pull/3287) -- Reformat code indentation in ReturnFromFinallySpec.kt - [#3278](https://github.com/detekt/detekt/pull/3278) -- Inline ReturnFromFinally report message text - [#3277](https://github.com/detekt/detekt/pull/3277) -- Simplify ReturnFromFinally check for finally expressions - [#3276](https://github.com/detekt/detekt/pull/3276) -- CI with Java 15 - [#3262](https://github.com/detekt/detekt/pull/3262) -- Enabled publishing of sha256 and sha512 signatures - [#3249](https://github.com/detekt/detekt/pull/3249) -- Remove default config entries in detekt.yml - [#3239](https://github.com/detekt/detekt/pull/3239) -- Fix grammar in configuration guide - [#3238](https://github.com/detekt/detekt/pull/3238) -- Exclude detekt:LargeClass rule in test sources - [#3237](https://github.com/detekt/detekt/pull/3237) -- Release 1.15.0 rc1 - [#3236](https://github.com/detekt/detekt/pull/3236) -- Remove unused format function in RuleExtensions - [#3234](https://github.com/detekt/detekt/pull/3234) -- Update spek to v2.0.14 - [#3231](https://github.com/detekt/detekt/pull/3231) -- Remove already activated rules from detekt.yml - [#3230](https://github.com/detekt/detekt/pull/3230) -- Fix broken website redirects - [#3227](https://github.com/detekt/detekt/pull/3227) -- Remove unused resources from the website - [#3226](https://github.com/detekt/detekt/pull/3226) -- Simplify EqualsOnSignatureLine rule - [#3224](https://github.com/detekt/detekt/pull/3224) -- Remove unnecessary suppression in main - [#3217](https://github.com/detekt/detekt/pull/3217) -- Simplify MissingWhenCase by removing an unnecessary alternative path - [#3216](https://github.com/detekt/detekt/pull/3216) -- Refactor HasPlatformType rule - [#3210](https://github.com/detekt/detekt/pull/3210) -- Remove Suppress annotation from ArrayPrimitive - [#3209](https://github.com/detekt/detekt/pull/3209) -- Refactor UselessCallOnNotNull rule - [#3208](https://github.com/detekt/detekt/pull/3208) -- Refactor MissingWhenCase - [#3207](https://github.com/detekt/detekt/pull/3207) -- Refactor NullableToStringCall - [#3206](https://github.com/detekt/detekt/pull/3206) -- Refactor RedundantElseInWhen - [#3205](https://github.com/detekt/detekt/pull/3205) -- Refactor PreferToOverPairSyntax - [#3204](https://github.com/detekt/detekt/pull/3204) -- Remove Suppress annotation from MagicNumber - [#3203](https://github.com/detekt/detekt/pull/3203) -- Remove Suppress annotation from UnusedImports - [#3202](https://github.com/detekt/detekt/pull/3202) -- Refactor FunctionNaming rule - [#3201](https://github.com/detekt/detekt/pull/3201) -- Setup the website publishing pipeline - [#3199](https://github.com/detekt/detekt/pull/3199) -- Improve code coverage for DefaultCliInvoker testing happy and error path - [#3195](https://github.com/detekt/detekt/pull/3195) -- Make kotlinc adapted rule comments internal - [#3192](https://github.com/detekt/detekt/pull/3192) -- Improve PreferToOverPairSyntax - [#3181](https://github.com/detekt/detekt/pull/3181) -- Simplify PreferToOverPairSyntax check - [#3180](https://github.com/detekt/detekt/pull/3180) -- Improves in IgnoredReturnValue - [#3174](https://github.com/detekt/detekt/pull/3174) -- Move KtFileContent to FileParsingRule - [#3173](https://github.com/detekt/detekt/pull/3173) -- Don't use deprecated onStart - [#3172](https://github.com/detekt/detekt/pull/3172) - -See all issues at: [1.15.0](https://github.com/detekt/detekt/milestone/79) - -#### 1.14.2 - 2020-10-20 - -##### Changelog - -- Do not report vararg arguments which are just passed to a vararg parameter - [#3157](https://github.com/detekt/detekt/pull/3157) -- Simplify documentation - [#3156](https://github.com/detekt/detekt/pull/3156) -- Respect inspection aliases ClassName, PackageDirectoryMismatch, RedundantVisibilityModifier - [#3153](https://github.com/detekt/detekt/pull/3153) -- Change spek and assertj to compile only dependencies for detekt-test consumers - [#3152](https://github.com/detekt/detekt/pull/3152) -- False positive performance SpreadOperator in case of pass-through vararg - [#3145](https://github.com/detekt/detekt/issues/3145) -- ClassOrdering rule reports a list of errors - [#3142](https://github.com/detekt/detekt/pull/3142) -- ClassOrdering only reports first misorder, not all misorders - [#3141](https://github.com/detekt/detekt/issues/3141) -- UnusedPrivateMember: fix false positive with getValue/setValue operator functions - [#3139](https://github.com/detekt/detekt/pull/3139) -- ClassOrdering reports a message describing the misorder - [#3138](https://github.com/detekt/detekt/pull/3138) -- False positive UnusedPrivateMember for getValue, setValue operator functions - [#3128](https://github.com/detekt/detekt/issues/3128) -- Add aliases to class and package Naming rules - [#3124](https://github.com/detekt/detekt/issues/3124) -- Artifact detekt-test forces dependency constraining - [#3082](https://github.com/detekt/detekt/issues/3082) - -##### Housekeeping & Refactorings - -- Fix two eager Regex creations in rules which may confuse users if this rules are inactive but evaluated - [#3154](https://github.com/detekt/detekt/pull/3154) -- Update Gradle to 6.7 - [#3148](https://github.com/detekt/detekt/pull/3148) -- Bump github-pages from 208 to 209 in /docs - [#3135](https://github.com/detekt/detekt/pull/3135) - -See all issues at: [1.14.2](https://github.com/detekt/detekt/milestone/78) - -#### 1.14.1 - 2020-09-30 - -##### Changelog - -- Write recipe to compare user and default config - #3065 - [#3114](https://github.com/detekt/detekt/pull/3114) -- Improve description of AbsentOrWrongFileLicense rule - [#3109](https://github.com/detekt/detekt/pull/3109) -- Report Unit returned by method implementations in interfaces - [#3108](https://github.com/detekt/detekt/pull/3108) -- Change OptionalUnit to report Unit returned by method implementations in interfaces - [#3099](https://github.com/detekt/detekt/issues/3099) -- 1.13.0 changes to detektGenerateConfig - [#3065](https://github.com/detekt/detekt/issues/3065) -- detekt 1.12.0 and org.springframework.boot 2.2.6.RELEASE clash - [#3058](https://github.com/detekt/detekt/issues/3058) - -##### Housekeeping & Refactorings - -- Update mockk to 1.10.2 - [#3113](https://github.com/detekt/detekt/pull/3113) -- Refactoring: Use indices syntax in loop - [#3112](https://github.com/detekt/detekt/pull/3112) -- Specify type explicitly in DetektCreateBaselineTask - [#3111](https://github.com/detekt/detekt/pull/3111) -- Refactoring: Class member can have private visibility - [#3110](https://github.com/detekt/detekt/pull/3110) -- Fix kotlin-reflect problem for idea plugin - [#3107](https://github.com/detekt/detekt/pull/3107) - -See all issues at: [1.14.1](https://github.com/detekt/detekt/milestone/77) - -#### 1.14.0 - 2020-09-26 - -##### Notable Changes - -- New standard rules: `ReplaceSafeCallChainWithRun`, `ClassOrdering`, `SuspendFunWithFlowReturnType` -- New experimental KtLint rules: `AnnotationSpacing`, `ArgumentListWrapping` - -##### Changelog - -- Add additional classpaths to KtTestCompiler - [#3101](https://github.com/detekt/detekt/pull/3101) -- New rule: SuspendFunWithFlowReturnType - [#3098](https://github.com/detekt/detekt/pull/3098) -- Fix formatting issues have no absolute path - #3063 - [#3097](https://github.com/detekt/detekt/pull/3097) -- Fix false positive (+= overload) in UnusedPrivateMember - [#3094](https://github.com/detekt/detekt/pull/3094) -- Update RedundantVisibilityModifierRule to find redundant internal modifiers - [#3092](https://github.com/detekt/detekt/pull/3092) -- New rule: ReplaceSafeCallChainWithRun - [#3089](https://github.com/detekt/detekt/pull/3089) -- New rule: ClassOrdering - [#3088](https://github.com/detekt/detekt/pull/3088) -- Use File.pathSeparator to split entries in classpath - [#3084](https://github.com/detekt/detekt/pull/3084) -- Wrap new KtLint rules - [#3083](https://github.com/detekt/detekt/pull/3083) -- Wrap KtLint AnnotationSpacingRule - [#3081](https://github.com/detekt/detekt/issues/3081) -- Wrap KtLint ArgumentListWrappingRule - [#3080](https://github.com/detekt/detekt/issues/3080) -- UnusedImports rule: fix false positives when type resolution is enabled - [#3079](https://github.com/detekt/detekt/pull/3079) -- Move SNAPSHOT from artifactory to sonatype - [#3076](https://github.com/detekt/detekt/pull/3076) -- Update KtLint to 0.39.0 - [#3075](https://github.com/detekt/detekt/pull/3075) -- UnusedImports: Lots of false positives - [#3074](https://github.com/detekt/detekt/issues/3074) -- Update dependency badge to maven central - [#3072](https://github.com/detekt/detekt/pull/3072) -- Simplify reporting message for IgnoredReturnValue - [#3068](https://github.com/detekt/detekt/pull/3068) -- Add ability to pass rootclasspaths to KtTestCompiler - [#3066](https://github.com/detekt/detekt/issues/3066) -- MagicNumber rule: don't check Character, Boolean and null - [#3064](https://github.com/detekt/detekt/pull/3064) -- KtLint formatting checks do not include full path in report - [#3063](https://github.com/detekt/detekt/issues/3063) -- IgnoredReturnValue should only report name of method/function called - [#3052](https://github.com/detekt/detekt/issues/3052) - -##### Housekeeping & Refactorings - -- Update jacoco with Java 15 support - [#3105](https://github.com/detekt/detekt/pull/3105) -- Update project dependencies - [#3104](https://github.com/detekt/detekt/pull/3104) -- Enable parallel spek test discovery - [#3090](https://github.com/detekt/detekt/pull/3090) -- Update Gradle to 6.7-rc-2 - [#3071](https://github.com/detekt/detekt/pull/3071) -- Update spek framework to 2.0.13 - [#3070](https://github.com/detekt/detekt/pull/3070) -- Update kramdown dependency due to a vulnerability - [#3069](https://github.com/detekt/detekt/pull/3069) -- Add test asserting the report message - [#3061](https://github.com/detekt/detekt/pull/3061) - -See all issues at: [1.14.0](https://github.com/detekt/detekt/milestone/76) - -#### 1.13.1 - 2020-09-13 - -##### Notable Changes - -We now publish directly to maven central. -The 1.13.0 release got corrupted and should not be used. - -#### 1.13.0 - 2020-09-07 - -##### Migration - -- This release drops several deprecations in `detekt-api`. - -##### Changelog - -- Set modifier order based on Kotlin coding conventions - [#3056](https://github.com/detekt/detekt/pull/3056) -- FunctionNaming: allow anonymous functions - [#3055](https://github.com/detekt/detekt/pull/3055) -- FunctionNaming should ignore anonymous functions - [#3054](https://github.com/detekt/detekt/issues/3054) -- Fix ModifierOrder for false positive reported by ModifierOrder when using fun interfaces - [#3051](https://github.com/detekt/detekt/pull/3051) -- False positive reported by ModifierOrder when using fun interfaces - [#3050](https://github.com/detekt/detekt/issues/3050) -- Fix PreferToOverPairSyntax exception - [#3046](https://github.com/detekt/detekt/pull/3046) -- PreferToOverPairSyntax throws exceptions - [#3044](https://github.com/detekt/detekt/issues/3044) -- Remove deprecated entity and location members - [#3037](https://github.com/detekt/detekt/pull/3037) -- Respect configured config file when running the detektCreateConfig task - [#3036](https://github.com/detekt/detekt/pull/3036) -- Remove last years api deprecations - [#3035](https://github.com/detekt/detekt/pull/3035) -- UnusedImports rule: fix false negative when same name identifiers are imported and used - [#3033](https://github.com/detekt/detekt/pull/3033) -- ForbiddenMethodCall: report operator calls - [#3032](https://github.com/detekt/detekt/pull/3032) -- Improve documentation for Gradle repositories setup - [#3030](https://github.com/detekt/detekt/pull/3030) -- how to use the type resolution to make ForbiddenMethodCall to check bigdecimal.equals using bigdecimal == bigdecimal? - [#3029](https://github.com/detekt/detekt/issues/3029) -- Use lazy gradle APIs in docs - [#3028](https://github.com/detekt/detekt/pull/3028) -- Implement option to turn config property deprecation warnings as errors - [#3026](https://github.com/detekt/detekt/pull/3026) -- Fix RedundantSuspendModifier message - [#3025](https://github.com/detekt/detekt/pull/3025) -- Print filtered paths in debug mode for easier bug tracing - [#3022](https://github.com/detekt/detekt/pull/3022) -- Unused import not detected - [#3020](https://github.com/detekt/detekt/issues/3020) -- Include reports and formatting features to the system test - [#3018](https://github.com/detekt/detekt/pull/3018) -- detektGenerateConfig ignores detekt.config paramenter - [#2565](https://github.com/detekt/detekt/issues/2565) -- Treat config property deprecations as errors - [#2545](https://github.com/detekt/detekt/issues/2545) -- Print filtered paths in debug mode - [#869](https://github.com/detekt/detekt/issues/869) - -##### Housekeeping & Refactorings - -- Remove confusing annotation for UnusedImports rule - [#3039](https://github.com/detekt/detekt/pull/3039) -- Remove obsolete signature workaround for formatting plugin - [#3038](https://github.com/detekt/detekt/pull/3038) -- Upgrade to new dokka - [#2931](https://github.com/detekt/detekt/pull/2931) - -See all issues at: [1.13.0](https://github.com/detekt/detekt/milestone/75) - -#### 1.12.0 - 2020-08-25 - -##### Notable Changes - -- Kotlin 1.4 support -- New rules: `UseCheckNotNull`, `UseRequireNotNull`, `NonBooleanPropertyPrefixedWithIs` -- The Gradle plugin now requires at least Gradle 5.4. This aligns with Kotlin's Gradle plugin. -- The Gradle plugin now supports configuration avoidance -- The Gradle plugin now generates additional detekt tasks for Android projects -- KtLint 0.38.1 support (via detekt-formatting) - -##### Migration - -- `ArrayPrimitive` rule is more precise but requires type resolution now. -- The deprecated `customReports` property of the Gradle plugin got removed. -- Deprecated properties `xmlReportFile`, `htmlReportFile`, `txtReportFile` are now internal. - -Note the default `gradle detekt` task does not run over test sources. -To include test sources following setup can be used: - -```kt -detekt { - // ... - input = objects.fileCollection().from( - "src/main/java", - "src/test/java", - "src/main/kotlin", - "src/test/kotlin" - ) -} -``` - -This does not apply to `gradle detektTest`. -We encourage to also check test sources. -We will include test sources by default in detekt `1.15.0` or later. - -##### Changelog - -- Consolidate working for Type Resolution - [#3011](https://github.com/detekt/detekt/pull/3011) -- ArrayPrimitive rule: report variable/receiver types and factory methods - [#3009](https://github.com/detekt/detekt/pull/3009) -- Add requiresTypeResolution annotation to UseCheckNotNull/UseRequireNotNull - [#3008](https://github.com/detekt/detekt/pull/3008) -- Update kotlinx.html dependencies - [#3007](https://github.com/detekt/detekt/pull/3007) -- Do not overwrite bintray publication - [#3006](https://github.com/detekt/detekt/pull/3006) -- Update Ktlint to 0.38.0 - [#3004](https://github.com/detekt/detekt/pull/3004) -- Add UseRequireNotNull/UseCheckNotNull rules - [#3003](https://github.com/detekt/detekt/pull/3003) -- Workaround config - [#3001](https://github.com/detekt/detekt/pull/3001) -- Replace `require(x != null)` with `requireNotNull(x)` - [#2998](https://github.com/detekt/detekt/issues/2998) -- Minor Gradle plugin cleanup - [#2997](https://github.com/detekt/detekt/pull/2997) -- detekt-gradle-plugin has two publishing configuration - [#2996](https://github.com/detekt/detekt/issues/2996) -- Introduce @requiresTypeResolution to KDoc for rules - [#2993](https://github.com/detekt/detekt/pull/2993) -- Fix support for Gradle configuration cache - [#2992](https://github.com/detekt/detekt/pull/2992) -- Fix false positive for UnnecessaryLet with disabled type resolution - [#2991](https://github.com/detekt/detekt/pull/2991) -- Deprecation: False positive with Kotlin 1.4.0 - [#2990](https://github.com/detekt/detekt/issues/2990) -- False positive in UnnecessaryLet - [#2987](https://github.com/detekt/detekt/issues/2987) -- Gradle plugin fixes - [#2986](https://github.com/detekt/detekt/pull/2986) -- Remove deprecated customReports detekt task property - #2811 - [#2944](https://github.com/detekt/detekt/pull/2944) -- Rename IsPropertyNaming to NonBooleanPropertyPrefixedWithIs? - [#2819](https://github.com/detekt/detekt/pull/2819) -- Add automatic detekt tasks for Android Plugins - [#2787](https://github.com/detekt/detekt/pull/2787) - -##### Housekeeping & Refactorings - -- Update Gradle to 6.6.1 - [#3016](https://github.com/detekt/detekt/pull/3016) -- Run detekt with type resolution analysis on CI - [#3015](https://github.com/detekt/detekt/pull/3015) -- Run Gradle Android tests conditionally when sdk path is defined - [#3014](https://github.com/detekt/detekt/pull/3014) -- Fix documentation for NonBooleanPropertyPrefixedWithIs - [#3012](https://github.com/detekt/detekt/pull/3012) -- Run detekt on all test sources - [#3010](https://github.com/detekt/detekt/pull/3010) -- Do not publish test fixture; removing warning - [#3005](https://github.com/detekt/detekt/pull/3005) -- Implement custom rule to check spek test discovery performance issues - [#2954](https://github.com/detekt/detekt/pull/2954) - -See all issues at: [1.12.0](https://github.com/detekt/detekt/milestone/71) - -#### 1.12.0-RC1 - 2020-08-20 - -##### Notable Changes - -The Gradle plugin now requires at least Gradle 5.4. This aligns with Kotlin's Gradle plugin. - -##### Changelog - -- Support Kotlin 1.4 - [#2981](https://github.com/detekt/detekt/pull/2981) -- 1.10.0 to 1.11.0 | Could not find org.spekframework.spek2:spek-dsl-jvm - [#2976](https://github.com/detekt/detekt/issues/2976) -- Make a release built against Kotlin 1.4 - [#2974](https://github.com/detekt/detekt/issues/2974) -- Roll back to non snapshot spek version - [#2922](https://github.com/detekt/detekt/pull/2922) - -See all issues at: [1.12.0-RC1](https://github.com/detekt/detekt/milestone/73) - -#### 1.11.2 - 2020-08-19 - -##### Changelog - -- Fix formatting regression where issues printed the whole filename - [#2988](https://github.com/detekt/detekt/pull/2988) -- Baseline adds file path instead package - [#2985](https://github.com/detekt/detekt/issues/2985) - -See all issues at: [1.11.2](https://github.com/detekt/detekt/milestone/74) - -#### 1.11.1 - 2020-08-18 - -##### Changelog - -- Fix regression separating classpath entries - #2961 - [#2977](https://github.com/detekt/detekt/pull/2977) -- Show groovy and kotlin dsl in the same page - [#2971](https://github.com/detekt/detekt/pull/2971) -- Fix typo - [#2969](https://github.com/detekt/detekt/pull/2969) -- UnnecessaryLet: fix false positive when let is used for destructuring - [#2968](https://github.com/detekt/detekt/pull/2968) -- UnnecessaryLet false positive when let is used for destructuring - [#2966](https://github.com/detekt/detekt/issues/2966) -- Merge gradle groovy dsl and kotlin dsl documentation in the same page - [#2846](https://github.com/detekt/detekt/issues/2846) -- Run Detekt as Kotlin Compiler Plugin - [#2119](https://github.com/detekt/detekt/issues/2119) - -See all issues at: [1.11.1](https://github.com/detekt/detekt/milestone/72) - -#### 1.11.0 - 2020-08-13 - -##### Changelog - -- Fix false positive for UnnecessaryApply with disabled type resolution - [#2963](https://github.com/detekt/detekt/pull/2963) -- Add new rule: LibraryEntitiesCannotBePublic - [#2959](https://github.com/detekt/detekt/pull/2959) -- Suggest rule: Class cannot be public. - [#2943](https://github.com/detekt/detekt/issues/2943) -- False positive in UnnecessaryApply - [#2938](https://github.com/detekt/detekt/issues/2938) -- Add NullableToStringCall rule - [#2903](https://github.com/detekt/detekt/pull/2903) -- New rule: toString over a nullable value - [#2901](https://github.com/detekt/detekt/issues/2901) -- Introduce tooling-api - [#2860](https://github.com/detekt/detekt/issues/2860) - -See all issues at: [1.11.0](https://github.com/detekt/detekt/milestone/70) -See all issues at: [1.11.0-RC2](https://github.com/detekt/detekt/milestone/68) -See all issues at: [1.11.0-RC1](https://github.com/detekt/detekt/milestone/69) - - -#### 1.11.0-RC2 - 2020-08-09 - -##### Changelog - -- Actually print the invalid properties - [#2955](https://github.com/detekt/detekt/pull/2955) -- Update FindingsReport doc - [#2942](https://github.com/detekt/detekt/pull/2942) -- Document reports on homepage - [#2941](https://github.com/detekt/detekt/pull/2941) -- Set missing code languages in doc - [#2935](https://github.com/detekt/detekt/pull/2935) -- Fix sitemap.xml - [#2933](https://github.com/detekt/detekt/pull/2933) -- Flag listOfNotNull if all arguments are non-nullable - [#2932](https://github.com/detekt/detekt/pull/2932) -- Add LanguageVersionSettings and DataFlowValueFactory to BaseRule - [#2929](https://github.com/detekt/detekt/pull/2929) -- Generate release date to the changelog entries - [#2924](https://github.com/detekt/detekt/pull/2924) -- Add informative message to UselessCallOnNotNull report - [#2920](https://github.com/detekt/detekt/pull/2920) -- Flag listOfNotNull if all arguments are non-nullable - [#2916](https://github.com/detekt/detekt/issues/2916) - -##### Housekeeping & Refactorings - -- Reduce test discovery for metrics module - [#2953](https://github.com/detekt/detekt/pull/2953) -- Reduce test discovery for rules-style module - [#2952](https://github.com/detekt/detekt/pull/2952) -- Reduce test discovery for rules-naming module - [#2951](https://github.com/detekt/detekt/pull/2951) -- Reduce test discovery for rules-exceptions module - [#2950](https://github.com/detekt/detekt/pull/2950) -- Reduce test discovery for rules-complexity module - [#2949](https://github.com/detekt/detekt/pull/2949) -- Reduce test discovery for formatting module - [#2948](https://github.com/detekt/detekt/pull/2948) -- Reduce test discovery for core module - [#2947](https://github.com/detekt/detekt/pull/2947) -- Reduce test discovery for cli module - [#2946](https://github.com/detekt/detekt/pull/2946) -- Reduce test discovery for api module - [#2945](https://github.com/detekt/detekt/pull/2945) -- Update kramdown to remedy CVE vulnerability - [#2940](https://github.com/detekt/detekt/pull/2940) - -See all issues at: [1.11.0-RC2](https://github.com/detekt/detekt/milestone/68) - -#### 1.11.0-RC1 - 2020-08-02 - -##### Changelog - -- Add non-affirming test cases for UselessCallOnNotNull - [#2918](https://github.com/detekt/detekt/pull/2918) -- Add Github Action: Detekt All to readme - [#2915](https://github.com/detekt/detekt/pull/2915) -- Remove deprecated BuildFailureReport from doc - [#2914](https://github.com/detekt/detekt/pull/2914) -- Document Console Reports code - [#2913](https://github.com/detekt/detekt/pull/2913) -- Update docs in ProjectMetric class - [#2912](https://github.com/detekt/detekt/pull/2912) -- Document Output Reports code - [#2911](https://github.com/detekt/detekt/pull/2911) -- Document Output Reports on the home page - [#2910](https://github.com/detekt/detekt/pull/2910) -- Add doc to UseDataClass - [#2909](https://github.com/detekt/detekt/pull/2909) -- Generate output report config parts for config validation to know the properties - [#2907](https://github.com/detekt/detekt/pull/2907) -- Fix UseDataClass to accept classes that implement interfaces - [#2905](https://github.com/detekt/detekt/pull/2905) -- UseDataClass does not report for classes that implement interfaces - [#2904](https://github.com/detekt/detekt/issues/2904) -- Add bindingContext function to FileProcessListener - #2872 - [#2900](https://github.com/detekt/detekt/pull/2900) -- IgnoredReturnValue: Fix false positive on chained statements - [#2895](https://github.com/detekt/detekt/pull/2895) -- Setup local PGP signing of published artifacts - [#2893](https://github.com/detekt/detekt/pull/2893) -- error in output-reports config - [#2891](https://github.com/detekt/detekt/issues/2891) -- OptionalUnit: fix false positive with 'else if' - [#2888](https://github.com/detekt/detekt/pull/2888) -- OptionalUnit: don't report it if Unit is used as an expression - [#2886](https://github.com/detekt/detekt/pull/2886) -- Preserve original exception when loading an invalid config - [#2884](https://github.com/detekt/detekt/pull/2884) -- Sign artifacts and publish checksums - [#2883](https://github.com/detekt/detekt/issues/2883) -- Check string arguments with TR enabled - [#2879](https://github.com/detekt/detekt/pull/2879) -- Detekt Deployment is missing Gradle Module files - [#2878](https://github.com/detekt/detekt/issues/2878) -- Better Support for Guard Clauses in ThrowsCount Rule - [#2876](https://github.com/detekt/detekt/pull/2876) -- Make KtTestCompiler internal - [#2874](https://github.com/detekt/detekt/pull/2874) -- Don't mention the old performance impact - [#2873](https://github.com/detekt/detekt/pull/2873) -- Support for BindingContext in FileProcessListener - [#2872](https://github.com/detekt/detekt/issues/2872) -- Hide KtTestCompiler as internal - [#2871](https://github.com/detekt/detekt/issues/2871) -- Document Console and Output Reports - [#2869](https://github.com/detekt/detekt/issues/2869) -- Split rules module into a module per rule set - [#2865](https://github.com/detekt/detekt/pull/2865) -- Add new rule UseEmptyCounterpart - [#2864](https://github.com/detekt/detekt/pull/2864) -- Introduce tooling api module - [#2861](https://github.com/detekt/detekt/pull/2861) -- Extend docs on Processors - [#2854](https://github.com/detekt/detekt/pull/2854) -- Add a rule to flag places where `emptyList` (and similar) can be used - [#2850](https://github.com/detekt/detekt/issues/2850) -- Clarify / document processors and console reports in config - [#2833](https://github.com/detekt/detekt/issues/2833) -- Fix UnnecessaryLet false negatives - [#2828](https://github.com/detekt/detekt/pull/2828) -- UnnecessaryLet false negatives - [#2826](https://github.com/detekt/detekt/issues/2826) -- False positive in OptionalUnit rule - [#2452](https://github.com/detekt/detekt/issues/2452) - -##### Housekeeping & Refactorings - -- Test performance improvements - [#2921](https://github.com/detekt/detekt/pull/2921) -- Remove redundant guard clauses - [#2919](https://github.com/detekt/detekt/pull/2919) -- The tests are slow - [#2902](https://github.com/detekt/detekt/issues/2902) -- Drop dependency on detekt test utils for Gradle plugin - [#2899](https://github.com/detekt/detekt/pull/2899) -- Use KtFile.name instead of storing an absolute path key - [#2898](https://github.com/detekt/detekt/pull/2898) -- Fix testcase with early access jdk's - [#2897](https://github.com/detekt/detekt/pull/2897) -- Publish to Bintray using maven-publish - [#2885](https://github.com/detekt/detekt/pull/2885) -- Simplify internal parsing to KtFile's - [#2875](https://github.com/detekt/detekt/pull/2875) -- Mention bazel integration and a new blog article - [#2867](https://github.com/detekt/detekt/pull/2867) -- Mention bazel and github actions integration - [#2866](https://github.com/detekt/detekt/pull/2866) -- Cleanup code - [#2862](https://github.com/detekt/detekt/pull/2862) -- Make sure to always target JVM 8 bytecode - [#2853](https://github.com/detekt/detekt/pull/2853) -- Refactor - [#2849](https://github.com/detekt/detekt/pull/2849) -- Clear findings even if we are not going to visit the file - [#2848](https://github.com/detekt/detekt/pull/2848) -- Update Spek to 2.0.12 - [#2847](https://github.com/detekt/detekt/pull/2847) -- Speed up generateDocumentation - [#2832](https://github.com/detekt/detekt/pull/2832) -- Simplify pre-merge.yaml - [#2823](https://github.com/detekt/detekt/pull/2823) - -See all issues at: [1.11.0-RC1](https://github.com/detekt/detekt/milestone/69) - -#### 1.10.0 - -##### Notable Changes - -- New rules: `IgnoredReturnValue`, `ImplictUnitReturnType` -- The complexity report (console/html) now calculates the [cognitive complexity metric](https://www.sonarsource.com/docs/CognitiveComplexity.pdf) for your project. -- Issues at functions and classes are now reported at the identifiers. This is especially helpful in the IntelliJ plugin. -- Extension authors can now manipulate the findings with the new [ReportingExtension](https://github.com/detekt/detekt/blob/main/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/ReportingExtension.kt). -- `detekt-formatting` was updated to use KtLint 0.37.2 which includes a lot of improvements and changes. Please see their [changelog](https://github.com/pinterest/ktlint/releases/tag/0.37.0). - - New wrapper rules: `SpacingAroundDoubleColon`, `SpacingBetweenDeclarationsWithCommentsRule`, `SpacingBetweenDeclarationsWithAnnotationsRule` - - You can configure the [layoutPattern](https://github.com/pinterest/ktlint/blob/0.37.0/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/ImportOrderingRule.kt#L18) for `ImportOrdering` in detekt's configuration file. - - `Indentation` rule was replaced with a new [implementation](https://github.com/pinterest/ktlint/pull/758). -- The `default-detekt-config` moved to `detekt-core/src/main/resources/default-detekt-config.yml`. -Please update your links if you used it for references. - -##### Migration - -- We fixed a regression in baseline signatures. This breaks baseline ids for reported issues at functions for some rules. You may need to regenerate the baseline file or manually change the ids. We are very sorry for this inconvenience. -- KtLint replaced their default `Indentation` rule. Expect new formatting issues here! -- We removed `HierachicalConfig` interface. It was deprecated in 1.7.0 and could lead to OOM errors when reusing `Config` -embedding detekt. - If you used `Config.parent.key` in your code, `Config.parentPath` is an alternative for this interface. -- We are dropping the thin wrapper tasks over Intellij's `inspections.sh` and `format.sh`. -They were broken for some time and in general sparingly used. -There are alternative ways to run these scripts: https://www.jetbrains.com/help/idea/command-line-formatter.html or https://github.com/bentolor/idea-cli-inspector. -- XML-tags in the baseline file now have more meaningful names: - - `Whitelist` -> `ManuallySuppressedIssues` - - `Blacklist` -> `CurrentIssues` - - Note: the old names will work until a new major release - -##### Changelog - -- UnusedPrivateClass: fix false negative with import directives - [#2817](https://github.com/detekt/detekt/pull/2817) -- UnusedPrivateClass: false negative with import directives - [#2816](https://github.com/detekt/detekt/issues/2816) -- Publish detekt-bom module - [#2814](https://github.com/detekt/detekt/pull/2814) -- [Gradle] Configuration cache support - [#2813](https://github.com/detekt/detekt/pull/2813) -- UnusedPrivateClass: don't report imported classes - [#2812](https://github.com/detekt/detekt/pull/2812) -- False positive UnusedPrivateClass when importing private enum constants directly. - [#2809](https://github.com/detekt/detekt/issues/2809) -- Upgrade ktlint to version 0.37.2 - [#2807](https://github.com/detekt/detekt/pull/2807) -- LongMethod: disregard params in method definition - [#2806](https://github.com/detekt/detekt/pull/2806) -- LongMethod should not consider parameters while calculating the number of lines - [#2804](https://github.com/detekt/detekt/issues/2804) -- Local vars inside object literals can't be const - Closes #2794 - [#2799](https://github.com/detekt/detekt/pull/2799) -- MayBeConst should not report properties in local anonymous object declarations - [#2794](https://github.com/detekt/detekt/issues/2794) -- Fix false positive for UnusedPrivateClass on generics - [#2793](https://github.com/detekt/detekt/pull/2793) -- Report ComplexInterface issues at identifiers - [#2786](https://github.com/detekt/detekt/pull/2786) -- Construct signatures based on named declaration instead of just the identifier - [#2785](https://github.com/detekt/detekt/pull/2785) -- KtLint to 0.37.1 - [#2783](https://github.com/detekt/detekt/pull/2783) -- Implement new rule ImplictUnitReturnTypet - [#2781](https://github.com/detekt/detekt/pull/2781) -- Feature/restrict is properties - [#2779](https://github.com/detekt/detekt/pull/2779) -- Rename Blacklist and Whitelist to be self explanatory - [#2778](https://github.com/detekt/detekt/pull/2778) -- Remove deprecated HierarchicalConfig which could lead to OOM when reusing Config objects - [#2768](https://github.com/detekt/detekt/pull/2768) -- Support layout property for ImportOrdering rule - [#2763](https://github.com/detekt/detekt/pull/2763) -- Wrap three new experimental KtLint rules - [#2762](https://github.com/detekt/detekt/pull/2762) -- Upgrade to ktlint 0.37.0 - [#2760](https://github.com/detekt/detekt/pull/2760) -- Introduce reporting extensions - [#2755](https://github.com/detekt/detekt/pull/2755) -- Add default print methods to ForbiddenMethodCall - [#2753](https://github.com/detekt/detekt/pull/2753) -- Add the `ignoreAnnotated` array parameter to the FunctionNaming rule - [#2734](https://github.com/detekt/detekt/pull/2734) -- FunctionNaming: Needs "ignoreAnnotated" - [#2733](https://github.com/detekt/detekt/issues/2733) -- State that speeding the detekt task just applies to version < 1.7.0 - [#2730](https://github.com/detekt/detekt/pull/2730) -- Add cognitive complexity in complexity report - [#2727](https://github.com/detekt/detekt/pull/2727) -- add better documentation for the LongParameterList ignoreAnnotated - [#2714](https://github.com/detekt/detekt/pull/2714) -- IgnoreReturnValue: config options - [#2712](https://github.com/detekt/detekt/pull/2712) -- Use experimental indentation rule set instead of the unused from the standard rule set - [#2709](https://github.com/detekt/detekt/pull/2709) -- Remove idea integration - [#2706](https://github.com/detekt/detekt/pull/2706) -- Improve issue reporting/report at identifiers and package declarations - #2699 - [#2702](https://github.com/detekt/detekt/pull/2702) -- Feature request - limit number of lines for an issue to 1 - [#2699](https://github.com/detekt/detekt/issues/2699) -- New Rule: IgnoredReturnValue - [#2698](https://github.com/detekt/detekt/pull/2698) -- New rule: NoPrintStatement - [#2678](https://github.com/detekt/detekt/issues/2678) -- Add default values to SwallowedException rule - [#2661](https://github.com/detekt/detekt/pull/2661) -- [V1.6.0 -> V1.7.4] Error reading configuration file, java.util.zip.ZipException: invalid code lengths set. - [#2582](https://github.com/detekt/detekt/issues/2582) -- New rule: Warn on ignored return value - [#2239](https://github.com/detekt/detekt/issues/2239) -- File 'C\...\.idea' specified for property 'ideaExtension.path' is not a file. - [#2172](https://github.com/detekt/detekt/issues/2172) -- ktlint integration does not report most errors - [#2161](https://github.com/detekt/detekt/issues/2161) -- Non deterministic output. False positives on Indentation rule - [#1633](https://github.com/detekt/detekt/issues/1633) - -##### Housekeeping & Refactorings - -- use parallel build options - [#2808](https://github.com/detekt/detekt/pull/2808) -- Compile Test Snippets on Java 14 - [#2803](https://github.com/detekt/detekt/pull/2803) -- Cleanup MayBeConst tests - [#2802](https://github.com/detekt/detekt/pull/2802) -- Refactor compare_releases script to use clikt - [#2801](https://github.com/detekt/detekt/pull/2801) -- Simplify the Code Coverage workflow - [#2798](https://github.com/detekt/detekt/pull/2798) -- Run compile-test-snippets in a isolated job - [#2797](https://github.com/detekt/detekt/pull/2797) -- Run verifyGeneratorOutput in a isolated job - [#2796](https://github.com/detekt/detekt/pull/2796) -- Introduce BoM to manage our own dependencies - [#2792](https://github.com/detekt/detekt/pull/2792) -- Smarter Caching on Github Actions - [#2788](https://github.com/detekt/detekt/pull/2788) -- Fix config generation directory - [#2782](https://github.com/detekt/detekt/pull/2782) -- Disable Gradle daemon on CI - [#2780](https://github.com/detekt/detekt/pull/2780) -- Convert github-milestone-report.groovy to main.kts - [#2777](https://github.com/detekt/detekt/pull/2777) -- Prepare 1.10.0-RC1 release - [#2776](https://github.com/detekt/detekt/pull/2776) -- Fix memory leak with not closing processing settings - [#2775](https://github.com/detekt/detekt/pull/2775) -- Do not print passing tests on the console - [#2774](https://github.com/detekt/detekt/pull/2774) -- Run in parallel by default - [#2773](https://github.com/detekt/detekt/pull/2773) -- Remove core module dependency for detekt-test - [#2771](https://github.com/detekt/detekt/pull/2771) -- Unify extension debug printing - [#2770](https://github.com/detekt/detekt/pull/2770) -- Package editorconfig dependency into the jar for formatting module - [#2769](https://github.com/detekt/detekt/pull/2769) -- Update spek to 2.0.11 disabling timeouts - [#2767](https://github.com/detekt/detekt/pull/2767) -- Introduce additional changelog section filtering developing/refactoring noise for the users - [#2766](https://github.com/detekt/detekt/pull/2766) -- Move config validation from cli to core - [#2764](https://github.com/detekt/detekt/pull/2764) -- Improve the performance of tests which use type resolution - [#2756](https://github.com/detekt/detekt/pull/2756) -- Move reporting logic to core module - [#2754](https://github.com/detekt/detekt/pull/2754) -- Cleanup tests in ProtectedMemberInFinalClass - [#2752](https://github.com/detekt/detekt/pull/2752) -- Add referential equality test case in EqualsAlwaysReturnsTrueOrFalse - [#2751](https://github.com/detekt/detekt/pull/2751) -- Extract xml and html reports to own modules - [#2750](https://github.com/detekt/detekt/pull/2750) -- Separate console and output report loading - [#2749](https://github.com/detekt/detekt/pull/2749) -- Bump actions/cache to v2 - [#2746](https://github.com/detekt/detekt/pull/2746) -- Fix EqualsAlwaysReturnsTrueOrFalse doc - [#2744](https://github.com/detekt/detekt/pull/2744) -- Simplify core facade class - [#2743](https://github.com/detekt/detekt/pull/2743) -- Mark some well known cli functions as implicit unsupported api - [#2742](https://github.com/detekt/detekt/pull/2742) -- Move baseline feature to core module - [#2741](https://github.com/detekt/detekt/pull/2741) -- Make baseline entities internal - [#2740](https://github.com/detekt/detekt/pull/2740) -- Simplify baseline data structures - [#2739](https://github.com/detekt/detekt/pull/2739) -- Move baseline utils to the baseline package - [#2738](https://github.com/detekt/detekt/pull/2738) -- Bump github-pages from 204 to 206 in /docs - [#2737](https://github.com/detekt/detekt/pull/2737) -- Update gradle scan plugin - [#2736](https://github.com/detekt/detekt/pull/2736) -- Update test dependencies - [#2735](https://github.com/detekt/detekt/pull/2735) -- Move three core-related tests to core module - [#2731](https://github.com/detekt/detekt/pull/2731) -- Update to Gradle 6.4.1 - [#2729](https://github.com/detekt/detekt/pull/2729) -- Migrate to resource function of test-utils - [#2728](https://github.com/detekt/detekt/pull/2728) -- Remove own collectByType function as Kotlin's does not crash anymore - [#2726](https://github.com/detekt/detekt/pull/2726) -- Move processors to metrics module - [#2725](https://github.com/detekt/detekt/pull/2725) -- Create publish tasks lazily - [#2723](https://github.com/detekt/detekt/pull/2723) -- Faster documentation generation - [#2722](https://github.com/detekt/detekt/pull/2722) -- Modularize test module - [#2720](https://github.com/detekt/detekt/pull/2720) -- Introduce parser and psi module - [#2716](https://github.com/detekt/detekt/pull/2716) -- Clean up code by using builtin associateBy function - [#2715](https://github.com/detekt/detekt/pull/2715) -- [Security] Bump activesupport from 6.0.2.1 to 6.0.3.1 in /docs - [#2708](https://github.com/detekt/detekt/pull/2708) -- Correct formatting issues - [#2707](https://github.com/detekt/detekt/pull/2707) -- [Gradle plugin/rule authors]: Invalidate jars on modified date changes - [#2703](https://github.com/detekt/detekt/pull/2703) - -See all issues at: [1.10.0](https://github.com/detekt/detekt/milestone/67) - -#### 1.9.1 - -##### Changelog - -- Add negative tests to UnreachableCode rule - [#2697](https://github.com/detekt/detekt/pull/2697) -- Inline test cases of CollapsibleIfStatements - [#2696](https://github.com/detekt/detekt/pull/2696) -- Inline unreachable code - [#2695](https://github.com/detekt/detekt/pull/2695) -- Fix wrong test cases for CollapsibleIfs rule - [#2694](https://github.com/detekt/detekt/pull/2694) -- Print loaded rule set classes on debug - [#2691](https://github.com/detekt/detekt/pull/2691) -- Fix wrong test cases for MandatoryBracesIfStatements - [#2689](https://github.com/detekt/detekt/pull/2689) -- Simplify LongParameterList tests - [#2688](https://github.com/detekt/detekt/pull/2688) -- Fix serialVersionUID false positive in UnderscoresInNumericLiteral - [#2687](https://github.com/detekt/detekt/pull/2687) -- False positive UnderscoresInNumericLiterals in Serializable - [#2686](https://github.com/detekt/detekt/issues/2686) -- Report a better message for LongParameterList - [#2685](https://github.com/detekt/detekt/pull/2685) -- Report a better message for LongParameterList - [#2684](https://github.com/detekt/detekt/pull/2684) -- Test against the newest Java version - [#2682](https://github.com/detekt/detekt/pull/2682) - -See all issues at: [1.9.1](https://github.com/detekt/detekt/milestone/66) - -#### 1.9.0 - -##### Changelog - -- Extra documentation added to pitfalls section - [#2675](https://github.com/detekt/detekt/pull/2675) -- Use configuration avoidance for withType usages - [#2672](https://github.com/detekt/detekt/pull/2672) -- GuardClause also matches if-with-body that contains a return - [#2671](https://github.com/detekt/detekt/pull/2671) -- Simplify patterns - [#2668](https://github.com/detekt/detekt/pull/2668) -- Include Kotlin multiplatform test folders to default exclude config - [#2667](https://github.com/detekt/detekt/pull/2667) -- Remove duplicate MandatoryBracesLoops rule tests - [#2665](https://github.com/detekt/detekt/pull/2665) -- Remove print statement in MandatoryBracesLoops - [#2664](https://github.com/detekt/detekt/pull/2664) -- Remove $ as a valid char in class and method names - [#2662](https://github.com/detekt/detekt/pull/2662) -- Build detekt executable before publishing it - #2654 - [#2659](https://github.com/detekt/detekt/pull/2659) -- Add style rule for mandatory braces in for loop bodies - [#2658](https://github.com/detekt/detekt/pull/2658) -- Asset in release 1.8.0 is not up-to-date - [#2654](https://github.com/detekt/detekt/issues/2654) -- Rule: Mandatory braces for single-line for loop bodies - [#2652](https://github.com/detekt/detekt/issues/2652) -- Use task configuration avoidance for detekt plugin - [#2651](https://github.com/detekt/detekt/pull/2651) -- Add detekt GitHub action to readme - [#2650](https://github.com/detekt/detekt/pull/2650) -- Don't report unused private properties in expect class - [#2646](https://github.com/detekt/detekt/pull/2646) -- UnusedPrivateMember: don't report parameters in expect/actual functions - [#2643](https://github.com/detekt/detekt/pull/2643) -- UnusedPrivateMembers on expect class - [#2636](https://github.com/detekt/detekt/issues/2636) -- Include Kotlin multiplatform test folders to default exclude configuration - [#2608](https://github.com/detekt/detekt/issues/2608) - -See all issues at: [1.9.0](https://github.com/detekt/detekt/milestone/65) - -#### 1.8.0 - -##### Notable Changes - -- Most rule properties now support yaml lists next to string's with comma-separated-entries. -- Standalone `detekt` executable on GitHub release pages -- New rules: `UnnecessaryNotNullOperator` and `UnnecessarySafeCall` - -##### Migration - -- Formatting rules get reported now on the correct lines. The baseline file may need to be adjusted/regenerated. -- Issues concerning classes and objects are now reported at the identifier. The baseline file may need to be adjusted/regenerated. - -##### Changelog - -- Use yaml lists in our own configuration and tests - [#2623](https://github.com/detekt/detekt/pull/2623) -- Run code coverage as an own action - [#2622](https://github.com/detekt/detekt/pull/2622) -- Modularize build script by introducing buildSrc module - [#2621](https://github.com/detekt/detekt/pull/2621) -- *>excludes allow yaml list - [#2620](https://github.com/detekt/detekt/pull/2620) -- Kotlin to 1.3.72 - [#2619](https://github.com/detekt/detekt/pull/2619) -- Set failfast to false for pre-merge - [#2618](https://github.com/detekt/detekt/pull/2618) -- Update documentation - [#2617](https://github.com/detekt/detekt/pull/2617) -- ThrowingExceptionsWithoutMessageOrCause>exceptions allow yaml list - [#2616](https://github.com/detekt/detekt/pull/2616) -- SwallowedException>ignoredExceptionTypes allow yaml list - [#2615](https://github.com/detekt/detekt/pull/2615) -- ForbiddenPublicDataClass>ignorePackages allow yaml list - [#2614](https://github.com/detekt/detekt/pull/2614) -- LabeledExpression>ignoredLabels allow yaml list - [#2613](https://github.com/detekt/detekt/pull/2613) -- ForbiddenMethodCall>methods allow yaml list - [#2612](https://github.com/detekt/detekt/pull/2612) -- Generate the cli as a stand alone executable - [#2607](https://github.com/detekt/detekt/pull/2607) -- Report class and object violations at the identifier - [#2606](https://github.com/detekt/detekt/pull/2606) -- Fix formatting line reporting - [#2604](https://github.com/detekt/detekt/pull/2604) -- Correct documentation/recommendation of EmptyCatchBlock rule - [#2603](https://github.com/detekt/detekt/pull/2603) -- Incorrect (or unclear) EmptyCatchBlock rule - [#2602](https://github.com/detekt/detekt/issues/2602) -- Use more lintAndCompile - [#2601](https://github.com/detekt/detekt/pull/2601) -- MagicNumber>ignoredNumbers allow yaml list - [#2600](https://github.com/detekt/detekt/pull/2600) -- Remove unnecesary symbolic link - [#2598](https://github.com/detekt/detekt/pull/2598) -- WildcardImport>excludeImports allow yaml list - [#2596](https://github.com/detekt/detekt/pull/2596) -- ForbiddenClassName>forbiddenName allow yaml list - [#2595](https://github.com/detekt/detekt/pull/2595) -- Fix false positives in UndocumentedPublicProperty - [#2591](https://github.com/detekt/detekt/pull/2591) -- Fix false positive in UndocumentedPublicClass - [#2588](https://github.com/detekt/detekt/pull/2588) -- *>*Annotated* allow yaml lists - [#2587](https://github.com/detekt/detekt/pull/2587) -- ForbiddenComment>values allow yaml list - [#2585](https://github.com/detekt/detekt/pull/2585) -- ExceptionRaisedInUnexpectedLocation>methodNames allow yaml list - [#2584](https://github.com/detekt/detekt/pull/2584) -- ComplexMethod>nestingFunctions allow yaml list - [#2583](https://github.com/detekt/detekt/pull/2583) -- UndocumentedPublicClass false positive for inner types - [#2580](https://github.com/detekt/detekt/issues/2580) -- New Rule: UnnecessaryNotNullOperator - [#2578](https://github.com/detekt/detekt/pull/2578) -- New Rule: UnnecessarySafeCall - [#2574](https://github.com/detekt/detekt/pull/2574) -- New Rule: UnnecessarySafeCall - [#2572](https://github.com/detekt/detekt/issues/2572) -- Add ignoreAnnotated option to LongParameterList - [#2570](https://github.com/detekt/detekt/pull/2570) -- Rule configuration request: Ignore based on annotations - [#2563](https://github.com/detekt/detekt/issues/2563) -- codecov test coverage report doesn't work correctly - [#2558](https://github.com/detekt/detekt/issues/2558) -- Support yaml lists in the configuration values - [#2498](https://github.com/detekt/detekt/issues/2498) -- Baseline ignoring MaxLineLength: on 1.0.1 - [#1906](https://github.com/detekt/detekt/issues/1906) -- Formatting rules are reported at wrong line (e.g. MaximumLineLength) - [#1843](https://github.com/detekt/detekt/issues/1843) - -See all issues at: [1.8.0](https://github.com/detekt/detekt/milestone/63) - -#### 1.7.4 - -##### Notable Changes - -The last Gradle plugin version was referencing 1.7.2 instead of 1.7.3. -This was fixed and specifying the `toolVersion` is not necessary anymore. - -```kotlin -detekt { - toolversion = "1.7.3" -} -``` - -##### Changelog - -- Revert warning: jcenter is missing (#2550) - [#2576](https://github.com/detekt/detekt/pull/2576) -- Add additional task input for plugin version task - [#2575](https://github.com/detekt/detekt/pull/2575) -- jcenter() requirement - [#2571](https://github.com/detekt/detekt/issues/2571) - -See all issues at: [1.7.4](https://github.com/detekt/detekt/milestone/64) - -#### 1.7.3 - -##### Changelog - -- OptionalWhenBraces: fix false positive with lambda which has no arrow - [#2568](https://github.com/detekt/detekt/pull/2568) -- OptionalWhenBraces: false positive with lambda which has no arrow - [#2567](https://github.com/detekt/detekt/issues/2567) -- valueOrDefaultCommaSeparated throws a ClassCastException - [#2566](https://github.com/detekt/detekt/pull/2566) -- 1.6.0 -> 1.7.2: java.lang.String cannot be cast to java.util.List - [#2561](https://github.com/detekt/detekt/issues/2561) -- Display actual and threshold values for several metric rules - [#2559](https://github.com/detekt/detekt/pull/2559) -- Return the actual values for complexity rules - [#2557](https://github.com/detekt/detekt/issues/2557) -- UseCheckOrError/UseRequire: fix false positive with a non-String argument - [#2556](https://github.com/detekt/detekt/pull/2556) -- InstanceOfCheckForException: do not report when catch blocks do not check for the subtype of an exception - [#2555](https://github.com/detekt/detekt/pull/2555) -- Include statistics for our custom detekt tasks - [#2554](https://github.com/detekt/detekt/pull/2554) -- Remove unnecesary parentheses - [#2553](https://github.com/detekt/detekt/pull/2553) -- Fix console output indentation - [#2552](https://github.com/detekt/detekt/pull/2552) -- Console output is not indented correctly - [#2551](https://github.com/detekt/detekt/issues/2551) -- Check jcenter repository present in Gradle plugin - [#2550](https://github.com/detekt/detekt/pull/2550) -- Adding Detekt to a project from scratch, detektGenerateConfig is broken - [#2549](https://github.com/detekt/detekt/issues/2549) -- Validate Wrapper only on push to master - [#2548](https://github.com/detekt/detekt/pull/2548) -- Cleanup Gradle Folders - [#2547](https://github.com/detekt/detekt/pull/2547) -- Require CI to pass to run codecov - [#2546](https://github.com/detekt/detekt/pull/2546) -- Export bintray key to publish snapshots - [#2544](https://github.com/detekt/detekt/pull/2544) -- Activate UseErrorOrCheck rule - [#2542](https://github.com/detekt/detekt/pull/2542) -- Refactor build file to sections - [#2541](https://github.com/detekt/detekt/pull/2541) -- False positive: UseCheckOrError - [#2514](https://github.com/detekt/detekt/issues/2514) -- InstanceOfCheckForException should be ignored for catch blocks that is more than an if expression - [#1927](https://github.com/detekt/detekt/issues/1927) - -See all issues at: [1.7.3](https://github.com/detekt/detekt/milestone/62) - -#### 1.7.2 - -##### Changelog - -- Remove ignore:AppVeyor from codecov config - [#2540](https://github.com/detekt/detekt/pull/2540) -- Use kotlin-stdlib-jdk8 to reduce dependency conflicts - #2527 - [#2538](https://github.com/detekt/detekt/pull/2538) -- Update Gradle plugin-publish to 0.11.0 - [#2537](https://github.com/detekt/detekt/pull/2537) -- Delete created temp dir automatically on JVM exit - [#2536](https://github.com/detekt/detekt/pull/2536) -- Delete created temp file automatically on JVM exit - [#2535](https://github.com/detekt/detekt/pull/2535) -- Refactor MemberNameEqualsClassNameSpec tests - [#2534](https://github.com/detekt/detekt/pull/2534) -- Fix UnnecessaryAbstractClass false-positive - [#2533](https://github.com/detekt/detekt/pull/2533) -- Update GroovyDSL doc to mention input - [#2532](https://github.com/detekt/detekt/pull/2532) -- Update KotlinDSL doc to mention input - [#2531](https://github.com/detekt/detekt/pull/2531) -- Fix report for documented data classes property - [#2530](https://github.com/detekt/detekt/pull/2530) -- UndocumentedPublicProperty reported for documented data classes property - [#2529](https://github.com/detekt/detekt/issues/2529) -- Detekt using gradle documentation out of data - [#2528](https://github.com/detekt/detekt/issues/2528) -- 1.7.1 does not depend on Kotlin 1.3.71 - [#2527](https://github.com/detekt/detekt/issues/2527) -- UnnecessaryAbstractClass false positive for abstractproperties - [#2526](https://github.com/detekt/detekt/issues/2526) -- Do not fail the build on config property warnings/deprecations - #2523 - [#2525](https://github.com/detekt/detekt/pull/2525) -- regression 1.7.1, threshhold does not exist - [#2523](https://github.com/detekt/detekt/issues/2523) -- Setup GitHub Actions - [#2512](https://github.com/detekt/detekt/pull/2512) - -See all issues at: [1.7.2](https://github.com/detekt/detekt/milestone/61) - -#### 1.7.1 - -##### Changelog - -- UnnecessaryAbstractClass: fix false positive when abstract class has abstract inherited members - [#2513](https://github.com/detekt/detekt/pull/2513) -- UnusedPrivateMember: report unused overloaded operators - [#2510](https://github.com/detekt/detekt/pull/2510) -- Fix build compile error resulted from merging two conflicting PRs - [#2508](https://github.com/detekt/detekt/pull/2508) -- Update Kotlin to 1.3.71 - [#2507](https://github.com/detekt/detekt/pull/2507) -- Remove duplicated test task setup for gradle plugin - [#2506](https://github.com/detekt/detekt/pull/2506) -- Add LicenceHeaderExtension test to verify resource path loading is supported - [#2505](https://github.com/detekt/detekt/pull/2505) -- Ensure filesystems are created so paths can be gotten - [#2504](https://github.com/detekt/detekt/pull/2504) -- FileSystemNotFoundException in detekt 1.7.0 when using --config-resource - [#2503](https://github.com/detekt/detekt/issues/2503) -- MemberNameEqualsClassName: fix false negative when function has no explicit return type - [#2502](https://github.com/detekt/detekt/pull/2502) -- Use the system-dependent line separator in NotificationReport - [#2497](https://github.com/detekt/detekt/pull/2497) -- Remove default print stream - [#2496](https://github.com/detekt/detekt/pull/2496) -- Don't use System.out in the ProgressListeners - [#2495](https://github.com/detekt/detekt/pull/2495) -- Make the gradle plugin a sub project again - [#2493](https://github.com/detekt/detekt/pull/2493) -- Move test factory outside the main code - [#2491](https://github.com/detekt/detekt/pull/2491) -- Single runner - [#2490](https://github.com/detekt/detekt/pull/2490) -- ProcessingSettings - [#2489](https://github.com/detekt/detekt/pull/2489) -- Don't use println :detekt-generator - [#2488](https://github.com/detekt/detekt/pull/2488) -- Simplify tests with StringPrintStream - [#2487](https://github.com/detekt/detekt/pull/2487) -- Improve tests - [#2486](https://github.com/detekt/detekt/pull/2486) -- Use PrinterStream in AstPrinter - [#2485](https://github.com/detekt/detekt/pull/2485) -- Errors running detekt in the detekt project - [#2484](https://github.com/detekt/detekt/issues/2484) -- Unify yml strings - [#2482](https://github.com/detekt/detekt/pull/2482) -- Use yml arrays to list the ForbiddenImports - [#2474](https://github.com/detekt/detekt/pull/2474) -- Add date, detekt-version + link to HtmlReport - [#2470](https://github.com/detekt/detekt/pull/2470) -- Refactor FindingsReport + FileBasedFindingsReport - [#2454](https://github.com/detekt/detekt/pull/2454) -- The Detekt HTML Report should include date, version number, website link (Feature Request) - [#2416](https://github.com/detekt/detekt/issues/2416) -- Added validation of constructors to LongParameterList - [#2410](https://github.com/detekt/detekt/pull/2410) -- UnusedPrivateMember doesn't report the correct warning count - [#1981](https://github.com/detekt/detekt/issues/1981) -- UnusedPrivateMember should consider overloaded operators - [#1444](https://github.com/detekt/detekt/issues/1444) -- False positive on rule UnnecessaryAbstractClass - [#727](https://github.com/detekt/detekt/issues/727) -- MemberNameEqualsClassName ignores functions which return a single expression - [#655](https://github.com/detekt/detekt/issues/655) - -See all issues at: [1.7.1](https://github.com/detekt/detekt/milestone/60) - -#### 1.7.0 - -##### Notable Changes - -- The Gradle plugin should be on par with the CLI performance-wise -- Good to know: detekt CLI always supported argument files (`java -jar detekt-cli.jar @argsfile`) -- New CLI `--version` flag -- New Rule `AbsentOrWrongFileLicense` and other rule improvements - -##### Changelog - -- Update Travis to use the newest xcode11.3 image - [#2480](https://github.com/detekt/detekt/pull/2480) -- Synchronize use of root extension point - [#2479](https://github.com/detekt/detekt/pull/2479) -- Extend ComplexInterface to support exclusion of private member/functions - [#2478](https://github.com/detekt/detekt/pull/2478) -- Minor refactors around --create-baseline - [#2477](https://github.com/detekt/detekt/pull/2477) -- Check primary ctor in UndocumentedPublicProperty - [#2475](https://github.com/detekt/detekt/pull/2475) -- Unify yaml strings - [#2472](https://github.com/detekt/detekt/pull/2472) -- Running detektBaseline generates too general exceptions, disabling rules - [#2471](https://github.com/detekt/detekt/issues/2471) -- UndocumentedPublicProperty doesn't check primary constructor - [#2468](https://github.com/detekt/detekt/issues/2468) -- Remove default implementations of toString() - [#2467](https://github.com/detekt/detekt/pull/2467) -- Remove tags from core documentation sites - [#2466](https://github.com/detekt/detekt/pull/2466) -- Validate boolean config values - Closes #2045 - [#2465](https://github.com/detekt/detekt/pull/2465) -- Add test for BaselineHandler - [#2462](https://github.com/detekt/detekt/pull/2462) -- Refactor BaselineFormatSpec.kt - [#2461](https://github.com/detekt/detekt/pull/2461) -- Add tests for BaselineFacade - [#2460](https://github.com/detekt/detekt/pull/2460) -- Fix toString() output for Whitelist class - [#2459](https://github.com/detekt/detekt/pull/2459) -- Remove unused functions in XmlExtensions.kt - [#2458](https://github.com/detekt/detekt/pull/2458) -- Add test cases for invalid yaml config - [#2457](https://github.com/detekt/detekt/pull/2457) -- Add edge test cases for ComplexityReportGenerator - [#2456](https://github.com/detekt/detekt/pull/2456) -- Simplify anonymous Detektion object creation - [#2455](https://github.com/detekt/detekt/pull/2455) -- Update trim logic in Debt:toString() - [#2453](https://github.com/detekt/detekt/pull/2453) -- Refactor FindingsReport + FileBasedFindingsReport - [#2451](https://github.com/detekt/detekt/pull/2451) -- Rename tests with _Test prefix to _Spec - [#2450](https://github.com/detekt/detekt/pull/2450) -- Refactor HtmlOutputReport - [#2449](https://github.com/detekt/detekt/pull/2449) -- Simplify UnnecessaryApplySpec test cases - [#2448](https://github.com/detekt/detekt/pull/2448) -- Link code samples package for extension guide - [#2447](https://github.com/detekt/detekt/pull/2447) -- ComplexInterface - should it also count private methods? - [#2446](https://github.com/detekt/detekt/issues/2446) -- Update AppVeyor branch conf to comply with Travis - [#2445](https://github.com/detekt/detekt/pull/2445) -- Add PsiViewer plugin to Contributing guide - [#2444](https://github.com/detekt/detekt/pull/2444) -- UnnecessaryApply: fix false positive when it's used as an expression - [#2442](https://github.com/detekt/detekt/pull/2442) -- Add detekt-hint to integrations - [#2441](https://github.com/detekt/detekt/pull/2441) -- SwallowedException: fix false negative when using variables - [#2436](https://github.com/detekt/detekt/pull/2436) -- UnnecessaryApply false positive cases - [#2435](https://github.com/detekt/detekt/issues/2435) -- Prepare 1.7.0-beta2 release - [#2434](https://github.com/detekt/detekt/pull/2434) -- Parallel invocation of DetektFacade fails spuriously - [#2433](https://github.com/detekt/detekt/issues/2433) -- Deprecate BaseRule and state that it will be make sealed - #2365 - [#2432](https://github.com/detekt/detekt/pull/2432) -- Add License rule - [#2429](https://github.com/detekt/detekt/pull/2429) -- Skip all guard clauses at function start for ReturnCount - Closes #2342 - [#2428](https://github.com/detekt/detekt/pull/2428) -- Fail if `--baseline` file not found - [#2427](https://github.com/detekt/detekt/pull/2427) -- Add tests for YamlConfig - [#2426](https://github.com/detekt/detekt/pull/2426) -- Choose a minimum codecov patch coverage ratio - [#2425](https://github.com/detekt/detekt/pull/2425) -- Include ruleset-suppression feature doc - [#2424](https://github.com/detekt/detekt/pull/2424) -- Add Groovy DSL example for jvmTarget to homepage - [#2423](https://github.com/detekt/detekt/pull/2423) -- Add groovy dsl example for jvmTarget - Closes #2408 - [#2422](https://github.com/detekt/detekt/pull/2422) -- Deprecate hierarchical config - [#2421](https://github.com/detekt/detekt/pull/2421) -- Deprecate implementations of Config - [#2420](https://github.com/detekt/detekt/pull/2420) -- Remove YAML Extension Requirement - [#2419](https://github.com/detekt/detekt/pull/2419) -- Update Spek version to 2.0.10 - [#2418](https://github.com/detekt/detekt/pull/2418) -- file does not end with .yml! - [#2417](https://github.com/detekt/detekt/issues/2417) -- Disable autoCorrect property for all rules if global flag is set to false - [#2413](https://github.com/detekt/detekt/pull/2413) -- Release 1.7.0 beta - [#2409](https://github.com/detekt/detekt/pull/2409) -- Stop using kotlin-reflect - [#2405](https://github.com/detekt/detekt/pull/2405) -- Stop compiling with experimental flag - [#2404](https://github.com/detekt/detekt/pull/2404) -- Only post a code coverage patch status to PRs - [#2402](https://github.com/detekt/detekt/pull/2402) -- ExplicitCollectionElementAccessMethod: Don't report on nullable collection - [#2401](https://github.com/detekt/detekt/pull/2401) -- Discourage new Case files - [#2399](https://github.com/detekt/detekt/pull/2399) -- Use argsfiles for CI - [#2397](https://github.com/detekt/detekt/pull/2397) -- Update to Kotlin v1.3.70 - [#2396](https://github.com/detekt/detekt/pull/2396) -- Fix typo in VersionPrinter test - [#2395](https://github.com/detekt/detekt/pull/2395) -- Add documentation for cli --version flag - [#2392](https://github.com/detekt/detekt/pull/2392) -- ExplicitCollectionElementAccessMethod: Do not report map?.get("foo") - [#2391](https://github.com/detekt/detekt/issues/2391) -- Update Gradle to 6.2.1 - [#2390](https://github.com/detekt/detekt/pull/2390) -- Do not report conditional elvis continue statements - Closes#2388 - [#2389](https://github.com/detekt/detekt/pull/2389) -- False positive: UnconditionalJumpStatementInLoop with elvis operator ?: - [#2388](https://github.com/detekt/detekt/issues/2388) -- Refactor getting the detekt version for readability - [#2387](https://github.com/detekt/detekt/pull/2387) -- Create less objects and sets when creating findings id map - [#2385](https://github.com/detekt/detekt/pull/2385) -- Add --version to cli - [#2383](https://github.com/detekt/detekt/pull/2383) -- Add `--version` CLI option - [#2382](https://github.com/detekt/detekt/issues/2382) -- Add test cases for cli/runners package - [#2381](https://github.com/detekt/detekt/pull/2381) -- Sort and run correctable rules first - #2341 - [#2378](https://github.com/detekt/detekt/pull/2378) -- Should fail if `--baseline` file does not found? - [#2374](https://github.com/detekt/detekt/issues/2374) -- Deprecate rule set methods which expose implementation details of detekt-core - [#2366](https://github.com/detekt/detekt/pull/2366) -- Deprecate api's exposing detekt-core implementation details - [#2365](https://github.com/detekt/detekt/issues/2365) -- ReturnCount excludeGuardClauses not working - [#2342](https://github.com/detekt/detekt/issues/2342) -- Mixing autocorrectable and non correctable rules results in obsolete issue locations for reports - [#2341](https://github.com/detekt/detekt/issues/2341) -- Allow Detekt CLI to take an args file. - [#2318](https://github.com/detekt/detekt/issues/2318) -- Homepage doesn't show Jekyll tags correctly - [#2309](https://github.com/detekt/detekt/issues/2309) -- Call detekt reflectively - [#2282](https://github.com/detekt/detekt/pull/2282) -- Copyright header rule for Kotlin files - #1515 - [#2077](https://github.com/detekt/detekt/pull/2077) -- SwallowedException false negative - [#2049](https://github.com/detekt/detekt/issues/2049) -- Invalid boolean config values are evaluated silently to false - [#2045](https://github.com/detekt/detekt/issues/2045) -- Detekt gradle is much slower than the jar - [#2035](https://github.com/detekt/detekt/issues/2035) -- Cases files are super rigorous to work with - [#1089](https://github.com/detekt/detekt/issues/1089) - -See all issues at: [1.7.0](https://github.com/detekt/detekt/milestone/59) - -#### 1.6.0 - -##### Migration - -Rule set authors do not need to exclude their rule set from config validation anymore. -This will be done by default now. - -If you need to include further config property checks, give the new `ConfigValidator` api a try. - -##### Changelog - -- Check-in ConfigValidator documentation - [#2368](https://github.com/detekt/detekt/pull/2368) -- Remove obsolete PathFilter class - [#2367](https://github.com/detekt/detekt/pull/2367) -- Reference coroutines doc for homepage - [#2363](https://github.com/detekt/detekt/pull/2363) -- [Documentation Request] Coroutine Ruleset - [#2362](https://github.com/detekt/detekt/issues/2362) -- Extend AnnotationExcluder to catch fully qualified annotations - [#2361](https://github.com/detekt/detekt/pull/2361) -- UnnecessaryAbstractClass excludeAnnotatedClasses not working - [#2360](https://github.com/detekt/detekt/issues/2360) -- Replace LinkedList with ArrayDeque - [#2358](https://github.com/detekt/detekt/pull/2358) -- Fix detection of CRLF line endings - [#2357](https://github.com/detekt/detekt/pull/2357) -- Introduce new ConfigValidator extensions - #2285 - [#2356](https://github.com/detekt/detekt/pull/2356) -- Include options to better meet requirements for utility files - [#2355](https://github.com/detekt/detekt/pull/2355) -- Don't normalize file content twice - [#2354](https://github.com/detekt/detekt/pull/2354) -- Remove unused code in rules/Case.kt - [#2351](https://github.com/detekt/detekt/pull/2351) -- Add blog post about speeding up a detekt task - [#2349](https://github.com/detekt/detekt/pull/2349) -- Add tests for setting KtLint's config - [#2348](https://github.com/detekt/detekt/pull/2348) -- add details into internal validation - [#2347](https://github.com/detekt/detekt/pull/2347) -- Minor change in the HTML report: Remove extra space when you copy the file path - [#2344](https://github.com/detekt/detekt/pull/2344) -- detekt does not always inject the required EDITOR_CONFIG_USER_DATA_KEY for ktlint - [#2339](https://github.com/detekt/detekt/issues/2339) -- Remove duplicate tests for TooManyFunctions rule - [#2338](https://github.com/detekt/detekt/pull/2338) -- Add EmptyTryBlock rule - [#2337](https://github.com/detekt/detekt/pull/2337) -- Use requireNotNull for arguments checking - [#2336](https://github.com/detekt/detekt/pull/2336) -- Refactor and add tests to Ast- and ElementPrinter - [#2335](https://github.com/detekt/detekt/pull/2335) -- Add test case for disabled reports - [#2334](https://github.com/detekt/detekt/pull/2334) -- Refactor ReportPath:load() - [#2333](https://github.com/detekt/detekt/pull/2333) -- Add test case for FileProcessorLocator - [#2332](https://github.com/detekt/detekt/pull/2332) -- Add test cases for Kt(Tree)Compiler - [#2331](https://github.com/detekt/detekt/pull/2331) -- Add equality test cases for PathFiler - [#2330](https://github.com/detekt/detekt/pull/2330) -- Add local function test case for MethodOverloading rule - [#2328](https://github.com/detekt/detekt/pull/2328) -- Add anonymous object expression test case for MethodOverloading rule - [#2327](https://github.com/detekt/detekt/pull/2327) -- Validate Gradle Wrapper - [#2326](https://github.com/detekt/detekt/pull/2326) -- Use more consistent metrics in HtmlReport - [#2325](https://github.com/detekt/detekt/pull/2325) -- Fix ClassCastException in ExplicitCollectionElementAccessMethod - [#2323](https://github.com/detekt/detekt/pull/2323) -- ExplicitCollectionElementAccessMethod crashes - [#2322](https://github.com/detekt/detekt/issues/2322) -- use same behaviour for valueOrNull as for valueOrDefault - [#2319](https://github.com/detekt/detekt/pull/2319) -- FailFastConfig.valueOrNull should return specified value for active and maxIssues - [#2316](https://github.com/detekt/detekt/issues/2316) -- Bugfix: MagicNumber with ignoreNamedArgument and a negative value - [#2315](https://github.com/detekt/detekt/pull/2315) -- More consistent reports - [#2291](https://github.com/detekt/detekt/issues/2291) -- Change MatchingDeclarationName to handle utility files - [#1500](https://github.com/detekt/detekt/issues/1500) -- False-positive MagicNumber issue reported when using negative numbers - [#530](https://github.com/detekt/detekt/issues/530) - -See all issues at: [1.6.0](https://github.com/detekt/detekt/milestone/57) - -#### 1.5.1 - -- Update intro page to deprecate input property - [#2311](https://github.com/detekt/detekt/pull/2311) -- Update codecov run settings to after_n_builds=4 - [#2305](https://github.com/detekt/detekt/pull/2305) -- Update GroovyDSL doc to deprecate input property - [#2304](https://github.com/detekt/detekt/pull/2304) -- Update KotlinDSL doc to deprecate input property - [#2303](https://github.com/detekt/detekt/pull/2303) -- Fix ExplicitCollectionElementAccessMethod crash - [#2302](https://github.com/detekt/detekt/pull/2302) -- ExplicitCollectionElementAccessMethod crashes - [#2301](https://github.com/detekt/detekt/issues/2301) - -See all issues at: [1.5.1](https://github.com/detekt/detekt/milestone/58) - -#### 1.5.0 - -##### Notable Changes - -- detekt is now _silent_ by default. It only prints something if issues are found. -Remove the following excludes if you want the old behavior back. - -```yaml -console-reports: - active: true - exclude: - - 'ProjectStatisticsReport' - - 'ComplexityReport' - - 'NotificationReport' -``` - -- detekt now fails the build if any issue is found. Change the `maxIssues` property to 10 for the old threshold. - -```yaml -build: - maxIssues: 0 -``` - -- The `HTML` report now prints the issue count per rule and rule set. -- New rules: `ExplicitCollectionElementAccessMethod` and `ForbiddenMethod` - -##### Changelog - -- add new mention to README.md - [#2293](https://github.com/detekt/detekt/pull/2293) -- Sort html report - [#2290](https://github.com/detekt/detekt/pull/2290) -- Number format in some report - [#2289](https://github.com/detekt/detekt/pull/2289) -- Show the finding count in the html report - [#2288](https://github.com/detekt/detekt/pull/2288) -- Keep the order of the issues in the html report - [#2287](https://github.com/detekt/detekt/issues/2287) -- Show issue count in the html report - [#2286](https://github.com/detekt/detekt/issues/2286) -- Fixing the Documentation not properly calling the superclass - [#2284](https://github.com/detekt/detekt/pull/2284) -- Do you have to call super in custom rules? - [#2283](https://github.com/detekt/detekt/issues/2283) -- Measure performance of various stages when using --debug - [#2281](https://github.com/detekt/detekt/pull/2281) -- Remove printing the whole config for --debug - [#2280](https://github.com/detekt/detekt/pull/2280) -- Introduce DefaultRuleSetProvider interface marking detekt-rules providers as default - [#2279](https://github.com/detekt/detekt/pull/2279) -- Simplify test dependency setup in build files - [#2278](https://github.com/detekt/detekt/pull/2278) -- Fix class loader memory leaks when loading services - [#2277](https://github.com/detekt/detekt/pull/2277) -- Always dispose Kotlin environment fixing memory leak in error cases - [#2276](https://github.com/detekt/detekt/pull/2276) -- Sanitize gradle build scripts and suppress unstable api usages - [#2271](https://github.com/detekt/detekt/pull/2271) -- Update website ruby dependencies fixing potential security vulnerability - [#2270](https://github.com/detekt/detekt/pull/2270) -- Fix regression not considering baseline file when calculating build failure threshold - [#2269](https://github.com/detekt/detekt/pull/2269) -- Turn detekt silent by default - [#2268](https://github.com/detekt/detekt/pull/2268) -- Remove redundant build failure message - #2264 - [#2266](https://github.com/detekt/detekt/pull/2266) -- Build failed with... is printed twice in the cli - [#2264](https://github.com/detekt/detekt/issues/2264) -- Update config:maxIssues value to 0 - [#2263](https://github.com/detekt/detekt/pull/2263) -- Don't flag inherited visibility in NestedClassesVisibility - [#2261](https://github.com/detekt/detekt/pull/2261) -- Simplify argument parsing logic, remove any exitProcess() calls from buildRunner - [#2260](https://github.com/detekt/detekt/pull/2260) -- Modify default behavior to not output unless errors are found. Adding a verbose flag which will have legacy behavior - [#2258](https://github.com/detekt/detekt/pull/2258) -- Test some edge cases in detekt-api - [#2256](https://github.com/detekt/detekt/pull/2256) -- Add a new line at the end of the txt report - [#2255](https://github.com/detekt/detekt/pull/2255) -- Implement ExplicitCollectionElementAccessMethod rule - [#2215](https://github.com/detekt/detekt/pull/2215) -- ForbiddenMethod Rule - [#1954](https://github.com/detekt/detekt/pull/1954) -- NestedClassesVisibility(False negative): Nested class doesn't inherit visibility from parent - [#1930](https://github.com/detekt/detekt/issues/1930) - -See all issues at: [1.5.0](https://github.com/detekt/detekt/milestone/56) - -#### 1.4.0 - -##### Notable Changes - -New rule set `coroutines` with two specialized rules was added. -As always new rules must be activated by the user until they get stable. - -```yaml -coroutines: - active: true - GlobalCoroutineUsage: - active: false - RedundantSuspendModifier: - active: false -``` - -Wrapped `KtLint` was updated to `0.36.0` introducing two rules -- EnumEntryNameCase -- NoEmptyFirstLineInMethodBlock - -##### Migration - -The properties `ignoreOverriddenFunction` and `ignoreOverriddenFunctions` of some rules got deprecated and unified to a new property `ignoreOverridden`. - -##### Changelog - -- Refactor BuildFailure code - [#2250](https://github.com/detekt/detekt/pull/2250) -- Fix nested methods bug in MethodOverloading rule - [#2249](https://github.com/detekt/detekt/pull/2249) -- ThrowingExceptionInMain rule should consider main() function with no parameters - [#2248](https://github.com/detekt/detekt/issues/2248) -- MethodOverloading bug with nested overloaded methods - [#2247](https://github.com/detekt/detekt/issues/2247) -- Reduce complexity in FindingsReport - [#2246](https://github.com/detekt/detekt/pull/2246) -- Add RedundantSuspendModifier rule - [#2244](https://github.com/detekt/detekt/pull/2244) -- New ktlint rules - [#2243](https://github.com/detekt/detekt/pull/2243) -- Inline MethodOverloading case file - [#2241](https://github.com/detekt/detekt/pull/2241) -- ThrowingExceptionInMain: fix #2248 and add tests - [#2240](https://github.com/detekt/detekt/pull/2240) -- Add disposing Kotlin environment. - [#2238](https://github.com/detekt/detekt/pull/2238) -- OOM on multiple invocations - [#2237](https://github.com/detekt/detekt/issues/2237) -- Improve doc for UnusedPrivateMember - [#2236](https://github.com/detekt/detekt/pull/2236) -- Don't resolve dependencies during project configuration - [#2235](https://github.com/detekt/detekt/pull/2235) -- Revert "Introduce Pull Request Labeler" - [#2234](https://github.com/detekt/detekt/pull/2234) -- Fix #2230 equals() func detection - [#2233](https://github.com/detekt/detekt/pull/2233) -- Fix git commit-hook label and code snippet doc - [#2232](https://github.com/detekt/detekt/pull/2232) -- WrongEqualsTypeParameter does not ignore multi-parameter equals methods - [#2230](https://github.com/detekt/detekt/issues/2230) -- Introduce Pull Request Labeler - [#2228](https://github.com/detekt/detekt/pull/2228) -- Gradle plugin: Build upon default detekt config - [#2227](https://github.com/detekt/detekt/pull/2227) -- Apply ktlint formatting plugin to Gradle plugin - [#2226](https://github.com/detekt/detekt/pull/2226) -- Bump dependencies - [#2225](https://github.com/detekt/detekt/pull/2225) -- Run shadowJar & installShadowDist task with everything else - [#2220](https://github.com/detekt/detekt/pull/2220) -- Travis: Use consistent Java vendor - [#2219](https://github.com/detekt/detekt/pull/2219) -- "Property is misspelled or does not exist" error for new rules in default rulesets - [#2217](https://github.com/detekt/detekt/issues/2217) -- MethodOverloading false positive if every entry of an enum implement a method. - [#2216](https://github.com/detekt/detekt/issues/2216) -- Add Git detekt pre-commit hook doc - [#2214](https://github.com/detekt/detekt/pull/2214) -- Remove exclude workaround for new build property - [#2203](https://github.com/detekt/detekt/pull/2203) -- Add GlobalCoroutineUsage rule + coroutines ruleset - [#2174](https://github.com/detekt/detekt/pull/2174) -- Add rule [RedundantSuspend] to detect redundant suspend modifiers - [#2156](https://github.com/detekt/detekt/issues/2156) -- Deprecate ignoreOverriddenFunction/s in favor of ignoreOverridden - [#2132](https://github.com/detekt/detekt/pull/2132) - -See all issues at: [1.4.0](https://github.com/detekt/detekt/milestone/55) - -#### 1.3.1 - -- Remove old unused documentation - [#2210](https://github.com/detekt/detekt/pull/2210) -- Show code snippet erros in html reports - [#2209](https://github.com/detekt/detekt/pull/2209) -- Use compileAndLint in UnusedPrivateClassSpec - [#2208](https://github.com/detekt/detekt/pull/2208) -- Fix false positive in UnusedPrivateClass - [#2207](https://github.com/detekt/detekt/pull/2207) -- Update readme promoting new properties of the gradle plugin - [#2205](https://github.com/detekt/detekt/pull/2205) -- Rename default const containing _ACCEPTED_ - [#2204](https://github.com/detekt/detekt/pull/2204) -- Mistake From LongParameterList.kt - [#2202](https://github.com/detekt/detekt/issues/2202) -- Exclude yet unknown new build property - [#2201](https://github.com/detekt/detekt/pull/2201) -- Add comment regarding type resolution to README - [#2199](https://github.com/detekt/detekt/pull/2199) -- Type resolution doc - [#2198](https://github.com/detekt/detekt/pull/2198) -- Correct indentation for Groovy DSL doc - [#2197](https://github.com/detekt/detekt/pull/2197) -- Use shorthand syntax for assertThat() - [#2196](https://github.com/detekt/detekt/pull/2196) -- Refactor MagicNumber to use commaSeparatedPatterns - [#2195](https://github.com/detekt/detekt/pull/2195) -- Attach FILE_PATH_USER_DATA_KEY user data on FormattingRules (#1907) - [#2194](https://github.com/detekt/detekt/pull/2194) -- Handle invalid config exit code in gradle plugin - [#2193](https://github.com/detekt/detekt/pull/2193) -- Add tests showing how to exclude custom config properties in plugins - [#2192](https://github.com/detekt/detekt/pull/2192) -- Fix suppression of KtLint rules on file level - #2179 - [#2191](https://github.com/detekt/detekt/pull/2191) -- Mention needed kotlinx.html library from jcenter - #2146 - [#2190](https://github.com/detekt/detekt/pull/2190) -- UnusedPrivateClass has false positive behavior for deserialized items - [#2158](https://github.com/detekt/detekt/issues/2158) -- Use JDK 11 (LTS) + 13 for AppVeyor builds - [#2141](https://github.com/detekt/detekt/pull/2141) -- Document how to create a common baseline file for multi module gradle projects - [#2140](https://github.com/detekt/detekt/pull/2140) -- DetektAll with baseline fails with error - [#2100](https://github.com/detekt/detekt/issues/2100) -- ForbiddenMethod Rule - [#1954](https://github.com/detekt/detekt/pull/1954) -- Do not report auto-corrected formatting issues - [#1840](https://github.com/detekt/detekt/pull/1840) - -See all issues at: [1.3.1](https://github.com/detekt/detekt/milestone/54) - -#### 1.3.0 - -##### Notable changes - -- Minimal Gradle version increased to 5.0 -- New rules: - - `UnnecessaryAnnotationUseSiteTargetRule` - - `MapGetWithNotNullAssertionOperator` - -##### Changelog - -- Add printers to the command line runner - [#2188](https://github.com/detekt/detekt/pull/2188) -- Fix documentation of UseArrayLiteralsInAnnotations - [#2186](https://github.com/detekt/detekt/pull/2186) -- Inline resolving severity label for XML reports - [#2184](https://github.com/detekt/detekt/pull/2184) -- Extract common jvm target value, add jvmTarget into documentation. Cl… - [#2183](https://github.com/detekt/detekt/pull/2183) -- Fix Detekt gradle task cache restoration issue (#2180) - [#2182](https://github.com/detekt/detekt/pull/2182) -- Fix exception when running ArrayPrimitive on star-projected arrays - [#2181](https://github.com/detekt/detekt/pull/2181) -- Gradle cache restoration issue - [#2180](https://github.com/detekt/detekt/issues/2180) -- Add MacOS JDK13 build job to TravisCI - [#2177](https://github.com/detekt/detekt/pull/2177) -- Running "ArrayPrimitive" rule on "Array<*>" causes detekt to throw exception - [#2176](https://github.com/detekt/detekt/issues/2176) -- Update Spek to v2.0.9 - [#2173](https://github.com/detekt/detekt/pull/2173) -- Create Rule: MapGetWithNotNullAssertionOperator - [#2171](https://github.com/detekt/detekt/pull/2171) -- EqualsAlwaysReturnsTrueOrFalse fails hard on `override fun equals(other:Any) = ...` - [#2167](https://github.com/detekt/detekt/issues/2167) -- Prepare 1.3.0 release - [#2165](https://github.com/detekt/detekt/pull/2165) -- UnsafeCast: update documentation to match new behavior - [#2164](https://github.com/detekt/detekt/pull/2164) -- Add jvmTarget change into documentation - [#2157](https://github.com/detekt/detekt/issues/2157) -- Create UnnecessaryAnnotationUseSiteTargetRule - [#2099](https://github.com/detekt/detekt/pull/2099) -- Gradle 6 - [#1902](https://github.com/detekt/detekt/pull/1902) -- Gradle 6 planning - [#1820](https://github.com/detekt/detekt/issues/1820) - -See all issues at: [1.3.0](https://github.com/detekt/detekt/milestone/51) - -#### 1.2.2 - -##### Notable Changes - -- 1.2.1 introduced breaking changes for users of Gradle < 5. This was reverted. -- 1.3.0 will drop support for Gradle < 5. -- Fixed a regression in the html report. - -##### Changelog - -- regression updating 1.2.0 to 1.2.1, unknown property 'filters' for object of type DetektExtension - [#2163](https://github.com/detekt/detekt/issues/2163) -- StringIndexOutOfBoundsException when generating HTML report - [#2160](https://github.com/detekt/detekt/pull/2160) -- Restore KotlinExtension - [#2159](https://github.com/detekt/detekt/pull/2159) -- 1.2.1 breaks the build with: unresolved reference: detekt - [#2152](https://github.com/detekt/detekt/issues/2152) -- Updated to correct classpath documentation for Android projects. - [#2149](https://github.com/detekt/detekt/pull/2149) -- Update to Kotlin v1.3.61 - [#2147](https://github.com/detekt/detekt/pull/2147) -- Document how to exclude detekt from the check task - #1894 - [#2144](https://github.com/detekt/detekt/pull/2144) -- Use JDK 11 (LTS) + 13 for Travis builds - [#2142](https://github.com/detekt/detekt/pull/2142) -- Don't compile test snippets (bindingContext) - [#2137](https://github.com/detekt/detekt/pull/2137) -- StringIndexOutOfBoundsException: String index out of range: 8 when generating HTML report after update to 1.2.0 - [#2134](https://github.com/detekt/detekt/issues/2134) - -See all issues at: [1.2.2](https://github.com/detekt/detekt/milestone/53) - -#### 1.2.1 - -##### Notable changes - -- Supports Kotlin 1.3.60 -- Fixed a regression in configuration validation logic when using `build>weights>[RuleSet|Rule]` properties. -- Some rules got improvements (see changelog) - -##### Changelog - -- Exception analyzing file - [#2139](https://github.com/detekt/detekt/issues/2139) -- Simplify ConstructorParameterNaming:ignoreOverridden check - [#2136](https://github.com/detekt/detekt/pull/2136) -- Test common config sections pass through config validation - [#2135](https://github.com/detekt/detekt/pull/2135) -- Kotlin 1.3.60 with fix for "Unable to load JNA library" warning - [#2129](https://github.com/detekt/detekt/pull/2129) -- Unexpected nested config for 'build>weights'. - [#2128](https://github.com/detekt/detekt/issues/2128) -- Remove redundant Javadoc - [#2127](https://github.com/detekt/detekt/pull/2127) -- Lazy init KotlinScriptEnginePool - [#2126](https://github.com/detekt/detekt/pull/2126) -- Add tests for MagicNumber:ignoreLocalVariableDeclaration - [#2125](https://github.com/detekt/detekt/pull/2125) -- Fix NPE for EqualsAlwaysReturnsTrueOrFalse - [#2124](https://github.com/detekt/detekt/pull/2124) -- Add MagicNumber:ignoreLocalVariableDeclaration config - [#2123](https://github.com/detekt/detekt/pull/2123) -- Fix MagicNumber:ignoreConstantDeclaration doc - [#2116](https://github.com/detekt/detekt/pull/2116) -- Return non-nullable string in DebtSumming class - [#2113](https://github.com/detekt/detekt/pull/2113) -- Refactor TrailingWhitespace test - [#2112](https://github.com/detekt/detekt/pull/2112) -- Use inline code snippets instead of case files - [#2111](https://github.com/detekt/detekt/pull/2111) -- UnusedImports: False positive if referenced in @throws/@exception/@sample - [#2106](https://github.com/detekt/detekt/pull/2106) -- Don't compile test snippets - [#2105](https://github.com/detekt/detekt/pull/2105) -- MemberNameEqualsClassName should ignore overridden property names too - [#2104](https://github.com/detekt/detekt/pull/2104) -- EqualsAlwaysReturnsTrueOrFalse crashes on certain input - [#2103](https://github.com/detekt/detekt/issues/2103) -- UnusedImports: False positive if referenced only in @throws/@exception clause - [#2098](https://github.com/detekt/detekt/issues/2098) -- Add config flag ignoreOverridden to ConstructorParameterNaming - [#2097](https://github.com/detekt/detekt/pull/2097) -- compileAndLint is 2.5 times slower than lint - [#2095](https://github.com/detekt/detekt/issues/2095) -- Improve naming tests - [#2094](https://github.com/detekt/detekt/pull/2094) - -See all issues at: [1.2.1](https://github.com/detekt/detekt/milestone/52) - -#### 1.2.0 - -##### Notable changes - -- The HTML report now includes the complexity metrics and previews of the code locations. -- Suppression by rule set id is now supported `@Suppress("detekt.[RuleSetId].[RuleId]")` -- `parallel=true` and `--parallel` now effect both the compilation and analysis phase. -- Users of Gradle's `--parallel` flag are encouraged to turn off the parallelism of detekt. Or turn it on otherwise. -- detekt internally does not use the `ForkJoinPool.commonPool()` anymore. When embedding detekt feel free to pass your own `ExecutionService` to the `ProcessingSettings`. - -##### Migration - -- Some reported positions of rules have changed, see issues starting with "Improve text location: ". -This may lead to some unexpected changes in the baseline file. -- The rule `ComplexMethod` got refactored and counts the cyclomatic complexity according to https://www.ndepend.com/docs/code-metrics#CC. -This change lead to increasing the threshold to 15 (was ten). - -##### Changelog - -- Update to Kotlin v1.3.60 - [#2109](https://github.com/detekt/detekt/pull/2109) -- UnusedPrivateClass: Fix false positive with private annotations - [#2108](https://github.com/detekt/detekt/pull/2108) -- Refactor ComplexMethod - [#2090](https://github.com/detekt/detekt/pull/2090) -- Fix NestedBlockDepth false negative - [#2086](https://github.com/detekt/detekt/pull/2086) -- NestedBlockDepth false negative - [#2085](https://github.com/detekt/detekt/issues/2085) -- Deprecate Location.locationString - [#2084](https://github.com/detekt/detekt/pull/2084) -- Add license badge to README - [#2080](https://github.com/detekt/detekt/pull/2080) -- Deploy SNAPSHOTs automatically - [#2079](https://github.com/detekt/detekt/pull/2079) -- Fix TrailingWhitespace reported position - [#2078](https://github.com/detekt/detekt/pull/2078) -- Activate more rules by default - #1911 - [#2075](https://github.com/detekt/detekt/pull/2075) -- Report InvalidRange for empty until range - [#2074](https://github.com/detekt/detekt/pull/2074) -- Deprecate properties on Entity - Closes #2014 - [#2072](https://github.com/detekt/detekt/pull/2072) -- Add complexity report to html output - [#2071](https://github.com/detekt/detekt/pull/2071) -- Use constants for config keys in tests - [#2070](https://github.com/detekt/detekt/pull/2070) -- Mention location adjustment in rules for 1.2.0 - [#2068](https://github.com/detekt/detekt/issues/2068) -- Improve text location: TooManyFunctions - [#2065](https://github.com/detekt/detekt/pull/2065) -- Improve text location: OptionalAbstractKeyword - [#2064](https://github.com/detekt/detekt/pull/2064) -- Improve text location: NestedBlockDepth - [#2063](https://github.com/detekt/detekt/pull/2063) -- Improve text location: MatchingDeclarationName - [#2062](https://github.com/detekt/detekt/pull/2062) -- Improve text location: LongMethod - [#2061](https://github.com/detekt/detekt/pull/2061) -- Improve text location: LargeClass - [#2060](https://github.com/detekt/detekt/pull/2060) -- Improve text location: ComplexMethod - [#2059](https://github.com/detekt/detekt/pull/2059) -- Improve text location: EmptyClassBlock - [#2058](https://github.com/detekt/detekt/pull/2058) -- Replace spek test hasSize(0) with isEmpty() - [#2057](https://github.com/detekt/detekt/pull/2057) -- Remove MacOS JDK11 CI run as discussed in #2015 - [#2056](https://github.com/detekt/detekt/pull/2056) -- Introduces mocking library 'mockk' - [#2055](https://github.com/detekt/detekt/pull/2055) -- Improve text location: InvalidPackageDeclaration - [#2052](https://github.com/detekt/detekt/pull/2052) -- Improve text location: MandatoryBracesIfStatements - [#2051](https://github.com/detekt/detekt/pull/2051) -- Improve text location: ClassNaming - [#2050](https://github.com/detekt/detekt/pull/2050) -- potential-bugs InvalidRange does not work in all cases - [#2044](https://github.com/detekt/detekt/issues/2044) -- Don't checkBuildFailureThreshold if we are creating the baseline - [#2034](https://github.com/detekt/detekt/pull/2034) -- gradle detektBaseline task fails - [#2033](https://github.com/detekt/detekt/issues/2033) -- Fix #2021 - [#2032](https://github.com/detekt/detekt/pull/2032) -- Update dependencies - [#2031](https://github.com/detekt/detekt/pull/2031) -- Dokka fix - [#2030](https://github.com/detekt/detekt/pull/2030) -- Simplify and refactor RuleProviderTest - [#2029](https://github.com/detekt/detekt/pull/2029) -- Simplify MultiRuleCollector test cases - [#2028](https://github.com/detekt/detekt/pull/2028) -- Dont check WrongEqualsTypeParameter if the function is topLevel - [#2027](https://github.com/detekt/detekt/pull/2027) -- Fix false positive at EmptyIfBlock - [#2026](https://github.com/detekt/detekt/pull/2026) -- Support guard clause exclusion for ThrowsCount rule - [#2025](https://github.com/detekt/detekt/pull/2025) -- Add ImplicitDefaultLocale rule - [#2024](https://github.com/detekt/detekt/pull/2024) -- Use double backtick for the in-line code - [#2022](https://github.com/detekt/detekt/pull/2022) -- EqualsAlwaysReturnsTrueOrFalse: The original exception message was: java.util.NoSuchElementException: Array is empty. - [#2021](https://github.com/detekt/detekt/issues/2021) -- Ignore sealed classes for utility class having public constructor rule - [#2016](https://github.com/detekt/detekt/pull/2016) -- Better handling for the Suppresion of errors - [#2013](https://github.com/detekt/detekt/pull/2013) -- Fix description of NoLineBreakBeforeAssignment - [#2011](https://github.com/detekt/detekt/pull/2011) -- Copy paste error in message in NoLineBreakBeforeAssignment.kt - [#2008](https://github.com/detekt/detekt/issues/2008) -- UtilityClassWithPublicConstructor should not be reported for sealed classes - [#2005](https://github.com/detekt/detekt/issues/2005) -- Validate yaml configurations by comparing their structure - #516 - [#1998](https://github.com/detekt/detekt/pull/1998) -- Allow the user to collapse the rules in the html report - [#1997](https://github.com/detekt/detekt/pull/1997) -- Allow detekt findings to be suppessed with rule set id - Closes #766 - [#1994](https://github.com/detekt/detekt/pull/1994) -- Upgrade Spek to v2.0.8 - [#1992](https://github.com/detekt/detekt/pull/1992) -- Reimplement parallelism internal logic - [#1991](https://github.com/detekt/detekt/pull/1991) -- Findings assertions - [#1978](https://github.com/detekt/detekt/pull/1978) -- Fix EnumNaming textLocation - [#1977](https://github.com/detekt/detekt/pull/1977) -- Add snippet code in html report - [#1975](https://github.com/detekt/detekt/pull/1975) -- Change reported element in 2 documentation rules - [#1952](https://github.com/detekt/detekt/pull/1952) -- Enable more rules in failfast - [#1935](https://github.com/detekt/detekt/pull/1935) -- Add UndocumentedPublicProperty rule - closes #1670 - [#1923](https://github.com/detekt/detekt/pull/1923) -- Calculate MCC (McCabe Complexity) accordingly - [#1921](https://github.com/detekt/detekt/issues/1921) -- UseDataClass conflicts with DataClassShouldBeImmutable - [#1920](https://github.com/detekt/detekt/issues/1920) -- Redesign "parallel" flag/property - [#1845](https://github.com/detekt/detekt/issues/1845) -- SNAPSHOT process feedback - [#1826](https://github.com/detekt/detekt/issues/1826) -- Initial MCC change - [#1793](https://github.com/detekt/detekt/pull/1793) -- @Suppress("Detekt.ruleset") feature - [#766](https://github.com/detekt/detekt/issues/766) -- Validate Configuration file before using it - [#516](https://github.com/detekt/detekt/issues/516) - -See all issues at: [1.2.0](https://github.com/detekt/detekt/milestone/49) - -#### 1.1.1 - -##### Changelog - -- Improved test case for resolved #1971 (TrailingWhitespace and multiline string) - [#2003](https://github.com/detekt/detekt/pull/2003) -- Set defaults for boolean property when writing custom detekt tasks - [#1996](https://github.com/detekt/detekt/pull/1996) -- Generate PluginVersion.kt with newline at end - [#1993](https://github.com/detekt/detekt/pull/1993) -- Remove unnecessary logs from RuleProviderTest - [#1990](https://github.com/detekt/detekt/pull/1990) -- Use inline code snippets instead of case files - [#1989](https://github.com/detekt/detekt/pull/1989) -- Use config parameter for UseIfInsteadOfWhen rule - [#1987](https://github.com/detekt/detekt/pull/1987) -- Use inline code snippets instead of case files - [#1976](https://github.com/detekt/detekt/pull/1976) -- Don't flag trailing whitespaces in multiline strings - [#1971](https://github.com/detekt/detekt/pull/1971) - -See all issues at: [1.1.1](https://github.com/detekt/detekt/milestone/50) - -#### 1.1.0 - -##### Changelog - -- Clarify threshold pararameter meaning in docs - [#1974](https://github.com/detekt/detekt/pull/1974) -- Introduce ignoreLabeled config for ReturnFromFinally - [#1973](https://github.com/detekt/detekt/pull/1973) -- Ignore FunctionOnlyReturningConstant for allowed annotations - [#1968](https://github.com/detekt/detekt/pull/1968) -- Allow regex configuration support for Forbidden Import rule - [#1963](https://github.com/detekt/detekt/pull/1963) -- Refactor and simplify RuleCollectorSpec - [#1959](https://github.com/detekt/detekt/pull/1959) -- Use inline code snippets instead of case files - [#1958](https://github.com/detekt/detekt/pull/1958) -- Improve UnusedPrivateMember when it's related with parameters - [#1949](https://github.com/detekt/detekt/pull/1949) -- Fix SpacingBetweenPackageAndImports issue for scripts without packages - [#1947](https://github.com/detekt/detekt/pull/1947) -- Remove ConditionalPathVisitor - [#1944](https://github.com/detekt/detekt/pull/1944) -- Extend UseDataClass with the allowVars configuration property - [#1942](https://github.com/detekt/detekt/pull/1942) -- HasPlatformType rule - [#1938](https://github.com/detekt/detekt/pull/1938) -- Bogus SpacingBetweenPackageAndImports violation for KTS without package - [#1937](https://github.com/detekt/detekt/issues/1937) -- Gradle deprecations - [#1934](https://github.com/detekt/detekt/pull/1934) -- UnnecessaryParentheses should be ignored for bit operations - [#1929](https://github.com/detekt/detekt/issues/1929) -- Prepare 1.1.0 release - [#1919](https://github.com/detekt/detekt/pull/1919) -- Deprecate debug in IDEA tasks - [#1918](https://github.com/detekt/detekt/pull/1918) -- Refactoring: use more readable functions - [#1916](https://github.com/detekt/detekt/pull/1916) -- Don't fail on master when test coverage decreases - [#1914](https://github.com/detekt/detekt/pull/1914) -- Detect deprecations - [#1913](https://github.com/detekt/detekt/pull/1913) -- Fix typos - [#1908](https://github.com/detekt/detekt/pull/1908) -- Report PreferToOverPairSyntax only for kotlin.Pair - [#1905](https://github.com/detekt/detekt/pull/1905) -- Fix TimeoutCancellationException - downgrade Spek - [#1903](https://github.com/detekt/detekt/pull/1903) -- Update dependencies - [#1901](https://github.com/detekt/detekt/pull/1901) -- Add RedundantExplicitType rule - [#1900](https://github.com/detekt/detekt/pull/1900) -- Remove unused KtAnnotated util functions - [#1899](https://github.com/detekt/detekt/pull/1899) -- Simplify detekt rules - [#1898](https://github.com/detekt/detekt/pull/1898) -- Fix shared variable in detekt-extension rules - [#1897](https://github.com/detekt/detekt/pull/1897) -- Make samples more idiomatic - [#1895](https://github.com/detekt/detekt/pull/1895) -- Update detekt extensions doc - [#1893](https://github.com/detekt/detekt/pull/1893) -- Clarify `WildcardImport` rule configuration - [#1888](https://github.com/detekt/detekt/pull/1888) -- Add configuration to allow patterns for forbidden comment - [#1887](https://github.com/detekt/detekt/pull/1887) -- Only report UnsafeCallOnNullableType on actual nullable types - [#1886](https://github.com/detekt/detekt/pull/1886) -- Minimise usage of Kotlin reflection - [#1883](https://github.com/detekt/detekt/pull/1883) -- Refactor KotlinCoreEnvironment test setup - [#1880](https://github.com/detekt/detekt/pull/1880) -- Trust Kotlin compiler to identify unsafe casts - [#1879](https://github.com/detekt/detekt/pull/1879) -- Replace tabs with spaces in rule KDoc - [#1876](https://github.com/detekt/detekt/pull/1876) -- Make all Gradle tasks cacheable - [#1875](https://github.com/detekt/detekt/pull/1875) -- Indentation for compliant and non-compliant code examples is missing - [#1871](https://github.com/detekt/detekt/issues/1871) -- Don't build twice when PR created from branch - [#1866](https://github.com/detekt/detekt/pull/1866) -- Print rendered report if it's null or blank - [#1862](https://github.com/detekt/detekt/pull/1862) -- Silence report if containing no findings - [#1860](https://github.com/detekt/detekt/pull/1860) -- Group console violation reports by file - [#1852](https://github.com/detekt/detekt/pull/1852) -- Update Kotlin to v1.3.50 - [#1841](https://github.com/detekt/detekt/pull/1841) -- Gradle 5.6 - [#1833](https://github.com/detekt/detekt/pull/1833) -- Implement rule to suggest array literal instead of arrayOf-expression in annotations - [#1823](https://github.com/detekt/detekt/pull/1823) -- Make UnsafeCast less aggressive - [#1601](https://github.com/detekt/detekt/issues/1601) -- Consider publishing artifacts to mavenCentral instead of jCenter - [#1396](https://github.com/detekt/detekt/issues/1396) -- false positive unnecessary parentheses in conjunction with lambdas - [#1222](https://github.com/detekt/detekt/issues/1222) -- False positives on UnsafeCast on AppVeyor (Windows?) only - [#1137](https://github.com/detekt/detekt/issues/1137) -- PreferToOverPairSyntax false positive - [#1066](https://github.com/detekt/detekt/issues/1066) -- Rule ForbiddenComment - regexp support - [#959](https://github.com/detekt/detekt/issues/959) -- UnsafeCallOnNullableType should not be reported for platform types - [#880](https://github.com/detekt/detekt/issues/880) -- Exclusion patterns in detekt-config - [#775](https://github.com/detekt/detekt/issues/775) -- Rule: OptionalTypeDeclaration - [#336](https://github.com/detekt/detekt/issues/336) -- Check if it is feasible to integrate ktlint as a rule set - [#38](https://github.com/detekt/detekt/issues/38) - -See all issues at: [1.1.0](https://github.com/detekt/detekt/milestone/19) - -#### 1.0.1 - -##### Notable changes - -- Detekt runs can be completely silent on absence of findings](/blog/2019/08/14/custom-console-reports) -- All detekt's dependencies are now on MavenCentral. Bogus "*could not find JCommander dependency*" should be gone. - -##### Changelog - -- Migrate SafeCast test cases to JSR223 - [#1832](https://github.com/detekt/detekt/pull/1832) -- Remove unused case entries - [#1831](https://github.com/detekt/detekt/pull/1831) -- Migrate ComplexInterface test cases to JSR223 - [#1830](https://github.com/detekt/detekt/pull/1830) -- Remove pluginrepository from maventask.md - [#1827](https://github.com/detekt/detekt/pull/1827) -- Update maven-task --excludes arg - [#1825](https://github.com/detekt/detekt/pull/1825) -- Improve grammar on 1.0 release post - [#1822](https://github.com/detekt/detekt/pull/1822) -- Write guide on how to make detekt silent - [#1819](https://github.com/detekt/detekt/pull/1819) -- Use notifications instead of println - [#1818](https://github.com/detekt/detekt/pull/1818) -- JCommander 1.78 - [#1817](https://github.com/detekt/detekt/pull/1817) -- Fix typo in spelling of --auto-correct flag - [#1816](https://github.com/detekt/detekt/pull/1816) -- Update dependency versions - [#1815](https://github.com/detekt/detekt/pull/1815) -- Tidy the build files - [#1814](https://github.com/detekt/detekt/pull/1814) -- Downgrade to jcommander v1.72 - [#1809](https://github.com/detekt/detekt/pull/1809) -- Update docs to mention test-pattern deprecation - [#1808](https://github.com/detekt/detekt/pull/1808) -- Quiet mode or ability to disable all output in Gradle - [#1797](https://github.com/detekt/detekt/issues/1797) - -See all issues at: [1.0.1](https://github.com/detekt/detekt/milestone/47) - - -#### 1.0.0 - -##### Migration - -- Gradle Plugin: removed report consolidation. It was flawed and some users were stuck with RC14. It will be replaced in a further version. -- Gradle Plugin: `autoCorrect` property is now allowed on the detekt extension. No need to create a new task anymore. -- Formatting: updated to KtLint 0.34.2 which removed the two rules `NoItParamInMultilineLambda` and `SpacingAroundUnaryOperators`. - -##### Changelog - -- Gradle plugin: Set default path for "config" parameter - [#1801](https://github.com/detekt/detekt/pull/1801) -- Don't use provider value that may not have been set - [#1800](https://github.com/detekt/detekt/pull/1800) -- Remove raw URLs from README - [#1799](https://github.com/detekt/detekt/pull/1799) -- Add missing autoCorrect declarations - [#1798](https://github.com/detekt/detekt/pull/1798) -- Docs: Missing autoCorrect option for various rules - [#1796](https://github.com/detekt/detekt/issues/1796) -- Update to KtLint 0.34.2 - [#1791](https://github.com/detekt/detekt/pull/1791) -- Add auto correct flag to detekt extension - [#1790](https://github.com/detekt/detekt/pull/1790) -- Gradle plugin: Fix visibility of internal properties - [#1789](https://github.com/detekt/detekt/pull/1789) -- Check classes and functions documented for api module - [#1788](https://github.com/detekt/detekt/pull/1788) -- Provide default value for ignoreFailures - [#1787](https://github.com/detekt/detekt/pull/1787) -- Update detekt-api documentation - [#1786](https://github.com/detekt/detekt/pull/1786) -- Document meanings of rule severity levels - [#1785](https://github.com/detekt/detekt/pull/1785) -- Remove unused code - [#1784](https://github.com/detekt/detekt/pull/1784) -- Fix UseDataClass false positive (delegation) - [#1783](https://github.com/detekt/detekt/pull/1783) -- Add ignore pattern to SwallowedException - [#1782](https://github.com/detekt/detekt/pull/1782) -- Prevent adding author tags in code - [#1776](https://github.com/detekt/detekt/pull/1776) -- Remove xml report consolidation. - [#1774](https://github.com/detekt/detekt/pull/1774) -- Update Complex Method doc - closes #1009 - [#1773](https://github.com/detekt/detekt/pull/1773) -- Implement dry-run option for detekt gradle tasks. - [#1769](https://github.com/detekt/detekt/pull/1769) -- Fix missing report file issue. - [#1767](https://github.com/detekt/detekt/pull/1767) -- Not running formatting autocorrect - [#1766](https://github.com/detekt/detekt/issues/1766) -- Check if file exists before considering it for report merges - [#1763](https://github.com/detekt/detekt/pull/1763) -- Preset ignoreFailures property with false as it is also used by Gradle - [#1762](https://github.com/detekt/detekt/pull/1762) -- Rearrange badges, add codefactor - [#1760](https://github.com/detekt/detekt/pull/1760) -- Update Kotlin to 1.3.41 - [#1759](https://github.com/detekt/detekt/pull/1759) -- Update EmptyClassBlock to skip classes with comments in the body - [#1758](https://github.com/detekt/detekt/pull/1758) -- EmptyClassBlock should consider comment as "body" (via option?) - [#1756](https://github.com/detekt/detekt/issues/1756) -- Remove obsolete NoWildcardImports autoCorrect param - [#1751](https://github.com/detekt/detekt/pull/1751) -- Kotlin language version handling - [#1748](https://github.com/detekt/detekt/pull/1748) -- Fix cli execution doc - [#1747](https://github.com/detekt/detekt/pull/1747) -- Add naming test for ForbiddenVoid rule - [#1740](https://github.com/detekt/detekt/pull/1740) -- ForbiddenVoid: New option 'ignoreUsageInGenerics' - [#1738](https://github.com/detekt/detekt/pull/1738) -- Default Gradle config path should be config/detekt/config.yml - [#1262](https://github.com/detekt/detekt/issues/1262) - -See all issues at: [1.0.0](https://github.com/detekt/detekt/milestone/46) diff --git a/website/versioned_docs/version-1.21.0/introduction/changelog.md b/website/versioned_docs/version-1.21.0/introduction/changelog.md deleted file mode 100644 index c3b9b295c9d..00000000000 --- a/website/versioned_docs/version-1.21.0/introduction/changelog.md +++ /dev/null @@ -1,1768 +0,0 @@ ---- -id: changelog-rc -title: Changelog and Migration Guide - Pre 1.0.0 -keywords: [changelog, release-notes, migration] -sidebar_position: 2 ---- - - - -#### RC16 - -##### Migration - -- Notice that we removed the deprecated `warningThreshold` and `failThreshold`. Use `maxIssues` from now on instead. -- We updated KtLint integration to 0.33.0 which introduces four new rules. Make sure to enable them. - -##### Changelog - -- Use Codecov's recommended JaCoCo config - [#1739](https://github.com/detekt/detekt/pull/1739) -- Write a post about how to use snapshot releases - [#1737](https://github.com/detekt/detekt/pull/1737) -- Document how to include/exclude source files in the gradle plugin - [#1736](https://github.com/detekt/detekt/pull/1736) -- Publish snapshots to jfrogs oss artifactory - [#1734](https://github.com/detekt/detekt/pull/1734) -- Extract building runner - [#1733](https://github.com/detekt/detekt/pull/1733) -- Move to JSR compilation for rule Specs - [#1732](https://github.com/detekt/detekt/pull/1732) -- Remove deprecated threshold settings doc - [#1730](https://github.com/detekt/detekt/pull/1730) -- Publish snapshots to jfrogs oss artifactory - [#1729](https://github.com/detekt/detekt/pull/1729) -- Remove deprecated build failure threshold settings - #1723 - [#1728](https://github.com/detekt/detekt/pull/1728) -- Print to console the count of weighted issues if above 0 - [#1725](https://github.com/detekt/detekt/pull/1725) -- Extract building a runner from main method - [#1719](https://github.com/detekt/detekt/pull/1719) -- Run all detekt tasks with project dependencies - [#1718](https://github.com/detekt/detekt/pull/1718) -- Update doc for UnusedImports rule - [#1714](https://github.com/detekt/detekt/pull/1714) -- Update Kotlin to 1.3.40 - [#1713](https://github.com/detekt/detekt/pull/1713) -- Unable to use "exclude" in 1.0.0-RC15 with groovy dsl - [#1712](https://github.com/detekt/detekt/issues/1712) -- Introduce lock-bot - [#1711](https://github.com/detekt/detekt/pull/1711) -- Fix broken hasLocationStrings and similar broken assert - [#1707](https://github.com/detekt/detekt/pull/1707) -- Rule improvement: False positive UnusedImport for componentN - [#1705](https://github.com/detekt/detekt/pull/1705) -- Update doc (report extension section) - [#1703](https://github.com/detekt/detekt/pull/1703) -- Disable colors on Windows OS - [#1701](https://github.com/detekt/detekt/pull/1701) -- Add two more examples and one integrating site - [#1699](https://github.com/detekt/detekt/pull/1699) -- Filter fake elements when processing ast nodes - Closes #1688 - [#1698](https://github.com/detekt/detekt/pull/1698) -- Set ignoreFailures on all sourceset tasks - [#1697](https://github.com/detekt/detekt/pull/1697) -- Gradle plugin: Pass arguments to detekt in a file - [#1696](https://github.com/detekt/detekt/pull/1696) -- Gradle: Upgrade the ktlint version to 0.33.0 - [#1692](https://github.com/detekt/detekt/pull/1692) -- Fixed bug reporting false positives with EmptyFunctionBlock - [#1690](https://github.com/detekt/detekt/pull/1690) -- Fix reporting logic for UseRequire and UseCheckOrErrorSpec - [#1689](https://github.com/detekt/detekt/pull/1689) -- Bogus NoTrailingSpaces findings in some files - [#1688](https://github.com/detekt/detekt/issues/1688) -- Implement LibraryCodeMustSpecifyReturnType rule - [#1659](https://github.com/detekt/detekt/pull/1659) -- Add RedundantElseInWhen rule - [#1603](https://github.com/detekt/detekt/pull/1603) -- Wrap four new KtLint rules - [#1455](https://github.com/detekt/detekt/pull/1455) - -See all issues at: [RC16](https://github.com/detekt/detekt/milestone/45) - -#### RC15 - -##### Migration - -- **Cli**: `filters` concept got deprecated and removed. Please use the new `excludes` and `includes` options. - `excludes` works exactly like `filters` did except it takes now a comma separated list of [*globing patterns*](https://en.wikipedia.org/wiki/Glob_%28programming%29) instead of a *regular expressions*. - For example `--filters .*/resources/.*` becomes `--excludes **/resources/**`. `includes` also accepts *globing patterns*. - *Globing patterns* allow us to reuse some common logic of the `java.nio.file` package which for example handle Windows specific paths for us. - This change also allows to be more fine granular with analyzing files: `--excludes **/generated/** --includes **/generated/this-needs-to-be-checked`. - The following [how-to guide](/blog/2019/06/08/migrating-the-test-pattern) describes the migration process from the **test-pattern** functionality. -- **Gradle Plugin**: Including or excluding paths and files from detekt scanning is now done by setting `include` & `exclude` on the - detekt task which aligns with how other static analysis tools handle filters. Any use of `filters` will be ignored. See custom [task examples for Groovy and Kotlin](/docs/gettingstarted/gradle#defining-custom-detekt-task). - For details of syntax see https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/util/PatternFilterable.html -- **Gradle Plugin**: Adds support for TXT report. -- **Cli/Gradle Plugin**: `autoCorrect` inside the yaml config was removed. Please use the `--auto-correct` cli flag or `autoCorrect` detekt extension property in the Gradle plugin. - -##### Changelog - -- Adding test for UselessCallOnNotNull and platform types - [#1674](https://github.com/detekt/detekt/pull/1674) -- Fix MaxLineLength and suppressing issues with multiline strings - [#1673](https://github.com/detekt/detekt/pull/1673) -- Update website for all breaking changes in RC15 - [#1671](https://github.com/detekt/detekt/issues/1671) -- Fix TooManyFunctions report logic - [#1669](https://github.com/detekt/detekt/pull/1669) -- Rework UnderscoresInNumericLiterals Rule - [#1664](https://github.com/detekt/detekt/pull/1664) -- JaCoCo 0.8.4 - [#1663](https://github.com/detekt/detekt/pull/1663) -- Add support for JSR test infrastructure for type resolved rules - [#1661](https://github.com/detekt/detekt/pull/1661) -- Unify use of kotlin environment and make AST modification work again - [#1657](https://github.com/detekt/detekt/pull/1657) -- Do not use relativePath as it is not set anymore and will crash the detekt run - [#1655](https://github.com/detekt/detekt/pull/1655) -- Move autocorrect to cli - [#1654](https://github.com/detekt/detekt/pull/1654) -- Replace test pattern concept with rule excludes - [#1651](https://github.com/detekt/detekt/pull/1651) -- Refactor api tests to use test-api - [#1649](https://github.com/detekt/detekt/pull/1649) -- Allow to configure exclusion and inclusion patterns for rule sets - [#1648](https://github.com/detekt/detekt/pull/1648) -- Revert cross module coverage - [#1647](https://github.com/detekt/detekt/pull/1647) -- Migrate to lazy searching of child nodes - [#1646](https://github.com/detekt/detekt/pull/1646) -- Do not report when using shortcut 'return' on nullable types - [#1645](https://github.com/detekt/detekt/pull/1645) -- Consider default functions inside interface for used private functions - [#1644](https://github.com/detekt/detekt/pull/1644) -- Lazily add `detekt` task as a dependency of the `check` task - [#1641](https://github.com/detekt/detekt/pull/1641) -- Detekt gradle task is not executed upon check - [#1640](https://github.com/detekt/detekt/issues/1640) -- Remove git commit message check - [#1638](https://github.com/detekt/detekt/pull/1638) -- Remove additional space in EmptyClassBlock report msg - [#1636](https://github.com/detekt/detekt/pull/1636) -- Whitelist provideDelegate operator in UnusedImports rule - [#1632](https://github.com/detekt/detekt/pull/1632) -- Reports no duplicated findings in empty ruleset - [#1623](https://github.com/detekt/detekt/pull/1623) -- Add support for JSR test infrastructure in style ruleset - [#1620](https://github.com/detekt/detekt/pull/1620) -- Update to kotlin version 1.3.31 - [#1618](https://github.com/detekt/detekt/pull/1618) -- Publish detekt-api docs to the detekt documentation site - [#1615](https://github.com/detekt/detekt/pull/1615) -- False Positive on UnusedPrivateMember with interface's default method - [#1613](https://github.com/detekt/detekt/issues/1613) -- Update dependencies - [#1612](https://github.com/detekt/detekt/pull/1612) -- Improve handling of classpaths in Gradle plugin - [#1609](https://github.com/detekt/detekt/pull/1609) -- False positive from UnusedImports on org.gradle.kotlin.dsl.provideDelegate - [#1608](https://github.com/detekt/detekt/issues/1608) -- Provide meaningful config error message by tracking sub configurations - [#1607](https://github.com/detekt/detekt/pull/1607) -- Replace cli filters parameter with incudes and excludes - [#1606](https://github.com/detekt/detekt/pull/1606) -- Duplicated findings are being added to `Detektion.findings` - [#1605](https://github.com/detekt/detekt/issues/1605) -- Don't trigger SpreadOperator rule when array copy not required - [#1604](https://github.com/detekt/detekt/pull/1604) -- Add MissingWhenCase rule - [#1602](https://github.com/detekt/detekt/pull/1602) -- Custom reports in gradle plugin - [#1598](https://github.com/detekt/detekt/pull/1598) -- Gradle plugin: create task per source set (JVM) - [#1597](https://github.com/detekt/detekt/pull/1597) -- Added auto correct information to finding - [#1595](https://github.com/detekt/detekt/pull/1595) -- Add DataClassShouldBeImmutable rule - [#1588](https://github.com/detekt/detekt/pull/1588) -- Using custom output inside Gradle plugin - [#1583](https://github.com/detekt/detekt/issues/1583) -- Colorizes CLI output. - [#1581](https://github.com/detekt/detekt/pull/1581) -- Using the Gradle Plugin analyzes files sequentially - [#1580](https://github.com/detekt/detekt/issues/1580) -- Bump Spek version - [#1578](https://github.com/detekt/detekt/pull/1578) -- Ignore void types in overridden function signatures. - [#1576](https://github.com/detekt/detekt/pull/1576) -- Test case and fix for issue #1573 - [#1575](https://github.com/detekt/detekt/pull/1575) -- ForbiddenImport matches on substring, not full class - [#1573](https://github.com/detekt/detekt/issues/1573) -- Silence dokka - [#1572](https://github.com/detekt/detekt/pull/1572) -- AssertJ housekeeping - [#1571](https://github.com/detekt/detekt/pull/1571) -- Add rules to suggest usage of check(), require() and error(). - [#1570](https://github.com/detekt/detekt/pull/1570) -- Allow configuration to ignore magic number in ranges. - [#1567](https://github.com/detekt/detekt/pull/1567) -- Add support for JSR test infrastructure in naming ruleset - [#1564](https://github.com/detekt/detekt/pull/1564) -- Add support for JSR test infrastructure in empty ruleset - [#1563](https://github.com/detekt/detekt/pull/1563) -- Add support for JSR test infrastructure in complexity ruleset - [#1562](https://github.com/detekt/detekt/pull/1562) -- Add support for JSR test infrastructure in bugs ruleset - [#1561](https://github.com/detekt/detekt/pull/1561) -- Add detekt mention to readme - [#1560](https://github.com/detekt/detekt/pull/1560) -- Add formatting issue to baseline - [#1559](https://github.com/detekt/detekt/pull/1559) -- Update doc for fail-fast argument - [#1558](https://github.com/detekt/detekt/pull/1558) -- Travis: Skip default install step - [#1557](https://github.com/detekt/detekt/pull/1557) -- Fix the check for private top-level property naming - [#1556](https://github.com/detekt/detekt/pull/1556) -- Allow to ignore local properties in magic number - Closes #1536 - [#1555](https://github.com/detekt/detekt/pull/1555) -- Test on OpenJDK 12 - [#1554](https://github.com/detekt/detekt/pull/1554) -- Update Gradle & dependencies - [#1549](https://github.com/detekt/detekt/pull/1549) -- Simplify Java interop - [#1547](https://github.com/detekt/detekt/pull/1547) -- Improve RC13 migration instructions in changelog - [#1546](https://github.com/detekt/detekt/pull/1546) -- Enable local build cache for CI - [#1544](https://github.com/detekt/detekt/pull/1544) -- ktlint 0.31.0 - [#1543](https://github.com/detekt/detekt/pull/1543) -- Add code formatting instructions to CONTRIBUTING.md - [#1542](https://github.com/detekt/detekt/pull/1542) -- Remove non popular watcher module - [#1541](https://github.com/detekt/detekt/pull/1541) -- Add ignoreVariables to MagicNumber - [#1536](https://github.com/detekt/detekt/issues/1536) -- Ignore local properties - [#1535](https://github.com/detekt/detekt/pull/1535) -- Enable Kotlin's progressive compilation mode - [#1534](https://github.com/detekt/detekt/pull/1534) -- Type and symbol resolving - [#1532](https://github.com/detekt/detekt/pull/1532) -- Remove the timestamp from the baseline doc #1524 - [#1531](https://github.com/detekt/detekt/pull/1531) -- Add newline at end of baseline files - [#1527](https://github.com/detekt/detekt/pull/1527) -- Add a final newline in the baseline files - [#1525](https://github.com/detekt/detekt/issues/1525) -- Configure build-scan plugin - [#1523](https://github.com/detekt/detekt/pull/1523) -- [docs] Introduce guides in the news section - [#1522](https://github.com/detekt/detekt/pull/1522) -- Repackage formatting to make it able to use the jar as --plugins jar for cli runs - [#1521](https://github.com/detekt/detekt/pull/1521) -- Single statement in nullable apply calls - [#1520](https://github.com/detekt/detekt/pull/1520) -- Update dependencies - [#1519](https://github.com/detekt/detekt/pull/1519) -- Fix compliant/noncompliant code example in OptionalWhenBraces - [#1511](https://github.com/detekt/detekt/pull/1511) -- Ensure IntelliJ is configured to use official Kotlin style - [#1510](https://github.com/detekt/detekt/pull/1510) -- Fix deprecation warnings - [#1509](https://github.com/detekt/detekt/pull/1509) -- Exit process with specific code when detekt finds code issues - [#1508](https://github.com/detekt/detekt/pull/1508) -- Show friendlier error when wrong type used for a config parameter - [#1507](https://github.com/detekt/detekt/pull/1507) -- Show message only when failFast in config is not null - [#1506](https://github.com/detekt/detekt/pull/1506) -- Convert tasks to SourceTasks - [#1505](https://github.com/detekt/detekt/pull/1505) -- Load dependencies over HTTPS - [#1504](https://github.com/detekt/detekt/pull/1504) -- Exception thrown when running detekt with -p [detekt-format jar] - [#1503](https://github.com/detekt/detekt/issues/1503) -- Ignore enums in ProtectedMemberInFinalClass rule - #1489 - [#1496](https://github.com/detekt/detekt/pull/1496) -- Add "issues found" exit code - [#1493](https://github.com/detekt/detekt/issues/1493) -- Project dependency to override detekt-cli in composite build does not run assemble automatically - [#1208](https://github.com/detekt/detekt/issues/1208) -- Gradle plugin: create task per source set - [#1198](https://github.com/detekt/detekt/issues/1198) - -See all issues at: [RC15](https://github.com/detekt/detekt/milestone/44) - -#### RC14 - -##### Changelog - -- TooManyFunctions: Use existing functions to be more readable - [#1491](https://github.com/detekt/detekt/pull/1491) -- Disable rules that ktlint disables by default - [#1490](https://github.com/detekt/detekt/pull/1490) -- Add ignoreOverridden option for TooManyFunctions rule - #1411 - [#1488](https://github.com/detekt/detekt/pull/1488) -- Do only consider calls and member accesses in UnnecessaryApply rule - [#1487](https://github.com/detekt/detekt/pull/1487) -- Remove project cache dir workaround from tests - [#1484](https://github.com/detekt/detekt/pull/1484) -- Add comment about baseline setup on readme - [#1483](https://github.com/detekt/detekt/pull/1483) -- Test Gradle plugin on multiple Gradle versions - [#1482](https://github.com/detekt/detekt/pull/1482) -- Update Default acceptableDecimalLength for UnderscoresInNumericLiterals - [#1477](https://github.com/detekt/detekt/pull/1477) -- RC13 doesn't work on gradlew 4.9 - [#1475](https://github.com/detekt/detekt/issues/1475) -- False Positive UnusedPrivateClass - [#1474](https://github.com/detekt/detekt/issues/1474) -- False Positive UnnecessaryApply - [#1473](https://github.com/detekt/detekt/issues/1473) -- Spek 2 - [#1470](https://github.com/detekt/detekt/pull/1470) - -See all issues at: [Upcoming](https://github.com/detekt/detekt/milestone/43) - -#### RC13 - -##### Migration - -- 'failFast' inside the yaml config was deprecated. Please use the `--fail-fast` cli flag or `failFast` detekt extension property in the Gradle plugin. -- The `--buildUponDefaultConfig` CLI flag or `buildUponDefaultConfig` detekt Gradle extension property allow to run detekt with the default config without duplicating it in your project. All users who use the default config and override some properties in a second config file are encouraged to migrate. -- `LongMethod` and `LargeClass` rules got refactored and now count source lines of code and not statements anymore. You may need to change your defaults. -- Files matching `.*/androidTest/.*` and `*Spek.kt` are now part of the `test-pattern` by default. - -##### Changelog - -- Support new flags in gradle plugin - [#1465](https://github.com/detekt/detekt/pull/1465) -- Add UnderscoresInNumericLiterals Rule - [#1464](https://github.com/detekt/detekt/pull/1464) -- Prepare RC13 - [#1462](https://github.com/detekt/detekt/pull/1462) -- Use sensible defaults for not set properties - Closes #1457 - [#1461](https://github.com/detekt/detekt/pull/1461) -- Update to Kotlin v1.3.21 - [#1460](https://github.com/detekt/detekt/pull/1460) -- Gradle 5.2 - [#1458](https://github.com/detekt/detekt/pull/1458) -- Custom Detekt Task fails with Gradle 5.2: No value has been specified for this provider - [#1457](https://github.com/detekt/detekt/issues/1457) -- Treat androidTest directory and *Spek.kt files as test sources. - [#1456](https://github.com/detekt/detekt/pull/1456) -- Exclude inline classes as they are a light form of data class - Closes #1450 - [#1454](https://github.com/detekt/detekt/pull/1454) -- Publish shadowed jars (-all) - [#1453](https://github.com/detekt/detekt/pull/1453) -- Reimplement lines of code based rules (LargeClass & LongMethod) - [#1448](https://github.com/detekt/detekt/pull/1448) -- Add test case for TooManyFunctons fix - #1439 - [#1447](https://github.com/detekt/detekt/pull/1447) -- Fix false positives for UnnecessaryApply rule - Closes #1305 - [#1446](https://github.com/detekt/detekt/pull/1446) -- Skip operator functions when searching for unused private members - #1354 - [#1445](https://github.com/detekt/detekt/pull/1445) -- Do not report annotation classes as candidates for utility class - #1428 - [#1442](https://github.com/detekt/detekt/pull/1442) -- Do not report unused import when alias is used by import from same package - [#1441](https://github.com/detekt/detekt/pull/1441) -- Update Kotlin to 1.3.20 - [#1438](https://github.com/detekt/detekt/pull/1438) -- Mention jcenter repository in getting started guides - [#1437](https://github.com/detekt/detekt/pull/1437) -- Do not report main functions args parameter in objects - [#1436](https://github.com/detekt/detekt/pull/1436) -- Update default package naming rule according to official style guide. Closes #1429 - [#1434](https://github.com/detekt/detekt/pull/1434) -- UtilityClassWithPublicConstructor on annotation class - [#1428](https://github.com/detekt/detekt/issues/1428) -- UnusedPrivateMember with main method - [#1427](https://github.com/detekt/detekt/issues/1427) -- Ignore InstanceOfCheckForException by default for tests. - [#1424](https://github.com/detekt/detekt/pull/1424) -- Respect @Suppress in UnusedPrivateMember - [#1423](https://github.com/detekt/detekt/pull/1423) -- Documentation - using Gradle 5.0, need jcenter() in top-level dependencies block, not just buildscript - [#1420](https://github.com/detekt/detekt/issues/1420) -- Build upon default config for cli module - [#1417](https://github.com/detekt/detekt/pull/1417) -- Better wording when default config isn't up to date. - [#1416](https://github.com/detekt/detekt/pull/1416) -- UnusedPrivateClass does not consider when class is referenced via ::class.java - [#1410](https://github.com/detekt/detekt/issues/1410) -- Slight tweak to lazy task configuration. - [#1407](https://github.com/detekt/detekt/pull/1407) -- Reformat code base before 1.0 - [#1406](https://github.com/detekt/detekt/issues/1406) -- Introduce script to find and compare differences between two releases - [#1405](https://github.com/detekt/detekt/pull/1405) -- Add a section about how to integrate custom extensions into detekt - [#1403](https://github.com/detekt/detekt/pull/1403) -- Run detekt on detekt-gradle-plugin - [#1402](https://github.com/detekt/detekt/pull/1402) -- Add LabeledExpression ignore label option - [#1399](https://github.com/detekt/detekt/pull/1399) -- Consider double colon references for class usages - Closes #1390 - [#1391](https://github.com/detekt/detekt/pull/1391) -- False positive UnusedPrivateClass when using class references - [#1390](https://github.com/detekt/detekt/issues/1390) -- Fix some issues reported by IntelliJ - [#1389](https://github.com/detekt/detekt/pull/1389) -- Minor improvements to detekt-rules - [#1388](https://github.com/detekt/detekt/pull/1388) -- False positive on UnusedImport when using 'as' and the same package - [#1385](https://github.com/detekt/detekt/issues/1385) -- Build upon default config - Closes #1248 - [#1384](https://github.com/detekt/detekt/pull/1384) -- Document api module for 1.0 - [#1382](https://github.com/detekt/detekt/pull/1382) -- false positive EmptyDefaultConstructor for annotation - [#1362](https://github.com/detekt/detekt/issues/1362) -- Update to Gradle v5 - [#1350](https://github.com/detekt/detekt/pull/1350) -- False Positive UnnecessaryApply - [#1305](https://github.com/detekt/detekt/issues/1305) -- LongMethod counts statements but not actual lines as its description says - [#1279](https://github.com/detekt/detekt/issues/1279) -- Build upon the default configuration - [#1248](https://github.com/detekt/detekt/issues/1248) - -See all issues at: [RC13](https://github.com/detekt/detekt/milestone/3) - -#### RC12 - -##### Changelog - -- Actually print the exception message next to the stacktrace - [#1378](https://github.com/detekt/detekt/pull/1378) -- Added support for JSR test infrastructure in documentation ruleset - [#1377](https://github.com/detekt/detekt/pull/1377) -- Actually load the manifest to report detekt's version - [#1376](https://github.com/detekt/detekt/pull/1376) -- fix typo - [#1374](https://github.com/detekt/detekt/pull/1374) -- Drop JDK 9 & 10 from CI - [#1371](https://github.com/detekt/detekt/pull/1371) -- Add EqualsOnSignatureLine - [#1370](https://github.com/detekt/detekt/pull/1370) -- Do not add +1 complexity for nested functions inside functions - [#1365](https://github.com/detekt/detekt/pull/1365) -- Do not report expect'ed annotation classes with an empty constructor … - [#1364](https://github.com/detekt/detekt/pull/1364) -- Add more talks mentioning detekt - [#1363](https://github.com/detekt/detekt/pull/1363) -- false positive EmptyDefaultConstructor for annotation - [#1362](https://github.com/detekt/detekt/issues/1362) -- Mention published url change in the migration guide - [#1361](https://github.com/detekt/detekt/pull/1361) -- Support multiple it refs in UnnecessaryLet (#1359) - [#1360](https://github.com/detekt/detekt/pull/1360) -- Allow multiple 'it' references in UnnecessaryLet - [#1359](https://github.com/detekt/detekt/issues/1359) -- Fix link to contributing guideline in PR template - [#1358](https://github.com/detekt/detekt/pull/1358) -- Updated groovydsl version doc - [#1353](https://github.com/detekt/detekt/pull/1353) -- gradle plugin min gradle version - [#1352](https://github.com/detekt/detekt/issues/1352) -- Hide dev flags in CLI - [#1351](https://github.com/detekt/detekt/pull/1351) -- Filter wildcards for type references as they can be null - Closes #1345 - [#1349](https://github.com/detekt/detekt/pull/1349) -- I can't please detekt and/or ktlint with the following - what's kotlin idiomatic approach - [#1348](https://github.com/detekt/detekt/issues/1348) -- False positive UnusedPrivateClass in RC11 - [#1347](https://github.com/detekt/detekt/issues/1347) -- UnusedPrivateClass check led to an exception - [#1345](https://github.com/detekt/detekt/issues/1345) -- Added support for JSR test infrasture in performance ruleset - [#1343](https://github.com/detekt/detekt/pull/1343) -- Added SwallowedException ignore type config - [#1342](https://github.com/detekt/detekt/pull/1342) -- RC10 not published? - [#1339](https://github.com/detekt/detekt/issues/1339) -- Allow to exclude labeled return statements - #1317 - [#1336](https://github.com/detekt/detekt/pull/1336) -- Updated kotlin version to 1.3.10 - [#1332](https://github.com/detekt/detekt/pull/1332) -- Don't publish Gradle plugin to Bintray - [#1161](https://github.com/detekt/detekt/pull/1161) -- ComplexMethod false positive for returning anonymous inner class - [#1037](https://github.com/detekt/detekt/issues/1037) - -See all issues at: [RC12](https://github.com/detekt/detekt/milestone/41) - -#### RC11 - -##### Migration - -- The --input parameter is no longer required. If it is missing, the current working directory is used instead. - -##### Changelog - -- Update docs dependencies due to security issues - [#1337](https://github.com/detekt/detekt/pull/1337) -- Fixes #1319 - false positive for UnusedImports - [#1335](https://github.com/detekt/detekt/pull/1335) -- Update appveyor.yml to support jdk11 - [#1334](https://github.com/detekt/detekt/pull/1334) -- Updated ObjectPropertyNaming privatePropertyPattern - fixes #1331 - [#1333](https://github.com/detekt/detekt/pull/1333) -- ObjectPropertyNaming defaults do not match Kotlin style guide - [#1331](https://github.com/detekt/detekt/issues/1331) -- Supports @this expr in extension functions - [#1328](https://github.com/detekt/detekt/pull/1328) -- Added first prototype for compiling test snippets - [#1327](https://github.com/detekt/detekt/pull/1327) -- Swallowed exception update - [#1326](https://github.com/detekt/detekt/pull/1326) -- Removed todo without description - [#1323](https://github.com/detekt/detekt/pull/1323) -- Added tests for excludeClassPattern in NamingRules - [#1322](https://github.com/detekt/detekt/pull/1322) -- Ignores interfaces in NestedClassesVisibility - fixes #1075 - [#1321](https://github.com/detekt/detekt/pull/1321) -- False positive for UnusedImports - [#1319](https://github.com/detekt/detekt/issues/1319) -- Option to only build reports on failure - [#1318](https://github.com/detekt/detekt/issues/1318) -- Update detekt-gradle-plugin version - [#1315](https://github.com/detekt/detekt/pull/1315) -- Ignore TooGenericExceptionCaught by default for tests. - [#1312](https://github.com/detekt/detekt/pull/1312) -- Update README with "detektPlugins" configuration. - [#1311](https://github.com/detekt/detekt/pull/1311) -- Add license scan report and status - [#1310](https://github.com/detekt/detekt/pull/1310) -- New Rule: UnusedPrivateClass - [#1309](https://github.com/detekt/detekt/pull/1309) -- Use current working directory if --input parameter is not specified. - [#1308](https://github.com/detekt/detekt/pull/1308) -- Set current directory as default input path - [#1301](https://github.com/detekt/detekt/issues/1301) - -See all issues at: [RC11](https://github.com/detekt/detekt/milestone/40) - -#### RC10 - -##### Migration - -The configurations in the Detekt Gradle Plugin have changed to align the Plugin further with other -static analysis plugins. Similar to FindBugs the Detekt Gradle Plugin now defines two configurations: -`detekt` and `detektPlugins`. -- `detekt` is now used to define detekt dependencies such as the `detekt-cli`. -- `detektPlugins` is used to define custom detekt RuleSets and rules such as the `detekt-formatting` -rules - -To define custom detekt extensions or to add the `detekt-formatting` rules you will now have to -define them as: - -```kotlin -dependencies { - detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:[version]") - detektPlugins("your.custom.detekt.rules:rules:[version]") -} -``` - -The report id `plain` has been renamed to `txt`. If you were using `--report "plain:/tmp/plaintxt"` before it's now `--report "txt:/tmp/plaintxt"`. - -The `--filters` argument no longer checks on the absolute path of files, but rather relative paths to the project root. - - -The published url changed slightly. So users using the old way of applying plugins need to change their gradle setup: -``` -buildscript { - repositories { - jcenter() - maven { url "https://plugins.gradle.org/m2/" } - } - dependencies { - // https://mvnrepository.com/artifact/gradle.plugin.io.gitlab.arturbosch.detekt/detekt-gradle-plugin - // for version <= 1.0.0.RC9.2 - classpath "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:[version]" - // https://mvnrepository.com/artifact/io.gitlab.arturbosch.detekt/detekt-gradle-plugin?repo=gradle-plugins - // for version >= 1.0.0-RC10 - classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:[version]" - } -} - -apply plugin: "io.gitlab.arturbosch.detekt" -``` - - -##### Changelog - -- Update regex for private properties in ObjectPropertyNaming to be on pare with intellij - [#1303](https://github.com/detekt/detekt/pull/1303) -- Get rid of jdk classes - [#1302](https://github.com/detekt/detekt/pull/1302) -- Clarification on Use Cases/Limitations - [#1300](https://github.com/detekt/detekt/issues/1300) -- Drop kotlin-dsl plugin from detekt-gradle-plugin - [#1298](https://github.com/detekt/detekt/pull/1298) -- Ask for Gradle version with bug reports - [#1297](https://github.com/detekt/detekt/pull/1297) -- Upgrade to Kotlin 1.3.0 - [#1296](https://github.com/detekt/detekt/pull/1296) -- Ignore FunctionMaxLength by default for tests. - [#1293](https://github.com/detekt/detekt/pull/1293) -- Typealiases for RuleId and RuleSetId - [#1292](https://github.com/detekt/detekt/pull/1292) -- Generate test coverage report and upload to Codecov - [#1291](https://github.com/detekt/detekt/pull/1291) -- Drop FunctionMinLength & FunctionMaxLength - [#1290](https://github.com/detekt/detekt/issues/1290) -- Fix a simple typo in TooManyFunctions rule's description text - [#1289](https://github.com/detekt/detekt/pull/1289) -- [WIP] [POC] Config based aliases - [#1287](https://github.com/detekt/detekt/pull/1287) -- Question: drop kotlin-dsl dependency from Gradle plugin? - [#1286](https://github.com/detekt/detekt/issues/1286) -- Add test coverage report for detekt project - [#1285](https://github.com/detekt/detekt/issues/1285) -- Add test case for reported false positive - #1264 - [#1284](https://github.com/detekt/detekt/pull/1284) -- Depend on open jdk and include openjdk11 - [#1282](https://github.com/detekt/detekt/pull/1282) -- Drop rules that ktlint implements - [#1281](https://github.com/detekt/detekt/issues/1281) -- Readd missing `detekt-rules` dependency for cli to avoid NOP detekt run - [#1280](https://github.com/detekt/detekt/pull/1280) -- Change the way we locate and filter Rules - [#1278](https://github.com/detekt/detekt/issues/1278) -- Gradle plugin: print path reports in output - [#1277](https://github.com/detekt/detekt/issues/1277) -- MagicNumber: Allow 300 by default. - [#1275](https://github.com/detekt/detekt/pull/1275) -- Added tests for PropertyNaming rules - [#1274](https://github.com/detekt/detekt/pull/1274) -- Updated MethodOverloading message - fixed #1223 - [#1273](https://github.com/detekt/detekt/pull/1273) -- Show error messages for unused properties distinguish (#1243) - [#1272](https://github.com/detekt/detekt/pull/1272) -- No BuildFailure for create-baseline - [#1271](https://github.com/detekt/detekt/pull/1271) -- Add rule for detecting arrays of primitive types in function parameters - [#1270](https://github.com/detekt/detekt/pull/1270) -- Split UnnecessaryApply tests - [#1269](https://github.com/detekt/detekt/pull/1269) -- Consider variable to be this prefixed - Closes #1257 - [#1268](https://github.com/detekt/detekt/pull/1268) -- Remove duplicate configurations for reports. - [#1267](https://github.com/detekt/detekt/pull/1267) -- Update ktlint - [#1266](https://github.com/detekt/detekt/pull/1266) -- [Gradle] Don't fail the build if baseline file is missing - [#1265](https://github.com/detekt/detekt/issues/1265) -- false positive unused import - [#1264](https://github.com/detekt/detekt/issues/1264) -- Remove unused baseline - [#1263](https://github.com/detekt/detekt/pull/1263) -- detektBaseline task returns failure on success - [#1261](https://github.com/detekt/detekt/issues/1261) -- Fix formatting issues - [#1259](https://github.com/detekt/detekt/pull/1259) -- Fix formatting issues - [#1258](https://github.com/detekt/detekt/pull/1258) -- VarCouldBeVal false positive - [#1257](https://github.com/detekt/detekt/issues/1257) -- Use PathFilter in TestPattern to make patterns OS independent - [#1256](https://github.com/detekt/detekt/pull/1256) -- Run detekt-formatting plugin on detekt itself - [#1255](https://github.com/detekt/detekt/pull/1255) -- Travis: oraclejdk10 > openjdk10 - [#1254](https://github.com/detekt/detekt/pull/1254) -- Use detekt formatting plugin on detekt - [#1252](https://github.com/detekt/detekt/issues/1252) -- Issue with Travis build on JDK 10 - [#1251](https://github.com/detekt/detekt/issues/1251) -- Change --filters argument to only check relative paths - [#1250](https://github.com/detekt/detekt/pull/1250) -- Add missing reports {} closure in docs - [#1247](https://github.com/detekt/detekt/pull/1247) -- Removed `MaximumLineLength` - [#1246](https://github.com/detekt/detekt/pull/1246) -- Fixed #1238 - MethodOverloading false positive - [#1244](https://github.com/detekt/detekt/pull/1244) -- Improve err message for UnusedPrivateMember distinguish between property/param etc. - [#1243](https://github.com/detekt/detekt/issues/1243) -- run travis build on windows and linux - [#1241](https://github.com/detekt/detekt/pull/1241) -- AppVeyor: Disable Kotlin's incremental build support - [#1240](https://github.com/detekt/detekt/pull/1240) -- AppVeyor: Disable Kotlin incremental compilation - [#1239](https://github.com/detekt/detekt/pull/1239) -- MethodOverloading false positive if extension function for different receiver - [#1238](https://github.com/detekt/detekt/issues/1238) -- [RFC] activateAll config flag - [#1236](https://github.com/detekt/detekt/issues/1236) -- fix test-pattern to support windows path separator - [#1234](https://github.com/detekt/detekt/pull/1234) -- Exclude external functions from unused parameter check. - [#1232](https://github.com/detekt/detekt/pull/1232) -- AppVeyor: Timeout before deleting Gradle lock file - [#1231](https://github.com/detekt/detekt/pull/1231) -- AppVeyor: w: The '-d' option with a directory destination is ignored because '-Xbuild-file' is specified - [#1230](https://github.com/detekt/detekt/issues/1230) -- Add unnecessary apply rule - [#1229](https://github.com/detekt/detekt/pull/1229) -- Suppress UNUSED_PARAMETER should work as well - [#1228](https://github.com/detekt/detekt/issues/1228) -- false positive UnusedPrivateMember for external function - [#1227](https://github.com/detekt/detekt/issues/1227) -- CliArgs Doc Change - [#1225](https://github.com/detekt/detekt/pull/1225) -- MethodOverloading with wrong line - [#1223](https://github.com/detekt/detekt/issues/1223) -- create one detekt task per sourceset - [#1220](https://github.com/detekt/detekt/pull/1220) -- [WIP] AppVeyor: Save Gradle cache to the AppVeyor build cache - [#1218](https://github.com/detekt/detekt/pull/1218) -- AppVeyor fails downloading dependencies - [#1217](https://github.com/detekt/detekt/issues/1217) -- Unsafe cast is wrong - [#1216](https://github.com/detekt/detekt/issues/1216) -- Allow for additional aliases to @Suppress rules - [#1215](https://github.com/detekt/detekt/issues/1215) -- UnnecessaryApply rule - [#1214](https://github.com/detekt/detekt/issues/1214) -- Migrate JUnit tests to Spek - [#1213](https://github.com/detekt/detekt/pull/1213) -- Filters apply to absolute paths not relative paths - [#1212](https://github.com/detekt/detekt/issues/1212) -- fix gradle plugin link - [#1211](https://github.com/detekt/detekt/pull/1211) -- fix gradle plugin link - [#1210](https://github.com/detekt/detekt/pull/1210) -- Build: build detekt-cli before running detekt tasks - [#1207](https://github.com/detekt/detekt/pull/1207) -- [gradle plugin] test code refactoring - [#1205](https://github.com/detekt/detekt/pull/1205) -- Revert "Re-add additional empty check for report paths" - [#1204](https://github.com/detekt/detekt/pull/1204) -- Add new style multi-option issue templates - [#1203](https://github.com/detekt/detekt/pull/1203) -- clarify error message in verify documentation task - [#1202](https://github.com/detekt/detekt/pull/1202) -- Documentation verification requires committing changes but that's not clear - [#1199](https://github.com/detekt/detekt/issues/1199) -- Rule `Explicit it lambda parameter` - [#1197](https://github.com/detekt/detekt/pull/1197) -- Do not detect parameter name violations in overridden function - [#1196](https://github.com/detekt/detekt/pull/1196) -- Fatal error on the android project - Unable to find method 'org.gradle.api.tasks.TaskContainer.register - [#1195](https://github.com/detekt/detekt/issues/1195) -- [gradle-plugin] use lazy evaluation of properties - [#1194](https://github.com/detekt/detekt/pull/1194) -- Implement lazy configuration for Gradle plugin - [#1193](https://github.com/detekt/detekt/issues/1193) -- Revert "Revert "Update dependencies"" - [#1192](https://github.com/detekt/detekt/pull/1192) -- Revert "Update dependencies" - [#1191](https://github.com/detekt/detekt/pull/1191) -- Change PathSensitivity to RELATIVE - [#1190](https://github.com/detekt/detekt/pull/1190) -- Use new GitHub Issue Templates - [#1189](https://github.com/detekt/detekt/issues/1189) -- remove gitlab CI config - [#1188](https://github.com/detekt/detekt/pull/1188) -- explicitly give KtTestCompiler a filename ending in .kt - [#1187](https://github.com/detekt/detekt/pull/1187) -- make OptionalUnit ignore functions in interfaces - [#1186](https://github.com/detekt/detekt/pull/1186) -- update kotlin to v1.2.71 - [#1185](https://github.com/detekt/detekt/pull/1185) -- Rename Plain reporting to Txt. - [#1184](https://github.com/detekt/detekt/pull/1184) -- Allow importing just detekt-gradle-plugin into IDE - [#1183](https://github.com/detekt/detekt/pull/1183) -- Update dependencies - [#1182](https://github.com/detekt/detekt/pull/1182) -- Gradle Plugin: If tasks are configured eagerly configuration from DetektExtension isn't used - [#1181](https://github.com/detekt/detekt/issues/1181) -- Fix build failing to compile on master - [#1180](https://github.com/detekt/detekt/pull/1180) -- Master is broken - [#1179](https://github.com/detekt/detekt/issues/1179) -- Detekt should not use PathSensitivity.ABSOLUTE for Detekt task - [#1178](https://github.com/detekt/detekt/issues/1178) -- Re-remove kotlin-reflect dependency - [#1177](https://github.com/detekt/detekt/pull/1177) -- OptionalUnit triggers on a default method in an interface - [#1176](https://github.com/detekt/detekt/issues/1176) -- FunctionParameterNaming false positive - [#1175](https://github.com/detekt/detekt/issues/1175) -- Migrate all assertions to AssertJ - [#1174](https://github.com/detekt/detekt/pull/1174) -- rename configurations of Gradle Plugin to detekt and detektPlugins - [#1173](https://github.com/detekt/detekt/pull/1173) -- CI: Test on Java 10 - [#1172](https://github.com/detekt/detekt/pull/1172) -- Gradle configuration not respecting configuration in RC9.2 - [#1171](https://github.com/detekt/detekt/issues/1171) -- Choose single assertion library and test engine - [#1170](https://github.com/detekt/detekt/issues/1170) -- ObjectPropertyNaming should to flag const properties that are not simple types - [#1167](https://github.com/detekt/detekt/issues/1167) -- Architecture Compliance Rule - [#1164](https://github.com/detekt/detekt/issues/1164) -- Fix typo on getting started docs pages - [#1163](https://github.com/detekt/detekt/pull/1163) -- Detekt Gradle Plugin Configurations - [#1162](https://github.com/detekt/detekt/issues/1162) -- Gradle Plugin Portal "latest" version incorrect - [#1159](https://github.com/detekt/detekt/issues/1159) -- In Travis CI: "0 kotlin files were analyzed." - [#1158](https://github.com/detekt/detekt/issues/1158) - -See all issues at: [RC10](https://github.com/detekt/detekt/milestone/39) - -#### RC9.2 - -##### Migration - -Please update to this bug fix version of RC9 as it contains many essential and important fixes for the new gradle plugin. -Also take a look at the migration section of RC9 if you are < RC9. - -##### Changelog - -- Revert change to ignoreNamedArguments - Closes #1115 - [#1157](https://github.com/detekt/detekt/pull/1157) -- Rename config and id of ConfigAware - [#1156](https://github.com/detekt/detekt/pull/1156) -- Add test case for parameter annotations - Closes #1115 - [#1155](https://github.com/detekt/detekt/pull/1155) -- use correct instance of valueOrDefault in FormattingRule - [#1154](https://github.com/detekt/detekt/pull/1154) -- Make `config` property in `Rule` effectively private - [#1153](https://github.com/detekt/detekt/issues/1153) -- Use correct accessor method for config in LazyRegex - [#1152](https://github.com/detekt/detekt/pull/1152) -- print test outcome for debugging during the build - [#1150](https://github.com/detekt/detekt/pull/1150) -- Fix Gradle Plugin Tests - [#1148](https://github.com/detekt/detekt/pull/1148) -- Prevent overwriting of defaultDependency detekt-cli by additional detekt dependencies - [#1147](https://github.com/detekt/detekt/pull/1147) -- Fix issue with wrong report name - [#1145](https://github.com/detekt/detekt/pull/1145) -- Set group to Detekt task - [#1144](https://github.com/detekt/detekt/pull/1144) -- Running RC9 gradlew detekt crashes with detekt-formatting included - [#1143](https://github.com/detekt/detekt/issues/1143) -- The IntelliJ IDEA plugin does not define the settings from the Gradle - [#1142](https://github.com/detekt/detekt/issues/1142) -- RC9 creates files called "C" with checkstyle tags inside - [#1141](https://github.com/detekt/detekt/issues/1141) -- Sample / demo code? - [#1140](https://github.com/detekt/detekt/issues/1140) -- Reimplement watch service - [#1139](https://github.com/detekt/detekt/pull/1139) -- RC9 not working with gradle 4.4 - [#1136](https://github.com/detekt/detekt/issues/1136) -- Fix issue when multiple input files are specified - [#1134](https://github.com/detekt/detekt/pull/1134) -- Nested functions not reported by FunctionNaming - [#1133](https://github.com/detekt/detekt/issues/1133) -- #1122/Add tests for ObjectPropertyNaming for private val overrides - [#1130](https://github.com/detekt/detekt/pull/1130) -- #1120/Ignore naming of overridden functions and properties - [#1129](https://github.com/detekt/detekt/pull/1129) -- Upload JUnit test results to AppVeyor - [#1128](https://github.com/detekt/detekt/pull/1128) -- 1125/Allow spaces in CLI filters param - [#1127](https://github.com/detekt/detekt/pull/1127) -- detektCheck starts failing - Was passed main parameter '--output' but no main parameter was defined in your arg class - [#1126](https://github.com/detekt/detekt/issues/1126) -- Spaces around separators in CLI input filters break filters - [#1125](https://github.com/detekt/detekt/issues/1125) -- HTML report created at the wrong place - [#1123](https://github.com/detekt/detekt/issues/1123) -- ObjectPropertyNaming/privatePropertyPattern not loaded from configuration - [#1122](https://github.com/detekt/detekt/issues/1122) -- Missing GitHub release & tag for RC9 - [#1121](https://github.com/detekt/detekt/issues/1121) -- FunctionNaming should exclude overridden functions - [#1120](https://github.com/detekt/detekt/issues/1120) -- Use plugin version as default Detekt version - [#1119](https://github.com/detekt/detekt/pull/1119) -- Remove hardcoded default version in Detekt Gradle Plugin - [#1118](https://github.com/detekt/detekt/issues/1118) -- Documented version not available in gradle plugins - [#1117](https://github.com/detekt/detekt/issues/1117) -- MagicNumber regression with RC9 in Annotation methods - [#1115](https://github.com/detekt/detekt/issues/1115) -- IndexOutOfBoundsException when changing --output to --report with RC9 - [#1114](https://github.com/detekt/detekt/issues/1114) -- Updated contributors list - [#1112](https://github.com/detekt/detekt/pull/1112) -- update Gradle to v4.10.1 - [#1109](https://github.com/detekt/detekt/pull/1109) -- Print stacktraces recursively - Closes #1107 - [#1108](https://github.com/detekt/detekt/pull/1108) -- Detektor doesn't print stack trace causes which makes debugging difficult - [#1107](https://github.com/detekt/detekt/issues/1107) -- Delete a bunch of files from the docs directory - [#1106](https://github.com/detekt/detekt/pull/1106) -- use KtImportDirective instead of KtImportList for ForbiddenImport - [#1105](https://github.com/detekt/detekt/pull/1105) -- Reference vcsreader repo via GrabResolver - Fixes #1101 - [#1104](https://github.com/detekt/detekt/pull/1104) -- org.vcsreader:vcsreader:1.1.0 does not exist - [#1101](https://github.com/detekt/detekt/issues/1101) - -See all issues at: [RC9.2](https://github.com/detekt/detekt/milestone/38) - -#### RC9 - -##### Migration - -You need Gradle 4.9 or higher to migrate to RC9. - -With RC9, which is the last major release candidate before 1.0.0, a new gradle plugin gets introduced. -The `detekt` extension configuration changes a bit and the concept of `profiles` was removed. -There is no `detektCheck` task anymore, just a `detekt` task which is incremental and is bound to the check task. -Now the `detekt` plugin must be applied to every project and just analyzes `Kotlin` files in the source set of this project. - -An important change is that `detekt-gradle-plugin` does not pull the latest version which is found online but has a hardcoded version by default. -This can break your current setup if you have not specified a `version = "...""` property! -Furthermore this `version` property got now removed and the new `toolVersion` property is used to specify the underlying `detekt` tool version. -This was done to be inline with other static analysis tools. - -Instead of writing -```gradle -detekt { - defaultProfile { // or profile("main") {...} - // properties - } -} -``` -we now write -```gradle -detekt { - // properties -} -``` - - If we want all our sub projects to get analyzed by detekt, something like - ```gradle - subprojects { - detekt { - // properties - } - } - ``` -can be applied to the root build file. - -A full `detekt` configuration for multi-module gradle project could look like `detekt`'s own build file. -Attention(!) this must be translated to Groovy if you do not use the Kotlin DSL. See [this page for reference](/docs/gettingstarted/gradle). -```gradle -plugins { - id("io.gitlab.arturbosch.detekt") version "[1.0.0.RC9]" -} -... -subprojects { - ... - apply { - plugin("io.gitlab.arturbosch.detekt") - ... - } - - val userHome = System.getProperty("user.home") - - detekt { - debug = true - toolVersion = usedDetektVersion - config = files( - project.rootDir.resolve("detekt-core/src/main/resources/default-detekt-config.yml"), - project.rootDir.resolve("reports/failfast.yml") - ) - filters = ".*/resources/.*,.*/build/.*" - baseline = project.rootDir.resolve("reports/baseline.xml") - - reports { - xml.enabled = true - html { - enabled = true - destination = project.rootDir.resolve("reports/detekt.html") - } - } - - idea { - path = "$userHome/.idea" - codeStyleScheme = "$userHome/.idea/idea-code-style.xml" - inspectionsProfile = "$userHome/.idea/inspect.xml" - report = "project.projectDir/reports" - mask = "*.kt" - } -} -``` - -Make sure that all properties expecting a path expect a `FileCollection` or a `File` type now. -The `config` property now explicitly tells the user that `detekt` can consume multiple configuration yaml files (config = files(...)). - -There is also a breaking change for the `detekt-cli` module which will attack custom gradle task and cli users. -The `output` and `reports` options are no longer. There is the new `--report` option which can be used multiple times to generate specific reports. -The report pattern now is `--report [report-id:path-to-store-report]`. -There are three provided output reports named: `plain`, `xml` and `html`. Custom reports can be added to leveraging the detekt extension mechanism as described on the [website](/docs/introduction/extensions). - -##### Changes - -- fix false positive in UnnecessaryParentheses - [#1098](https://github.com/detekt/detekt/pull/1098) -- remove duplicated `detekt` in readme - [#1097](https://github.com/detekt/detekt/pull/1097) -- use debug flag for printing outputs in gradle plugin - [#1096](https://github.com/detekt/detekt/pull/1096) -- update documentation to use new detekt gradle plugin - [#1095](https://github.com/detekt/detekt/pull/1095) -- remove img/ directory and link to docs images - [#1094](https://github.com/detekt/detekt/pull/1094) -- Update "Features" section of the README.md and documentation - [#1093](https://github.com/detekt/detekt/pull/1093) -- Allow to use kotlin.Any? - #1085 - [#1092](https://github.com/detekt/detekt/pull/1092) -- UnnecessaryAbstractClass: Support exclusion via Annotations. - [#1091](https://github.com/detekt/detekt/pull/1091) -- Auto deploy SNAPSHOT versions. - [#1088](https://github.com/detekt/detekt/pull/1088) -- MaxLineLength: Ignore comments that end with a long url. - [#1087](https://github.com/detekt/detekt/pull/1087) -- Move Issue template & Pull Request template into .github directory. - [#1086](https://github.com/detekt/detekt/pull/1086) -- EqualsWithHashCodeExist false positives - [#1085](https://github.com/detekt/detekt/issues/1085) -- Feature #1047 OptionalUnit - [#1084](https://github.com/detekt/detekt/pull/1084) -- Replace Regex with LazyRegex in Rules - [#1083](https://github.com/detekt/detekt/pull/1083) -- Invalid line value on TrailingWhitespace error with gradle - [#1082](https://github.com/detekt/detekt/issues/1082) -- Lazy regex evaluation on Rules - [#1080](https://github.com/detekt/detekt/pull/1080) -- Merge gradle plugin rework - [#1079](https://github.com/detekt/detekt/pull/1079) -- Fixed typo line:35 from diffently to differently - [#1076](https://github.com/detekt/detekt/pull/1076) -- Stuff RC8 - [#1074](https://github.com/detekt/detekt/pull/1074) -- Fixed #1065 - ThrowingExceptionsWithoutMessageOrCause assert - [#1073](https://github.com/detekt/detekt/pull/1073) -- re-add useJUnitPlatform - [#1071](https://github.com/detekt/detekt/pull/1071) -- MaxLineLength should ignore link only comments by default - [#1070](https://github.com/detekt/detekt/issues/1070) -- Detekt MagicNumber ignoreHashCodeFunction on by default - [#1069](https://github.com/detekt/detekt/issues/1069) -- MaxLineLength should ignore import statements by default - [#1068](https://github.com/detekt/detekt/issues/1068) -- NoTabs Ignore in strings - [#1067](https://github.com/detekt/detekt/issues/1067) -- ThrowingExceptionsWithoutMessageOrCause false positive - [#1065](https://github.com/detekt/detekt/issues/1065) -- Unknown exception thrown when running detekt - [#1064](https://github.com/detekt/detekt/issues/1064) -- Juggling between `CollapsibleIfStatements` and `ComplexCondition` - [#1063](https://github.com/detekt/detekt/issues/1063) -- Make "ComplexMethod" rule also ignore "return when" if configured - [#1062](https://github.com/detekt/detekt/pull/1062) -- Improvement #1055 MagicNumber - [#1061](https://github.com/detekt/detekt/pull/1061) -- Improvement #1056 TooGenericExceptionCaught - [#1060](https://github.com/detekt/detekt/pull/1060) -- Add ForbiddenVoid rule - [#1059](https://github.com/detekt/detekt/pull/1059) -- Forbid usage of Void - [#1058](https://github.com/detekt/detekt/issues/1058) -- DetektCheck only for git commiting files? - [#1057](https://github.com/detekt/detekt/issues/1057) -- TooGenericExceptionCaught should not be reported if the name is ignored - [#1056](https://github.com/detekt/detekt/issues/1056) -- False positive with MagicNumber on default value for parameters - [#1055](https://github.com/detekt/detekt/issues/1055) -- ComplexMethod should treat "return when" as "single when" expression when ignoring - [#1054](https://github.com/detekt/detekt/issues/1054) -- CLI description says only single config file supported - [#1053](https://github.com/detekt/detekt/issues/1053) -- Reworked NoTabs rule - [#1052](https://github.com/detekt/detekt/pull/1052) -- False positive: Unnecessary parentheses for functions with two function parameters - [#1051](https://github.com/detekt/detekt/issues/1051) -- Fixed #932 - Updated documentation for configuring detekt using kotlin-dsl - [#1050](https://github.com/detekt/detekt/pull/1050) -- Fix #1043 UtilityClassWithPublicConstructor - [#1049](https://github.com/detekt/detekt/pull/1049) -- Reworked UnconditionalJumpStatementInLoop - [#1048](https://github.com/detekt/detekt/pull/1048) -- OptionalUnit - lone Unit statement - [#1047](https://github.com/detekt/detekt/issues/1047) -- Add ParameterNaming rules for Constructors and Functions parameters - [#1046](https://github.com/detekt/detekt/pull/1046) -- Cannot generate baseline file - [#1044](https://github.com/detekt/detekt/issues/1044) -- Detekt reports classes with only constructors as UtilityClassWithPublicConstructor - [#1043](https://github.com/detekt/detekt/issues/1043) -- Fixed #1039 - Indentation and MaximumLineLength configuration paramet… - [#1042](https://github.com/detekt/detekt/pull/1042) -- RC8 patch - Updated rule config option and description - [#1041](https://github.com/detekt/detekt/pull/1041) -- Changing indentation settings is not effective - [#1039](https://github.com/detekt/detekt/issues/1039) -- Fixes Gradle plugin badge version - [#1038](https://github.com/detekt/detekt/pull/1038) -- Update LabeledExpression to support outer class refs - [#1036](https://github.com/detekt/detekt/pull/1036) -- Removed FeatureEnvy test case - [#1035](https://github.com/detekt/detekt/pull/1035) -- OptionalUnit update - [#1034](https://github.com/detekt/detekt/pull/1034) -- Fix incorrect line number in TrailingWhitespace - [#1033](https://github.com/detekt/detekt/pull/1033) -- Fix RuleProvider - [#1032](https://github.com/detekt/detekt/pull/1032) -- Update kotlin version to 1.2.60 - [#1031](https://github.com/detekt/detekt/pull/1031) -- TrailingWhitespace reports incorrect line number - [#1030](https://github.com/detekt/detekt/issues/1030) -- Tests are not run when using the CLI - [#1029](https://github.com/detekt/detekt/issues/1029) -- Fix #1027 - FunctionOnlyReturningConstant - [#1028](https://github.com/detekt/detekt/pull/1028) -- FunctionOnlyReturningConstant false positive for interfaces with default implementations - [#1027](https://github.com/detekt/detekt/issues/1027) -- Refactor ObjectPropertyNaming - [#1026](https://github.com/detekt/detekt/pull/1026) -- InstanceOfCheckForException being too general - [#1025](https://github.com/detekt/detekt/pull/1025) -- Add serialVersionUID to UnusedPrivateMember.allowedNames - [#1024](https://github.com/detekt/detekt/pull/1024) -- Ignore tabs in raw strings (""") for NoTabs? - [#1023](https://github.com/detekt/detekt/issues/1023) -- InstanceOfCheckForException being too general - [#1022](https://github.com/detekt/detekt/issues/1022) -- How to run "autoCorrect" - [#1021](https://github.com/detekt/detekt/issues/1021) -- Fix typo in KDoc of UnnecessaryAbstractClass - [#1020](https://github.com/detekt/detekt/pull/1020) -- Windows 10 : getting error while configuring detekt plugin - [#1019](https://github.com/detekt/detekt/issues/1019) -- Analyze issue #1014 - [#1018](https://github.com/detekt/detekt/pull/1018) -- Mr/gradle classes - [#1017](https://github.com/detekt/detekt/pull/1017) -- Change description of TopLevelPropertyNaming rule - [#1015](https://github.com/detekt/detekt/pull/1015) -- 'super.visitNamedDeclaration()' is not invoked in the short-circuit case - [#1014](https://github.com/detekt/detekt/issues/1014) -- Replace // with # in yaml code - [#1013](https://github.com/detekt/detekt/pull/1013) -- Activate rules in failfast.yml part3 - [#1004](https://github.com/detekt/detekt/pull/1004) -- UnnecessaryParentheses: Allow to use parenthesis when in math expression with mixed operators - [#969](https://github.com/detekt/detekt/issues/969) -- 1.0.0-RC7-2 is not published to gradlePluginPortal() - [#967](https://github.com/detekt/detekt/issues/967) - -See all issues at: [RC9](https://github.com/detekt/detekt/milestone/36) - -#### RC8 - -- Prepare rc8 - [#1011](https://github.com/detekt/detekt/pull/1011) -- Feature 'aliases documentation' - [#1008](https://github.com/detekt/detekt/pull/1008) -- Add another missing space - [#1006](https://github.com/detekt/detekt/pull/1006) -- Add a missing space - [#1005](https://github.com/detekt/detekt/pull/1005) -- Add prefix wildcard to SplitPattern - [#1002](https://github.com/detekt/detekt/pull/1002) -- Specify both prefix and suffix wildcard for ForbiddenImport pattern - [#1001](https://github.com/detekt/detekt/issues/1001) -- Flag empty nested functions - fixes #998 - [#999](https://github.com/detekt/detekt/pull/999) -- EmptyFunctionBlock should flag empty functions defined inside other functions - [#998](https://github.com/detekt/detekt/issues/998) -- UnusedImports: Add test for inner classes in same package - [#997](https://github.com/detekt/detekt/pull/997) -- Refactor ProfileStorage to be no singleton anymore - Fixes #980 - [#996](https://github.com/detekt/detekt/pull/996) -- Fix false positive lambda in constructor call - Fixes #990 - [#995](https://github.com/detekt/detekt/pull/995) -- Fix magic number report for named constructor calls - Fixes #992 - [#994](https://github.com/detekt/detekt/pull/994) -- magic number ignoreNamedArgument not working with inheriting abstract class - [#992](https://github.com/detekt/detekt/issues/992) -- Fix to work on maven multi-module project - [#991](https://github.com/detekt/detekt/pull/991) -- False positive UnnecessaryParentheses on constructors with lambdas - [#990](https://github.com/detekt/detekt/issues/990) -- UnusedImports: Add detection of imports in same package - [#989](https://github.com/detekt/detekt/pull/989) -- Document formatting rule set - Closes #925 - [#988](https://github.com/detekt/detekt/pull/988) -- Use ktlint for selfanalysis - [#987](https://github.com/detekt/detekt/pull/987) -- Refactor UnusedImports rule - [#986](https://github.com/detekt/detekt/pull/986) -- UnusedImports: False negative when importing class in same package - [#985](https://github.com/detekt/detekt/issues/985) -- Update kotlin version to 1.2.51 - [#984](https://github.com/detekt/detekt/pull/984) -- UnusedPrivateMember rule in abstract functions - [#983](https://github.com/detekt/detekt/issues/983) -- Mention --run-rule option and get_analysis_projects script - [#982](https://github.com/detekt/detekt/pull/982) -- Activate rules in failfast.yml part2 - [#981](https://github.com/detekt/detekt/pull/981) -- Detekt RC 7-3 checks the wrong Gradle module - [#980](https://github.com/detekt/detekt/issues/980) -- Add `aliases` to rules' documentations - [#979](https://github.com/detekt/detekt/issues/979) -- New rule: VarCouldBeVal - [#978](https://github.com/detekt/detekt/pull/978) -- Fix ExpressionBodySyntax when multiline expression - [#977](https://github.com/detekt/detekt/pull/977) -- ExpressionBodySyntax: false positive with includeLineWrapping in multiline expression - [#976](https://github.com/detekt/detekt/issues/976) -- Activate rules in failfast.yml - [#975](https://github.com/detekt/detekt/pull/975) -- UnusedPrivateMember: do not report unused parameters in abstract/open functions - [#973](https://github.com/detekt/detekt/pull/973) -- UnusedPrivateMember: Incorrectly reports unused params in open/abstract functions - [#972](https://github.com/detekt/detekt/issues/972) -- Use detekt 7-3 in self analysis - [#971](https://github.com/detekt/detekt/pull/971) -- UnnecessaryParentheses false positive when using extension function with default parameter - [#927](https://github.com/detekt/detekt/issues/927) -- Running ktlint formatting on every build - [#823](https://github.com/detekt/detekt/issues/823) - -See all issues at: [RC8](https://github.com/detekt/detekt/milestone/37) - -#### RC7-3 - -- UnusedPrivateMember: detect top level declarations - [#968](https://github.com/detekt/detekt/pull/968) -- Support suppression of single instances of MaxLineLength violations - [#966](https://github.com/detekt/detekt/pull/966) -- Fix SerialVersionUIDInSerializableClass when value's less then zero #964 - [#965](https://github.com/detekt/detekt/pull/965) -- SerialVersionUIDInSerializableClass reports when const value less then true - [#964](https://github.com/detekt/detekt/issues/964) -- Fixed #960 - private properties naming report - [#963](https://github.com/detekt/detekt/pull/963) -- Allow "All" in @Suppress statements - [#962](https://github.com/detekt/detekt/pull/962) -- TopLevelPropertyNaming description reports wrong regex with private properties - [#960](https://github.com/detekt/detekt/issues/960) -- Migrate detekt-formatting/build.gradle to Kotlin DSL - [#958](https://github.com/detekt/detekt/pull/958) -- Allow maxLines option for ExpressionBodySyntax - [#957](https://github.com/detekt/detekt/issues/957) -- Updated kotlin compiler to version 1.2.50 - [#956](https://github.com/detekt/detekt/pull/956) -- WildcardImport: Remove one force unwrap and reuse it from let function - [#955](https://github.com/detekt/detekt/pull/955) -- Use native junitPlatform from gradle 4.6 - [#953](https://github.com/detekt/detekt/pull/953) -- Fix #950 ExpressionBodySyntax - [#952](https://github.com/detekt/detekt/pull/952) -- Gradle native junitplatform in detekt gradle plugin project - [#951](https://github.com/detekt/detekt/pull/951) -- Prepare RC7-3 release - [#949](https://github.com/detekt/detekt/pull/949) -- Rule: find unused private top level properties, constants or functions - [#948](https://github.com/detekt/detekt/issues/948) -- Suppress undocumented classes in dokka - [#947](https://github.com/detekt/detekt/pull/947) -- Do not crash on rule exceptions - #793 #944 - [#946](https://github.com/detekt/detekt/pull/946) -- Provide signing config for bintray - #345 - [#945](https://github.com/detekt/detekt/pull/945) -- Exclude private functions for TooManyFunctions rule - [#943](https://github.com/detekt/detekt/issues/943) -- Add a space between two words - [#942](https://github.com/detekt/detekt/pull/942) -- MaybeConst tests - [#938](https://github.com/detekt/detekt/pull/938) -- Respect string interpolation - Closes #808 - [#937](https://github.com/detekt/detekt/pull/937) - -See all issues at: [RC7-3](https://github.com/detekt/detekt/milestone/35) - -#### RC7-2 - -- Generate javadocJar for maven central publishing - #345 - [#934](https://github.com/detekt/detekt/pull/934) -- TooManyFunctions : Add option to ignore private functions - [#933](https://github.com/detekt/detekt/pull/933) -- Fixed some IntelliJ inspection warnings in test cases - [#931](https://github.com/detekt/detekt/pull/931) -- Fixed MayBeConst false negative when concatenating strings #900 - [#930](https://github.com/detekt/detekt/pull/930) -- Remove #807 workaround - [#929](https://github.com/detekt/detekt/pull/929) -- Fix divergent issues with UnsafeCasts rule on windows - Closes #926 - [#928](https://github.com/detekt/detekt/pull/928) -- Divergent behaviour for UnsafeCast rule on *nix & Windows - [#926](https://github.com/detekt/detekt/issues/926) -- Build Gradle plugin using composite build - [#924](https://github.com/detekt/detekt/pull/924) -- Extended documentation - [#923](https://github.com/detekt/detekt/issues/923) -- Don't treat 'input' and 'output' parameters to Gradle as an InputDirectory/OutputDirectory - [#922](https://github.com/detekt/detekt/pull/922) -- Build Gradle plugin using a composite build - [#920](https://github.com/detekt/detekt/issues/920) -- CI: Test Windows build on Java 9 - [#919](https://github.com/detekt/detekt/pull/919) -- CI: Improve Windows testing - [#918](https://github.com/detekt/detekt/pull/918) -- Added missing message to CollapsibleIfStatements rule - [#917](https://github.com/detekt/detekt/pull/917) -- Support more range expressions in ForEachOnRange rule - [#916](https://github.com/detekt/detekt/pull/916) -- Support more range expressions in ForEachOnRange rule (downTo, step, until etc.) - [#915](https://github.com/detekt/detekt/issues/915) -- Add rule for preferring to syntax for creating pairs - [#914](https://github.com/detekt/detekt/pull/914) -- Upgrade to Gradle 4.7 - [#913](https://github.com/detekt/detekt/pull/913) -- Style rule: Prefer to over Pair - [#912](https://github.com/detekt/detekt/issues/912) -- Add style rule for mandatory braces for control flow statements - [#911](https://github.com/detekt/detekt/pull/911) -- Applied allowedNames in UnusedPrivateMember to declarations - [#910](https://github.com/detekt/detekt/pull/910) -- UnusedPrivateMember – allowedNames is not applied to properties - [#909](https://github.com/detekt/detekt/issues/909) -- Updated StringLiteralDuplication to treat multiline string parts as 1 - [#908](https://github.com/detekt/detekt/pull/908) -- Added support for special handling in RethrowCaughtException - [#907](https://github.com/detekt/detekt/pull/907) -- RethrowCaughtException Usage - [#906](https://github.com/detekt/detekt/issues/906) -- VariableNaming not working after 1.0.0.RC5-6 - [#905](https://github.com/detekt/detekt/issues/905) -- StringLiteralDuplication - 3/3 - [toString] unclear error - [#904](https://github.com/detekt/detekt/issues/904) -- Adjust terminal output in case there's only one file. - [#903](https://github.com/detekt/detekt/pull/903) -- Updated MatchingDeclarationName with typealias - [#901](https://github.com/detekt/detekt/pull/901) -- MatchingDeclarationName with typealias - [#898](https://github.com/detekt/detekt/issues/898) -- Exclude ForEachOnRange in default config for test-pattern. - [#897](https://github.com/detekt/detekt/pull/897) -- Make website/documentation link more prominent - [#896](https://github.com/detekt/detekt/issues/896) -- Print link to html report in console on check fail - [#894](https://github.com/detekt/detekt/issues/894) -- 0 kotlin files were analyzed while running on concourse - [#889](https://github.com/detekt/detekt/issues/889) -- Link to documentation for new 'maxIssues' config property - [#887](https://github.com/detekt/detekt/issues/887) -- `./gradlew detektBaseline` fails with "Creating a baseline.xml requires the --baseline parameter to specify a path." - [#886](https://github.com/detekt/detekt/issues/886) -- Add "FunctionName" alias for suppressing "FunctionNaming" rule - [#882](https://github.com/detekt/detekt/issues/882) -- CompositeConfig does not allow forcing the default value - [#881](https://github.com/detekt/detekt/issues/881) -- False positive with OptionalAbstractKeyword - [#879](https://github.com/detekt/detekt/issues/879) - -See all issues at: [RC7-2](https://github.com/detekt/detekt/milestone/34) - -#### RC7 - -- Add functionname alias - [#884](https://github.com/detekt/detekt/pull/884) -- Make executor in detekt configurable - #862 - [#883](https://github.com/detekt/detekt/pull/883) -- Add missing ` character to exception ruleset docs - [#878](https://github.com/detekt/detekt/pull/878) -- Updated kotlinVersion to 1.2.40 - [#874](https://github.com/detekt/detekt/pull/874) -- Gradle plugin - can't run detektCheck with JDK 9 - [#873](https://github.com/detekt/detekt/issues/873) -- Adjust top level property naming to be on pair with intellij - #866 - [#872](https://github.com/detekt/detekt/pull/872) -- Splitted positve and negative test cases - [#871](https://github.com/detekt/detekt/pull/871) -- Spaces around colon - [#870](https://github.com/detekt/detekt/issues/870) -- Corrected "Allowed Maximum" message - [#868](https://github.com/detekt/detekt/pull/868) -- Ignored deprecated functions for TooManyFunctions rule - [#867](https://github.com/detekt/detekt/pull/867) -- Allow top level properties to be named as constants - [#866](https://github.com/detekt/detekt/issues/866) -- Migrate detekt-gradle-plugin/settings.gradle to Gradle DSL - [#864](https://github.com/detekt/detekt/pull/864) -- Migrate detekt-gradle-plugin/settings.gradle to Kotlin DSL - [#863](https://github.com/detekt/detekt/issues/863) -- Incorrect "Allowed Maximum" message - [#861](https://github.com/detekt/detekt/issues/861) -- Detekt task always runs on the same module - [#860](https://github.com/detekt/detekt/issues/860) -- Ignore deprecated functions for TooManyFunctions rule - [#859](https://github.com/detekt/detekt/issues/859) -- Fixes #857 - Fixes UselessPostfixExpression false positives - [#858](https://github.com/detekt/detekt/pull/858) -- UselessPostfixExpression false positives - [#857](https://github.com/detekt/detekt/issues/857) -- Additional cli options for printing AST's and running single rules - [#856](https://github.com/detekt/detekt/pull/856) -- Implement detekt-formatting, a wrapper over ktlint - [#855](https://github.com/detekt/detekt/pull/855) -- detekt-cli tests - [#851](https://github.com/detekt/detekt/pull/851) -- Splitted test cases for NamingRulesSpec - [#850](https://github.com/detekt/detekt/pull/850) -- Added option to exclude comments from MaxLineLength - [#849](https://github.com/detekt/detekt/pull/849) -- Allow underscore as ignored exception name in EmptyCatchBlock - [#848](https://github.com/detekt/detekt/pull/848) -- Implement script to download given analysis projects - [#847](https://github.com/detekt/detekt/pull/847) -- Set up pipeline to test new detekt rules/features on selected kotlin projects - [#846](https://github.com/detekt/detekt/issues/846) -- Add dependencies for gradle plugin (for custom rules) - [#845](https://github.com/detekt/detekt/pull/845) -- Should ObjectPropertyNaming have a constantPattern? - [#844](https://github.com/detekt/detekt/issues/844) -- VariableMinLength is in the wrong category - [#843](https://github.com/detekt/detekt/issues/843) -- MatchingDeclarationName behavior results in false positives. - [#841](https://github.com/detekt/detekt/issues/841) -- Fix false positives in unused private members - [#840](https://github.com/detekt/detekt/pull/840) -- Use absolute paths in console output to make them clickable - [#839](https://github.com/detekt/detekt/pull/839) -- [Console Output] Change all file paths from relative to absolute - [#838](https://github.com/detekt/detekt/issues/838) -- False positive for UnnecessaryParentheses - [#836](https://github.com/detekt/detekt/issues/836) -- Fixed #783 - OptionalAbstractKeyword false positive - [#835](https://github.com/detekt/detekt/pull/835) -- Added rule debt to documentation - [#834](https://github.com/detekt/detekt/pull/834) -- Update mention of git commit hook in CONTRIBUTING.md - [#833](https://github.com/detekt/detekt/pull/833) -- Do not write deprecated build fail properties to default config file - [#831](https://github.com/detekt/detekt/pull/831) -- Fix debt reporting in console report - [#830](https://github.com/detekt/detekt/pull/830) -- Update kotlin to v1.2.31 - [#829](https://github.com/detekt/detekt/pull/829) -- Build depends on a full download of IntelliJ - [#827](https://github.com/detekt/detekt/issues/827) -- Extract intellij plugin to its own repository - [#826](https://github.com/detekt/detekt/pull/826) -- Updates Readme with corrected links to RuleSets documentation - [#825](https://github.com/detekt/detekt/pull/825) -- Added threshold change to changelog - [#824](https://github.com/detekt/detekt/pull/824) -- Threshold changed when updating from RC6-3 to RC6-4 - [#822](https://github.com/detekt/detekt/issues/822) -- Migrate detekt/build.gradle to kotlin dsl - [#821](https://github.com/detekt/detekt/pull/821) -- Migrate detekt-sample-extensions/build.gradle to kotlin dsl - [#820](https://github.com/detekt/detekt/pull/820) -- Fixed #816 - webpage documentation generator - [#819](https://github.com/detekt/detekt/pull/819) -- NestedClassesVisibility doesn't detect violation for object - [#817](https://github.com/detekt/detekt/pull/817) -- potential-bugs web page is broken - [#816](https://github.com/detekt/detekt/issues/816) -- Commit hook - [#815](https://github.com/detekt/detekt/pull/815) -- NestedClassesVisibility doesn't detect violation for "object" - [#814](https://github.com/detekt/detekt/issues/814) -- UnusedPrivateMember false positives - [#812](https://github.com/detekt/detekt/issues/812) -- deprecation message is printed even when warningThreshold and failThreshold are not used - [#811](https://github.com/detekt/detekt/issues/811) -- Added naming ruleset to RC6-3 migration guide - [#810](https://github.com/detekt/detekt/pull/810) -- 1.0.0.RC6-3 changelog migration block is incomplete - [#809](https://github.com/detekt/detekt/issues/809) -- Add Novoda static analysis plugin to readme - [#806](https://github.com/detekt/detekt/pull/806) -- Added filepath to console output when generating reports - [#805](https://github.com/detekt/detekt/pull/805) -- Updated EmptyFunctionBlock rule - [#804](https://github.com/detekt/detekt/pull/804) -- Updated debt report - [#803](https://github.com/detekt/detekt/pull/803) -- When generating reports it would be nice if the path would be printed out as well - [#801](https://github.com/detekt/detekt/issues/801) -- False negatives for EmptyFunctionBlock with overridden functions - [#800](https://github.com/detekt/detekt/issues/800) -- Updated rule debt values - [#776](https://github.com/detekt/detekt/pull/776) -- WIP: Detekt IntelliJ Plugin - [#773](https://github.com/detekt/detekt/pull/773) - -See all issues at: [RC7](https://github.com/detekt/detekt/milestone/32) - -#### RC6-4 - -- NoSuchElementException when running from build.gradle.kts - [#793](https://github.com/detekt/detekt/issues/793) -- No files analysed if path contains test - [#792](https://github.com/detekt/detekt/issues/792) -- Does detekt include copy/paste detector ? - [#789](https://github.com/detekt/detekt/issues/789) -- @Suppress("MaxLineLength") at file-level doesn't work - [#788](https://github.com/detekt/detekt/issues/788) -- Update test dependencies and publish versions - [#787](https://github.com/detekt/detekt/pull/787) -- Bitrise step to run detekt - [#785](https://github.com/detekt/detekt/issues/785) -- Add no tabs rule - [#782](https://github.com/detekt/detekt/pull/782) -- Added test case for EmptyCatchBlock rule - [#781](https://github.com/detekt/detekt/pull/781) -- Add trailing whitespace rule - [#780](https://github.com/detekt/detekt/pull/780) -- EmptyCatchBlock.allowedExceptionNameRegex doesn't seem to be useful - [#779](https://github.com/detekt/detekt/issues/779) -- Incorrect behavior for EqualsAlwaysReturnsTrueOrFalse - [#778](https://github.com/detekt/detekt/issues/778) -- Thresholds rework - [#774](https://github.com/detekt/detekt/pull/774) -- Implemented EndOfSentenceFormat to support urls as last argument - [#772](https://github.com/detekt/detekt/pull/772) -- Fixed report of unnecessary parentheses when assigning a lambda to a val - [#770](https://github.com/detekt/detekt/pull/770) -- TopLevelPropertyNaming ease UPPER_CASE notation on vals - [#769](https://github.com/detekt/detekt/issues/769) -- EndOfSentenceFormat does not work well with urls. - [#768](https://github.com/detekt/detekt/issues/768) -- UnnecessaryParentheses false positive when copying with a function - [#767](https://github.com/detekt/detekt/issues/767) -- Added excludeClassPattern for VariableNaming rule - [#765](https://github.com/detekt/detekt/pull/765) -- Add class name exclusion or pattern exclusion for VariableNaming rule - [#764](https://github.com/detekt/detekt/issues/764) -- update kotlin to v1.2.30 - [#763](https://github.com/detekt/detekt/pull/763) -- update gradle to v4.6 - [#762](https://github.com/detekt/detekt/pull/762) -- Remove useTabs from sample Maven config in README - [#761](https://github.com/detekt/detekt/pull/761) -- Change exceptions property to throwable - #109 - [#760](https://github.com/detekt/detekt/pull/760) -- Overriding defaults throws java.util.ConcurrentModificationException - [#758](https://github.com/detekt/detekt/issues/758) -- Rule: Unnecessary brackets - [#756](https://github.com/detekt/detekt/issues/756) -- What do you think about making configuration type safe? - [#755](https://github.com/detekt/detekt/issues/755) -- 0 kotlin files were analyzed Android Setup. - [#754](https://github.com/detekt/detekt/issues/754) -- Space before curly brackets - [#753](https://github.com/detekt/detekt/issues/753) -- Fix in yaml syntax - [#752](https://github.com/detekt/detekt/pull/752) -- Added ignoreSingleWhenExpression config for ComplexMethod rule - [#750](https://github.com/detekt/detekt/pull/750) -- Generate documentation inside website folder - [#746](https://github.com/detekt/detekt/pull/746) -- Removed obsolete OptionalReturnKeyword rule - [#745](https://github.com/detekt/detekt/pull/745) -- add task inputs/outputs to detektCheck task - [#743](https://github.com/detekt/detekt/pull/743) -- define inputs/outputs for detekt-generator task - [#742](https://github.com/detekt/detekt/pull/742) -- Fixes for .kts files - [#741](https://github.com/detekt/detekt/pull/741) -- EqualsAlwaysReturnsTrueOrFalse for multiple returns - [#740](https://github.com/detekt/detekt/pull/740) -- Getting EqualsAlwaysReturnsTrueOrFalse incorrectly (I think) - [#738](https://github.com/detekt/detekt/issues/738) -- add messages to all CodeSmells - [#737](https://github.com/detekt/detekt/pull/737) -- Added allowedExceptionNameRegex config for EmptyCatchBlock - [#736](https://github.com/detekt/detekt/pull/736) -- Extend EmptyCatchBlock - [#734](https://github.com/detekt/detekt/issues/734) -- Add MayBeConst rule - [#733](https://github.com/detekt/detekt/pull/733) -- Simplify `SingleAssign` by using `lateinit` and add tests for it - [#732](https://github.com/detekt/detekt/pull/732) -- Style rule: val constants can be declared as const - [#731](https://github.com/detekt/detekt/issues/731) -- Allow aliases for rules to allow for suppression - [#730](https://github.com/detekt/detekt/pull/730) -- More idiomatic build configuration - [#729](https://github.com/detekt/detekt/pull/729) -- Ignored classes with supertype entries from UnnecessaryAbstractClass - [#728](https://github.com/detekt/detekt/pull/728) -- Handle @Suppress("UNCHECKED_CAST") for UnsafeCast rule - [#726](https://github.com/detekt/detekt/issues/726) -- The "detektCheck" Gradle task is never UP-TO-DATE - [#725](https://github.com/detekt/detekt/issues/725) -- Fixed incorrect behavior of EmptyDefaultConstructor - #723 - [#724](https://github.com/detekt/detekt/pull/724) -- EmptyDefaultConstructor incorrect behavior - [#723](https://github.com/detekt/detekt/issues/723) -- OptionalReturnKeyword incorrect behavior - [#722](https://github.com/detekt/detekt/issues/722) -- Fix message for TooGenericExceptionCaught - [#720](https://github.com/detekt/detekt/pull/720) -- Gradle plugin rework - new dsl - [#719](https://github.com/detekt/detekt/pull/719) -- Corrected documentation in EnumNaming - [#717](https://github.com/detekt/detekt/pull/717) -- EnumNaming should also allow digits - [#716](https://github.com/detekt/detekt/issues/716) -- External dependency 'detekt-cli' not found when using Gradle plugin in submodule - [#713](https://github.com/detekt/detekt/issues/713) -- Quickfixes API - [#710](https://github.com/detekt/detekt/issues/710) - -See all issues at: [RC6-4](https://github.com/detekt/detekt/milestone/33) - - -##### Migration - -- changed threshold definition (`value >= threshold` instead of `value > threshold`) -- build failure threshold properties are now deprecated in favor of the new `maxIssues` property. -- `warningThreshold` and `failThreshold` will get removed in a later release, a deprecation warning is printed to the console. - -```yaml -build: - warningThreshold: 5 // deprecated - failThreshold: 10 // deprecated - maxIssues: 10 -``` - -#### RC6-3 - -- Improve documentation of sample project - #438 - [#712](https://github.com/detekt/detekt/pull/712) -- Added tests for naming rules - [#711](https://github.com/detekt/detekt/pull/711) -- Gradle Plugin: Expose a copy of `profiles` - [#709](https://github.com/detekt/detekt/pull/709) -- update gradle to v4.5 - [#708](https://github.com/detekt/detekt/pull/708) -- EmptyClassBlock should not be reported for objects deriving from superclasses - [#707](https://github.com/detekt/detekt/issues/707) -- remove FeatureEnvy class - [#706](https://github.com/detekt/detekt/pull/706) -- Tooling: Accessing the profiles defined by the user - [#705](https://github.com/detekt/detekt/issues/705) -- make detekt-cli tests depend on updated documentation/config - [#704](https://github.com/detekt/detekt/pull/704) -- KDocStyle MultiRule with EndOfSentenceFormat Rule - [#703](https://github.com/detekt/detekt/pull/703) -- Add documentation for style rules - [#702](https://github.com/detekt/detekt/pull/702) -- Add documentation for complexity rules - [#701](https://github.com/detekt/detekt/pull/701) -- [Question] How to reference to a version of the plugin in the main project before it's even published? - [#700](https://github.com/detekt/detekt/issues/700) -- Rule: KDoc's first sentence should have a proper end - [#699](https://github.com/detekt/detekt/issues/699) -- Added documentation for naming rule set - [#697](https://github.com/detekt/detekt/pull/697) -- update kotlin to v1.2.20 - [#696](https://github.com/detekt/detekt/pull/696) -- Added `excludeAnnotatedClasses` to UseDataClass - #694 - [#695](https://github.com/detekt/detekt/pull/695) -- Consider adding `excludeAnnotatedClasses` to UseDataClass. - [#694](https://github.com/detekt/detekt/issues/694) -- Fix compliant case for UntilInsteadOfRangeTo rule - [#693](https://github.com/detekt/detekt/pull/693) -- Documentation generator truncates config descriptions - [#692](https://github.com/detekt/detekt/pull/692) -- Documentation generator truncates some configuration descriptions - [#691](https://github.com/detekt/detekt/issues/691) -- Introduce "naming" ruleset - [#690](https://github.com/detekt/detekt/pull/690) -- Sort Rules in Config & Documentation alphabetically - [#689](https://github.com/detekt/detekt/pull/689) -- Default configuration file should be sorted alphabetically - [#688](https://github.com/detekt/detekt/issues/688) -- Fix MatchingDeclarationName false positives - [#687](https://github.com/detekt/detekt/pull/687) -- MatchingDeclarationName has false positives - [#686](https://github.com/detekt/detekt/issues/686) -- UtilityClassWithPublicConstructor reports classes with delegates - [#682](https://github.com/detekt/detekt/issues/682) -- `ComplexMethod` rule question - [#680](https://github.com/detekt/detekt/issues/680) -- generator: anchor tags are lower case; TOC links to CamelCase - [#678](https://github.com/detekt/detekt/issues/678) - -See all issues at: [RC6-3](https://github.com/detekt/detekt/milestone/31) - -##### Migration - -- ATTENTION!! The default configuration now uses an alphabetical order. We apologize for any inconveniences -this might cause. -- Introduced **naming** ruleset containing - - Naming Rules (min/max length, naming regex rules, forbidden name) - - `MatchingDeclarationName` - - `MemberNameEqualsClassName` -- Fixed false positives in `UtilityClassWithPublicConstructor`, `MatchingDeclarationName` and `EmptyClassBlock` -- make sure to rerun your baseline (if you ignored some of these)! - -#### RC6-2 - -- Updates two rules to detect violated range expressions outside of loops - [#684](https://github.com/detekt/detekt/pull/684) -- Add UntilInsteadOfRangeTo rule - [#676](https://github.com/detekt/detekt/pull/676) -- Implement MatchingDeclarationName rule - [#674](https://github.com/detekt/detekt/pull/674) -- Consider adding ignoreOptionalParameters to LongParameterList - [#673](https://github.com/detekt/detekt/issues/673) -- Fix false negative reporting of non-named argument - Fixes #659 - [#672](https://github.com/detekt/detekt/pull/672) -- Change LateInitUsage to LateinitUsage in failfast.yml - [#671](https://github.com/detekt/detekt/pull/671) -- Rule: 'rangeTo' or the '..' call can be replaced with 'until' - [#670](https://github.com/detekt/detekt/issues/670) -- Treat all compiler warnings as errors - [#669](https://github.com/detekt/detekt/pull/669) -- Do not run EmptyFunctionBlock on open functions - [#667](https://github.com/detekt/detekt/pull/667) -- EmptyFunctionBlock should not flag functions with open modifier - [#666](https://github.com/detekt/detekt/issues/666) -- Do not run EmptyClassBlock on objects of anonymous classes - [#665](https://github.com/detekt/detekt/pull/665) -- MatchingDeclarationName rule to match single declaration to file name - [#664](https://github.com/detekt/detekt/issues/664) -- Rename *.yaml to *.yml so fixtures use expected line endings - [#661](https://github.com/detekt/detekt/pull/661) -- Appveyor: Use default git config - [#660](https://github.com/detekt/detekt/pull/660) -- `ignoreNamedArguments` breaks marking non-named magic number params - [#659](https://github.com/detekt/detekt/issues/659) -- Run tests on Travis on Oracle JDK 8 & 9 - [#658](https://github.com/detekt/detekt/pull/658) - -See all issues at: [RC6-2](https://github.com/detekt/detekt/milestone/30) - -##### Migration - -- The new rule `MatchingDeclarationName` is active on default. If a file has only one top-level declaration then the -file name must match the declaration name according to the jetbrains and android style guides. - -#### RC6-1 - -- Added factory function check to MemberNameEqualsClassName - [#653](https://github.com/detekt/detekt/pull/653) -- detekt generator tests - rc6 - [#650](https://github.com/detekt/detekt/pull/650) -- Rule examples improvement - [#649](https://github.com/detekt/detekt/pull/649) -- Improved documentation for rule test cases - [#648](https://github.com/detekt/detekt/pull/648) -- Apply compiler and baseline changes to work properly on java 9 - [#647](https://github.com/detekt/detekt/pull/647) -- Test coverage rc6 - [#645](https://github.com/detekt/detekt/pull/645) -- Implements #643 - MagicNumber ignores default values in ctor properties - [#644](https://github.com/detekt/detekt/pull/644) -- update gradle to v4.4.1 - [#642](https://github.com/detekt/detekt/pull/642) -- Documentation for Exceptions RuleSet - [#640](https://github.com/detekt/detekt/pull/640) -- Documentation for "emtpy" rules - [#639](https://github.com/detekt/detekt/pull/639) -- Documentation for documentation rules - [#638](https://github.com/detekt/detekt/pull/638) -- Change variable min & max length to match IntelliJ. - [#635](https://github.com/detekt/detekt/pull/635) -- Remove "native filesystem" warning on Windows - [#634](https://github.com/detekt/detekt/pull/634) -- Failed to initialize native filesystem for Windows - [#630](https://github.com/detekt/detekt/issues/630) - -See all issues at: [RC6-1](https://github.com/detekt/detekt/milestone/29) - -##### Migration - -- Running detekt under Java 9 should work again with newest Kotlin Version -- Ignores default values in constructor properties (MagicNumber) - [#644](https://github.com/detekt/detekt/pull/644) - -#### RC6 - -- Allow numbers in ClassNaming. - [#631](https://github.com/detekt/detekt/pull/631) -- Renamed MethodNameEqualsClassName to support properties - [#629](https://github.com/detekt/detekt/pull/629) -- Allow detekt to run on kts too. - [#628](https://github.com/detekt/detekt/pull/628) -- Updated kotlin compiler version - [#625](https://github.com/detekt/detekt/pull/625) -- Add TooManyFunctions to test-pattern exclude-rules by default. - [#624](https://github.com/detekt/detekt/pull/624) -- Consider adding TooManyFunctions to the test-pattern exclude-rules - [#622](https://github.com/detekt/detekt/issues/622) -- Added rule documentation to CONTRIBUTING.md - [#621](https://github.com/detekt/detekt/pull/621) -- Merged CHANGELOG.md and MIGRATION_GUIDE.md - [#620](https://github.com/detekt/detekt/pull/620) -- Do not depend on a specific project path in core classes - #605 - [#619](https://github.com/detekt/detekt/pull/619) -- Consider merging CHANGELOG.md and MIGRATION_GUIDE.md - [#618](https://github.com/detekt/detekt/issues/618) -- remove migration module - [#617](https://github.com/detekt/detekt/pull/617) -- Removed code-smell ruleset - [#616](https://github.com/detekt/detekt/pull/616) -- Remove CodeSmell RuleSet - [#615](https://github.com/detekt/detekt/issues/615) -- Remove migration module - [#614](https://github.com/detekt/detekt/issues/614) -- Allow checks on Kotlin script files (.kts) - [#612](https://github.com/detekt/detekt/issues/612) -- compliant and non-compliant code examples documentation - [#610](https://github.com/detekt/detekt/pull/610) -- Error message agrees with require condition - [#609](https://github.com/detekt/detekt/pull/609) -- False positive in ExceptionRaisedInUnexpectedLocation - [#608](https://github.com/detekt/detekt/pull/608) -- Update dependencies - [#607](https://github.com/detekt/detekt/pull/607) -- Checkout *.md, *.yml & *.html with LF line endings - [#606](https://github.com/detekt/detekt/pull/606) -- Allow --input to handle multiple paths - [#605](https://github.com/detekt/detekt/issues/605) -- update documentation after some merges to master - [#604](https://github.com/detekt/detekt/pull/604) -- README: Remove copy of default-detekt-config.yml - [#603](https://github.com/detekt/detekt/pull/603) -- HtmlOutputFormatTest tests assume Unix-style line endings - [#602](https://github.com/detekt/detekt/issues/602) -- add gradle task to assert config and documentation are generated up-to-date - [#601](https://github.com/detekt/detekt/pull/601) -- update CONTRIBUTING.md to take detekt-generator behavior into account - [#600](https://github.com/detekt/detekt/pull/600) -- ReturnCount augmented to ignore specified function names - [#599](https://github.com/detekt/detekt/pull/599) -- Add SpreadOperator to exclude-rules in test-pattern. - [#598](https://github.com/detekt/detekt/pull/598) -- update gradle to v4.4 - [#597](https://github.com/detekt/detekt/pull/597) -- DetektCli depends on kotlin-compiler-embeddable which pulls in older version of json-org-java - [#596](https://github.com/detekt/detekt/issues/596) -- Turn off comments over private function/property - #589 - [#595](https://github.com/detekt/detekt/pull/595) -- removes active mark for StringLiteralDuplication - [#594](https://github.com/detekt/detekt/pull/594) -- Replace default-detekt-config.yml with generated one - [#593](https://github.com/detekt/detekt/pull/593) -- TooManyFunctions description could be improved - [#592](https://github.com/detekt/detekt/issues/592) -- Automatically run detekt-generator on detekt-rules build task - [#590](https://github.com/detekt/detekt/pull/590) -- Add documentation to generate default config - [#589](https://github.com/detekt/detekt/pull/589) -- Add documentation in bugs rules - [#588](https://github.com/detekt/detekt/pull/588) -- Remove InterruptedException from TooGenericExceptionCaught rule - [#587](https://github.com/detekt/detekt/pull/587) -- InterruptedException is too generic - [#586](https://github.com/detekt/detekt/issues/586) -- detekt-generator code examples - [#584](https://github.com/detekt/detekt/pull/584) -- Add OutputReport implementation that generates an HTML report - [#583](https://github.com/detekt/detekt/pull/583) -- Fix my blogpost title in the README :) - [#582](https://github.com/detekt/detekt/pull/582) -- detekt-generator: content section - [#579](https://github.com/detekt/detekt/pull/579) -- README: Update description of the 'output' parameter for the Gradle plugin - [#578](https://github.com/detekt/detekt/pull/578) -- Output is a folder and not a file anymore - [#577](https://github.com/detekt/detekt/issues/577) -- add detekt-generator module to generate documentation and default config - [#563](https://github.com/detekt/detekt/pull/563) -- Add message to CodeSmell - [#480](https://github.com/detekt/detekt/pull/480) -- Generate default-detekt-config.yml according to rules - [#189](https://github.com/detekt/detekt/issues/189) - -See all issues at: [RC6](https://github.com/detekt/detekt/milestone/23) - -##### Migration - -- We are now generating documentation for all rule sets. They are stored as -markdown files and will later be hosted on the official detekt website. -- rename `MethodNameEqualsClassName` to `MemberNameEqualsClassName` (rule checks also properties now) -- `CHANGELOG.md` and `MIGRATION.md` are now merged. The changelog now has also a migration subsection. -- Numbers are now allowed in class names (aligned to IntelliJ inspections) - `ClassNaming`-Rule -- If you are using the text or xml output option of detekt, consider also the new html output format. -- The `--input` cli property now supports multiple paths separated by a comma. -- `TooManyFunctions` and `SpreadOperator` rules are turned off for test files per default. - -#### RC5-6 - -- update Kotlin to v1.1.61 - [#573](https://github.com/detekt/detekt/pull/573) -- rules-test-rc5 - [#571](https://github.com/detekt/detekt/pull/571) -- UnsafeCast: Fix in SpacingBetweenPackageImports, turn on rule, add present to baseline - [#570](https://github.com/detekt/detekt/pull/570) -- Rework naming rules to match intellij inspections - [#569](https://github.com/detekt/detekt/pull/569) -- 1.0.0-RC5-5 org.jetbrains.kotlin.psi.KtProperty cannot be cast to org.jetbrains.kotlin.psi.KtClassOrObject - [#568](https://github.com/detekt/detekt/issues/568) -- housekeeping_rules - [#565](https://github.com/detekt/detekt/pull/565) - -See all issues at: [RC5-6](https://github.com/detekt/detekt/milestone/28) - -##### Migration - -- fixed a critical bug in `SpacingBetweenPackageImports`, please update if you use this rule. -- Aligned naming conventions rules to meet intellij inspections. - - ConstantNaming got removed - - TopLevelPropertyNaming and ObjectPropertyNaming was added - - there are now configuration parameters for private properties - -```yaml - VariableNaming: - active: true - variablePattern: '[a-z][A-Za-z0-9]*' - privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' - ObjectPropertyNaming: - active: true - propertyPattern: '[A-Za-z][_A-Za-z0-9]*' - TopLevelPropertyNaming: - active: true - constantPattern: '[A-Z][_A-Z0-9]*' - propertyPattern: '[a-z][A-Za-z\d]*' - privatePropertyPattern: '(_)?[a-z][A-Za-z0-9]*' -``` - -#### RC5-5 - -- Add --plugins option to gradle plugin - Fixes #545 - [#561](https://github.com/detekt/detekt/pull/561) -- Rewrite messages and issue description for TooManyFunctions rule - #552 - [#560](https://github.com/detekt/detekt/pull/560) -- Run built snapshot also on test sources - [#559](https://github.com/detekt/detekt/pull/559) -- TooManyFunctions message can be misleading - [#552](https://github.com/detekt/detekt/issues/552) -- Added UnnecessaryAbstractClass without body detection - [#551](https://github.com/detekt/detekt/pull/551) -- UnnecessaryAbstractClass: misses class without body - [#550](https://github.com/detekt/detekt/issues/550) -- Use newer extension syntax in example for Kotlin DSL and add in expli… - [#549](https://github.com/detekt/detekt/pull/549) -- improve message of PackageDeclarationStyle - [#548](https://github.com/detekt/detekt/pull/548) -- Update to Kotlin 1.1.60 - [#546](https://github.com/detekt/detekt/pull/546) -- Using plugin rulesets in Android project - [#545](https://github.com/detekt/detekt/issues/545) - -See all issues at: [RC5-5](https://github.com/detekt/detekt/milestone/27) - -##### Migration - -- TooManyFunctions rule got a rework. Old property `threshold` was replaced with: - - `thresholdInFiles: 10` - - `thresholdInClasses: 10` - - `thresholdInInterfaces: 10` - - `thresholdInObjects: 10` - - `thresholdInEnums: 10` - -#### RC5-4 - -- Testcase refactoring - #527 - [#541](https://github.com/detekt/detekt/pull/541) -- Build improvements - [#539](https://github.com/detekt/detekt/pull/539) -- Allow throwing exceptions in init blocks - closes #537 - [#538](https://github.com/detekt/detekt/pull/538) -- ExceptionRaisedInUnexpectedLocation in constructer - [#537](https://github.com/detekt/detekt/issues/537) -- UnnecessaryAbstractClass takes primary constructor vals into account - [#535](https://github.com/detekt/detekt/pull/535) -- UnnecessaryAbstractClass does not see member variables - [#534](https://github.com/detekt/detekt/issues/534) - -See all issues at: [RC5-4](https://github.com/detekt/detekt/milestone/26) - -#### RC5-3 - -- MaxLineLengthRule line number reporting issue - [#526](https://github.com/detekt/detekt/pull/526) -- Fixed #522 - CollapsibleIf must not have a if-else child - [#525](https://github.com/detekt/detekt/pull/525) -- Implemented #523 - open function option FunctionOnlyReturningConstant - [#524](https://github.com/detekt/detekt/pull/524) - -See all issues at: [RC5-3](https://github.com/detekt/detekt/milestone/25) - -#### RC5-2 - -- Enhancement #514 - [#519](https://github.com/detekt/detekt/pull/519) -- Test cases RC5 - [#511](https://github.com/detekt/detekt/pull/511) -- Prepend project name to findings path - #171 - [#510](https://github.com/detekt/detekt/pull/510) -- Do not apply rule filters on main sources - [#509](https://github.com/detekt/detekt/pull/509) -- WildcardImport should support regex exclusions - [#506](https://github.com/detekt/detekt/issues/506) - -See all issues at: [RC5-2](https://github.com/detekt/detekt/milestone/24) - -##### Migration - -- rule filters which are defined in the `test-pattern` were applied to main sources too, this is now fixed. - -#### RC5 - -- Remove double check in condition - [#505](https://github.com/detekt/detekt/pull/505) -- Update README for failFast option - [#502](https://github.com/detekt/detekt/pull/502) -- Allow to suppress StringLiteralDuplication on class level - closes #442 - [#494](https://github.com/detekt/detekt/pull/494) -- Restrict Postfix operators to ++ and -- - closes #491 - [#493](https://github.com/detekt/detekt/pull/493) -- If formatting rule - [#489](https://github.com/detekt/detekt/pull/489) -- README: update sample output from the tool - [#488](https://github.com/detekt/detekt/pull/488) -- Remove stale rules from config files - [#487](https://github.com/detekt/detekt/pull/487) -- Minor: Use toX instead of java.lang.x.parseX - [#486](https://github.com/detekt/detekt/pull/486) -- Yml config test - [#484](https://github.com/detekt/detekt/pull/484) -- don't report UselessPostfixExpressions on fields in return expressions - [#483](https://github.com/detekt/detekt/pull/483) -- ignore "_" named variables for VariableNaming and VariableMinLength - [#482](https://github.com/detekt/detekt/pull/482) -- VariableNaming and VariableMinLength: Exclude simple Underscore from Rule - [#481](https://github.com/detekt/detekt/issues/481) -- Refactored all detekt-config tests - [#478](https://github.com/detekt/detekt/pull/478) -- Fix for #465 - [#477](https://github.com/detekt/detekt/pull/477) -- Rule:NestedClassVisibility update - [#474](https://github.com/detekt/detekt/pull/474) -- Added DetektYamlConfigTest - [#472](https://github.com/detekt/detekt/pull/472) -- Redundant modifier rule - [#470](https://github.com/detekt/detekt/pull/470) -- MethodNameEqualsClassName rule - [#469](https://github.com/detekt/detekt/pull/469) -- reword detekt timing message and use measureTimeMillis - [#468](https://github.com/detekt/detekt/pull/468) -- Processors test - [#463](https://github.com/detekt/detekt/pull/463) -- Added static declaration count to ComplexInterface - [#461](https://github.com/detekt/detekt/pull/461) -- Apply java-gradle-plugin to detekt-gradle-plugin - [#460](https://github.com/detekt/detekt/pull/460) -- Test pattern - #227 - [#459](https://github.com/detekt/detekt/pull/459) -- correcly handle imports used in KDoc tags in UnusedImports rule - [#458](https://github.com/detekt/detekt/pull/458) -- More false positive for unused imports - [#457](https://github.com/detekt/detekt/issues/457) -- Enum constant parameter flagged for MagicNumber - [#455](https://github.com/detekt/detekt/issues/455) -- remove default description of modifier order rule - [#454](https://github.com/detekt/detekt/pull/454) -- update gradle to v4.2.1 - [#453](https://github.com/detekt/detekt/pull/453) -- ModifierOrder has wrong description - [#452](https://github.com/detekt/detekt/issues/452) -- update kotlin to v1.1.51 - [#450](https://github.com/detekt/detekt/pull/450) -- Add AnnotationExcluder to be able to reuse exluding by annotation mechanism. - [#447](https://github.com/detekt/detekt/pull/447) -- Nested class, interface or enum shouldn't be publicly visible - [#446](https://github.com/detekt/detekt/pull/446) -- Nested class, interface or enum shouldn't be publicly visible - [#444](https://github.com/detekt/detekt/issues/444) -- RuleProviderTest and cleanup of test-cases - [#443](https://github.com/detekt/detekt/pull/443) -- Suppressing string duplication doesn't work - [#442](https://github.com/detekt/detekt/issues/442) -- Complexity rules: ComplexInterface + MethodOverloading - [#440](https://github.com/detekt/detekt/pull/440) -- Fixed #435 - false-positive for UseDataClass rule - [#439](https://github.com/detekt/detekt/pull/439) -- Config refactoring - [#436](https://github.com/detekt/detekt/pull/436) -- FalsePositive for UseDataClass on enum and annotation classes - [#435](https://github.com/detekt/detekt/issues/435) -- DataClassContainsFunctions - allow conversion function - [#434](https://github.com/detekt/detekt/issues/434) -- Exception rules modification - [#432](https://github.com/detekt/detekt/pull/432) -- Update FunctionNaming regex to work for sentences - [#425](https://github.com/detekt/detekt/pull/425) -- Added SerialVersionUIDInSerializableClass rule - [#424](https://github.com/detekt/detekt/pull/424) -- Update "MagicNumber" to not mark "Named Arguments" as code smells - [#415](https://github.com/detekt/detekt/issues/415) -- Support idea tasks also for windows - closes #413 - [#414](https://github.com/detekt/detekt/pull/414) -- IDEA inspections does not work under Windows - [#413](https://github.com/detekt/detekt/issues/413) -- Use the default-config.yml as default configuration - [#412](https://github.com/detekt/detekt/pull/412) -- Get warning when rule is not defined - [#407](https://github.com/detekt/detekt/issues/407) -- Remove formatting module - [#406](https://github.com/detekt/detekt/pull/406) -- Add .editorconfig - [#401](https://github.com/detekt/detekt/pull/401) -- Add a Gitter chat badge to README.md - [#400](https://github.com/detekt/detekt/pull/400) -- Correct mccabe complexity calculation - closes #396 - [#399](https://github.com/detekt/detekt/pull/399) -- Update to Gradle 4.1 - [#398](https://github.com/detekt/detekt/pull/398) -- Open gitter for easier interaction with users - [#395](https://github.com/detekt/detekt/issues/395) -- Fixed #389 in ProtectedMemberInFinalClass rule - [#392](https://github.com/detekt/detekt/pull/392) -- False positive ProtectedMemberInFinalClass - [#389](https://github.com/detekt/detekt/issues/389) -- Ignore sealed classes for UseDataClass rule check - [#387](https://github.com/detekt/detekt/pull/387) -- Use case specific descriptions in UnnecessarySuperTypeDeclaration - [#386](https://github.com/detekt/detekt/pull/386) -- Loop rules - [#385](https://github.com/detekt/detekt/pull/385) -- Test improvement - [#383](https://github.com/detekt/detekt/pull/383) -- Add additional FileProcessListener event - [#381](https://github.com/detekt/detekt/pull/381) -- Unnecessary supertype declaration - [#380](https://github.com/detekt/detekt/pull/380) -- Address some IntelliJ lint & Kotlin compiler warnings - [#378](https://github.com/detekt/detekt/pull/378) -- Do not flag empty functions which are meant to be overridden - [#376](https://github.com/detekt/detekt/pull/376) -- Deprecate formatting - [#326](https://github.com/detekt/detekt/issues/326) -- Introduce config based way of skipping certain rules for test classes - [#227](https://github.com/detekt/detekt/issues/227) - -See all issues at: [RC5](https://github.com/detekt/detekt/milestone/22) - -##### Migration - -- Formatting rule set was removed. Use the `detektIdeaFormat` task, KtLint or wait for the official kotlin format -tool which will be released soon (Hadi mentioned it in a reply to a tweet somewhere). -- McCabe calculation was corrected and can now be slightly higher which can result in unexpected `ComplexMethod` -findings. -- Instead of using a pattern like `.*/test/.*` to filter test sources, you can now specify a `test-pattern` inside a -configuration. This allows to turn off specific rules or rule sets for test sources. - -#### RC4-3 - Second bugfix release for RC4 with a bunch of new contributed rules! - -- UndocumentedPublicClass: Fix enum support - [#375](https://github.com/detekt/detekt/pull/375) -- add rule to forbid certain class names - [#374](https://github.com/detekt/detekt/pull/374) -- Tests are not executed anymore but skipped! - [#373](https://github.com/detekt/detekt/issues/373) -- Use failfast configuration in CI - [#372](https://github.com/detekt/detekt/pull/372) -- Added break and continue to unreachable code rule - [#371](https://github.com/detekt/detekt/pull/371) -- A few more exception rules - [#370](https://github.com/detekt/detekt/pull/370) -- Added UnnecessaryAbstractClass rule - [#369](https://github.com/detekt/detekt/pull/369) -- remove spaces in default-detekt-config.yml - [#368](https://github.com/detekt/detekt/pull/368) -- Advanced exception rules - [#366](https://github.com/detekt/detekt/pull/366) -- Added PackageDeclaration style rule - [#364](https://github.com/detekt/detekt/pull/364) -- Implement Data class rule - [#354](https://github.com/detekt/detekt/pull/354) -- Feature/data class rule - [#353](https://github.com/detekt/detekt/pull/353) -- Extend naming ruleset - [#302](https://github.com/detekt/detekt/issues/302) -- Data class rule - [#263](https://github.com/detekt/detekt/issues/263) - -See all issues at: [RC4-3](https://github.com/detekt/detekt/milestone/21) - -#### RC4-2 - Bugfix release for RC4 - -- Bugfix FunctionMaxLength typo - [#367](https://github.com/detekt/detekt/pull/367) -- Fixed protected member report in sealed class - [#362](https://github.com/detekt/detekt/pull/362) -- Renamed UselessIncrement to UselessPostfixExp - [#360](https://github.com/detekt/detekt/pull/360) -- Bugfix/variable max length const - [#359](https://github.com/detekt/detekt/pull/359) -- UndocumentedPublicClass: Add searchInInnerObject configuration property. - [#358](https://github.com/detekt/detekt/pull/358) -- fix link to default-detekt-config.yml in migration guide for RC4 - [#357](https://github.com/detekt/detekt/pull/357) - -See all issues at: [RC4-2](https://github.com/detekt/detekt/milestone/20) - -#### RC4 - -- Do not use reflection for toString methods - closes #349 - [#351](https://github.com/detekt/detekt/pull/351) -- Detekt Gradle plugin breaks the Gradle properties task - [#349](https://github.com/detekt/detekt/issues/349) -- Decouple KtTreeCompiler from Detektor - #341 - [#348](https://github.com/detekt/detekt/pull/348) -- fix README to mention the renamed --plugins instead of --rules - [#346](https://github.com/detekt/detekt/pull/346) -- Decouple KtTreeCompiler, KtCompiler from Detektor - [#341](https://github.com/detekt/detekt/issues/341) -- Reimplement thrown-/catched exception rules - #95 - [#334](https://github.com/detekt/detekt/pull/334) -- Reimplement throw-/catch-exception-rules as MultiRules - [#332](https://github.com/detekt/detekt/pull/332) -- remove unnecessary parentheses in the main codebase - [#330](https://github.com/detekt/detekt/pull/330) -- Added packagePattern option to config - [#329](https://github.com/detekt/detekt/pull/329) -- add rule to detect Unnecessary Parentheses - [#328](https://github.com/detekt/detekt/pull/328) -- PackagePattern in naming conventions - [#327](https://github.com/detekt/detekt/issues/327) -- align naming patterns for enum entries in rule + default config - [#325](https://github.com/detekt/detekt/pull/325) -- allow suppressing `all` - [#324](https://github.com/detekt/detekt/pull/324) -- Combine all empty block rules into one multi rule - #95 - [#322](https://github.com/detekt/detekt/pull/322) -- Refactored tests and increased coverage - [#321](https://github.com/detekt/detekt/pull/321) -- Refactor Naming rules and add Variable/Function length rules - [#320](https://github.com/detekt/detekt/pull/320) -- Added protected member in final class rule - [#317](https://github.com/detekt/detekt/pull/317) -- [Poll] Do people care about separated EmptyXXXBlock, ThrowXXX and CatchXXX rules? - [#95](https://github.com/detekt/detekt/issues/95) - -See all issues at: [RC4](https://github.com/detekt/detekt/milestone/18) - -##### Migration - -- CatchXXX and ThrowXXX rules were reimplemented and combined into TooGenericExceptionCatched and -TooGenericExceptionThrown rules. Own exceptions can be added to the list. -- EmptyXXXBlock rules were reimplemented and can be turned off individually -- The rule NamingConventions was reimplemented and now every case is separately configurable and new cases were added - -See [default-detekt-config.yml](https://github.com/detekt/detekt/blob/main/detekt-core/src/main/resources/default-detekt-config.yml) - -#### RC3 - -- Do not consider empty returns as OptionalReturnKeyword - [#314](https://github.com/detekt/detekt/pull/314) -- Added % to comment-source ratio output - [#309](https://github.com/detekt/detekt/pull/309) -- Add rules property for multirule - [#308](https://github.com/detekt/detekt/pull/308) -- Use function instead of method in descriptions and ids of CommentOver… - [#307](https://github.com/detekt/detekt/pull/307) -- update kotlin to v1.1.4 - [#306](https://github.com/detekt/detekt/pull/306) -- OptionalReturnKeyword: Fails with expressions - [#304](https://github.com/detekt/detekt/issues/304) -- Treat comment as non-empty block body - [#303](https://github.com/detekt/detekt/pull/303) -- Added StringLiteralDuplication rule - [#300](https://github.com/detekt/detekt/pull/300) -- Added naming rule for packages - [#299](https://github.com/detekt/detekt/pull/299) -- Update used detekt to RC2 - [#298](https://github.com/detekt/detekt/pull/298) -- Equals() smells - [#297](https://github.com/detekt/detekt/pull/297) - -See all issues at: [RC3](https://github.com/detekt/detekt/milestone/17) - -##### Migration - -- MagicNumber rule has now different ignore properties - -#### RC2 - -- Remove magic numbers and other detekt issues - [#295](https://github.com/detekt/detekt/pull/295) -- Ignore based on checkstyle for MagicNumber - [#289](https://github.com/detekt/detekt/pull/289) -- Revert implementation configuration in cli module - [#283](https://github.com/detekt/detekt/pull/283) -- Run cli on ci - [#282](https://github.com/detekt/detekt/pull/282) -- Variables/Properties declaring numbers shouldn't be flagged for MagicNumber - [#280](https://github.com/detekt/detekt/issues/280) -- Added UnnecessaryConversionTemporary rule - [#279](https://github.com/detekt/detekt/pull/279) -- More metrics - [#277](https://github.com/detekt/detekt/pull/277) -- MagicNumber rule throw report for null initialized variable - [#276](https://github.com/detekt/detekt/issues/276) -- Improve build setup - [#275](https://github.com/detekt/detekt/pull/275) - -See all issues at: [RC2](https://github.com/detekt/detekt/milestone/16) - -##### Migration - -- Make sure to upgrade! RC2 fixes a number of MagicNumber's issues and adds properties to make this rule more configurable. - -#### RC1 - -- Allow to override the output name of output reports - [#272](https://github.com/detekt/detekt/pull/272) -- Rewrite sample project featuring processors, reports and rule sets - [#268](https://github.com/detekt/detekt/pull/268) -- Update detekt-sample-ruleset - [#257](https://github.com/detekt/detekt/issues/257) -- Fix input flag for standalone gradle task in README - [#256](https://github.com/detekt/detekt/pull/256) -- Added rule for safe cast to config.yml - [#254](https://github.com/detekt/detekt/pull/254) -- LateInitUsage: One annotation match is enough to let the property be ignored. - [#245](https://github.com/detekt/detekt/pull/245) -- Exclude extensions by id or priority - [#243](https://github.com/detekt/detekt/issues/243) -- Plugins & Extensions - [#242](https://github.com/detekt/detekt/pull/242) -- Rule: ModifierOrder - [#239](https://github.com/detekt/detekt/pull/239) -- Added metrics for packages and kt files - [#238](https://github.com/detekt/detekt/pull/238) -- Added metrics for classes, methods and fields - [#237](https://github.com/detekt/detekt/pull/237) -- Fix --project mention in README. - [#236](https://github.com/detekt/detekt/pull/236) -- Use newest detekt with failfast profile in CI - [#234](https://github.com/detekt/detekt/pull/234) -- Added rule for safe cast instead of if-else-null - [#233](https://github.com/detekt/detekt/pull/233) -- Terminal Output customization - [#171](https://github.com/detekt/detekt/issues/171) -- Change Main.rules to something like 'jars' or 'plugins' - [#134](https://github.com/detekt/detekt/issues/134) -- FileProcessListener's should be loaded through a ServiceLoader - [#101](https://github.com/detekt/detekt/issues/101) - -See all issues at: [RC1](https://github.com/detekt/detekt/milestone/15) - -##### Migration - -- Attention: new `MagicNumber` and `ReturnCount` rules can let your CI fail -- Sample project now reflects all possible custom extensions to detekt, see `extensions` section in README -- `--output` points to a directory now. This is due the fact that many output reports can be generated at once -- Each `OutputReport` specifies a file name and ending. The parameter `--output-name` can be used to override the -default provided file name of the `OutputReport`. Unnecessary output reports for your project can be turned off in -the configuration. - -#### M13.2 - -- Always use the 'main' profile as default even if 'profile' parameter set but a profile with name 'main' exists - [#231](https://github.com/detekt/detekt/issues/231) -- Fix DetektGenerateConfigTask to use --input instead of --project. - [#230](https://github.com/detekt/detekt/pull/230) -- Run Detekt on Detekt [#212](https://github.com/detekt/detekt/pull/212) -- Extend UndocumentedPublicClass with searchInNestedClass, searchInInnerClass & searchInInnerInterface properties. - [#210](https://github.com/detekt/detekt/pull/210) - -See all issues at: [M13.2](https://github.com/detekt/detekt/milestone/14) - -#### M13.1 - -- LateinitUsage: Add ignoreOnClassesPattern property. - [#226](https://github.com/detekt/detekt/pull/226) -- Implement ForbiddenComment Rule. - [#225](https://github.com/detekt/detekt/pull/225) -- Add Excludes to WildcardImport rule reusing logic from LateinitUsage - [#224](https://github.com/detekt/detekt/pull/224) -- Excluding specific imports from the WildcardImport rule - [#223](https://github.com/detekt/detekt/issues/223) -- Anonymous classes should not be checked for documentation - [#221](https://github.com/detekt/detekt/pull/221) -- Provide a test case for custom rule sets - [#220](https://github.com/detekt/detekt/pull/220) -- Update Detekt to 1.0.0.M13 and add usedDetektVersion to gradle.properties. - [#218](https://github.com/detekt/detekt/pull/218) -- Change gradle task parametr 'rulesets' to 'ruleSets' - [#216](https://github.com/detekt/detekt/pull/216) -- UndocumentedPublicClass for anonymous classes - [#213](https://github.com/detekt/detekt/issues/213) -- rename dept to debt - [#211](https://github.com/detekt/detekt/pull/211) -- LateInitUsage: Ignore this rule in tests - [#207](https://github.com/detekt/detekt/issues/207) -- change cli parameter --project (-p) to --input (-i) - [#206](https://github.com/detekt/detekt/pull/206) -- Meaning of Dept - [#205](https://github.com/detekt/detekt/issues/205) -- Add new line to each kotlin file. - [#204](https://github.com/detekt/detekt/pull/204) -- Fix unused import false positive in kdoc - closes#201 - [#203](https://github.com/detekt/detekt/pull/203) -- False positive UnusedImports - [#201](https://github.com/detekt/detekt/issues/201) -- Add Tests for WildcardImport and NamingConvention rules - [#200](https://github.com/detekt/detekt/pull/200) -- Allow package matching via excludeAnnotatedProperties in LateinitUsage Rule. - [#199](https://github.com/detekt/detekt/pull/199) -- UndocumentedPublicClass false positive with annotations - [#194](https://github.com/detekt/detekt/issues/194) -- Rule TodoComment - [#182](https://github.com/detekt/detekt/issues/182) -- Rule NewlineAtEndOfFile - [#181](https://github.com/detekt/detekt/issues/181) -- Fail fast approach / configuration - [#179](https://github.com/detekt/detekt/issues/179) -- Rule: SpreadOperator - [#167](https://github.com/detekt/detekt/issues/167) -- Not providing a detekt-closure or profile should not crash the gradle-plugin but instead just use the default profile - [#166](https://github.com/detekt/detekt/issues/166) - -See all issues at: [M13.1](https://github.com/detekt/detekt/milestone/13) - -##### Migration - -- Misspelled class `Dept` was renamed to `Debt`, if you using custom rule sets, please rebuild it -- CLI parameter `--project` was renamed to `--input` to match the input parameter of the gradle plugin - -#### M13 - -- Add missing unit test for Int.reached. - [#191](https://github.com/detekt/detekt/pull/191) -- Add failFast option to the configuration. - [#186](https://github.com/detekt/detekt/pull/186) -- Convert single line methods to Expression Bodys. - [#185](https://github.com/detekt/detekt/pull/185) -- Fix issue when default config should from the resources by the cli - [#178](https://github.com/detekt/detekt/pull/178) -- Rule: SpreadOperator - [#177](https://github.com/detekt/detekt/pull/177) -- Update readme, contributors, changelog, migration guide for M13 - [#176](https://github.com/detekt/detekt/issues/176) -- Rule: Expression with label - [#175](https://github.com/detekt/detekt/pull/175) -- Rule: Report unsafe call on nullable types - [#174](https://github.com/detekt/detekt/pull/174) -- Rule: Expression with label - [#173](https://github.com/detekt/detekt/issues/173) -- Rule: Report unsafe call on nullable types - [#172](https://github.com/detekt/detekt/issues/172) -- Fix off by one error in Int.reached regarding SmellThreshold. - [#170](https://github.com/detekt/detekt/pull/170) -- Set the group to verification on all gradle tasks. - [#168](https://github.com/detekt/detekt/pull/168) -- Fix a typo in CHANGELOG.md - [#165](https://github.com/detekt/detekt/pull/165) -- Update kotlin version to 1.1.3-2 - closes #124 - [#164](https://github.com/detekt/detekt/pull/164) -- Added missed brackets to repository name in readme - [#163](https://github.com/detekt/detekt/pull/163) -- Rule: Find usages of forEach on Ranges - [#161](https://github.com/detekt/detekt/pull/161) -- Running formatting checks without formatting the code on CI - [#159](https://github.com/detekt/detekt/issues/159) -- Remove lateinit usage in Main.kt - [#156](https://github.com/detekt/detekt/pull/156) -- Rule: Report forEach usages on Ranges - [#155](https://github.com/detekt/detekt/issues/155) -- More descriptions to for most rules - [#154](https://github.com/detekt/detekt/pull/154) -- Always show the absolute number of code smells - [#152](https://github.com/detekt/detekt/issues/152) -- Use the latest version in gradle-plugin as default - [#151](https://github.com/detekt/detekt/issues/151) -- Turn off auto correction for sonar analysis - [#147](https://github.com/detekt/detekt/pull/147) -- Fix AppVeyor badge in `README.md` - [#146](https://github.com/detekt/detekt/pull/146) -- README: Fix various issues with variables in code examples - [#142](https://github.com/detekt/detekt/pull/142) -- add descriptions to rules in style, empty, exceptions - [#140](https://github.com/detekt/detekt/pull/140) -- Remove lateinit in project property in Main class - [#132](https://github.com/detekt/detekt/issues/132) -- Should rule providers have their own package or live in the according package - [#131](https://github.com/detekt/detekt/issues/131) -- Issue descriptions for each rule (also displayed in `Detekt way` - sonar plugin) - [#110](https://github.com/detekt/detekt/issues/110) - -See all issues at: [M13](https://github.com/detekt/detekt/milestone/12) - -#### M12.1 & M12.2 & M12.3 & M12.4 - -- Convert Kotlin source code strings to Unix line endings - [#137](https://github.com/detekt/detekt/pull/137) -- Simplify reading resource files - [#136](https://github.com/detekt/detekt/pull/136) -- [WIP] Windows support - [#135](https://github.com/detekt/detekt/pull/135) -- M12.1 fails with "URISyntaxException: Illegal character in authority at index 7" under windows - [#128](https://github.com/detekt/detekt/issues/128) -- Rule to find `lateinit` usages - [#127](https://github.com/detekt/detekt/pull/127) -- Wrong link format in Changelog - [#121](https://github.com/detekt/detekt/issues/121) -- Setup appveyor for windows builds - [#118](https://github.com/detekt/detekt/issues/118) -- Duplicate main profile - [#116](https://github.com/detekt/detekt/issues/116) -- Referring to custom detekt.yml config results in InvalidPathExceptionon Windows - [#115](https://github.com/detekt/detekt/issues/115) -- MaxLineLength should allow excluding import and package statements - [#111](https://github.com/detekt/detekt/issues/111) -- Rule: Prohibit usage of `lateinit` - [#106](https://github.com/detekt/detekt/issues/106) -- Use the latest version in gradle-plugin as default - [#151](https://github.com/detekt/detekt/issues/151) -- False positive for EmptyFunctionBlock with overriden function - [#151](https://github.com/detekt/detekt/issues/148) - -See all issues at: [M12.2](https://github.com/detekt/detekt/milestone/9) - -#### M12 - -- Suppress for TooManyFunctions is not considered in detekt - [#108](https://github.com/detekt/detekt/issues/108) -- Update documentation and migration guide for M12 - [#105](https://github.com/detekt/detekt/issues/105) -- NoDocOverPublicClass always reported for objects - [#104](https://github.com/detekt/detekt/issues/104) -- Script to generate release notes from milestone - [#102](https://github.com/detekt/detekt/issues/102) -- Encapsulate common fields of Rule and Finding in Issue class - [#97](https://github.com/detekt/detekt/issues/97) -- Separate findings logic from rule logic - [#93](https://github.com/detekt/detekt/issues/93) -- Add support for composable configurations - [#92](https://github.com/detekt/detekt/issues/92) -- ClassCastException: java.lang.Integer cannot be cast to java.lang.String - [#89](https://github.com/detekt/detekt/issues/89) -- Baseline does not work anymore as expected due to inner restructure for the new output formats - [#83](https://github.com/detekt/detekt/issues/83) -- Prevent ClassCastExceptions in Configurations - [#82](https://github.com/detekt/detekt/issues/82) -- Migrate away from load() method in tests - [#77](https://github.com/detekt/detekt/issues/77) -- Support any common report file format - [#66](https://github.com/detekt/detekt/issues/66) -- Not all return keywords are removed when using ExpressionBodySyntax quickfix - [#58](https://github.com/detekt/detekt/issues/58) -- Rule: Max line length - [#56](https://github.com/detekt/detekt/issues/56) -- Rule: SingleExpression statements with multiple return paths - [#45](https://github.com/detekt/detekt/issues/45) -- Allow different naming conventions for tests - [#24](https://github.com/detekt/detekt/issues/24) - -See all issues at: [M12](https://github.com/detekt/detekt/milestone/8) - -##### Migration - -###### CLI - -- No break just extra notification that you can pass now more than one configuration file within the `--config` and `--config-resource` parameters - -This allows overriding certain configuration parameters in the base configuration (left-most config) - -###### Gradle Plugin - -- the detekt extension is now aware of `configuration profiles` -- non default or 'main' profile, needs to be specified like `gradle detektCheck -Ddetekt.profile=[profile-name]` - -Instead of writing something like - -```groovy -detekt { - version = "1.0.0.M11" - input = "$project.projectDir/src" - filters = '.*/test/.*' - config = "$project.projectDir/detekt-config.yml" - output = "$project.projectDir/output.xml" - idea { - path = "$userHome/.idea" - codeStyleScheme = "$userHome/.idea/idea-code-style.xml" - inspectionsProfile = "$userHome/.idea/inspect.xml" - mask = "*.kt," - } -} -``` - -you have to put a `profile`-closure around the parameters - -```groovy -detekt { - profile("main") { - version = "1.0.0.M11" - input = "$project.projectDir/src" - filters = '.*/test/.*' - config = "$project.projectDir/detekt-config.yml" - output = "$project.projectDir/output.xml" - } - profile("test") { - filters = ".*/src/main/kotlin/.*" - config = "$project.projectDir/detekt-test-config.yml" - } - idea { - path = "$userHome/.idea" - codeStyleScheme = "$userHome/.idea/idea-code-style.xml" - inspectionsProfile = "$userHome/.idea/inspect.xml" - mask = "*.kt," - } -} -``` - -This allows you too configure `detekt-rules` specific for each module. Also allowing to have different configurations for production or test code. - -###### Renamings - -- `NoDocOverPublicClass` -> `UndocumentedPublicClass` -- `NoDocOverPublicMethod` -> `UndocumentedPublicFunction` - -Rename this id's in your configuration - -#### M11 - -- False positive SpacingAfterKeyword - [#71](https://github.com/detekt/detekt/issues/71) -- Embedabble compiler - [#70](https://github.com/detekt/detekt/pull/70) -- Support for Android? Failed to apply plugin [id 'com.android.application'] - [#69](https://github.com/detekt/detekt/issues/69) -- Add gradle task to integrate idea formatting/inspection - [#67](https://github.com/detekt/detekt/issues/67) -- Crash when detekt.yml is empty - [#64](https://github.com/detekt/detekt/issues/64) -- Add Support For GSK - [#59](https://github.com/detekt/detekt/issues/59) -- Decouple/Rewrite/Publish smell-baseline-format - [#57](https://github.com/detekt/detekt/issues/57) -- Export Config with `--generate-config` - [#54](https://github.com/detekt/detekt/pull/54) -- Support indentation formatting in different formats (X spaces, x spaces for tabs etc) - [#53](https://github.com/detekt/detekt/issues/53) -- NestedBlockDepth: Elif-Structure counts as two - [#51](https://github.com/detekt/detekt/issues/51) -- Generate default yaml configuration on cli flag - [#48](https://github.com/detekt/detekt/issues/48) -- Support @Suppress("ALL") - [#47](https://github.com/detekt/detekt/issues/47) -- [WIP] Formatting rework - [#46](https://github.com/detekt/detekt/pull/46) -- Rule: Expression-syntax line breaks - [#36](https://github.com/detekt/detekt/issues/36) -- Rule: Expression syntax - [#35](https://github.com/detekt/detekt/issues/35) -- Allow Indentation check to handle "align when multiline" option - [#25](https://github.com/detekt/detekt/issues/25) -- SpacingAroundCurlyBraces throw IndexOutOfFound when determinating Location.of(node) as LineAndColumn calculation is simple wrong (of Idea?) - [#18](https://github.com/detekt/detekt/issues/18) - - -See all issues at: [M11](https://github.com/detekt/detekt/milestone/5) -See all issues at: [Formatting](https://github.com/detekt/detekt/milestone/6) - -##### Migration - -- `detekt` task was renamed to `detektCheck` (gradle-plugin) -- `empty` rule set was renamed to `empty-blocks` rule set - -#### M10 - -- detekt-gradle-plugin - [#16](https://github.com/detekt/detekt/issues/16) -- experimental migration module which can migrate imports- [#30](https://github.com/detekt/detekt/issues/30) -- NamingConventionViolation is now aware about backticks - [contributed by Svyatoslav Chatchenko](https://github.com/detekt/detekt/pull/34) -- cli and core module refactorings, jcenter publishing, travis ci -- gradle-plugin version is not configurable, task configurations should be in `afterEvaluate` - [#41](https://api.github.com/repos/detekt/detekt/issues/41) -- Add Contributing Guide - [#37](https://api.github.com/repos/detekt/detekt/issues/37) -- NamingConventionViolation is now aware about backticks “`” - [#34](https://api.github.com/repos/detekt/detekt/issues/34) - -See all issues at: [M10](https://github.com/detekt/detekt/milestone/4) -See all issues at: [M10.1](https://api.github.com/repos/detekt/detekt/milestones/7) - -##### Migration - -- `code-smell` rule set was renamed to `complexity` rule set (config) - -#### M9 - -- Support suppressing rules (@SuppressWarnings, @Suppress) - [#6](https://github.com/detekt/detekt/issues/6) -- Allow easier navigation in README - [#24](https://github.com/detekt/detekt/issues/24) - -See all issues at: [M9](https://github.com/detekt/detekt/milestone/2) - -#### M8, M8.1 - -##### feature - -- Introduce complexity ruleset - [#4](https://github.com/detekt/detekt/issues/4) -- Provide a new screenshot showing detekt in action [#13](https://github.com/detekt/detekt/issues/13) -- Update Readme/Rulesets for changes in code-smell/complexity rulesets [#14](https://github.com/detekt/detekt/issues/14) -- NamingConventionViolation should allow customization [#20](https://github.com/detekt/detekt/issues/20) - - -##### bugs fixed - -- Prevent division by zero (thx @olivierlemasle) - -See all issues at: [M8](https://github.com/detekt/detekt/milestone/1) - -#### M7 - -##### defect - -- Remove NoElseInWhenExpression rule [#10](https://github.com/detekt/detekt/issues/10) - -##### feature - -- As an user I want to give more weight to some rule sets than to others - [#83](https://gitlab.com/arturbosch/detekt/issues/83) -- Integrate debug rule set provider into cli - [#70](https://gitlab.com/arturbosch/detekt/issues/70) - -##### feedback - -- [Test] Analyze Kotlin project (30.000+ KtFiles) - [#85](https://gitlab.com/arturbosch/detekt/issues/85) - -##### improvement - -- Consider other than BodyExpression expressions inside current rules - [#1](https://gitlab.com/arturbosch/detekt/issues/1) - -##### release - -- As an user I want to get more often releases to try out the new stuff - [#87](https://gitlab.com/arturbosch/detekt/issues/87) -- Update to kotlin 1.0.6 - [#84](https://gitlab.com/arturbosch/detekt/issues/84) -- Update to kotlin 1.1.1 - [#2](https://github.com/detekt/detekt/issues/2) -- Get rid of hamkrest - [#9](https://github.com/detekt/detekt/issues/9) - -See all issues at: [M7](https://gitlab.com/arturbosch/detekt/milestones/7) - -#### M6 - -##### New features - -- allow to fail builds on code smell thresholds (configurable), see 'Configure build failure thresholds' in README -- suppress code smells which are false positives -- generate a baseline of code smells if your project is already old and has many smells, so only new -smells are shown in analysis (see 'Code Smell baseline and ignore list' in README) - -##### Improvements - -- move formatting to own rule set project as formatting works great on my kotlin projects but line/column calculation -from within PsiElements is wrong (!?) -- OptionalUnit and -Semicolon should be auto correctable and moved to formatting -- show progress while waiting for the analysis - -See all issues at: https://gitlab.com/arturbosch/detekt/milestones/6 - -#### M5 - -- Threat variables in object declarations as constants too - #67 -- Normalize file content prevents some exceptions inside Psi - #66 -- Fix an "Underestimated text length" problem inside Psi - #65 -- Filter top level members from LargeClass and EqualsWithHashCode rules, preventing NoSuchElementExceptions - #64 - -In this milestone the goal was to fully be able to analyze the Kotlin project. -All rule sets (except formatting) successfully run now. Formatting needs some fixes -as line and column values are sometimes not correctly determined by the AST. - -One idea of mine is to threat formatting as an extern rule set and only allow auto correcting -the source code without an report to skip line/column problem. - -More issues: https://gitlab.com/arturbosch/detekt/milestones/5 - -#### M4 - -- Rewrite UnusedImport-rule to fix deleting infix extension function imports - #60 -- Cli flag: --parallel to compile all kotlin files in parallel, use when your project has more than 1000+ files, - detection is always parallel - #46 -- Cli flag: --format (--useTabs) to allow formatting of your source code without a detekt configuration file. -All formatting rules are turned off except indentation with spaces if --useTabs is used - #54 - -More issues: https://gitlab.com/arturbosch/detekt/milestones/4 - -#### M3 - -- exceptions rule set (Too generic Exceptions thrown/catched) -- potential bugs rule set (EqualsWithHashCode, DuplicateCaseInWhen, ExplicitGarbageCollectionCall, NoElseInWhen) -- Ported formatting rules of KtLint (Credits to Shyiko) - -More issues: https://gitlab.com/arturbosch/detekt/milestones/3 - -#### M2 - -- yaml configuration of rules -- empty rule set (empty block statements) -- include detekt in your projects - -More issues: https://gitlab.com/arturbosch/detekt/milestones/2 - -#### M1 - -- Command line interface -- RuleSetProvider plugin system -- code smell rule set -- style rule set - -More issues: https://gitlab.com/arturbosch/detekt/milestones/1 diff --git a/website/versioned_sidebars/version-1.21.0-sidebars.json b/website/versioned_sidebars/version-1.21.0-sidebars.json index cff0c94e170..59aa2861f25 100644 --- a/website/versioned_sidebars/version-1.21.0-sidebars.json +++ b/website/versioned_sidebars/version-1.21.0-sidebars.json @@ -3,6 +3,22 @@ { "type": "autogenerated", "dirName": "." + }, + { + "type": "category", + "label": "Changelogs", + "items": [ + { + "type": "link", + "label": "1.x Changelog", + "href": "/changelog" + }, + { + "type": "link", + "label": "0.x Changelog", + "href": "/changelog-rc" + } + ] } ] } diff --git a/website/yarn.lock b/website/yarn.lock index d0bde528ff6..7bec7b75646 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -2128,10 +2128,10 @@ "@docsearch/css" "3.1.1" algoliasearch "^4.0.0" -"@docusaurus/core@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/core/-/core-2.0.1.tgz#a2b0d653e8f18eacddda4778a46b638dd1f0f45c" - integrity sha512-Prd46TtZdiixlTl8a+h9bI5HegkfREjSNkrX2rVEwJZeziSz4ya+l7QDnbnCB2XbxEG8cveFo/F9q5lixolDtQ== +"@docusaurus/core@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/core/-/core-2.1.0.tgz#4aedc306f4c4cd2e0491b641bf78941d4b480ab6" + integrity sha512-/ZJ6xmm+VB9Izbn0/s6h6289cbPy2k4iYFwWDhjiLsVqwa/Y0YBBcXvStfaHccudUC3OfP+26hMk7UCjc50J6Q== dependencies: "@babel/core" "^7.18.6" "@babel/generator" "^7.18.7" @@ -2143,13 +2143,13 @@ "@babel/runtime" "^7.18.6" "@babel/runtime-corejs3" "^7.18.6" "@babel/traverse" "^7.18.8" - "@docusaurus/cssnano-preset" "2.0.1" - "@docusaurus/logger" "2.0.1" - "@docusaurus/mdx-loader" "2.0.1" + "@docusaurus/cssnano-preset" "2.1.0" + "@docusaurus/logger" "2.1.0" + "@docusaurus/mdx-loader" "2.1.0" "@docusaurus/react-loadable" "5.5.2" - "@docusaurus/utils" "2.0.1" - "@docusaurus/utils-common" "2.0.1" - "@docusaurus/utils-validation" "2.0.1" + "@docusaurus/utils" "2.1.0" + "@docusaurus/utils-common" "2.1.0" + "@docusaurus/utils-validation" "2.1.0" "@slorber/static-site-generator-webpack-plugin" "^4.0.7" "@svgr/webpack" "^6.2.1" autoprefixer "^10.4.7" @@ -2205,33 +2205,33 @@ webpack-merge "^5.8.0" webpackbar "^5.0.2" -"@docusaurus/cssnano-preset@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/cssnano-preset/-/cssnano-preset-2.0.1.tgz#4d0c49338cf3aa88c5bd7cffbf77654db8e1e3b2" - integrity sha512-MCJ6rRmlqLmlCsZIoIxOxDb0rYzIPEm9PYpsBW+CGNnbk+x8xK+11hnrxzvXHqDRNpxrq3Kq2jYUmg/DkqE6vg== +"@docusaurus/cssnano-preset@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/cssnano-preset/-/cssnano-preset-2.1.0.tgz#5b42107769b7cbc61655496090bc262d7788d6ab" + integrity sha512-pRLewcgGhOies6pzsUROfmPStDRdFw+FgV5sMtLr5+4Luv2rty5+b/eSIMMetqUsmg3A9r9bcxHk9bKAKvx3zQ== dependencies: cssnano-preset-advanced "^5.3.8" postcss "^8.4.14" postcss-sort-media-queries "^4.2.1" tslib "^2.4.0" -"@docusaurus/logger@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/logger/-/logger-2.0.1.tgz#78a940a333d2f654fd9dea24db2c962034d4b1ff" - integrity sha512-wIWseCKko1w/WARcDjO3N/XoJ0q/VE42AthP0eNAfEazDjJ94NXbaI6wuUsuY/bMg6hTKGVIpphjj2LoX3g6dA== +"@docusaurus/logger@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/logger/-/logger-2.1.0.tgz#86c97e948f578814d3e61fc2b2ad283043cbe87a" + integrity sha512-uuJx2T6hDBg82joFeyobywPjSOIfeq05GfyKGHThVoXuXsu1KAzMDYcjoDxarb9CoHCI/Dor8R2MoL6zII8x1Q== dependencies: chalk "^4.1.2" tslib "^2.4.0" -"@docusaurus/mdx-loader@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/mdx-loader/-/mdx-loader-2.0.1.tgz#cc73690ca5d356687d9e75740560b4159cd5cdb5" - integrity sha512-tdNeljdilXCmhbaEND3SAgsqaw/oh7v9onT5yrIrL26OSk2AFwd+MIi4R8jt8vq33M0R4rz2wpknm0fQIkDdvQ== +"@docusaurus/mdx-loader@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/mdx-loader/-/mdx-loader-2.1.0.tgz#3fca9576cc73a22f8e7d9941985590b9e47a8526" + integrity sha512-i97hi7hbQjsD3/8OSFhLy7dbKGH8ryjEzOfyhQIn2CFBYOY3ko0vMVEf3IY9nD3Ld7amYzsZ8153RPkcnXA+Lg== dependencies: "@babel/parser" "^7.18.8" "@babel/traverse" "^7.18.8" - "@docusaurus/logger" "2.0.1" - "@docusaurus/utils" "2.0.1" + "@docusaurus/logger" "2.1.0" + "@docusaurus/utils" "2.1.0" "@mdx-js/mdx" "^1.6.22" escape-html "^1.0.3" file-loader "^6.2.0" @@ -2246,13 +2246,13 @@ url-loader "^4.1.1" webpack "^5.73.0" -"@docusaurus/module-type-aliases@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/module-type-aliases/-/module-type-aliases-2.0.1.tgz#44d7132297bedae0890695b0e7ebbe14a73e26d1" - integrity sha512-f888ylnxHAM/3T8p1lx08+lTc6/g7AweSRfRuZvrVhHXj3Tz/nTTxaP6gPTGkJK7WLqTagpar/IGP6/74IBbkg== +"@docusaurus/module-type-aliases@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/module-type-aliases/-/module-type-aliases-2.1.0.tgz#322f8fd5b436af2154c0dddfa173435730e66261" + integrity sha512-Z8WZaK5cis3xEtyfOT817u9xgGUauT0PuuVo85ysnFRX8n7qLN1lTPCkC+aCmFm/UcV8h/W5T4NtIsst94UntQ== dependencies: "@docusaurus/react-loadable" "5.5.2" - "@docusaurus/types" "2.0.1" + "@docusaurus/types" "2.1.0" "@types/history" "^4.7.11" "@types/react" "*" "@types/react-router-config" "*" @@ -2260,33 +2260,33 @@ react-helmet-async "*" react-loadable "npm:@docusaurus/react-loadable@5.5.2" -"@docusaurus/plugin-client-redirects@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-client-redirects/-/plugin-client-redirects-2.0.1.tgz#3b00cd0a816fe85e6c505651f28b59fff723ac67" - integrity sha512-A/giM3MIRRyUmxNzLb/jWvmRf0NtPYX4bV04njAnziAdPo4dqT4dZF2Hvy0uUSaF/SXPGLUjrZWWpzTl5mTJtQ== - dependencies: - "@docusaurus/core" "2.0.1" - "@docusaurus/logger" "2.0.1" - "@docusaurus/utils" "2.0.1" - "@docusaurus/utils-common" "2.0.1" - "@docusaurus/utils-validation" "2.0.1" +"@docusaurus/plugin-client-redirects@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-client-redirects/-/plugin-client-redirects-2.1.0.tgz#4141040552faad48aefc5bc8f3827c3c4eba1ab8" + integrity sha512-3PhzwHSyZWqBAFPJuLJE3dZVuKWQEj9ReQP85Z3/2hpnQoVNBgAqc+64FIko0FvvK1iluLeasO7NWGyuATngvw== + dependencies: + "@docusaurus/core" "2.1.0" + "@docusaurus/logger" "2.1.0" + "@docusaurus/utils" "2.1.0" + "@docusaurus/utils-common" "2.1.0" + "@docusaurus/utils-validation" "2.1.0" eta "^1.12.3" fs-extra "^10.1.0" lodash "^4.17.21" tslib "^2.4.0" -"@docusaurus/plugin-content-blog@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.0.1.tgz#a37065e18ffd26e022ffb16a21ff28199140729e" - integrity sha512-/4ua3iFYcpwgpeYgHnhVGROB/ybnauLH2+rICb4vz/+Gn1hjAmGXVYq1fk8g49zGs3uxx5nc0H5bL9P0g977IQ== - dependencies: - "@docusaurus/core" "2.0.1" - "@docusaurus/logger" "2.0.1" - "@docusaurus/mdx-loader" "2.0.1" - "@docusaurus/types" "2.0.1" - "@docusaurus/utils" "2.0.1" - "@docusaurus/utils-common" "2.0.1" - "@docusaurus/utils-validation" "2.0.1" +"@docusaurus/plugin-content-blog@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.1.0.tgz#32b1a7cd4b0026f4a76fce4edc5cfdd0edb1ec42" + integrity sha512-xEp6jlu92HMNUmyRBEeJ4mCW1s77aAEQO4Keez94cUY/Ap7G/r0Awa6xSLff7HL0Fjg8KK1bEbDy7q9voIavdg== + dependencies: + "@docusaurus/core" "2.1.0" + "@docusaurus/logger" "2.1.0" + "@docusaurus/mdx-loader" "2.1.0" + "@docusaurus/types" "2.1.0" + "@docusaurus/utils" "2.1.0" + "@docusaurus/utils-common" "2.1.0" + "@docusaurus/utils-validation" "2.1.0" cheerio "^1.0.0-rc.12" feed "^4.2.2" fs-extra "^10.1.0" @@ -2297,18 +2297,18 @@ utility-types "^3.10.0" webpack "^5.73.0" -"@docusaurus/plugin-content-docs@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-docs/-/plugin-content-docs-2.0.1.tgz#4059591b4bff617e744e856ca680674b27c0b98a" - integrity sha512-2qeBWRy1EjgnXdwAO6/csDIS1UVNmhmtk/bQ2s9jqjpwM8YVgZ8QVdkxFAMWXgZWDQdwWwdP1rnmoEelE4HknQ== - dependencies: - "@docusaurus/core" "2.0.1" - "@docusaurus/logger" "2.0.1" - "@docusaurus/mdx-loader" "2.0.1" - "@docusaurus/module-type-aliases" "2.0.1" - "@docusaurus/types" "2.0.1" - "@docusaurus/utils" "2.0.1" - "@docusaurus/utils-validation" "2.0.1" +"@docusaurus/plugin-content-docs@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-docs/-/plugin-content-docs-2.1.0.tgz#3fcdf258c13dde27268ce7108a102b74ca4c279b" + integrity sha512-Rup5pqXrXlKGIC4VgwvioIhGWF7E/NNSlxv+JAxRYpik8VKlWsk9ysrdHIlpX+KJUCO9irnY21kQh2814mlp/Q== + dependencies: + "@docusaurus/core" "2.1.0" + "@docusaurus/logger" "2.1.0" + "@docusaurus/mdx-loader" "2.1.0" + "@docusaurus/module-type-aliases" "2.1.0" + "@docusaurus/types" "2.1.0" + "@docusaurus/utils" "2.1.0" + "@docusaurus/utils-validation" "2.1.0" "@types/react-router-config" "^5.0.6" combine-promises "^1.1.0" fs-extra "^10.1.0" @@ -2319,84 +2319,84 @@ utility-types "^3.10.0" webpack "^5.73.0" -"@docusaurus/plugin-content-pages@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-pages/-/plugin-content-pages-2.0.1.tgz#013f2e66f80d19b5c95a2d941d67c7cdb67b7191" - integrity sha512-6apSVeJENnNecAH5cm5VnRqR103M6qSI6IuiP7tVfD5H4AWrfDNkvJQV2+R2PIq3bGrwmX4fcXl1x4g0oo7iwA== - dependencies: - "@docusaurus/core" "2.0.1" - "@docusaurus/mdx-loader" "2.0.1" - "@docusaurus/types" "2.0.1" - "@docusaurus/utils" "2.0.1" - "@docusaurus/utils-validation" "2.0.1" +"@docusaurus/plugin-content-pages@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-pages/-/plugin-content-pages-2.1.0.tgz#714d24f71d49dbfed888f50c15e975c2154c3ce8" + integrity sha512-SwZdDZRlObHNKXTnFo7W2aF6U5ZqNVI55Nw2GCBryL7oKQSLeI0lsrMlMXdzn+fS7OuBTd3MJBO1T4Zpz0i/+g== + dependencies: + "@docusaurus/core" "2.1.0" + "@docusaurus/mdx-loader" "2.1.0" + "@docusaurus/types" "2.1.0" + "@docusaurus/utils" "2.1.0" + "@docusaurus/utils-validation" "2.1.0" fs-extra "^10.1.0" tslib "^2.4.0" webpack "^5.73.0" -"@docusaurus/plugin-debug@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-debug/-/plugin-debug-2.0.1.tgz#2b2a473f8e01fd356e32236f753665b48209bcd4" - integrity sha512-jpZBT5HK7SWx1LRQyv9d14i44vSsKXGZsSPA2ndth5HykHJsiAj9Fwl1AtzmtGYuBmI+iXQyOd4MAMHd4ZZ1tg== +"@docusaurus/plugin-debug@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-debug/-/plugin-debug-2.1.0.tgz#b3145affb40e25cf342174638952a5928ddaf7dc" + integrity sha512-8wsDq3OIfiy6440KLlp/qT5uk+WRHQXIXklNHEeZcar+Of0TZxCNe2FBpv+bzb/0qcdP45ia5i5WmR5OjN6DPw== dependencies: - "@docusaurus/core" "2.0.1" - "@docusaurus/types" "2.0.1" - "@docusaurus/utils" "2.0.1" + "@docusaurus/core" "2.1.0" + "@docusaurus/types" "2.1.0" + "@docusaurus/utils" "2.1.0" fs-extra "^10.1.0" react-json-view "^1.21.3" tslib "^2.4.0" -"@docusaurus/plugin-google-analytics@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-analytics/-/plugin-google-analytics-2.0.1.tgz#e3b84237aad2e94dcd1cf1810c1c9bc3d94f186d" - integrity sha512-d5qb+ZeQcg1Czoxc+RacETjLdp2sN/TAd7PGN/GrvtijCdgNmvVAtZ9QgajBTG0YbJFVPTeZ39ad2bpoOexX0w== +"@docusaurus/plugin-google-analytics@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-analytics/-/plugin-google-analytics-2.1.0.tgz#c9a7269817b38e43484d38fad9996e39aac4196c" + integrity sha512-4cgeqIly/wcFVbbWP03y1QJJBgH8W+Bv6AVbWnsXNOZa1yB3AO6hf3ZdeQH9x20v9T2pREogVgAH0rSoVnNsgg== dependencies: - "@docusaurus/core" "2.0.1" - "@docusaurus/types" "2.0.1" - "@docusaurus/utils-validation" "2.0.1" + "@docusaurus/core" "2.1.0" + "@docusaurus/types" "2.1.0" + "@docusaurus/utils-validation" "2.1.0" tslib "^2.4.0" -"@docusaurus/plugin-google-gtag@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-gtag/-/plugin-google-gtag-2.0.1.tgz#4cbcf9d520f7ec8124679fbe00867f2299a2f6bb" - integrity sha512-qiRufJe2FvIyzICbkjm4VbVCI1hyEju/CebfDKkKh2ZtV4q6DM1WZG7D6VoQSXL8MrMFB895gipOM4BwdM8VsQ== +"@docusaurus/plugin-google-gtag@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-gtag/-/plugin-google-gtag-2.1.0.tgz#e4f351dcd98b933538d55bb742650a2a36ca9a32" + integrity sha512-/3aDlv2dMoCeiX2e+DTGvvrdTA+v3cKQV3DbmfsF4ENhvc5nKV23nth04Z3Vq0Ci1ui6Sn80TkhGk/tiCMW2AA== dependencies: - "@docusaurus/core" "2.0.1" - "@docusaurus/types" "2.0.1" - "@docusaurus/utils-validation" "2.0.1" + "@docusaurus/core" "2.1.0" + "@docusaurus/types" "2.1.0" + "@docusaurus/utils-validation" "2.1.0" tslib "^2.4.0" -"@docusaurus/plugin-sitemap@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-sitemap/-/plugin-sitemap-2.0.1.tgz#6f8edb82b745b040d6b1495e2798396f63e50289" - integrity sha512-KcYuIUIp2JPzUf+Xa7W2BSsjLgN1/0h+VAz7D/C3RYjAgC5ApPX8wO+TECmGfunl/m7WKGUmLabfOon/as64kQ== - dependencies: - "@docusaurus/core" "2.0.1" - "@docusaurus/logger" "2.0.1" - "@docusaurus/types" "2.0.1" - "@docusaurus/utils" "2.0.1" - "@docusaurus/utils-common" "2.0.1" - "@docusaurus/utils-validation" "2.0.1" +"@docusaurus/plugin-sitemap@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-sitemap/-/plugin-sitemap-2.1.0.tgz#b316bb9a42a1717845e26bd4e2d3071748a54b47" + integrity sha512-2Y6Br8drlrZ/jN9MwMBl0aoi9GAjpfyfMBYpaQZXimbK+e9VjYnujXlvQ4SxtM60ASDgtHIAzfVFBkSR/MwRUw== + dependencies: + "@docusaurus/core" "2.1.0" + "@docusaurus/logger" "2.1.0" + "@docusaurus/types" "2.1.0" + "@docusaurus/utils" "2.1.0" + "@docusaurus/utils-common" "2.1.0" + "@docusaurus/utils-validation" "2.1.0" fs-extra "^10.1.0" sitemap "^7.1.1" tslib "^2.4.0" -"@docusaurus/preset-classic@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/preset-classic/-/preset-classic-2.0.1.tgz#21a806e16b61026d2a0efa6ca97e17397065d894" - integrity sha512-nOoniTg46My1qdDlLWeFs55uEmxOJ+9WMF8KKG8KMCu5LAvpemMi7rQd4x8Tw+xiPHZ/sQzH9JmPTMPRE4QGPw== - dependencies: - "@docusaurus/core" "2.0.1" - "@docusaurus/plugin-content-blog" "2.0.1" - "@docusaurus/plugin-content-docs" "2.0.1" - "@docusaurus/plugin-content-pages" "2.0.1" - "@docusaurus/plugin-debug" "2.0.1" - "@docusaurus/plugin-google-analytics" "2.0.1" - "@docusaurus/plugin-google-gtag" "2.0.1" - "@docusaurus/plugin-sitemap" "2.0.1" - "@docusaurus/theme-classic" "2.0.1" - "@docusaurus/theme-common" "2.0.1" - "@docusaurus/theme-search-algolia" "2.0.1" - "@docusaurus/types" "2.0.1" +"@docusaurus/preset-classic@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/preset-classic/-/preset-classic-2.1.0.tgz#45b23c8ec10c96ded9ece128fac3a39b10bcbc56" + integrity sha512-NQMnaq974K4BcSMXFSJBQ5itniw6RSyW+VT+6i90kGZzTwiuKZmsp0r9lC6BYAvvVMQUNJQwrETmlu7y2XKW7w== + dependencies: + "@docusaurus/core" "2.1.0" + "@docusaurus/plugin-content-blog" "2.1.0" + "@docusaurus/plugin-content-docs" "2.1.0" + "@docusaurus/plugin-content-pages" "2.1.0" + "@docusaurus/plugin-debug" "2.1.0" + "@docusaurus/plugin-google-analytics" "2.1.0" + "@docusaurus/plugin-google-gtag" "2.1.0" + "@docusaurus/plugin-sitemap" "2.1.0" + "@docusaurus/theme-classic" "2.1.0" + "@docusaurus/theme-common" "2.1.0" + "@docusaurus/theme-search-algolia" "2.1.0" + "@docusaurus/types" "2.1.0" "@docusaurus/react-loadable@5.5.2", "react-loadable@npm:@docusaurus/react-loadable@5.5.2": version "5.5.2" @@ -2406,23 +2406,23 @@ "@types/react" "*" prop-types "^15.6.2" -"@docusaurus/theme-classic@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-classic/-/theme-classic-2.0.1.tgz#043b6fcd2ecb2aecd134419b198c9f519029d5e7" - integrity sha512-0jfigiqkUwIuKOw7Me5tqUM9BBvoQX7qqeevx7v4tkYQexPhk3VYSZo7aRuoJ9oyW5makCTPX551PMJzmq7+sw== - dependencies: - "@docusaurus/core" "2.0.1" - "@docusaurus/mdx-loader" "2.0.1" - "@docusaurus/module-type-aliases" "2.0.1" - "@docusaurus/plugin-content-blog" "2.0.1" - "@docusaurus/plugin-content-docs" "2.0.1" - "@docusaurus/plugin-content-pages" "2.0.1" - "@docusaurus/theme-common" "2.0.1" - "@docusaurus/theme-translations" "2.0.1" - "@docusaurus/types" "2.0.1" - "@docusaurus/utils" "2.0.1" - "@docusaurus/utils-common" "2.0.1" - "@docusaurus/utils-validation" "2.0.1" +"@docusaurus/theme-classic@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-classic/-/theme-classic-2.1.0.tgz#d957a907ea8dd035c1cf911d0fbe91d8f24aef3f" + integrity sha512-xn8ZfNMsf7gaSy9+ClFnUu71o7oKgMo5noYSS1hy3svNifRTkrBp6+MReLDsmIaj3mLf2e7+JCBYKBFbaGzQng== + dependencies: + "@docusaurus/core" "2.1.0" + "@docusaurus/mdx-loader" "2.1.0" + "@docusaurus/module-type-aliases" "2.1.0" + "@docusaurus/plugin-content-blog" "2.1.0" + "@docusaurus/plugin-content-docs" "2.1.0" + "@docusaurus/plugin-content-pages" "2.1.0" + "@docusaurus/theme-common" "2.1.0" + "@docusaurus/theme-translations" "2.1.0" + "@docusaurus/types" "2.1.0" + "@docusaurus/utils" "2.1.0" + "@docusaurus/utils-common" "2.1.0" + "@docusaurus/utils-validation" "2.1.0" "@mdx-js/react" "^1.6.22" clsx "^1.2.1" copy-text-to-clipboard "^3.0.1" @@ -2437,17 +2437,17 @@ tslib "^2.4.0" utility-types "^3.10.0" -"@docusaurus/theme-common@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-common/-/theme-common-2.0.1.tgz#9594d58fbef11fe480967b5ce4cdbb3cd78d9ca3" - integrity sha512-I3b6e/ryiTQMsbES40cP0DRGnfr0E2qghVq+XecyMKjBPejISoSFEDn0MsnbW8Q26k1Dh/0qDH8QKDqaZZgLhA== - dependencies: - "@docusaurus/mdx-loader" "2.0.1" - "@docusaurus/module-type-aliases" "2.0.1" - "@docusaurus/plugin-content-blog" "2.0.1" - "@docusaurus/plugin-content-docs" "2.0.1" - "@docusaurus/plugin-content-pages" "2.0.1" - "@docusaurus/utils" "2.0.1" +"@docusaurus/theme-common@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-common/-/theme-common-2.1.0.tgz#dff4d5d1e29efc06125dc06f7b259f689bb3f24d" + integrity sha512-vT1otpVPbKux90YpZUnvknsn5zvpLf+AW1W0EDcpE9up4cDrPqfsh0QoxGHFJnobE2/qftsBFC19BneN4BH8Ag== + dependencies: + "@docusaurus/mdx-loader" "2.1.0" + "@docusaurus/module-type-aliases" "2.1.0" + "@docusaurus/plugin-content-blog" "2.1.0" + "@docusaurus/plugin-content-docs" "2.1.0" + "@docusaurus/plugin-content-pages" "2.1.0" + "@docusaurus/utils" "2.1.0" "@types/history" "^4.7.11" "@types/react" "*" "@types/react-router-config" "*" @@ -2457,19 +2457,19 @@ tslib "^2.4.0" utility-types "^3.10.0" -"@docusaurus/theme-search-algolia@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-search-algolia/-/theme-search-algolia-2.0.1.tgz#0aab8407b2163f67eb4c48f1de33944e1695fa74" - integrity sha512-cw3NaOSKbYlsY6uNj4PgO+5mwyQ3aEWre5RlmvjStaz2cbD15Nr69VG8Rd/F6Q5VsCT8BvSdkPDdDG5d/ACexg== +"@docusaurus/theme-search-algolia@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-search-algolia/-/theme-search-algolia-2.1.0.tgz#e7cdf64b6f7a15b07c6dcf652fd308cfdaabb0ee" + integrity sha512-rNBvi35VvENhucslEeVPOtbAzBdZY/9j55gdsweGV5bYoAXy4mHB6zTGjealcB4pJ6lJY4a5g75fXXMOlUqPfg== dependencies: "@docsearch/react" "^3.1.1" - "@docusaurus/core" "2.0.1" - "@docusaurus/logger" "2.0.1" - "@docusaurus/plugin-content-docs" "2.0.1" - "@docusaurus/theme-common" "2.0.1" - "@docusaurus/theme-translations" "2.0.1" - "@docusaurus/utils" "2.0.1" - "@docusaurus/utils-validation" "2.0.1" + "@docusaurus/core" "2.1.0" + "@docusaurus/logger" "2.1.0" + "@docusaurus/plugin-content-docs" "2.1.0" + "@docusaurus/theme-common" "2.1.0" + "@docusaurus/theme-translations" "2.1.0" + "@docusaurus/utils" "2.1.0" + "@docusaurus/utils-validation" "2.1.0" algoliasearch "^4.13.1" algoliasearch-helper "^3.10.0" clsx "^1.2.1" @@ -2479,18 +2479,18 @@ tslib "^2.4.0" utility-types "^3.10.0" -"@docusaurus/theme-translations@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-translations/-/theme-translations-2.0.1.tgz#955a687c974265a811bfc743d98ef3eab0379100" - integrity sha512-v1MYYlbsdX+rtKnXFcIAn9ar0Z6K0yjqnCYS0p/KLCLrfJwfJ8A3oRJw2HiaIb8jQfk1WMY2h5Qi1p4vHOekQw== +"@docusaurus/theme-translations@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-translations/-/theme-translations-2.1.0.tgz#ce9a2955afd49bff364cfdfd4492b226f6dd3b6e" + integrity sha512-07n2akf2nqWvtJeMy3A+7oSGMuu5F673AovXVwY0aGAux1afzGCiqIFlYW3EP0CujvDJAEFSQi/Tetfh+95JNg== dependencies: fs-extra "^10.1.0" tslib "^2.4.0" -"@docusaurus/types@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/types/-/types-2.0.1.tgz#8696a70e85c4b9be80b38ac592d520f6fe72618b" - integrity sha512-o+4hAFWkj3sBszVnRTAnNqtAIuIW0bNaYyDwQhQ6bdz3RAPEq9cDKZxMpajsj4z2nRty8XjzhyufAAjxFTyrfg== +"@docusaurus/types@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/types/-/types-2.1.0.tgz#01e13cd9adb268fffe87b49eb90302d5dc3edd6b" + integrity sha512-BS1ebpJZnGG6esKqsjtEC9U9qSaPylPwlO7cQ1GaIE7J/kMZI3FITnNn0otXXu7c7ZTqhb6+8dOrG6fZn6fqzQ== dependencies: "@types/history" "^4.7.11" "@types/react" "*" @@ -2501,30 +2501,30 @@ webpack "^5.73.0" webpack-merge "^5.8.0" -"@docusaurus/utils-common@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/utils-common/-/utils-common-2.0.1.tgz#b6f2b029547f739e1431ec84abd16974edf495e0" - integrity sha512-kajCCDCXRd1HFH5EUW31MPaQcsyNlGakpkDoTBtBvpa4EIPvWaSKy7TIqYKHrZjX4tnJ0YbEJvaXfjjgdq5xSg== +"@docusaurus/utils-common@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/utils-common/-/utils-common-2.1.0.tgz#248434751096f8c6c644ed65eed2a5a070a227f8" + integrity sha512-F2vgmt4yRFgRQR2vyEFGTWeyAdmgKbtmu3sjHObF0tjjx/pN0Iw/c6eCopaH34E6tc9nO0nvp01pwW+/86d1fg== dependencies: tslib "^2.4.0" -"@docusaurus/utils-validation@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/utils-validation/-/utils-validation-2.0.1.tgz#69f7d4944288d71f00fdba6dde10f05008f04308" - integrity sha512-f14AnwFBy4/1A19zWthK+Ii80YDz+4qt8oPpK3julywXsheSxPBqgsND3LVBBvB2p3rJHvbo2m3HyB9Tco1JRw== +"@docusaurus/utils-validation@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/utils-validation/-/utils-validation-2.1.0.tgz#c8cf1d8454d924d9a564fefa86436268f43308e3" + integrity sha512-AMJzWYKL3b7FLltKtDXNLO9Y649V2BXvrnRdnW2AA+PpBnYV78zKLSCz135cuWwRj1ajNtP4onbXdlnyvCijGQ== dependencies: - "@docusaurus/logger" "2.0.1" - "@docusaurus/utils" "2.0.1" + "@docusaurus/logger" "2.1.0" + "@docusaurus/utils" "2.1.0" joi "^17.6.0" js-yaml "^4.1.0" tslib "^2.4.0" -"@docusaurus/utils@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@docusaurus/utils/-/utils-2.0.1.tgz#37b4b42e29175e5d2d811fcbf9f93bffeca7c353" - integrity sha512-u2Vdl/eoVwMfUjDCkg7FjxoiwFs/XhVVtNxQEw8cvB+qaw6QWyT73m96VZzWtUb1fDOefHoZ+bZ0ObFeKk9lMQ== +"@docusaurus/utils@2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@docusaurus/utils/-/utils-2.1.0.tgz#b77b45b22e61eb6c2dcad8a7e96f6db0409b655f" + integrity sha512-fPvrfmAuC54n8MjZuG4IysaMdmvN5A/qr7iFLbSGSyDrsbP4fnui6KdZZIa/YOLIPLec8vjZ8RIITJqF18mx4A== dependencies: - "@docusaurus/logger" "2.0.1" + "@docusaurus/logger" "2.1.0" "@svgr/webpack" "^6.2.1" file-loader "^6.2.0" fs-extra "^10.1.0"