KEMBAR78
EndingBlankLineChecker: refactor last line check logic by DDtKey · Pull Request #207 · dotenv-linter/dotenv-linter · GitHub
Skip to content

Conversation

@DDtKey
Copy link
Member

@DDtKey DDtKey commented May 28, 2020

In fact, this refactoring was not as trivial as it seemed 😅

In the end, I came to the conclusion that read a file into memory and a small change in the logic of creating FileEntry can be useful (for example, reuse, without re-reading).
Files are processed in turn and accordingly there will not be more than one file in RAM.

In any case, we stored all the lines for the 1st file in memory before (Vec<LineEntry>).
But, in a similar way, we can easily count in memory the necessary number of lines and then use them for their intended purpose.

Thanks @evgeniy-r for the idea.

Also, the reading of the lines was made in FileEntry, because, it seems to me, this is more consistent with the principle of single responsibility, instead of the extensive functions of lib.rs

I will be glad to discuss your suggestions and comments!

✔ Checklist:

  • This PR has been added to CHANGELOG.md (at the top of the list);
  • Tests for the changes have been added (for bug fixes / features)

@codecov-commenter
Copy link

codecov-commenter commented May 28, 2020

Codecov Report

Merging #207 into master will decrease coverage by 0.18%.
The diff coverage is 93.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #207      +/-   ##
==========================================
- Coverage   96.76%   96.57%   -0.19%     
==========================================
  Files          15       15              
  Lines        1422     1431       +9     
==========================================
+ Hits         1376     1382       +6     
- Misses         46       49       +3     
Impacted Files Coverage Δ
src/checks/duplicated_key.rs 100.00% <ø> (ø)
src/checks/incorrect_delimiter.rs 97.05% <ø> (-0.03%) ⬇️
src/checks/key_without_value.rs 94.33% <ø> (ø)
src/checks/leading_character.rs 97.16% <ø> (ø)
src/checks/lowercase_key.rs 93.75% <ø> (ø)
src/checks/quote_character.rs 96.25% <ø> (ø)
src/checks/space_character.rs 96.70% <ø> (ø)
src/checks/trailing_whitespace.rs 91.17% <ø> (ø)
src/checks/unordered_key.rs 100.00% <ø> (ø)
src/common.rs 95.94% <89.13%> (-1.95%) ⬇️
... and 10 more

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 e49d25a...dc0e530. Read the comment docs.

@mgrachev
Copy link
Member

@DDtKey Thank you for your contribution! 🔥

I need a bit more time to review your PR.

Copy link
Member

@mgrachev mgrachev left a comment

Choose a reason for hiding this comment

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

@DDtKey Sorry for the long response 🙏

I have left some comments. Could you look at them?

@DDtKey DDtKey requested a review from mgrachev June 8, 2020 16:50
@DDtKey
Copy link
Member Author

DDtKey commented Jun 8, 2020

@DDtKey Sorry for the long response pray

I have left some comments. Could you look at them?

Thanks so much for the comments!
I made corrections and answered some.

@mgrachev mgrachev merged commit 32f9b41 into dotenv-linter:master Jun 8, 2020
@mgrachev
Copy link
Member

mgrachev commented Jun 8, 2020

@DDtKey Excellent work! Thank you! ❤️

@DDtKey DDtKey deleted the refactor_204 branch June 8, 2020 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants