Repository: analysis-dev/diktat (kotlin)

Issue:
CLASS_SHOULD_NOT_BE_ABSTRACT: abstract fields are ignored
```
abstract class BaseUsesProcessor() {
    // Store uses by file
    abstract val a: String
    
    fun foo() {}
}
```

is incorrectly treated as NON abstract class

Pull request:
### What's done:
* Fix logic
* Add tests

## Which rule and warnings did you add?

This pull request closes #1100

Patch:
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/AbstractClassesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/AbstractClassesRule.kt
index b409636397..460beb3f8a 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/AbstractClassesRule.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/AbstractClassesRule.kt
@@ -14,6 +14,7 @@ import com.pinterest.ktlint.core.ast.ElementType.FUN
 import com.pinterest.ktlint.core.ast.ElementType.IDENTIFIER
 import com.pinterest.ktlint.core.ast.ElementType.MODIFIER_LIST
 import com.pinterest.ktlint.core.ast.ElementType.OPEN_KEYWORD
+import com.pinterest.ktlint.core.ast.ElementType.PROPERTY
 import org.jetbrains.kotlin.com.intellij.lang.ASTNode
 import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafPsiElement
 
@@ -40,10 +41,12 @@ class AbstractClassesRule(configRules: List<RulesConfig>) : DiktatRule(
     @Suppress("UnsafeCallOnNullableType")
     private fun handleAbstractClass(node: ASTNode, classNode: ASTNode) {
         val functions = node.getAllChildrenWithType(FUN)
+        val properties = node.getAllChildrenWithType(PROPERTY)
+        val members = functions + properties
 
         val identifier = classNode.getFirstChildWithType(IDENTIFIER)!!.text
 
-        if (functions.isNotEmpty() && functions.none { hasAbstractModifier(it) }) {
+        if (members.isNotEmpty() && members.none { hasAbstractModifier(it) }) {
             CLASS_SHOULD_NOT_BE_ABSTRACT.warnAndFix(configRules, emitWarn, isFixMode, identifier, node.startOffset, node) {
                 val modList = classNode.getFirstChildWithType(MODIFIER_LIST)!!
                 val abstractKeyword = modList.getFirstChildWithType(ABSTRACT_KEYWORD)!!


Test patch:
diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/AbstractClassesWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/AbstractClassesWarnTest.kt
index 76d2fc9511..4b7d1049a1 100644
--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/AbstractClassesWarnTest.kt
+++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/AbstractClassesWarnTest.kt
@@ -86,4 +86,19 @@ class AbstractClassesWarnTest : LintTestBase(::AbstractClassesRule) {
             LintError(1, 58, ruleId, "${Warnings.CLASS_SHOULD_NOT_BE_ABSTRACT.warnText()} CoroutineTest", true)
         )
     }
+
+    @Test
+    @Tag(CLASS_SHOULD_NOT_BE_ABSTRACT)
+    fun `should not remove abstract on class if there are only abstract properties`() {
+        lintMethod(
+            """
+                |abstract class BaseUsesProcessor() {
+                |    // Store uses by file
+                |    abstract val a: String
+                |    
+                |    fun foo() {}
+                |}
+            """.trimMargin()
+        )
+    }
 }