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

Fixing bug with lineNumber in autocorrect mode #400

Merged
merged 4 commits into from
Oct 19, 2020

Conversation

petertrr
Copy link
Member

What's done:

  • Use getLineNumber everywhere
  • Added test

This pull request closes #371

@codecov
Copy link

codecov bot commented Oct 14, 2020

Codecov Report

Merging #400 into master will decrease coverage by 0.01%.
The diff coverage is 86.02%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #400      +/-   ##
============================================
- Coverage     82.50%   82.49%   -0.02%     
- Complexity     1346     1347       +1     
============================================
  Files            65       65              
  Lines          3298     3313      +15     
  Branches       1053     1056       +3     
============================================
+ Hits           2721     2733      +12     
- Misses          178      179       +1     
- Partials        399      401       +2     
Flag Coverage Δ Complexity Δ
#unittests 82.49% <86.02%> (-0.02%) 1347.00 <4.00> (+1.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.07% <84.33%> (-0.16%) 0.00 <0.00> (ø)
...at/ruleset/rules/identifiers/LocalVariablesRule.kt 91.66% <100.00%> (ø) 24.00 <4.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 136500f...c2f147c. Read the comment docs.

}

/**
* This function calculates line number instead of using cached values.
Copy link
Member

Choose a reason for hiding this comment

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

I thought we discussed it and decided that ktlint calculates everything correctly.
So why it is needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

We discussed it regarding warning messages, but we also use line number in some rules (e.g., method ASTNode.isBefore), and when AST has already been mutated by previous rules, it leads to ArrayIndexOutOfBoundsException (see #371).

Copy link
Collaborator

@aktsay6 aktsay6 left a comment

Choose a reason for hiding this comment

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

lgtm

@petertrr petertrr merged commit 2180e77 into master Oct 19, 2020
@petertrr petertrr deleted the bugfix/getline-exception#371 branch October 19, 2020 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IndexOutOfBoundsException when calculating line number in fixing mode
3 participants