Repository: analysis-dev/diktat (kotlin)

Issue:
Incorrect duplicated logging of missing configuration
```
[WARN ] 2021-06-10 15:21:37 Configuration file not found in directory where diktat is run (null) or in the directory where diktat.jar is stored (null) or in system property <diktat.config.path> (null), the default file included in jar will be used. Some configuration options will be disabled or substituted with defaults. Custom configuration file should be placed in diktat working directory if run from CLI or provided as configuration options in plugins.
```

Pull request:
### What's done:
* Log file names of possible config locations even if they don't exist
* Remove accidental `println`s in rules
* Forbid `println`s via detekt
* Change maven-plugin debug property name
* Turn off debug logging for diktat self-check by default, keep only in diktat_snapshot.yml

This pull request closes #919 

### TODO:
* [x] Why can this logging be duplicated multiple times? - seems to be not reproducible in CLI mode

Patch:
diff --git a/.github/workflows/diktat_snapshot.yml b/.github/workflows/diktat_snapshot.yml
index f611101267..8a76fc8e79 100644
--- a/.github/workflows/diktat_snapshot.yml
+++ b/.github/workflows/diktat_snapshot.yml
@@ -45,6 +45,6 @@ jobs:
         run: |
           mvn -B versions:set -DnewVersion=${{ env.BASE_VERSION }}-SNAPSHOT
           mvn -B versions:set-property -Dproperty=diktat-check.version -DnewVersion=${{ env.BASE_VERSION }}-pre
-      - name: Run diktat snapshot via ktlint
+      - name: Run diktat snapshot via maven plugin
         run: |
-          mvn -B diktat:check@diktat
+          mvn -B diktat:check@diktat -Ddiktat.debug=true
diff --git a/detekt-config.yml b/detekt-config.yml
index f3e24ba4a3..6be27bd630 100644
--- a/detekt-config.yml
+++ b/detekt-config.yml
@@ -578,8 +578,9 @@ style:
     imports: []
     forbiddenPatterns: ''
   ForbiddenMethodCall:
-    active: false
+    active: true
     methods: ['kotlin.io.println', 'kotlin.io.print']
+    excludes: ["**/src/test/**"]
   ForbiddenPublicDataClass:
     active: true
     excludes: ['**']
diff --git a/diktat-maven-plugin/src/main/kotlin/org/cqfn/diktat/plugin/maven/DiktatBaseMojo.kt b/diktat-maven-plugin/src/main/kotlin/org/cqfn/diktat/plugin/maven/DiktatBaseMojo.kt
index 6e0ecad02a..dba71f2a3c 100644
--- a/diktat-maven-plugin/src/main/kotlin/org/cqfn/diktat/plugin/maven/DiktatBaseMojo.kt
+++ b/diktat-maven-plugin/src/main/kotlin/org/cqfn/diktat/plugin/maven/DiktatBaseMojo.kt
@@ -22,7 +22,7 @@ abstract class DiktatBaseMojo : AbstractMojo() {
     /**
      * Flag that indicates whether to turn debug logging on
      */
-    @Parameter(property = "debug")
+    @Parameter(property = "diktat.debug")
     var debug = false
 
     // FixMe: Reporter should be chosen via plugin configuration
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt
index 36f649a277..65adab2617 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt
@@ -98,14 +98,11 @@ const val DIKTAT_CONF_PROPERTY = "diktat.config.path"
  * @param diktatConfigFile - configuration file where all configurations for inspections and rules are stored
  */
 class DiktatRuleSetProvider(private var diktatConfigFile: String = DIKTAT_ANALYSIS_CONF) : RuleSetProvider {
-    private val possibleConfigs = sequence {
+    private val possibleConfigs: Sequence<String?> = sequence {
         yield(resolveDefaultConfig())
         yield(resolveConfigFileFromJarLocation())
         yield(resolveConfigFileFromSystemProperty())
     }
-        .map {
-            it?.takeIf { File(it).exists() }
-        }
 
     @Suppress(
         "LongMethod",
@@ -115,8 +112,7 @@ class DiktatRuleSetProvider(private var diktatConfigFile: String = DIKTAT_ANALYS
         log.debug("Will run $DIKTAT_RULE_SET_ID with $diktatConfigFile" +
                 " (it can be placed to the run directory or the default file from resources will be used)")
         val configPath = possibleConfigs
-            .filterNotNull()
-            .firstOrNull()
+            .firstOrNull { it != null && File(it).exists() }
         diktatConfigFile = configPath
             ?: run {
                 val possibleConfigsList = possibleConfigs.toList()
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/calculations/AccurateCalculationsRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/calculations/AccurateCalculationsRule.kt
index 1fc69c2de1..73c4a2ca45 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/calculations/AccurateCalculationsRule.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/calculations/AccurateCalculationsRule.kt
@@ -105,7 +105,6 @@ class AccurateCalculationsRule(configRules: List<RulesConfig>) : DiktatRule(
             val floatValue = left!!.takeIf { it.isFloatingPoint() }
                 ?: right!!.takeIf { it.isFloatingPoint() }
             checkFloatValue(floatValue, this)
-            println()
         }
 
     /**
diff --git a/pom.xml b/pom.xml
index e1fa3c61f8..bf1405f74a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -337,7 +337,6 @@
                             <goal>fix</goal>
                         </goals>
                         <configuration>
-                            <debug>true</debug>
                             <inputs>
                                 <input>${project.basedir}/src/main/kotlin</input>
                                 <input>${project.basedir}/src/test/kotlin</input>


Test patch:
diff --git a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestComparatorUnit.kt b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestComparatorUnit.kt
index b1dc4e4048..d921fb3d0b 100644
--- a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestComparatorUnit.kt
+++ b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestComparatorUnit.kt
@@ -56,7 +56,7 @@ class TestComparatorUnit(private val resourceFilePath: String,
         try {
             Files.newBufferedReader(Paths.get(fileName)).use { list = it.lines().collect(Collectors.toList()) }
         } catch (e: IOException) {
-            println("Not able to read file: $fileName")
+            log.error("Not able to read file: $fileName")
         }
         return list
     }