-
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. NPE in fixing of LineLength Rule #858
Conversation
### What's done: * Added test
### What's done: * Fixed bug
### What's done: * Fixed bug
### What's done: * Fixed bug
Codecov Report
@@ Coverage Diff @@
## master #858 +/- ##
============================================
+ Coverage 80.42% 80.52% +0.09%
- Complexity 2199 2208 +9
============================================
Files 101 101
Lines 5671 5669 -2
Branches 1747 1751 +4
============================================
+ Hits 4561 4565 +4
+ Misses 265 257 -8
- Partials 845 847 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
* 1. When fun foo() = ... | ||
* 2. There is an annotation before the function which breaks the maxLength parameter. | ||
*/ | ||
private fun fixFunction(wrongFunction: ASTNode, configuration: LineLengthConfiguration) { |
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.
Why did you support only annotated functions?
when (fixableType) { | ||
is LongLineFixableCases.Fun -> fixableType.node.appendNewlineMergingWhiteSpace(null, fixableType.node.findChildByType(EQ)!!.treeNext) | ||
is LongLineFixableCases.Fun -> fixFunction(fixableType.node, configuration) |
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.
Can we reuse existing logic for fixing long strings here?
### What's done: * Reworked logic of inserting new line in string template
### What's done: * Fixed bugs
### What's done: * Fixed bugs
diktat-rules/src/test/resources/test/paragraph3/long_line/LongLineRValueExpected.kt
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt
Outdated
Show resolved
Hide resolved
private fun checkFun(wrongNode: ASTNode) = | ||
if (!wrongNode.hasChildOfType(BLOCK)) LongLineFixableCases.Fun(wrongNode) else LongLineFixableCases.None | ||
if (!wrongNode.hasChildOfType(BLOCK) && !wrongNode.hasChildOfType(MODIFIER_LIST)) LongLineFixableCases.Fun(wrongNode) else LongLineFixableCases.None |
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 still for expression body functions only? Why not check for presence of EQ
child node then? What would happen for expression body function with long parameters in annotation?
### What's done: * Fixed bugs
### What's done: * Fixed bugs
What's done:
This pull request closes #842