-
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 of NPE in complex binary expressions in long line rule #983
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fb9ad74
Debug
kgevorkyan 77cedb2
Debug
kgevorkyan 0089494
WIP
kgevorkyan ec99676
Merge branch 'master' of github.com:cqfn/diKTat into bugfix/npe_long_…
kgevorkyan 74b607a
WIP
kgevorkyan 56cf4fa
Polish
kgevorkyan ea4ca15
Review
kgevorkyan b1e2c97
Merge branch 'master' into bugfix/npe_long_line_rule
kgevorkyan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
diktat-rules/src/test/resources/test/paragraph3/long_line/LongBinaryExpressionExpected.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package test.paragraph3.long_line | ||
|
||
fun foo() { | ||
val veryLongExpression = Methoooooooooooooooood() + | ||
12345 | ||
|
||
val veryLongExpression = Methoooooooooooooooood() ?: | ||
null | ||
|
||
val veryLongExpression = a.Methooooood() + | ||
b.field | ||
|
||
val variable = someField.filter { it.elementType == KDOC } | ||
|
||
// limit at the left side | ||
val variable = a?.filter { it.elementType == KDOC } ?: | ||
null | ||
|
||
// limit at the right side | ||
val variable = bar?.filter { it.b == c } ?: | ||
null | ||
|
||
// limit at the operation reference | ||
val variable = field?.filter { bar == foo } ?: | ||
null | ||
|
||
val variable = Methoooooooooooooooooooooooooood() ?: | ||
"some loooooong string" | ||
|
||
val variable = Methooooood() ?: "some" + | ||
" looong string" | ||
|
||
var headerKdoc = firstCodeNode.prevSibling { it.elementType == KDOC } ?: | ||
if (firstCodeNode == packageDirectiveNode) importsList?.prevSibling { it.elementType == KDOC } else null | ||
} |
26 changes: 26 additions & 0 deletions
26
diktat-rules/src/test/resources/test/paragraph3/long_line/LongBinaryExpressionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package test.paragraph3.long_line | ||
|
||
fun foo() { | ||
val veryLongExpression = Methoooooooooooooooood() + 12345 | ||
|
||
val veryLongExpression = Methoooooooooooooooood() ?: null | ||
|
||
val veryLongExpression = a.Methooooood() + b.field | ||
|
||
val variable = someField.filter { it.elementType == KDOC } | ||
|
||
// limit at the left side | ||
val variable = a?.filter { it.elementType == KDOC } ?: null | ||
|
||
// limit at the right side | ||
val variable = bar?.filter { it.b == c } ?: null | ||
|
||
// limit at the operation reference | ||
val variable = field?.filter { bar == foo } ?: null | ||
|
||
val variable = Methoooooooooooooooooooooooooood() ?: "some loooooong string" | ||
|
||
val variable = Methooooood() ?: "some looong string" | ||
|
||
var headerKdoc = firstCodeNode.prevSibling { it.elementType == KDOC } ?: if (firstCodeNode == packageDirectiveNode) importsList?.prevSibling { it.elementType == KDOC } else null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Did we add the same element multiple times here? How could it be?
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.
Yeah, thanks, I did a lot of experiments with
dfsForProperty
and it's remain from them, now it's not necessary, removed.