Repository: analysis-dev/diktat (kotlin)

Issue:
Function is not being simplified to expression body when semicolon is present
## Describe the bug
This code
```kotlin
class Example {
    fun doubleA(): Int {
       return 2 * a;
    }
}
```
is converted into
```kotlin
class Example {
    /**
     * @return
     */
    fun doubleA(): Int {
        return 2 * a
    }
}
```
but when semicolon is removed from the original code, result is
```kotlin
class Example {
    /**
     * @return
     */
    fun doubleA() = 2 * a
}
```

## Expected behavior
Results should be equal

## Environment information
* diktat version: 0.1.3
* how is diktat run (CLI, plugin, etc.): diktat-demo

Pull request:
### What's done:
   Fixed bug 
  closes #477

Patch:
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/ASTConstants.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/ASTConstants.kt
index 1d4c8c40cf..d3f9867d6d 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/ASTConstants.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/ASTConstants.kt
@@ -2,6 +2,7 @@ package org.cqfn.diktat.ruleset.utils
 
 import com.pinterest.ktlint.core.ast.ElementType.LBRACE
 import com.pinterest.ktlint.core.ast.ElementType.RBRACE
+import com.pinterest.ktlint.core.ast.ElementType.SEMICOLON
 import com.pinterest.ktlint.core.ast.ElementType.WHITE_SPACE
 
 /**
@@ -15,7 +16,7 @@ internal const val SET_PREFIX = "set"
 /**
  * List of element types present in empty code block `{ }`
  */
-val emptyBlockList = listOf(LBRACE, WHITE_SPACE, RBRACE)
+val emptyBlockList = listOf(LBRACE, WHITE_SPACE, SEMICOLON, RBRACE)
 
 internal const val EMPTY_BLOCK_TEXT = "{}"
 


Test patch:
diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/files/NewlinesRuleFixTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/files/NewlinesRuleFixTest.kt
index cf2062db62..7ba385f029 100644
--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/files/NewlinesRuleFixTest.kt
+++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/files/NewlinesRuleFixTest.kt
@@ -54,4 +54,10 @@ class NewlinesRuleFixTest : FixTestBase("test/paragraph3/newlines", ::NewlinesRu
     fun `should insert newlines in a long parameter or supertype list`() {
         fixAndCompare("ParameterListExpected.kt", "ParameterListTest.kt")
     }
+
+    @Test
+    @Tag(WarningNames.WRONG_NEWLINES)
+    fun `should fix one line function with and without semicolon`() {
+        fixAndCompare("OneLineFunctionExpected.kt", "OneLineFunctionTest.kt")
+    }
 }
diff --git a/diktat-rules/src/test/resources/test/paragraph3/newlines/OneLineFunctionExpected.kt b/diktat-rules/src/test/resources/test/paragraph3/newlines/OneLineFunctionExpected.kt
new file mode 100644
index 0000000000..f68b0c37ec
--- /dev/null
+++ b/diktat-rules/src/test/resources/test/paragraph3/newlines/OneLineFunctionExpected.kt
@@ -0,0 +1,6 @@
+package test.paragraph3.newlines
+
+class Example {
+    fun doubleA() = 2 * a
+    fun doubleA() = 2 * a
+}
diff --git a/diktat-rules/src/test/resources/test/paragraph3/newlines/OneLineFunctionTest.kt b/diktat-rules/src/test/resources/test/paragraph3/newlines/OneLineFunctionTest.kt
new file mode 100644
index 0000000000..bdcdc2f84a
--- /dev/null
+++ b/diktat-rules/src/test/resources/test/paragraph3/newlines/OneLineFunctionTest.kt
@@ -0,0 +1,10 @@
+package test.paragraph3.newlines
+
+class Example {
+    fun doubleA(): Int {
+        return 2 * a;
+    }
+    fun doubleA(): Int {
+        return 2 * a
+    }
+}