-
-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added rule for safe cast instead of if-else-null #233
Conversation
Looks good! Will check it out tomorror. Thank you very much! |
Maybe also add a test case for a negative case? |
import io.gitlab.arturbosch.detekt.rules.style.NamingConventionViolation | ||
import io.gitlab.arturbosch.detekt.rules.style.NewLineAtEndOfFile | ||
import io.gitlab.arturbosch.detekt.rules.style.WildcardImport | ||
import io.gitlab.arturbosch.detekt.rules.style.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls import the code-style.xml when working on detekt. The codebase should not have wildcards.
|
||
@Test | ||
fun findNegated() { | ||
val code = "fun test() {\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use multiline strings in your test cases. It's better to read :)
} | ||
|
||
private fun retrieveFindings(code: String): List<Finding> { | ||
return SafeCast().lint(code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extend RuleTest
and override the field rule
with SafeCast. rule.lint(code)
can then be inlined
#197 feature