-
-
Notifications
You must be signed in to change notification settings - Fork 797
Trust Kotlin compiler to identify unsafe casts #1879
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
Conversation
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.
Great! This PR contains some nice improvements and refactorings.
detekt-rules/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/MagicNumber.kt
Outdated
Show resolved
Hide resolved
detekt-rules/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnsafeCastSpec.kt
Outdated
Show resolved
Hide resolved
Blocked by #1880 |
detekt-rules/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMember.kt
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #1879 +/- ##
============================================
- Coverage 80.45% 80.44% -0.01%
- Complexity 1968 1969 +1
============================================
Files 326 326
Lines 5510 5513 +3
Branches 1022 1019 -3
============================================
+ Hits 4433 4435 +2
Misses 543 543
- Partials 534 535 +1
Continue to review full report at Codecov.
|
* Trust Kotlin compiler to identify unsafe casts * Remove unnecessary suppressions * Remove consecutive lines * Remove some "safe" calls * Remove unused import
* Trust Kotlin compiler to identify unsafe casts * Remove unnecessary suppressions * Remove consecutive lines * Remove some "safe" calls * Remove unused import
* Trust Kotlin compiler to identify unsafe casts * Remove unnecessary suppressions * Remove consecutive lines * Remove some "safe" calls * Remove unused import
* Trust Kotlin compiler to identify unsafe casts * Remove unnecessary suppressions * Remove consecutive lines * Remove some "safe" calls * Remove unused import
UnsafeCast now trusts the Kotlin compiler to identify casts that won't succeed. This should eliminate false positives though the detection rate for actual issues will drop, as some "safe" casts that the compiler cannot always tell will fail may still cause problems.
Now requires type/symbol resolution enabled in the detekt run for the rule to work.
Fixes #1601
Fixes #1137 (I couldn't replicate the original issue by just removing the suppression lines in
ThresholdedCodeSmellAssert
and rerunning CI in AppVeyor, though this should resolve it anyway).