Skip to content

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 19, 2026

Summary

Adds new lint checks and improves error messages:

New checks:

Code Severity Description
subcommand-required-no-subcommands error Command has subcommand_required=true but no subcommands defined
variadic-arg-not-last warning Variadic argument is not the last argument
count-flag-with-arg error Count flag also has an argument (conflicting semantics)

Improvements:

  • invalid-default-subcommand error now shows the list of valid subcommands

Example output:

error [invalid-default-subcommand]: default_subcommand 'nonexistent' does not exist (valid subcommands: install, update)

🤖 Generated with Claude Code


Note

Adds additional validation and clearer errors in CLI spec linting.

  • New checks:
    • subcommand-required-no-subcommands (error): subcommand_required=true but no subcommands
    • variadic-arg-not-last (warning): variadic arg appears before the last position
    • count-flag-with-arg (error): count flag also has an argument
  • Improves invalid-default-subcommand to include valid subcommands in the message
  • Extends test coverage for all new behaviors

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

Copilot AI review requested due to automatic review settings January 19, 2026 19:04
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 enhances the CLI linting functionality by adding three new lint checks and improving error message clarity for invalid default subcommands.

Changes:

  • Added validation for commands with subcommand_required=true but no defined subcommands
  • Added warning for variadic arguments that aren't positioned last
  • Added validation to prevent count flags from having arguments (conflicting semantics)
  • Enhanced error messages for invalid default subcommands to display available options

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

Comment on lines 142 to 146
let valid: Vec<_> = spec.cmd.subcommands.keys().collect();
let hint = if valid.is_empty() {
"no subcommands defined".to_string()
} else {
format!("valid subcommands: {}", valid.iter().map(|s| s.as_str()).collect::<Vec<_>>().join(", "))
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The intermediate collect::<Vec<_>>() is unnecessary. You can join the iterator directly without collecting it first. Consider changing to: valid.iter().map(|s| s.as_str()).collect::<Vec<_>>().join(\", \")valid.iter().map(|s| s.as_str()).collect::<Vec<_>>().join(\", \"). Actually, even better would be to avoid the double collect by using valid.join(\", \") directly since valid is already a Vec<&String>.

Suggested change
let valid: Vec<_> = spec.cmd.subcommands.keys().collect();
let hint = if valid.is_empty() {
"no subcommands defined".to_string()
} else {
format!("valid subcommands: {}", valid.iter().map(|s| s.as_str()).collect::<Vec<_>>().join(", "))
let valid: Vec<String> = spec.cmd.subcommands.keys().cloned().collect();
let hint = if valid.is_empty() {
"no subcommands defined".to_string()
} else {
format!("valid subcommands: {}", valid.join(", "))

Copilot uses AI. Check for mistakes.
@jdx jdx force-pushed the feat/lint-improvements branch from 3edb2c8 to 96b57c8 Compare January 19, 2026 19:43
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 76.74419% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.36%. Comparing base (5e030b1) to head (ab08e6e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cli/src/cli/lint.rs 76.74% 5 Missing and 15 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #446      +/-   ##
==========================================
+ Coverage   44.81%   45.36%   +0.55%     
==========================================
  Files          47       47              
  Lines        7145     7221      +76     
  Branches     7145     7221      +76     
==========================================
+ Hits         3202     3276      +74     
+ Misses       1992     1987       -5     
- Partials     1951     1958       +7     

☔ 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 force-pushed the feat/lint-improvements branch from 96b57c8 to 9264a19 Compare January 19, 2026 21:35
jdx and others added 2 commits January 19, 2026 15:35
New checks:
- subcommand-required-no-subcommands: command has subcommand_required=true
  but no subcommands defined (error)
- variadic-arg-not-last: variadic argument is not the last argument (warning)
- count-flag-with-arg: count flag also has an argument, which is
  conflicting semantics (error)

Improvements:
- invalid-default-subcommand now shows valid subcommands in the error message

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jdx jdx force-pushed the feat/lint-improvements branch from 9264a19 to ab08e6e Compare January 19, 2026 21:35
@jdx jdx merged commit 33dda62 into main Jan 19, 2026
9 checks passed
@jdx jdx deleted the feat/lint-improvements branch January 19, 2026 22:42
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