Repository: cqfn/diKTat (kotlin)

Issue:
Long import statements cause diktat to fail
## Describe the bug

Import statements that are longer than the configured maximum line length are considered an error by diktat.

## Expected behavior

Not entirely sure. The problem is that the imports can't be targeted by `@Suppress` annotations, so the only recurse is `file:Suppress`ing the error for the whole file or using workarounds that do not help code legibility in any way, but rather hinder it (e.g. putting `typealias`es in files with shorter package names).

I suppose ignoring import statements, or adding an option for such behavior, might be a solution. Alternatively, disabling checks via comments could be an alternative.

## Observed behavior

Diktat raises an error for each line containing an import statement that is longer than the configured limit.

## Steps to Reproduce

All that is needed is a file that conforms to all diktat rules, and then adding an import statement that is too long to it.

## Environment information

* diktat version: 1.0.0-rc.3
* build tool (maven/gradle): Gradle
* how is diktat run (CLI, plugin, etc.): IntelliJ IDEA, CLI (both Gradle diktatCheck tasks).
* kotlin version: 1.5.30
* operating system: macOS, Linux

Pull request description:
### What's done:
* Fix bug in code
* Update test

## Which rule and warnings did you add?

This pull request closes #1077 
We actually had logic, which doesn't check length of package directives and import statements. However, due to a small bug, it was not working from the very beginning...

Patch:
diff --git a/diktat-gradle-plugin/settings.gradle.kts b/diktat-gradle-plugin/settings.gradle.kts
new file mode 100644
index 0000000000..764fd320f2
--- /dev/null
+++ b/diktat-gradle-plugin/settings.gradle.kts
@@ -0,0 +1,6 @@
+pluginManagement {
+    repositories {
+        mavenCentral()
+        gradlePluginPortal()
+    }
+}
\ No newline at end of file
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt
index 6c7d94301f..e2f48757a0 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt
@@ -66,15 +66,17 @@ class LineLength(configRules: List<RulesConfig>) : DiktatRule(
     "line-length",
     configRules,
     listOf(LONG_LINE)) {
+    private val configuration by lazy {
+        LineLengthConfiguration(
+            configRules.getRuleConfig(LONG_LINE)?.configuration ?: emptyMap()
+        )
+    }
     private lateinit var positionByOffset: (Int) -> Pair<Int, Int>
 
     override fun logic(node: ASTNode) {
-        val configuration = LineLengthConfiguration(
-            configRules.getRuleConfig(LONG_LINE)?.configuration ?: emptyMap())
-
         if (node.elementType == FILE) {
             node.getChildren(null).forEach {
-                if (it.elementType != PACKAGE_DIRECTIVE || it.elementType != IMPORT_LIST) {
+                if (it.elementType != PACKAGE_DIRECTIVE && it.elementType != IMPORT_LIST) {
                     checkLength(it, configuration)
                 }
             }


Test patch:
diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/LineLengthWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/LineLengthWarnTest.kt
index 8342ba6fde..f9ba6ad23f 100644
--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/LineLengthWarnTest.kt
+++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/LineLengthWarnTest.kt
@@ -53,7 +53,8 @@ class LineLengthWarnTest : LintTestBase(::LineLength) {
                     |   fun foo() {
                     |   }
                     |}
-                """.trimMargin()
+                """.trimMargin(),
+            rulesConfigList = shortLineLength
         )
     }