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

Bugfix. NPE in fixing of LineLength Rule #858

Merged
merged 12 commits into from
Apr 30, 2021
Merged

Conversation

aktsay6
Copy link
Collaborator

@aktsay6 aktsay6 commented Apr 28, 2021

What's done:

  • Fixed the bug

This pull request closes #842

### What's done:
  * Added test
### What's done:
  * Fixed bug
@aktsay6 aktsay6 added the bug Something isn't working label Apr 28, 2021
### What's done:
  * Fixed bug
### What's done:
  * Fixed bug
@codecov
Copy link

codecov bot commented Apr 28, 2021

Codecov Report

Merging #858 (63c0cf5) into master (076ec56) will increase coverage by 0.09%.
The diff coverage is 78.94%.

Impacted file tree graph

@@             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     
Flag Coverage Δ Complexity Δ
unittests 80.52% <78.94%> (+0.09%) 2208.00 <8.00> (+9.00)

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

Impacted Files Coverage Δ Complexity Δ
...g/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt 86.40% <78.94%> (+2.75%) 82.00 <8.00> (+9.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 076ec56...63c0cf5. Read the comment docs.

@aktsay6 aktsay6 requested review from petertrr and kentr0w and removed request for petertrr April 28, 2021 12:58
* 1. When fun foo() = ...
* 2. There is an annotation before the function which breaks the maxLength parameter.
*/
private fun fixFunction(wrongFunction: ASTNode, configuration: LineLengthConfiguration) {
Copy link
Member

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)
Copy link
Member

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
@aktsay6 aktsay6 requested a review from petertrr April 29, 2021 15:39
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
Copy link
Member

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
@aktsay6 aktsay6 requested a review from petertrr April 30, 2021 09:14
@aktsay6 aktsay6 marked this pull request as ready for review April 30, 2021 14:04
@petertrr petertrr merged commit 8832cf3 into master Apr 30, 2021
@petertrr petertrr deleted the bugfix/npe-linelength(#842) branch April 30, 2021 14:49
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 fixing of LineLength Rule
2 participants