Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/andrey.shcheglov/indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
0x6675636b796f75676974687562 committed Jul 13, 2022
2 parents 4d07ceb + ad8718b commit 93575ec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class SmartCastRule(configRules: List<RulesConfig>) : DiktatRule(
* @property type a type to which the reference is being cast
* @property node a node that holds the entire expression
*/
class AsExpressions(
data class AsExpressions(
val identifier: String,
val type: String,
val node: ASTNode
Expand All @@ -262,7 +262,7 @@ class SmartCastRule(configRules: List<RulesConfig>) : DiktatRule(
* @property identifier a reference that is checked
* @property type a type with which the reference is being compared
*/
class IsExpressions(val identifier: String, val type: String)
data class IsExpressions(val identifier: String, val type: String)

companion object {
const val NAME_ID = "smart-cast-rule"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class DataClassesRule(configRules: List<RulesConfig>) : DiktatRule(
?: false &&
getFirstChildWithType(SUPER_TYPE_LIST) == null
}
return classBody?.getAllChildrenWithType(FUN)?.isEmpty() ?: false &&
return classBody?.getFirstChildWithType(FUN) == null &&
getFirstChildWithType(SUPER_TYPE_LIST) == null &&
// if there is any prop with logic in accessor then don't recommend to convert class to data class
classBody?.let(::areGoodProps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ class DataClassesRuleWarnTest : LintTestBase(::DataClassesRule) {
)
}

@Test
@Tag(USE_DATA_CLASS)
fun `_regression_ trigger on default class without a body`() {
lintMethod(
"""
|class Some(val a: Int = 5)
|
""".trimMargin(),
LintError(1, 1, ruleId, "${Warnings.USE_DATA_CLASS.warnText()} Some")
)
}

@Test
@Tag(USE_DATA_CLASS)
fun `should trigger - dont forget to consider this class in fix`() {
Expand Down

0 comments on commit 93575ec

Please sign in to comment.