Skip to content

Commit

Permalink
different functions due to semicolon (#557)
Browse files Browse the repository at this point in the history
### What's done:
   Fixed bug
  • Loading branch information
kentr0w authored Nov 23, 2020
1 parent a1ccdbd commit 0dd9f90
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -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 = "{}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package test.paragraph3.newlines

class Example {
fun doubleA() = 2 * a
fun doubleA() = 2 * a
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package test.paragraph3.newlines

class Example {
fun doubleA(): Int {
return 2 * a;
}
fun doubleA(): Int {
return 2 * a
}
}

0 comments on commit 0dd9f90

Please sign in to comment.