diff --git a/diktat-gradle-plugin/pom.xml b/diktat-gradle-plugin/pom.xml
index 54da8f318b..3969806433 100644
--- a/diktat-gradle-plugin/pom.xml
+++ b/diktat-gradle-plugin/pom.xml
@@ -14,13 +14,12 @@
pom
- ${project.basedir}/gradlew
+ ${project.basedir}
+ gradlew
build
build
false
false
-
-
@@ -61,12 +60,15 @@
org.codehaus.mojo
exec-maven-plugin
false
+
+ ${gradle.workingDir}
+ ${gradle.workingDir}/${gradle.executable}
+
gradle-test
test
- ${gradle.executable}
clean
test
@@ -88,7 +90,6 @@
gradle
prepare-package
- ${gradle.executable}
${gradle.task}
-Pgroup=${project.groupId}
@@ -98,7 +99,8 @@
-PjunitVersion=${junit.version}
-PjacocoVersion=${jacoco.version}
-S
- ${gradle.exclude.check}
+
+
${skip.gradle.build}
@@ -185,7 +187,7 @@
- ${project.basedir}/gradlew.bat
+ gradlew.bat
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt
index 516b141acc..9ac53e2c6e 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt
@@ -198,7 +198,7 @@ class KdocFormatting(configRules: List) : DiktatRule(
val kdocTags = node.kDocTags()
// distinct basic tags which are present in current KDoc, in proper order
val basicTagsOrdered = basicTagsList.filter { basicTag ->
- kdocTags.find { it.knownTag == basicTag } != null
+ kdocTags.any { it.knownTag == basicTag }
}
// all basic tags from current KDoc
val basicTags = kdocTags.filter { basicTagsOrdered.contains(it.knownTag) }
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MagicNumberRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MagicNumberRule.kt
index 1b8dd1b7c7..84d91930b9 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MagicNumberRule.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MagicNumberRule.kt
@@ -65,7 +65,7 @@ class MagicNumberRule(configRules: List) : DiktatRule(
this.findChildByType(OPERATION_REFERENCE)?.hasChildOfType(RANGE) ?: false
}
val isExtensionFunctions = node.parent({ it.elementType == FUN && (it.psi as KtFunction).isExtensionDeclaration() }) != null &&
- node.parents().find { it.elementType == PROPERTY } == null
+ node.parents().none { it.elementType == PROPERTY }
val result = listOf(isHashFunction, isPropertyDeclaration, isLocalVariable, isValueParameter, isConstant,
isCompanionObjectProperty, isEnums, isRanges, isExtensionFunctions).zip(mapConfiguration.map { configuration.getParameter(it.key) })
if (result.any { it.first && it.first != it.second } && !isIgnoreNumber) {
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SortRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SortRule.kt
index 195b38efe7..59afbf4eb4 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SortRule.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SortRule.kt
@@ -117,15 +117,14 @@ class SortRule(configRules: List) : DiktatRule(
@Suppress("TYPE_ALIAS")
private fun createOrderListOfList(propertyList: List): List> {
- var oneOrderList = mutableListOf(propertyList.first())
+ val oneOrderList = mutableListOf(propertyList.first())
val orderListOfList: MutableList> = mutableListOf()
propertyList.zipWithNext().forEach { (currentProperty, nextProperty) ->
- if (currentProperty.nextSibling { it.elementType == PROPERTY } == nextProperty) {
- oneOrderList.add(nextProperty)
- } else {
- orderListOfList.add(oneOrderList)
- oneOrderList = mutableListOf(nextProperty)
+ if (currentProperty.nextSibling { it.elementType == PROPERTY } != nextProperty) {
+ orderListOfList.add(oneOrderList.toMutableList())
+ oneOrderList.clear()
}
+ oneOrderList.add(nextProperty)
}
orderListOfList.add(oneOrderList)
return orderListOfList.toList()
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt
index 135cbc7826..6fb5c6ee61 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt
@@ -101,7 +101,7 @@ class TrailingCommaRule(configRules: List) : DiktatRule(
private fun ASTNode.checkTrailingComma(config: Boolean) {
val shouldFix = this.siblings(true).toList().run {
- !this.map { it.elementType }.contains(COMMA) && this.find { it.isWhiteSpaceWithNewline() || it.isPartOfComment() } != null
+ !this.map { it.elementType }.contains(COMMA) && this.any { it.isWhiteSpaceWithNewline() || it.isPartOfComment() }
}
if (shouldFix && config) {
// we should write type of node in warning, to make it easier for user to find the parameter
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt
index 70932f08c6..68c1a378cb 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt
@@ -641,15 +641,13 @@ class NewlinesRule(configRules: List) : DiktatRule(
return false
}
val callsByNewLine: ListOfList = mutableListOf()
- var callsInOneNewLine: MutableList = mutableListOf()
+ val callsInOneNewLine: MutableList = mutableListOf()
this.forEach { astNode ->
if (astNode.treePrev.isFollowedByNewline() || astNode.treePrev.isWhiteSpaceWithNewline()) {
- callsByNewLine.add(callsInOneNewLine)
- callsInOneNewLine = mutableListOf()
- callsInOneNewLine.add(astNode)
- } else {
- callsInOneNewLine.add(astNode)
+ callsByNewLine.add(callsInOneNewLine.toMutableList())
+ callsInOneNewLine.clear()
}
+ callsInOneNewLine.add(astNode)
if (astNode.treePrev.elementType == POSTFIX_EXPRESSION && !astNode.treePrev.isFollowedByNewline() && configuration.maxCallsInOneLine == 1) {
return true
}
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleInitRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleInitRule.kt
index d7ff713969..72ecc80076 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleInitRule.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleInitRule.kt
@@ -110,7 +110,7 @@ class SingleInitRule(configRules: List) : DiktatRule(
.filter { it.left is KtNameReferenceExpression }
.filter { statement ->
statement.right?.node?.findAllDescendantsWithSpecificType(REFERENCE_EXPRESSION)?.all { arg ->
- propertiesFromClassBody.any { (it.psi as KtProperty).name == arg.text } || propertiesFromPrimaryConstructor?.find { it == arg.text } != null
+ propertiesFromClassBody.any { (it.psi as KtProperty).name == arg.text } || propertiesFromPrimaryConstructor?.any { it == arg.text } == true
} ?: false
}
.groupBy { assignment ->
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/AstNodeUtils.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/AstNodeUtils.kt
index a6c6fdf8dd..71c996f9bf 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/AstNodeUtils.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/AstNodeUtils.kt
@@ -702,12 +702,11 @@ fun List.handleIncorrectOrder(
*/
@Suppress("WRONG_NEWLINES")
fun ASTNode.extractLineOfText(): String {
- var text: MutableList = mutableListOf()
+ val text: MutableList = mutableListOf()
siblings(false)
.map { it.text.split("\n") }
.takeWhileInclusive { it.size <= 1 }
- .forEach { text.add(it.last()) }
- text = text.asReversed()
+ .forEach { text.add(0, it.last()) }
text.add(this.text)
val nextNode = parent({ it.treeNext != null }, false) ?: this
nextNode.siblings(true)
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/KdocUtils.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/KdocUtils.kt
index 8c880df76b..3cd2d3c6a8 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/KdocUtils.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/KdocUtils.kt
@@ -32,7 +32,7 @@ fun ASTNode.kDocTags(): List {
* @return whether this tag is present
*/
fun Iterable.hasKnownKdocTag(knownTag: KDocKnownTag): Boolean =
- this.find { it.knownTag == knownTag } != null
+ this.any { it.knownTag == knownTag }
/**
* Checks for trailing newlines in tag's body. Handles cases, when there is no leading asterisk on an empty line:
diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/AvailableRulesDocTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/AvailableRulesDocTest.kt
index d07c06287f..b8268433af 100644
--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/AvailableRulesDocTest.kt
+++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/AvailableRulesDocTest.kt
@@ -33,7 +33,7 @@ class AvailableRulesDocTest {
allRulesFromCode.forEach { warning ->
val ruleName = warning.ruleName()
- val ruleFound = allRulesFromDoc.find { it.trim() == ruleName } != null
+ val ruleFound = allRulesFromDoc.any { it.trim() == ruleName }
Assertions.assertTrue(ruleFound) {
val docs = "| | | $ruleName" +
"| | | | |"
@@ -47,10 +47,10 @@ class AvailableRulesDocTest {
allRulesFromDoc.forEach { warning ->
val trimmedWarning = warning.trim()
- val ruleFound = allRulesFromCode.find { it.ruleName() == trimmedWarning } != null
+ val ruleFound = allRulesFromCode.any { it.ruleName() == trimmedWarning }
Assertions.assertTrue(ruleFound) {
"""
- Found rule (warning) in documentation: <$trimmedWarning> that does not exist in the code. Misprint or configuration was renamed?
+ Found rule (warning) in documentation: <$trimmedWarning> that does not exist in the code. Misprint or configuration was renamed?
""".trimIndent()
}
}
diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt
index 0517d3418f..510910fb77 100644
--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt
+++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/RulesConfigYamlTest.kt
@@ -98,10 +98,10 @@ class RulesConfigYamlTest {
allRulesFromConfig.forEach { warning ->
val warningName = warning.name
- val ruleFound = allRulesFromCode.find { it.ruleName() == warningName || warningName == "DIKTAT_COMMON" } != null
+ val ruleFound = allRulesFromCode.any { it.ruleName() == warningName || warningName == "DIKTAT_COMMON" }
Assertions.assertTrue(ruleFound) {
"""
- Found rule (warning) in $filePath: <$warningName> that does not exist in the code. Misprint or configuration was renamed?
+ Found rule (warning) in $filePath: <$warningName> that does not exist in the code. Misprint or configuration was renamed?
""".trimIndent()
}
}
diff --git a/pom.xml b/pom.xml
index 0f9524d01b..d0eb3bf0a9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,15 +47,15 @@
official
1.3.3
0.46.1
- 5.8.2
- 1.8.2
+ 5.9.0
+ 1.9.0
31.1-jre
1.7.36
1.5.0
1.2.3
1.12.0
- 1.20.0
- 1.7.0
+ 1.21.0
+ 1.7.10
0.8.8
3.6.4
1.23
@@ -244,7 +244,7 @@
org.apache.maven.plugins
maven-deploy-plugin
- 3.0.0-M2
+ 3.0.0
org.apache.maven.plugins
@@ -254,7 +254,7 @@
org.apache.maven.plugins
maven-assembly-plugin
- 3.4.1
+ 3.4.2
@@ -316,7 +316,7 @@
org.codehaus.mojo
exec-maven-plugin
- 3.0.0
+ 3.1.0
org.jacoco