refactor(cli[add]) Extract duplicated save-config dispatch helpers#530
refactor(cli[add]) Extract duplicated save-config dispatch helpers#530tony wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #530 +/- ##
==========================================
+ Coverage 83.30% 83.79% +0.48%
==========================================
Files 32 32
Lines 4492 4467 -25
Branches 903 902 -1
==========================================
+ Hits 3742 3743 +1
+ Misses 499 471 -28
- Partials 251 253 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
|
Re-authored on current |
0674d9d to
01640cd
Compare
why: master's add flow repeats the same save-with-error-handling block at six sites (three merge-path via save_config, three no-merge-path via _save_ordered_items) and derives the "current URL" from an existing entry with two identical isinstance ladders. The AddAction SKIP_PINNED/ SKIP_EXISTING split roughly doubled these over time. what: - Add _save_config_or_log_error(save_fn, *, config_file_path) wrapping the try/save/except-log-traceback pattern; each call site keeps its own success message via the returned bool - Add _extract_current_url(existing_config) for the string/dict/other URL derivation - Route all six save sites and both URL derivations through the helpers, preserving the merge vs no-merge dispatcher (save_config vs _save_ordered_items) via a passed closure - Cover both helpers with doctests and parametrized functional tests
01640cd to
02fd15e
Compare
Summary
Closes #521
_save_config_or_log_error()for the try/except/log.exception pattern (used 4x)_extract_current_url()for deriving display URLs from config entries (duplicated in merge/no-merge paths)_handle_skip_action()for SKIP_PINNED/SKIP_EXISTING branches (~30 lines each, duplicated)Test plan
uv run ruff check .— all checks passeduv run ruff format .— no changes neededuv run mypy— no issues founduv run py.test -vvv— 1175 passed