From ce74f67d0a21b6a38f2e414cf68548c5c6344026 Mon Sep 17 00:00:00 2001 From: kentr0w Date: Tue, 2 Feb 2021 11:34:50 +0300 Subject: [PATCH] Copyright as code ### What's done: Fixed after review --- .../diktat/ruleset/rules/chapter2/comments/CommentsRule.kt | 2 +- .../ruleset/rules/chapter6/classes/CompactInitialization.kt | 4 ++-- .../diktat/ruleset/chapter2/comments/CommentedCodeTest.kt | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt index c5795243b7..d3413646c0 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt @@ -152,7 +152,7 @@ class CommentsRule(private val configRules: List) : Rule("comments" private val functionRegex = """^(public|private|protected)*\s*(override|abstract|actual|expect)*\s?fun\s+\w+(\(.*\))?(\s*:\s*\w+)?\s*[{=]${'$'}""".toRegex() private val rightBraceRegex = """^\s*}$""".toRegex() private val requirePartOfCode = """val |var |=|(\{((.|\n)*)\})""".toRegex() - private val codeFileStartCases = listOf(classRegex, importOrPackageRegex, functionRegex, rightBraceRegex, requirePartOfCode) + private val codeFileStartCases = listOf(classRegex, importOrPackageRegex, functionRegex, rightBraceRegex) private val eolCommentStart = """// \S""".toRegex() } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt index ce1ec0b205..4c64fa4f95 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt @@ -52,7 +52,7 @@ class CompactInitialization(private val configRules: List) : Rule(" * Check property's initializer: if it is a method call, we find all consecutive statements that are this property's * fields accessors and wrap them in an `apply` function. */ - @Suppress("UnsafeCallOnNullableType", "COMMENTED_OUT_CODE") + @Suppress("UnsafeCallOnNullableType") private fun handleProperty(property: KtProperty) { property.run { val propertyName = name @@ -81,7 +81,7 @@ class CompactInitialization(private val configRules: List) : Rule(" } } - @Suppress("UnsafeCallOnNullableType", "NestedBlockDepth", "COMMENTED_OUT_CODE") + @Suppress("UnsafeCallOnNullableType", "NestedBlockDepth") private fun moveAssignmentIntoApply(property: KtProperty, assignment: KtBinaryExpression) { // get apply expression or create empty; convert `apply(::foo)` to `apply { foo(this) }` if necessary getOrCreateApplyBlock(property).let(::convertValueParametersToLambdaArgument) diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/comments/CommentedCodeTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/comments/CommentedCodeTest.kt index c880266260..b35327d1bd 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/comments/CommentedCodeTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/comments/CommentedCodeTest.kt @@ -319,7 +319,6 @@ class CommentedCodeTest : LintTestBase(::CommentsRule) { */ """.trimMargin(), LintError(7, 13, ruleId, "${COMMENTED_OUT_CODE.warnText()} ", false), - LintError(10, 13, ruleId, "${COMMENTED_OUT_CODE.warnText()} x = 2+4", false), LintError(14, 13, ruleId, "${COMMENTED_OUT_CODE.warnText()} ", false) ) }