diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSaveSmokeTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSaveSmokeTest.kt index 494cb18f05..07e5586267 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSaveSmokeTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSaveSmokeTest.kt @@ -1,121 +1,64 @@ package org.cqfn.diktat.ruleset.smoke import org.cqfn.diktat.common.config.rules.DIKTAT_COMMON -import org.cqfn.diktat.common.config.rules.RulesConfig -import org.cqfn.diktat.common.config.rules.RulesConfigReader import org.cqfn.diktat.ruleset.constants.Warnings -import org.cqfn.diktat.ruleset.rules.DiktatRuleSetProvider -import org.cqfn.diktat.util.FixTestBase -import com.charleskorn.kaml.Yaml -import com.charleskorn.kaml.YamlConfiguration -import com.pinterest.ktlint.core.LintError +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test import java.time.LocalDate -import kotlin.io.path.createTempFile -import kotlinx.serialization.builtins.ListSerializer - -class DiktatSaveSmokeTest : FixTestBase("test/smoke/src/main/kotlin", - { DiktatRuleSetProvider(configFilePath) }, - { lintError, _ -> unfixedLintErrors.add(lintError) }, -) { - /** - * Disable some of the rules. - */ - @Suppress("UnsafeCallOnNullableType") - private fun overrideRulesConfig(rulesToDisable: List, rulesToOverride: RuleToConfig = emptyMap()) { - val rulesConfig = RulesConfigReader(javaClass.classLoader).readResource(DEFAULT_CONFIG_PATH)!! - .toMutableList() - .also { rulesConfig -> - rulesToDisable.forEach { warning -> - rulesConfig.removeIf { it.name == warning.name } - rulesConfig.add(RulesConfig(warning.name, enabled = false, configuration = emptyMap())) - } - rulesToOverride.forEach { (warning, configuration) -> - rulesConfig.removeIf { it.name == warning } - rulesConfig.add(RulesConfig(warning, enabled = true, configuration = configuration)) - } - } - .toList() - createTempFile().toFile() - .also { - configFilePath = it.absolutePath - } - .writeText( - Yaml(configuration = YamlConfiguration(strictMode = true)) - .encodeToString(ListSerializer(RulesConfig.serializer()), rulesConfig) - ) +class DiktatSaveSmokeTest : DiktatSmokeTestBase() { + @BeforeEach + fun setUp() { + unfixedLintErrors.clear() } - @Test - @Tag("DiktatRuleSetProvider") - fun `save smoke test #1`() { - saveSmokeTest(DEFAULT_CONFIG_PATH, "Bug1Expected.kt", "Bug1Test.kt") + @AfterEach + fun tearDown() { + configFilePath = DEFAULT_CONFIG_PATH } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #2`() { - saveSmokeTest(DEFAULT_CONFIG_PATH, "DefaultPackageExpected.kt", "DefaultPackageTest.kt") - } - - @Test - @Tag("DiktatRuleSetProvider") - fun `save smoke test #3`() { - overrideRulesConfig( - rulesToDisable = emptyList(), - rulesToOverride = mapOf( - Warnings.WRONG_INDENTATION.name to mapOf( - "extendedIndentAfterOperators" to "true", - "extendedIndentBeforeDot" to "false", - ) - ) - ) - saveSmokeTest(configFilePath, "Example1Expected.kt", "Example1Test.kt") + override fun `regression - should not fail if package is not set`() { + overrideRulesConfig(listOf(Warnings.PACKAGE_NAME_MISSING, Warnings.PACKAGE_NAME_INCORRECT_PATH, + Warnings.PACKAGE_NAME_INCORRECT_PREFIX)) + saveSmokeTest(configFilePath, "DefaultPackageExpected.kt", "DefaultPackageTest.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #4`() { - overrideRulesConfig( - rulesToDisable = emptyList(), - rulesToOverride = mapOf( - Warnings.WRONG_INDENTATION.name to mapOf( - "extendedIndentAfterOperators" to "true", - "extendedIndentBeforeDot" to "true", - ) - ) - ) - saveSmokeTest(configFilePath, "Example2Expected.kt", "Example2Test.kt") + override fun `smoke test #8 - anonymous function`() { + saveSmokeTest(configFilePath, "Example8Expected.kt", "Example8Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #5`() { - saveSmokeTest(DEFAULT_CONFIG_PATH, "Example3Expected.kt", "Example3Test.kt") + override fun `smoke test #7`() { + saveSmokeTest(configFilePath, "Example7Expected.kt", "Example7Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #6`() { + override fun `smoke test #6`() { overrideRulesConfig( rulesToDisable = emptyList(), rulesToOverride = mapOf( Warnings.WRONG_INDENTATION.name to mapOf( "extendedIndentAfterOperators" to "true", - "extendedIndentBeforeDot" to "false", + "extendedIndentBeforeDot" to "true", ) ) ) - saveSmokeTest(configFilePath, "Example4Expected.kt", "Example4Test.kt") + saveSmokeTest(configFilePath, "Example6Expected.kt", "Example6Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #7`() { + override fun `smoke test #5`() { overrideRulesConfig(emptyList(), mapOf( Warnings.HEADER_MISSING_OR_WRONG_COPYRIGHT.name to mapOf( @@ -139,66 +82,103 @@ class DiktatSaveSmokeTest : FixTestBase("test/smoke/src/main/kotlin", @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #8`() { + override fun `smoke test #4`() { overrideRulesConfig( rulesToDisable = emptyList(), rulesToOverride = mapOf( Warnings.WRONG_INDENTATION.name to mapOf( "extendedIndentAfterOperators" to "true", - "extendedIndentBeforeDot" to "true", + "extendedIndentBeforeDot" to "false", ) ) ) - saveSmokeTest(configFilePath, "Example6Expected.kt", "Example6Test.kt") + saveSmokeTest(configFilePath, "Example4Expected.kt", "Example4Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #9`() { - saveSmokeTest(DEFAULT_CONFIG_PATH, "Example7Expected.kt", "Example7Test.kt") + override fun `smoke test #3`() { + saveSmokeTest(configFilePath, "Example3Expected.kt", "Example3Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #10`() { - saveSmokeTest(DEFAULT_CONFIG_PATH, "Example8Expected.kt", "Example8Test.kt") + override fun `regression - shouldn't throw exception in cases similar to #371`() { + saveSmokeTest(configFilePath, "Bug1Expected.kt", "Bug1Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #11`() { - saveSmokeTest(DEFAULT_CONFIG_PATH, "KdocFormattingMultilineTagsExpected.kt", "KdocFormattingMultilineTagsTest.kt") + override fun `smoke test #2`() { + overrideRulesConfig( + rulesToDisable = emptyList(), + rulesToOverride = mapOf( + Warnings.WRONG_INDENTATION.name to mapOf( + "extendedIndentAfterOperators" to "true", + "extendedIndentBeforeDot" to "true", + ) + ) + ) + saveSmokeTest(configFilePath, "Example2Expected.kt", "Example2Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #12`() { - saveSmokeTest(DEFAULT_CONFIG_PATH, "ManyLineTransformInLongLineExpected.kt", "ManyLineTransformInLongLineTest.kt") + override fun `smoke test #1`() { + overrideRulesConfig( + rulesToDisable = emptyList(), + rulesToOverride = mapOf( + Warnings.WRONG_INDENTATION.name to mapOf( + "extendedIndentAfterOperators" to "true", + "extendedIndentBeforeDot" to "false", + ) + ) + ) + saveSmokeTest(configFilePath, "Example1Expected.kt", "Example1Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test #13`() { - saveSmokeTest(DEFAULT_CONFIG_PATH, "LocalVariableWithOffsetExpected.kt", "LocalVariableWithOffsetTest.kt") + override fun `smoke test with kts files #2`() { + saveSmokeTest(configFilePath, "script/SimpleRunInScriptExpected.kts", "script/SimpleRunInScriptTest.kts") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test with kts files #2`() { - saveSmokeTest(DEFAULT_CONFIG_PATH, "script/SimpleRunInScriptExpected.kts", "script/SimpleRunInScriptTest.kts") + override fun `smoke test with kts files with package name`() { + saveSmokeTest(configFilePath, "script/PackageInScriptExpected.kts", "script/PackageInScriptTest.kts") } @Test @Tag("DiktatRuleSetProvider") - fun `save smoke test with kts files with package name`() { - saveSmokeTest(DEFAULT_CONFIG_PATH, "script/PackageInScriptExpected.kts", "script/PackageInScriptTest.kts") + override fun `disable charters`() { + overrideRulesConfig( + emptyList(), + mapOf( + DIKTAT_COMMON to mapOf( + "domainName" to "org.cqfn.diktat", + "disabledChapters" to "Naming,3,4,5,Classes" + ) + ) + ) + saveSmokeTest(configFilePath, "Example1-2Expected.kt", "Example1Test.kt") } - companion object { - private const val DEFAULT_CONFIG_PATH = "../diktat-analysis.yml" - private val unfixedLintErrors: MutableList = mutableListOf() + @Test + @Tag("DiktatRuleSetProvider") + override fun `regression - should correctly handle tags with empty lines`() { + saveSmokeTest(configFilePath, "KdocFormattingMultilineTagsExpected.kt", "KdocFormattingMultilineTagsTest.kt") + } + + @Test + @Tag("DiktatRuleSetProvider") + override fun `regression - FP of local variables rule`() { + saveSmokeTest(configFilePath, "LocalVariableWithOffsetExpected.kt", "LocalVariableWithOffsetTest.kt") + } - // by default using same yml config as for diktat code style check, but allow to override - private var configFilePath = DEFAULT_CONFIG_PATH + @Test + @Tag("DiktatRuleSetProvider") + override fun `fix can cause long line`() { + saveSmokeTest(configFilePath, "ManyLineTransformInLongLineExpected.kt", "ManyLineTransformInLongLineTest.kt") } } diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt index d0578e8a0a..40f4e11706 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTest.kt @@ -2,8 +2,6 @@ package org.cqfn.diktat.ruleset.smoke import org.cqfn.diktat.common.config.rules.DIKTAT_COMMON import org.cqfn.diktat.common.config.rules.DIKTAT_RULE_SET_ID -import org.cqfn.diktat.common.config.rules.RulesConfig -import org.cqfn.diktat.common.config.rules.RulesConfigReader import org.cqfn.diktat.ruleset.constants.Warnings import org.cqfn.diktat.ruleset.constants.Warnings.EMPTY_BLOCK_STRUCTURE_ERROR import org.cqfn.diktat.ruleset.constants.Warnings.FILE_NAME_MATCH_CLASS @@ -23,11 +21,8 @@ import org.cqfn.diktat.ruleset.rules.chapter2.kdoc.KdocFormatting import org.cqfn.diktat.ruleset.rules.chapter2.kdoc.KdocMethods import org.cqfn.diktat.ruleset.rules.chapter3.EmptyBlock import org.cqfn.diktat.ruleset.rules.chapter6.classes.InlineClassesRule -import org.cqfn.diktat.util.FixTestBase import org.cqfn.diktat.util.assertEquals -import com.charleskorn.kaml.Yaml -import com.charleskorn.kaml.YamlConfiguration import com.pinterest.ktlint.core.LintError import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions @@ -38,9 +33,6 @@ import org.junit.jupiter.api.Test import java.io.File import java.time.LocalDate -import kotlin.io.path.createTempFile -import kotlinx.serialization.builtins.ListSerializer - typealias RuleToConfig = Map> /** @@ -48,39 +40,7 @@ typealias RuleToConfig = Map> * Note: ktlint uses initial text from a file to calculate line and column from offset. Because of that line/col of unfixed errors * may change after some changes to text or other rules. */ -class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", - { DiktatRuleSetProvider(configFilePath) }, - { lintError, _ -> unfixedLintErrors.add(lintError) }, - null -) { - /** - * Disable some of the rules. - */ - @Suppress("UnsafeCallOnNullableType") - private fun overrideRulesConfig(rulesToDisable: List, rulesToOverride: RuleToConfig = emptyMap()) { - val rulesConfig = RulesConfigReader(javaClass.classLoader).readResource(configFilePath)!! - .toMutableList() - .also { rulesConfig -> - rulesToDisable.forEach { warning -> - rulesConfig.removeIf { it.name == warning.name } - rulesConfig.add(RulesConfig(warning.name, enabled = false, configuration = emptyMap())) - } - rulesToOverride.forEach { (warning, configuration) -> - rulesConfig.removeIf { it.name == warning } - rulesConfig.add(RulesConfig(warning, enabled = true, configuration = configuration)) - } - } - .toList() - createTempFile().toFile() - .also { - configFilePath = it.absolutePath - } - .writeText( - Yaml(configuration = YamlConfiguration(strictMode = true)) - .encodeToString(ListSerializer(RulesConfig.serializer()), rulesConfig) - ) - } - +class DiktatSmokeTest : DiktatSmokeTestBase() { @BeforeEach fun setUp() { unfixedLintErrors.clear() @@ -100,7 +60,7 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", @Test @Tag("DiktatRuleSetProvider") - fun `regression - should not fail if package is not set`() { + override fun `regression - should not fail if package is not set`() { overrideRulesConfig(listOf(Warnings.PACKAGE_NAME_MISSING, Warnings.PACKAGE_NAME_INCORRECT_PATH, Warnings.PACKAGE_NAME_INCORRECT_PREFIX)) fixAndCompareSmokeTest("DefaultPackageExpected.kt", "DefaultPackageTest.kt") @@ -108,19 +68,19 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", @Test @Tag("DiktatRuleSetProvider") - fun `smoke test #8 - anonymous function`() { + override fun `smoke test #8 - anonymous function`() { fixAndCompareSmokeTest("Example8Expected.kt", "Example8Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `smoke test #7`() { + override fun `smoke test #7`() { fixAndCompareSmokeTest("Example7Expected.kt", "Example7Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `smoke test #6`() { + override fun `smoke test #6`() { overrideRulesConfig( rulesToDisable = emptyList(), rulesToOverride = mapOf( @@ -135,7 +95,7 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", @Test @Tag("DiktatRuleSetProvider") - fun `smoke test #5`() { + override fun `smoke test #5`() { overrideRulesConfig(emptyList(), mapOf( Warnings.HEADER_MISSING_OR_WRONG_COPYRIGHT.name to mapOf( @@ -167,7 +127,7 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", @Test @Tag("DiktatRuleSetProvider") - fun `smoke test #4`() { + override fun `smoke test #4`() { overrideRulesConfig( rulesToDisable = emptyList(), rulesToOverride = mapOf( @@ -182,19 +142,19 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", @Test @Tag("DiktatRuleSetProvider") - fun `smoke test #3`() { + override fun `smoke test #3`() { fixAndCompareSmokeTest("Example3Expected.kt", "Example3Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `regression - shouldn't throw exception in cases similar to #371`() { + override fun `regression - shouldn't throw exception in cases similar to #371`() { fixAndCompareSmokeTest("Bug1Expected.kt", "Bug1Test.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `smoke test #2`() { + override fun `smoke test #2`() { overrideRulesConfig( rulesToDisable = emptyList(), rulesToOverride = mapOf( @@ -217,7 +177,7 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", @Test @Tag("DiktatRuleSetProvider") - fun `smoke test #1`() { + override fun `smoke test #1`() { overrideRulesConfig( rulesToDisable = emptyList(), rulesToOverride = mapOf( @@ -284,21 +244,21 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", @Test @Tag("DiktatRuleSetProvider") - fun `smoke test with kts files #2`() { + override fun `smoke test with kts files #2`() { fixAndCompareSmokeTest("script/SimpleRunInScriptExpected.kts", "script/SimpleRunInScriptTest.kts") Assertions.assertEquals(7, unfixedLintErrors.size) } @Test @Tag("DiktatRuleSetProvider") - fun `smoke test with kts files with package name`() { + override fun `smoke test with kts files with package name`() { fixAndCompareSmokeTest("script/PackageInScriptExpected.kts", "script/PackageInScriptTest.kts") Assertions.assertEquals(7, unfixedLintErrors.size) } @Test @Tag("DiktatRuleSetProvider") - fun `disable charters`() { + override fun `disable charters`() { overrideRulesConfig( emptyList(), mapOf( @@ -324,13 +284,13 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", @Test @Tag("DiktatRuleSetProvider") - fun `regression - should correctly handle tags with empty lines`() { + override fun `regression - should correctly handle tags with empty lines`() { fixAndCompareSmokeTest("KdocFormattingMultilineTagsExpected.kt", "KdocFormattingMultilineTagsTest.kt") } @Test @Tag("DiktatRuleSetProvider") - fun `regression - FP of local variables rule`() { + override fun `regression - FP of local variables rule`() { fixAndCompareSmokeTest("LocalVariableWithOffsetExpected.kt", "LocalVariableWithOffsetTest.kt") org.assertj .core @@ -344,15 +304,7 @@ class DiktatSmokeTest : FixTestBase("test/smoke/src/main/kotlin", @Test @Tag("DiktatRuleSetProvider") - fun `fix can cause long line`() { + override fun `fix can cause long line`() { fixAndCompareSmokeTest("ManyLineTransformInLongLineExpected.kt", "ManyLineTransformInLongLineTest.kt") } - - companion object { - private const val DEFAULT_CONFIG_PATH = "../diktat-analysis.yml" - private val unfixedLintErrors: MutableList = mutableListOf() - - // by default using same yml config as for diktat code style check, but allow to override - private var configFilePath = DEFAULT_CONFIG_PATH - } } diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTestBase.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTestBase.kt new file mode 100644 index 0000000000..422179b8b2 --- /dev/null +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTestBase.kt @@ -0,0 +1,114 @@ +@file:Suppress( + "MISSING_KDOC_CLASS_ELEMENTS", + "MISSING_KDOC_ON_FUNCTION", + "BACKTICKS_PROHIBITED", +) + +package org.cqfn.diktat.ruleset.smoke + +import org.cqfn.diktat.common.config.rules.RulesConfig +import org.cqfn.diktat.common.config.rules.RulesConfigReader +import org.cqfn.diktat.ruleset.constants.Warnings +import org.cqfn.diktat.ruleset.rules.DiktatRuleSetProvider +import org.cqfn.diktat.util.FixTestBase +import com.charleskorn.kaml.Yaml +import com.charleskorn.kaml.YamlConfiguration +import com.pinterest.ktlint.core.LintError +import org.junit.jupiter.api.Tag +import kotlinx.serialization.builtins.ListSerializer + +/** + * Base class for smoke test classes + */ +abstract class DiktatSmokeTestBase : FixTestBase("test/smoke/src/main/kotlin", + { DiktatRuleSetProvider(configFilePath) }, + { lintError, _ -> unfixedLintErrors.add(lintError) }, +) { + /** + * Disable some of the rules. + * + * @param rulesToDisable + * @param rulesToOverride + */ + @Suppress("UnsafeCallOnNullableType") + open fun overrideRulesConfig(rulesToDisable: List, rulesToOverride: RuleToConfig = emptyMap()) { + val rulesConfig = RulesConfigReader(javaClass.classLoader).readResource(DEFAULT_CONFIG_PATH)!! + .toMutableList() + .also { rulesConfig -> + rulesToDisable.forEach { warning -> + rulesConfig.removeIf { it.name == warning.name } + rulesConfig.add(RulesConfig(warning.name, enabled = false, configuration = emptyMap())) + } + rulesToOverride.forEach { (warning, configuration) -> + rulesConfig.removeIf { it.name == warning } + rulesConfig.add(RulesConfig(warning, enabled = true, configuration = configuration)) + } + } + .toList() + kotlin.io.path.createTempFile() + .toFile() + .also { + configFilePath = it.absolutePath + } + .writeText( + Yaml(configuration = YamlConfiguration(strictMode = true)) + .encodeToString(ListSerializer(RulesConfig.serializer()), rulesConfig) + ) + } + + @Tag("DiktatRuleSetProvider") + abstract fun `regression - should not fail if package is not set`() + + @Tag("DiktatRuleSetProvider") + abstract fun `smoke test #8 - anonymous function`() + + @Tag("DiktatRuleSetProvider") + abstract fun `smoke test #7`() + + @Tag("DiktatRuleSetProvider") + abstract fun `smoke test #6`() + + @Tag("DiktatRuleSetProvider") + abstract fun `smoke test #5`() + + @Tag("DiktatRuleSetProvider") + abstract fun `smoke test #4`() + + @Tag("DiktatRuleSetProvider") + abstract fun `smoke test #3`() + + @Tag("DiktatRuleSetProvider") + abstract fun `regression - shouldn't throw exception in cases similar to #371`() + + @Tag("DiktatRuleSetProvider") + abstract fun `smoke test #2`() + + @Tag("DiktatRuleSetProvider") + abstract fun `smoke test #1`() + + @Tag("DiktatRuleSetProvider") + abstract fun `smoke test with kts files #2`() + + @Tag("DiktatRuleSetProvider") + abstract fun `smoke test with kts files with package name`() + + @Tag("DiktatRuleSetProvider") + abstract fun `disable charters`() + + @Tag("DiktatRuleSetProvider") + abstract fun `regression - should correctly handle tags with empty lines`() + + @Tag("DiktatRuleSetProvider") + abstract fun `regression - FP of local variables rule`() + + @Tag("DiktatRuleSetProvider") + abstract fun `fix can cause long line`() + + companion object { + const val DEFAULT_CONFIG_PATH = "../diktat-analysis.yml" + val unfixedLintErrors: MutableList = mutableListOf() + + // by default using same yml config as for diktat code style check, but allow to override + var configFilePath = DEFAULT_CONFIG_PATH + } +} diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/FixTestBase.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/FixTestBase.kt index 9e637b1f64..e3aa7442b3 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/FixTestBase.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/FixTestBase.kt @@ -80,11 +80,11 @@ open class FixTestBase( val request = HttpGet(url) httpClient.use { val response: CloseableHttpResponse = httpClient.execute(request) - val fileSave = response.use { - response.entity - } - fileSave?.let { - FileOutputStream(file).use { outstream -> fileSave.writeTo(outstream) } + response.use { + val fileSave = response.entity + fileSave?.let { + FileOutputStream(file).use { outstream -> fileSave.writeTo(outstream) } + } } } }