Skip to content

Commit

Permalink
Detekt 1.16.0
Browse files Browse the repository at this point in the history
### What's done:
* Code style
  • Loading branch information
petertrr committed Mar 15, 2021
1 parent 3470597 commit 7311c32
Show file tree
Hide file tree
Showing 11 changed files with 836 additions and 202 deletions.
287 changes: 92 additions & 195 deletions detekt-config.yml

Large diffs are not rendered by default.

736 changes: 736 additions & 0 deletions detekt.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlin.system.exitProcess
/**
* Base class for working with properties files.
*/
@Suppress("SwallowedException")
open class ApplicationProperties(propertiesFileName: String) {
/**
* The [Properties] loaded from a file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import java.util.concurrent.atomic.AtomicInteger

import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
import java.util.Locale

const val DIKTAT_COMMON = "DIKTAT_COMMON"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal fun runDiktat(testProjectDir: TemporaryFolder,
) = GradleRunner.create()
.run(configureRunner)
.withProjectDir(testProjectDir.root)
.withArguments(*arguments.toTypedArray(), DiktatGradlePlugin.DIKTAT_CHECK_TASK)
.withArguments(arguments + DiktatGradlePlugin.DIKTAT_CHECK_TASK)
.withPluginClasspath()
.withJaCoCo(testsCounter.incrementAndGet())
.forwardOutput()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class DiktatRuleSetProvider(private var diktatConfigFile: String = DIKTAT_ANALYS
it?.takeIf { File(it).exists() }
}

@Suppress("LongMethod", "TOO_LONG_FUNCTION")
@Suppress("LongMethod", "TOO_LONG_FUNCTION", "SpreadOperator")
override fun get(): RuleSet {
log.debug("Will run $DIKTAT_RULE_SET_ID with $diktatConfigFile" +
" (it can be placed to the run directory or the default file from resources will be used)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class IdentifierNaming(configRules: List<RulesConfig>) : DiktatRule(
ENUM_VALUE, EXCEPTION_SUFFIX, FUNCTION_BOOLEAN_PREFIX, FUNCTION_NAME_INCORRECT_CASE,
IDENTIFIER_LENGTH, OBJECT_NAME_INCORRECT)) {
private val allMethodPrefixes by lazy {
if (configuration.allowedBooleanPrefixes.isNullOrEmpty()) {
if (configuration.allowedBooleanPrefixes.isEmpty()) {
booleanMethodPrefixes
} else {
booleanMethodPrefixes + configuration.allowedBooleanPrefixes.filter { it.isNotEmpty() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class FileStructureRule(configRules: List<RulesConfig>) : DiktatRule(
return hasCode
}

@Suppress("ComplexMethod", "TOO_LONG_FUNCTION")
@Suppress("ComplexMethod", "TOO_LONG_FUNCTION", "SpreadOperator")
private fun checkCodeBlocksOrderAndEmptyLines(node: ASTNode) {
// From KtFile.kt: 'scripts have no package directive, all other files must have package directives'.
// Kotlin compiler itself enforces it's position in the file if it is present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class StatelessClassesRule(configRules: List<RulesConfig>) : DiktatRule(
private fun isStatelessClass(node: ASTNode): Boolean {
val properties = (node.psi as KtClass).getProperties()
val functions = node.findAllDescendantsWithSpecificType(FUN)
return properties.isNullOrEmpty() &&
return properties.isEmpty() &&
functions.isNotEmpty() &&
!(node.psi as KtClass).hasExplicitPrimaryConstructor()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class NewlinesRuleWarnTest : LintTestBase(::NewlinesRule) {
private val lambdaWithArrowWarn = "${WRONG_NEWLINES.warnText()} in lambda with several lines in body newline should be placed after an arrow"
private val lambdaWithoutArrowWarn = "${WRONG_NEWLINES.warnText()} in lambda with several lines in body newline should be placed after an opening brace"
private val singleReturnWarn = "${WRONG_NEWLINES.warnText()} functions with single return statement should be simplified to expression body"
private val listParameter = "${WRONG_NEWLINES.warnText()} list parameter should be placed on different lines in declaration of <foo>"

@Test
@Tag(WarningNames.REDUNDANT_SEMICOLON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.slf4j.LoggerFactory
*/
class TestCheckWarn : TestCompare() {
@Suppress("MISSING_KDOC_CLASS_ELEMENTS") override val log: Logger = LoggerFactory.getLogger(TestCheckWarn::class.java)
private var testConfig: TestConfig? = null
@Suppress("UnusedPrivateMember") private var testConfig: TestConfig? = null

/**
* Get tests execution result
Expand Down

0 comments on commit 7311c32

Please sign in to comment.