Experiment: Refactored formatting code#53
Draft
olehermanse wants to merge 1 commit intocfengine:mainfrom
Draft
Conversation
From Claude: 1. Extracted named constants for repeated node type sets: INDENTED_TYPES, CLASS_GUARD_TYPES, BLOCK_TYPES 2. Extracted format_block_header() — the bundle/body header formatting logic that was inline in autoformat 3. Extracted needs_blank_line_before() — replaces the big if/elif chain for blank line insertion between children 4. Extracted get_comment_indent() — the comment indentation logic 5. Extracted is_empty_comment() — the bare # comment detection 6. Simplified the single-line promise path in autoformat by reusing can_single_line_promise() instead of duplicating its logic inline Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
Member
Author
|
This one is for review only, do not merge. |
Contributor
|
Without diving too deep into the intricacies, I would say that this refactor makes the code more readable. It's easier to digest the smaller functions. Furthermore, the function names also help the reader reason about what is happening. However, In many cases the docstrings just restates what the function names already clearly says. I think the docstring should convey information other than what is already obvious from the function name |
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
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.
From Claude:
its logic inline