Skip to content

Refactor (script/raw-changelog.ts: 198>): Function with high complexity (count = 24): format; Split up format() function - #97

Open
mchen1820 wants to merge 2 commits into
CMU-313:mainfrom
mchen1820:Issue-Branch-(script/raw-changelog.ts-198-)-Function-with-high-complexity-(count-=-24)-format
Open

Refactor (script/raw-changelog.ts: 198>): Function with high complexity (count = 24): format; Split up format() function#97
mchen1820 wants to merge 2 commits into
CMU-313:mainfrom
mchen1820:Issue-Branch-(script/raw-changelog.ts-198-)-Function-with-high-complexity-(count-=-24)-format

Conversation

@mchen1820

@mchen1820 mchen1820 commented Sep 7, 2026

Copy link
Copy Markdown

Decreased the complexity of the format() function by dividing up the function into several helper functions, including createGroups(), formatCommit(), groupCommits(), sectionHasEntries(), formatSection(), and formatContributors()

P1B: Starter Task: Refactoring PR

1. Issue

Link to the associated GitHub issue: #81

Full path to the refactored file: script/raw-changelog.ts

This file seems to generate and format changelog notes for the opencode repository.

Only the format() function was altered, with more helper functions added above the format() function.

This refactoring addressed the following Qlty-reported issue: Function with high complexity (count = 24): format

2. Refactoring

The high complexity issue I chose impacted the codebase's maintainability by making the format() code hard to read, and thus harder to test or change in the future.

To resolve this issue, I divided some of the complex subtasks of the format() function into smaller helper functions, making the format() function itself much shorter while performing the same tasks.

My changes improve maintainability by making the format() function much easier to read and understand. The format() function mostly consists of simple helper function calls that are very understandable since they are appropriately named after their subtask. This improves maintainability by making it easy for future contributors to understand and adjust the format() function or its subtasks as necessary as future changes are made to the overall codebase.

3. Validation

I validated that my changes were correct by making sure bun lint and bun test passed locally, creating new tests in raw-changelog.test.ts and checking they passed, and checking that the Qlty smell was reduced.

bun lint passing:
17313-bun lint

bun test passing (with new raw-changelog.test.ts tests):
17313-bun test

Qlty smell for script/raw-changelog.ts reduced:
17313-qlty

Decreased the complexity of the format() function by dividing up the function into several helper functions, including createGroups(), formatCommit(), groupCommits(), sectionHasEntries(), formatSection(), and formatContributors()
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