Skip to content
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

Merged
merged 5 commits into from
Jul 23, 2017
Merged

Added rule for safe cast instead of if-else-null #233

merged 5 commits into from
Jul 23, 2017

Conversation

schalkms
Copy link
Member

#197 feature

@arturbosch
Copy link
Member

Looks good! Will check it out tomorror. Thank you very much!

@vanniktech
Copy link
Contributor

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.*
Copy link
Member

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" +
Copy link
Member

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)
Copy link
Member

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

@arturbosch arturbosch merged commit 7602427 into detekt:master Jul 23, 2017
@arturbosch arturbosch modified the milestone: RC1 Jul 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants