Skip to content

Conversation

@peso
Copy link
Collaborator

@peso peso commented Nov 28, 2025

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_lines and cognitive_complexity to 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.

peso added 11 commits November 26, 2025 12:11
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.
@peso peso marked this pull request as draft November 28, 2025 07:33
peso added 11 commits November 28, 2025 08:53
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.
@peso peso force-pushed the refac/fix-too-many-lines branch from 1e281e7 to 12a6a2b Compare November 28, 2025 07:55
@peso peso marked this pull request as ready for review November 28, 2025 07:58
@peso peso merged commit 87b4473 into git-bahn:master Dec 5, 2025
5 checks passed
@peso peso deleted the refac/fix-too-many-lines branch January 8, 2026 20:44
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.

1 participant