Skip to content

Simplify run, runBuildRunner, and CLI error handling - #231

Merged
kevmoo merged 2 commits into
mainfrom
cc-v2c
Oct 11, 2026
Merged

kevmoo merged 2 commits into
mainfrom
cc-v2c

Conversation

@kevmoo

@kevmoo kevmoo commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Reduces cognitive complexity across bin/peanut.dart, lib/src/build_runner.dart, and lib/src/peanut.dart (+166 / -138 lines) and bumps the package version to 6.0.3-wip (14/14 tests pass, max cognitive complexity 51 -> 15).

  • bin/peanut.dart (main CC 17 -> 11): Replaces nested if (e is ...) branches inside catch with typed on PackageException and on PeanutException clauses and moves option parsing error handling into _getOptions.
  • lib/src/build_runner.dart (runBuildRunner CC 16 -> 6): Inlines single-use _defineValue and extracts _deleteExtraFiles with an early continue guard.
  • lib/src/peanut.dart (run CC 51 -> 15): Extracts _validatePackages, _writeRootIndexHtml, and _commitAndReport so run reads as a linear pipeline.
  • Version bump (6.0.3-wip): Bumps pubspec.yaml and lib/src/version.dart to 6.0.3-wip with an empty ## 6.0.3-wip section in CHANGELOG.md.

- Extract `_validatePackages`, `_writeRootIndexHtml`, and `_commitAndReport` from `run` (`47 -> 15`) while preserving `_prettyName` untouched.
- Inline single-use `_defineValue` and extract per-directory `_deleteExtraFiles` from `runBuildRunner` (`31 -> 12`, `_deleteExtraFiles` `11`).
- Flatten exception handling in `bin/peanut.dart` `main` (`26 -> 14`) and move option-parse error handling into `_getOptions` (`1 -> 5`).
@kevmoo
kevmoo merged commit f3654f5 into main Oct 11, 2026
12 checks passed
@kevmoo
kevmoo deleted the cc-v2c branch October 11, 2026 05:43
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