This file contains hidden or 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
adb help // List all comands | |
== Adb Server | |
adb kill-server | |
adb start-server | |
== Adb Reboot | |
adb reboot | |
adb reboot recovery | |
adb reboot-bootloader |
This file contains hidden or 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
override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression) { | |
super.visitLambdaExpression(lambdaExpression) | |
val whenExpressions = lambdaExpression.bodyExpression?.statements | |
?.filterIsInstance<KtWhenExpression>() | |
if (whenExpressions?.isNotEmpty() == true) { | |
report( | |
CodeSmell( | |
issue, Entity.from(lambdaExpression), MESSAGE |
This file contains hidden or 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
detekt-rules: | |
NonExhaustiveWhen: | |
active: true |
This file contains hidden or 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
detekt project(":detekt-rules") |
This file contains hidden or 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
com.github.olegosipenko.detektrules.CustomRulesetProvider |
This file contains hidden or 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
class CustomRulesetProvider: RuleSetProvider { | |
override val ruleSetId: String = "detekt-rules" | |
override fun instance(config: Config): RuleSet = RuleSet( | |
ruleSetId, | |
listOf( | |
NonExhaustiveWhen(config) | |
) | |
) | |
} |
This file contains hidden or 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
companion object { | |
@JvmStatic | |
fun compliantProvider(): Stream<Arguments> = | |
Stream.of( | |
arguments(COMPLIANT_WHEN_DOT, "dot expression"), | |
arguments(COMPLIANT_WHEN_PROPERTY, "property"), | |
arguments(COMPLIANT_WHEN_RETURN, "return") | |
) | |
} |
This file contains hidden or 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
@DisplayName("compliant ") | |
@MethodSource("compliantProvider") | |
@ParameterizedTest(name = "{1} should not warn") | |
internal fun testCompliantWhen(source: String, whenKind: String) { | |
val findings = NonExhaustiveWhen().lint(source) | |
assertThat(findings).isEmpty() | |
} |
This file contains hidden or 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
@Test | |
@DisplayName("non compliant when statement should warn") | |
internal fun nonCompliantCodeShouldWarn() { | |
val findings = NonExhaustiveWhen() | |
.lint(WHEN_STATEMENT.trimIndent()) | |
assertThat(findings).hasSize(1) | |
assertThat(findings[0].message).isEqualTo(MESSAGE) | |
} |
NewerOlder