-
-
Notifications
You must be signed in to change notification settings - Fork 767
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
Add RedundantExplicitType rule #1900
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.
Looks good! I would prefer to refactor the BindingContext
retrieval into an own generic method.
if (bindingContext == BindingContext.EMPTY) return | ||
if (!property.isLocal) return | ||
val typeReference = property.typeReference ?: return | ||
val type = |
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.
I see this pattern for getting the BindingContext
quite often.
Shall we refactor this into a generic method?
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.
I think that's a good idea. Can also provide a warning if context not available so user knows the rule (or parts of the rule) were not run even when the rule was enabled?
Can that be done in another PR though?
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.
Yes, that makes sense. This should be done in a separate PR.
Currently, our documentation states:
--jvm-target
EXPERIMENTAL: Target version of the generated JVM bytecode that was
generated during compilation and is now being used for type resolution
I think it’s not experimental anymore. Furthermore, we also need to update the samples.
I would also acknowledge the work ( |
I'm not clear on what actually needs to be done to provide proper attribution - I know detekt and Kotlin compiler have Apache 2.0 licenses which is good, but in terms of correct attribution, is the reference in the source file to the original enough? |
@3flex yes, I think so. I'll create an issue for that. |
Codecov Report
@@ Coverage Diff @@
## master #1900 +/- ##
============================================
- Coverage 80.4% 80.32% -0.09%
- Complexity 1973 1988 +15
============================================
Files 326 327 +1
Lines 5517 5549 +32
Branches 1027 1041 +14
============================================
+ Hits 4436 4457 +21
- Misses 543 545 +2
- Partials 538 547 +9
Continue to review full report at Codecov.
|
Closes #336
Since this is just a port of the IntelliJ rule this uses identical logic, meaning this only checks local properties - it doesn't check for types that don't need to be declared for any other element. I think this conservative posture makes sense and there shouldn't be any false positives.
A future config option could be to enable or disable checking on top-level properties, but that's not required for now.
Blocked by #1880