Skip to content

refactor: improve code quality with safety and lint fixes#427

Merged
jdx merged 2 commits intomainfrom
refactor/code-quality
Jan 19, 2026
Merged

refactor: improve code quality with safety and lint fixes#427
jdx merged 2 commits intomainfrom
refactor/code-quality

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Jan 19, 2026

Summary

  • Replace unsafe .unwrap() on Path::parent() with proper error handling in include directive parsing
  • Add #[must_use] attributes to builder build() methods and parse functions to prevent accidentally discarding important return values
  • Add doc comments to parse functions explaining their purpose

Changes

  • lib/src/spec/mod.rs: Fix unsafe unwrap in include handling, add #[must_use] to parse_file and parse_script
  • lib/src/spec/builder.rs: Add #[must_use] to all build() methods
  • lib/src/parse.rs: Add #[must_use] and doc comments to parse and parse_partial

Test plan

  • All existing tests pass
  • Clippy happy

🤖 Generated with Claude Code


Note

Improves API safety and clarity, and hardens file-include parsing.

  • Add #[must_use] to SpecFlagBuilder::build, SpecArgBuilder::build, SpecCommandBuilder::build, Spec::parse_file, Spec::parse_script, parse, and parse_partial
  • Document parse and parse_partial to clarify behavior and defaults
  • Replace ctx.file.parent().unwrap() with checked parent resolution in include handling (errors instead of panic)

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

- Replace unsafe .unwrap() on Path::parent() with proper error handling
  in include directive parsing
- Add #[must_use] attributes to builder build() methods and parse functions
  to prevent accidentally discarding important return values
- Add doc comments to parse functions explaining their purpose

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 19, 2026 02:33
Copy link
Copy Markdown
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 improves code safety and maintainability by replacing an unsafe unwrap() call with proper error handling and adding #[must_use] attributes to prevent accidentally discarding important return values.

Changes:

  • Replaced unsafe Path::parent().unwrap() with proper error handling using ok_or_else()
  • Added #[must_use] attributes to parse functions and builder build() methods
  • Added documentation comments to parse functions

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
lib/src/spec/mod.rs Replaced unsafe unwrap with error handling in include directive parsing; added #[must_use] and docs to parse_file and parse_script
lib/src/spec/builder.rs Added #[must_use] to all builder build() methods
lib/src/parse.rs Added #[must_use] attributes and documentation to parse and parse_partial functions

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.52%. Comparing base (397efe4) to head (19ef8a5).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lib/src/spec/mod.rs 0.00% 14 Missing ⚠️
lib/src/parse.rs 0.00% 7 Missing ⚠️
lib/src/spec/builder.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #427      +/-   ##
==========================================
- Coverage   47.68%   46.52%   -1.16%     
==========================================
  Files          45       45              
  Lines        6164     6236      +72     
  Branches     6164     6236      +72     
==========================================
- Hits         2939     2901      -38     
- Misses       1553     1625      +72     
- Partials     1672     1710      +38     

☔ 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 f9f5759 into main Jan 19, 2026
7 of 9 checks passed
@jdx jdx deleted the refactor/code-quality branch January 19, 2026 02:52
jdx pushed a commit that referenced this pull request Jan 19, 2026
### 🚀 Features

- **(release)** add LLM-generated prose summary to release notes by
[@jdx](https://github.com/jdx) in
[#421](#421)
- add LLM-generated release notes for GitHub releases by
[@jdx](https://github.com/jdx) in
[#423](#423)
- add spec lint command by [@jdx](https://github.com/jdx) in
[#430](#430)

### 🐛 Bug Fixes

- replace unsafe path unwrap chains with proper error handling by
[@jdx](https://github.com/jdx) in
[#424](#424)
- pass positional args through to executed scripts by
[@jdx](https://github.com/jdx) in
[#425](#425)
- replace unimplemented!() with proper errors for unsupported shells by
[@jdx](https://github.com/jdx) in
[#432](#432)
- update claude CLI model and add bypassPermissions by
[@jdx](https://github.com/jdx) in
[#435](#435)

### 🚜 Refactor

- remove unused double-shebang support by [@jdx](https://github.com/jdx)
in [#426](#426)
- replace once_cell with std::sync::LazyLock by
[@jdx](https://github.com/jdx) in
[#428](#428)
- improve code quality with safety and lint fixes by
[@jdx](https://github.com/jdx) in
[#427](#427)

### ⚡ Performance

- use Arc for flag/arg keys in ParseOutput to reduce cloning by
[@jdx](https://github.com/jdx) in
[#422](#422)

### 🔍 Other Changes

- update insta snapshots to newer format by
[@jdx](https://github.com/jdx) in
[#429](#429)
- fix legacy inline snapshot format warnings by
[@jdx](https://github.com/jdx) in
[#433](#433)
- replace TODO with doc comment for subcommand_lookup by
[@jdx](https://github.com/jdx) in
[#434](#434)

### 📦️ Dependency Updates

- update actions/setup-node digest to 6044e13 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#419](#419)
- replace dependency @tsconfig/node22 with @tsconfig/node24 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#418](#418)
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jan 19, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [usage](https://github.com/jdx/usage) | minor | `2.12.0` → `2.13.1` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jdx/usage (usage)</summary>

### [`v2.13.1`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#2131---2026-01-19)

[Compare Source](jdx/usage@v2.13.0...v2.13.1)

##### 🐛 Bug Fixes

- use correct PowerShell casing in enum variant by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;438](jdx/usage#438)

### [`v2.13.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#2130---2026-01-19)

[Compare Source](jdx/usage@v2.12.0...v2.13.0)

##### 🚀 Features

- **(release)** add LLM-generated prose summary to release notes by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;421](jdx/usage#421)
- add LLM-generated release notes for GitHub releases by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;423](jdx/usage#423)
- add spec lint command by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;430](jdx/usage#430)
- add PowerShell completion support by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;431](jdx/usage#431)

##### 🐛 Bug Fixes

- replace unsafe path unwrap chains with proper error handling by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;424](jdx/usage#424)
- pass positional args through to executed scripts by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;425](jdx/usage#425)
- replace unimplemented!() with proper errors for unsupported shells by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;432](jdx/usage#432)
- update claude CLI model and add bypassPermissions by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;435](jdx/usage#435)

##### 🚜 Refactor

- remove unused double-shebang support by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;426](jdx/usage#426)
- replace once\_cell with std::sync::LazyLock by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;428](jdx/usage#428)
- improve code quality with safety and lint fixes by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;427](jdx/usage#427)

##### ⚡ Performance

- use Arc for flag/arg keys in ParseOutput to reduce cloning by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;422](jdx/usage#422)

##### 🔍 Other Changes

- update insta snapshots to newer format by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;429](jdx/usage#429)
- fix legacy inline snapshot format warnings by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;433](jdx/usage#433)
- replace TODO with doc comment for subcommand\_lookup by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;434](jdx/usage#434)

##### 📦️ Dependency Updates

- update actions/setup-node digest to [`6044e13`](jdx/usage@6044e13) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;419](jdx/usage#419)
- replace dependency [@&#8203;tsconfig/node22](https://github.com/tsconfig/node22) with [@&#8203;tsconfig/node24](https://github.com/tsconfig/node24) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;418](jdx/usage#418)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44NC4yIiwidXBkYXRlZEluVmVyIjoiNDIuODQuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
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