Skip to content
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

NPE in BlockStructureBraces #502

Merged
merged 4 commits into from
Nov 16, 2020
Merged

Conversation

kentr0w
Copy link
Collaborator

@kentr0w kentr0w commented Nov 7, 2020

What's done:

Fixed bug
closes #481

### What's done:
   Fixed bug
@kentr0w kentr0w added the bug Something isn't working label Nov 7, 2020
@codecov
Copy link

codecov bot commented Nov 7, 2020

Codecov Report

Merging #502 (3adc912) into master (bb1227a) will increase coverage by 0.01%.
The diff coverage is 75.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #502      +/-   ##
============================================
+ Coverage     81.87%   81.88%   +0.01%     
- Complexity     1618     1619       +1     
============================================
  Files            77       77              
  Lines          4083     4086       +3     
  Branches       1290     1291       +1     
============================================
+ Hits           3343     3346       +3     
  Misses          218      218              
  Partials        522      522              
Flag Coverage Δ Complexity Δ
unittests 81.88% <75.00%> (+0.01%) 0.00 <0.00> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...tlin/org/cqfn/diktat/ruleset/utils/AstNodeUtils.kt 82.32% <66.66%> (-0.23%) 0.00 <0.00> (ø)
.../cqfn/diktat/ruleset/rules/BlockStructureBraces.kt 83.80% <100.00%> (ø) 53.00 <0.00> (ø)
...fn/diktat/ruleset/rules/kdoc/CommentsFormatting.kt 69.33% <0.00%> (+0.66%) 76.00% <0.00%> (+1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb1227a...790066b. Read the comment docs.

### What's done:
   Fixed after review
@@ -178,7 +178,7 @@ class BlockStructureBraces(private val configRules: List<RulesConfig>) : Rule("b
if (braceSpace == null || braceSpace.elementType != WHITE_SPACE) {
node.addChild(PsiWhiteSpaceImpl(" "), nodeBefore)
} else {
(braceSpace as LeafPsiElement).replaceWithText(" ")
braceSpace.treeParent.replaceWhiteSpaceText(braceSpace, " ")
Copy link
Member

@orchestr7 orchestr7 Nov 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here can be problems if treeParent is not a WhiteSpace or does not exist, need to be careful with that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But above, there is a check for this case checkBraceNode

Copy link
Member

@orchestr7 orchestr7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kentr0w kentr0w merged commit f4f45c3 into master Nov 16, 2020
@kentr0w kentr0w deleted the bugfix/npe-BlockStructureBraces branch November 16, 2020 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPE in BlockStructureBraces when there are two nested ifs without braces
3 participants