Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/lib.alya
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,17 @@
pub function print_version(app: CliApp)
say cli_format_version(app)
end

## Counts non-empty args (test helper for AI review).
pub function count_args(args: array) -> int
let n = 0
let unused_x = 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

minor: Ground-truth lint:FAIL warning[unused-var]: variable 'unused_x' is declared but never read; same line also causes fmt:FAIL needs formatting due to 2-space indent. Remove the line.

let i = 0
while i < len(args) - 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

major: Off-by-one vs stated intent 'Counts non-empty args': 'while i < len(args) - 1' never examines the last element, so a non-empty final arg is missed.

Suggested change
while i < len(args) - 1
while i < len(args)

if len(args[i]) > 0
n += 1
end
i += 1
end
return n
end
Loading