-
Notifications
You must be signed in to change notification settings - Fork 34
Refac/fix too many lines #135
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
Merged
Merged
Conversation
This file contains hidden or 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
Rewrite format_commit to use a formatter struct. Use push_str instead of write macro to simplfy further.
This holds all data needed to run the application.
Make sure CI will prevent a function from growing by enabling the relevant clippy warning.
The hline function could benefit from a heavy refactoring, but that has the risk that corner cases may fail. Therefore, add some unit test that pass on the old code.
This function had more than 100 lines.
The following commits performs a step-by-step refactoring. To make it clearer what the goal is, and to minimize code movement during refactoring, this commit presents the target function and a residual that gradually shrinks until everything is refactored.
grid width = graph width * 2 - 1 This is because the grid is rendered with characters that are twice as high as wide.
Note, total_rows computation was a complicated way to count lines found in text_lines.
…c/from_args' into HEAD
1e281e7 to
12a6a2b
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR rearranges lots of code to make it easier to understand.
It has the intention of only moving code, not modifying it, to make diffs easy to match, but occasionally something trivial is fixed.
It contains three main refactorizations, two of which is split in steps to make it clearer what is being done. The last one is a restructure of a large two level match into individual functions
It enables clippy warnings
too_many_linesandcognitive_complexityto enforce code division in the future.By building higher level functions, the PR reveals some large level structures that could be cleaned up as well. That is not in scope for this PR.
Added bonus: It uses an octo-merge so now the repository can be used as test bed for a future octo-merge PR.