Skip to content

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 19, 2026

Summary

Replace 14+ repetitive if-check patterns in Spec::merge with three local macros:

  • merge_str! for String fields (replace if non-empty)
  • merge_opt! for Option fields (replace if Some)
  • merge_extend! for Vec/IndexMap fields (extend if non-empty)

This reduces boilerplate and makes the merging strategy for each field immediately clear.

Before: 47 lines with repetitive if patterns
After: 42 lines with declarative macro calls

Test plan

  • All tests pass
  • No behavior changes - macro expansion produces identical code

🤖 Generated with Claude Code


Note

Refactors Spec::merge to reduce duplication and clarify merge behavior without changing functionality.

  • Introduces local macros: merge_str! (non-empty String), merge_opt! (Option is Some), and merge_extend! (extend non-empty collections)
  • Applies macros across name, bin, usage, about*, version, author, disable_help, min_usage_version, default_subcommand, complete, and examples
  • Retains existing merges for config (delegated merge) and cmd (self.cmd.merge(...))

Written by Cursor Bugbot for commit 5145714. This will update automatically on new commits. Configure here.

Replace 14+ repetitive if-check patterns with three local macros:
- merge_str! for String fields (replace if non-empty)
- merge_opt! for Option fields (replace if Some)
- merge_extend! for Vec/IndexMap fields (extend if non-empty)

This reduces boilerplate and makes the merging strategy for each field clear.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 19, 2026 19:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Spec::merge method by replacing repetitive conditional merging patterns with three declarative local macros (merge_str!, merge_opt!, merge_extend!), making the merge strategy for each field type immediately clear while reducing boilerplate code.

Changes:

  • Introduced three local macros to handle different field merging strategies (String, Option, and collection types)
  • Replaced 14+ repetitive if-check patterns with macro invocations
  • Reduced method from 47 to 42 lines while maintaining identical behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 0% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.29%. Comparing base (9df7c86) to head (5145714).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
lib/src/spec/mod.rs 0.00% 35 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #451      +/-   ##
==========================================
- Coverage   47.36%   47.29%   -0.07%     
==========================================
  Files          47       47              
  Lines        6653     6656       +3     
  Branches     6653     6656       +3     
==========================================
- Hits         3151     3148       -3     
- Misses       1739     1742       +3     
- Partials     1763     1766       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jdx jdx merged commit 949e3a5 into main Jan 19, 2026
9 of 11 checks passed
@jdx jdx deleted the refactor/simplify-merge branch January 19, 2026 19:29
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.

2 participants