-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WRONG_INDENTATION
: add the test which reproduces the regression
### What's done: * See #1490.
- Loading branch information
1 parent
2f51f57
commit 96dfd85
Showing
9 changed files
with
171 additions
and
82 deletions.
There are no files selected for viewing
48 changes: 40 additions & 8 deletions
48
...rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/spaces/ExpectedIndentationError.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,50 @@ | ||
package org.cqfn.diktat.ruleset.chapter3.spaces | ||
|
||
import org.cqfn.diktat.common.config.rules.DIKTAT_RULE_SET_ID | ||
import org.cqfn.diktat.ruleset.constants.Warnings.WRONG_INDENTATION | ||
import org.cqfn.diktat.ruleset.junit.ExpectedLintError | ||
import org.cqfn.diktat.ruleset.rules.chapter3.files.IndentationRule.Companion.NAME_ID | ||
import com.pinterest.ktlint.core.LintError | ||
|
||
/** | ||
* The expected indentation error (extracted from annotated code fragments). | ||
* | ||
* @property line the line number (1-based). | ||
* @property column the column number (1-based). | ||
* @property expectedIndent the expected indentation level (in space characters). | ||
* @property actualIndent the actual indentation level (in space characters). | ||
*/ | ||
data class ExpectedIndentationError( | ||
override val line: Int, | ||
override val column: Int = 1, | ||
val expectedIndent: Int, | ||
val actualIndent: Int | ||
) : ExpectedLintError | ||
class ExpectedIndentationError(override val line: Int, | ||
override val column: Int = 1, | ||
private val message: String | ||
) : ExpectedLintError { | ||
/** | ||
* @param line the line number (1-based). | ||
* @param column the column number (1-based). | ||
* @param expectedIndent the expected indentation level (in space characters). | ||
* @param actualIndent the actual indentation level (in space characters). | ||
*/ | ||
constructor(line: Int, | ||
column: Int = 1, | ||
expectedIndent: Int, | ||
actualIndent: Int | ||
) : this( | ||
line, | ||
column, | ||
warnText(expectedIndent)(actualIndent) | ||
) | ||
|
||
override fun asLintError(): LintError = | ||
LintError( | ||
line, | ||
column, | ||
"$DIKTAT_RULE_SET_ID:$NAME_ID", | ||
message, | ||
true) | ||
|
||
private companion object { | ||
private val warnText: (Int) -> (Int) -> String = { expectedIndent -> | ||
{ actualIndent -> | ||
"${WRONG_INDENTATION.warnText()} expected $expectedIndent but was $actualIndent" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters