Skip to content

fix: ZC1075 skips width-pad and typeset arrays#1423

Merged
afadesigns merged 2 commits into
mainfrom
fix/zc1075-width-typeset
Jun 25, 2026
Merged

fix: ZC1075 skips width-pad and typeset arrays#1423
afadesigns merged 2 commits into
mainfrom
fix/zc1075-width-typeset

Conversation

@afadesigns

Copy link
Copy Markdown
Owner

What

Two ZC1075 elision refinements.

  • A width modifier ${(l:n:)x} / ${(r:n:)x} pads to a fixed width — never an empty word. The l/r flag is not a word-splitting flag, so it slipped past the existing skip. Now skipped, distinguished from (r) (reverse, can be empty) by the :n: width argument.
  • typeset arr=(a b) declares an array, but the parser does not model its value as an ArrayLiteral here. The harvest now also reads a value that renders with a leading (; a quoted scalar q="(literal)" keeps its opening quote and is not mistaken for an array.

Verification

  • ${(l:5:)x} confirmed against real zsh: an unset value yields five spaces, never empty.
  • Removes 2 findings from the violation baseline (gitstatus ${(l:20:)pgid}, spaceship typeset -U sections=(...)); (r) reverse and quoted scalars still fire.
  • go test ./... passes, golangci-lint 0 issues, new helpers 100% covered, sweeps clean.

Two more elision refinements:

- A width modifier `${(l:n:)x}` / `${(r:n:)x}` pads to a fixed width, so
  the result is never an empty word. The kata flagged it because the
  `l`/`r` flag is not a word-splitting flag. It now skips width flags,
  distinguished from `(r)` (reverse, can still be empty) by the `:n:`
  argument.
- `typeset arr=(a b)` declares an array, but the parser does not model
  its value as an ArrayLiteral here, so the harvest missed it and a bare
  `$arr` was flagged. The harvest now also reads a value that renders
  with a leading `(`; a quoted scalar `q="(literal)"` keeps its opening
  quote and is not mistaken for an array.

Removes 2 findings from the violation baseline (gitstatus width-pad,
spaceship typeset array). Regression and helper tests added.

@redteamx redteamx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved on review. Width-pad + typeset-array skips verified against zsh; 2 baseline removals, helpers 100% covered.

redteamx
redteamx previously approved these changes Jun 25, 2026

@redteamx redteamx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved on review.

@github-actions github-actions Bot added ci CI/CD and workflow changes test Adding or correcting tests area/katas pkg/katas — detection logic labels Jun 25, 2026
@afadesigns afadesigns merged commit c646a5a into main Jun 25, 2026
19 checks passed
@afadesigns afadesigns deleted the fix/zc1075-width-typeset branch June 25, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/katas pkg/katas — detection logic ci CI/CD and workflow changes test Adding or correcting tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants