-
Notifications
You must be signed in to change notification settings - Fork 39
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
Bugfix. Inspect the logic of the data class rule #761
Bugfix. Inspect the logic of the data class rule #761
Conversation
### What's done: * Logic extended
Codecov Report
@@ Coverage Diff @@
## master #761 +/- ##
=========================================
Coverage 79.79% 79.79%
- Complexity 2019 2025 +6
=========================================
Files 97 97
Lines 5078 5089 +11
Branches 1621 1626 +5
=========================================
+ Hits 4052 4061 +9
Misses 246 246
- Partials 780 782 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
val hasPropertyInConstructor = findChildByType(PRIMARY_CONSTRUCTOR) | ||
?.let { constructor -> | ||
(constructor.psi as KtPrimaryConstructor) | ||
.valueParameters | ||
.run { isNotEmpty() && all { it.hasValOrVar() } } | ||
.run { isNotEmpty() && all { if (it.hasValOrVar()) true else { constructorParametersNames.add(it.name!!); false } } } |
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'd move this add
into separate onEach
before run
, now it's not very readable
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.
Fixed
val initBlocks = findChildByType(CLASS_BODY)?.getAllChildrenWithType(CLASS_INITIALIZER) | ||
initBlocks?.forEach { init -> | ||
val refExpressions = init.findAllNodesWithSpecificType(REFERENCE_EXPRESSION) | ||
if (refExpressions.any { it.text !in constructorParametersNames }) { |
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.
Is it right? Shouldn't it be 'any in'? Also please add tests with more parameters and more complex init blocks
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.
Should be. Added more tests
### What's done: * Added tests * Fixed bugs
val initBlocks = findChildByType(CLASS_BODY)?.getAllChildrenWithType(CLASS_INITIALIZER) | ||
initBlocks?.forEach { init -> | ||
val refExpressions = init.findAllNodesWithSpecificType(REFERENCE_EXPRESSION) | ||
if (refExpressions.any { it.text in constructorParametersNames }) { |
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.
Please add a test that would have passed when there was a mistake with !in
and shouldn't actually pass.
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.
Added
### What's done: * Added tests * Fixed bugs
### What's done: * Fixed bugs
### What's done: * Fixed bugs
What's done:
This pull request closes #750