Repository: cqfn/diKTat (kotlin)

Issue:
Interfaces are violating the USE_DATA_CLASS rule
## Describe the bug

Interfaces are violating the USE_DATA_CLASS rule.

## Expected behavior

Interfaces cannot be data classes, so this should not happen.

## Observed behavior

## Steps to Reproduce

Have an interface with simple fields:

```kotlin
interface MutationResponse {
    val code: String
    val success: Boolean
    val message: String
}
```

## Environment information
* diktat version: 1.0.0-rc.2
* build tool (maven/gradle): gradle
* how is diktat run (CLI, plugin, etc.): plugin
* kotlin version: 1.5.21
* operating system: macOS
* link to a project (if your project is public):

Pull request:
### What's done:
- Fixed bug
- Added test
- Closes #1003

Patch:
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/DataClassesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/DataClassesRule.kt
index 2f03d76afa..6bc07f5f01 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/DataClassesRule.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/DataClassesRule.kt
@@ -14,6 +14,7 @@ import com.pinterest.ktlint.core.ast.ElementType.DATA_KEYWORD
 import com.pinterest.ktlint.core.ast.ElementType.ENUM_KEYWORD
 import com.pinterest.ktlint.core.ast.ElementType.FUN
 import com.pinterest.ktlint.core.ast.ElementType.INNER_KEYWORD
+import com.pinterest.ktlint.core.ast.ElementType.INTERFACE_KEYWORD
 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.PRIMARY_CONSTRUCTOR
@@ -42,10 +43,11 @@ class DataClassesRule(configRules: List<RulesConfig>) : DiktatRule(
     }
 
     private fun handleClass(node: ASTNode) {
-        if (node.isDataClass()) {
-            return
+        with((node.psi as KtClass)) {
+            if (isData() || isInterface()) {
+                return
+            }
         }
-
         if (node.canBeDataClass()) {
             raiseWarn(node)
         }
@@ -143,15 +145,6 @@ class DataClassesRule(configRules: List<RulesConfig>) : DiktatRule(
         return true
     }
 
-    @Suppress("UnsafeCallOnNullableType")
-    private fun ASTNode.isDataClass(): Boolean {
-        if (hasChildOfType(MODIFIER_LIST)) {
-            val list = getFirstChildWithType(MODIFIER_LIST)!!
-            return list.getChildren(null).any { it.elementType == DATA_KEYWORD }
-        }
-        return false
-    }
-
     companion object {
         private val badModifiers = listOf(OPEN_KEYWORD, ABSTRACT_KEYWORD, INNER_KEYWORD, SEALED_KEYWORD, ENUM_KEYWORD)
     }


Test patch:
diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/DataClassesRuleWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/DataClassesRuleWarnTest.kt
index e9638b1656..8bac0d9747 100644
--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/DataClassesRuleWarnTest.kt
+++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter6/DataClassesRuleWarnTest.kt
@@ -275,4 +275,18 @@ class DataClassesRuleWarnTest : LintTestBase(::DataClassesRule) {
             """.trimMargin()
         )
     }
+
+    @Test
+    @Tag(USE_DATA_CLASS)
+    fun `shouldn't trigger on interface`() {
+        lintMethod(
+            """
+                |interface Credentials {
+                |   val code: String
+                |   val success: Boolean
+                |   val message: String
+                |}
+            """.trimMargin()
+        )
+    }
 }