refactor: batch config/meta rules — usage examples, flag naming, CI enforcement#75
Closed
olavostauros wants to merge 19 commits into
Closed
refactor: batch config/meta rules — usage examples, flag naming, CI enforcement#75olavostauros wants to merge 19 commits into
olavostauros wants to merge 19 commits into
Conversation
The codebase_target_for_rule() function treated the entire scope value as a single path, so a TOML string like or-true = ".mise/tasks lib" would produce a single target /repo/.mise/tasks lib (with space) instead of two separate targets /repo/.mise/tasks and /repo/lib. This meant multi-path scope overrides either errored (path doesn't exist) or silently scanned nothing — users thought they had multi-path coverage but got false passes. Changes: - lib/codebase-config.sh: Replace codebase_target_for_rule() with codebase_targets_for_rule() that splits the scope value on whitespace and emits one target line per token. - .mise/tasks/lint/_default: Iterate over the multi-line output so each target is linted independently. - test/lint/default.bats: Add test covering multi-path scope with space-separated path list. The fix uses shell word-splitting on the scope string (unquoted in a for loop), which naturally handles TOML string values with internal spaces. Each token is resolved as a relative path against the repo root, or passed through unchanged if absolute. Fixes KnickKnackLabs#22
Adds first-class lint groups/presets so repos can opt into convention bundles with a single @maintained-tool reference instead of enumerating every lint rule individually. Includes: - lib/lint-groups.sh — built-in group registry, expansion, and discoverability functions - lib/codebase-config.sh — source lint-groups.sh, expand @group references in codebase_configured_lint_rules(), support lint_exclude - .mise/tasks/lint/_default — show expanded group count in preamble; updated error hint to mention groups - .mise/tasks/lint/groups — new lint:groups discoverability task - test/lint/lint-groups/ — 17 BATS tests Closes KnickKnackLabs#69
Adds bash-empty-array-expansions lint rule that flags ${array[@]}
and ${array[*]} under set -u (nounset), suggesting the Bash-3-safe
alternate-value form ${arr[@]+"${arr[@]}"}.
Shares nounset detection pattern with bash-empty-argv-forwarding (KnickKnackLabs#48):
- has_nounset() - detect set -u / set -eu / set -euo pipefail
- is_safe_context() - exclude for loops and local array assignments
- has_safe_form() - exclude already-safe alternate-value forms
Standard text-based ripgrep approach with 11 fixture scenarios and
15 BATS tests. ShellCheck-clean.
Implements KnickKnackLabs#57 (KnickKnackLabs/codebase)
Adds bash-empty-argv-forwarding lint rule that flags "$@" and "${@}"
as command arguments in files with nounset enabled (set -u). This pattern
causes fatal unbound-variable errors on macOS Bash 3.2 when the argument
list is empty, while Linux Bash 5+ handles it silently.
The rule follows the established text-based ripgrep pattern from or-true,
caller-pwd-contract, etc. It correctly excludes safe contexts (for loops,
array assignments), already-safe alternate-value forms (${@+"$@"}),
and files without nounset.
Implements KnickKnackLabs#48 (KnickKnackLabs/codebase)
Scans .mise/tasks/* for #USAGE directives with var=#true, then flags
dangerous consumption of the resulting usage_* vars:
- eval 'ARRAY=${usage_X}' → ERROR: injection vector
- read -ra ARRAY <<< "$usage_X" → WARN: loses quoting
The correct pattern uses xargs printf for bash or shlex.split() for
Python tasks, per mise-conventions.md.
…g no-tasks fixture
…r suppression Adds text-based detection for 'exec' with stderr redirection (2>/dev/null, 2>&-, 2>!) that persists for the current shell. - Detection via bash regex: \bexec\b[^#]*2> with dangerous target - Fixtures: clean, dirty, ignored-inline, ignored-file, broad-walk, no-toml, empty - 17 BATS tests covering detection, ignore mechanisms, discovery, edge cases - Self-hosting verified: task file does not self-report - Follows or-true pattern for output format, ignore conventions, and scope
- Extracts flag names, placeholders, and usage_* env var names - Functions: usage_flag_name, usage_placeholder, usage_env_name, parse_usage_flags, discover_task_files - Reusable by sibling rules (KnickKnackLabs#35, KnickKnackLabs#39, KnickKnackLabs#43)
…r mismatches Scans .mise/tasks/** for #USAGE flag directives where the flag name and arg placeholder produce different usage_* env var names. When they differ, the flag silently does nothing (real bug from codebase#12). - Two-phase detection: parse #USAGE directives, compare env var names - Skips boolean flags (no placeholder), short-only (no long name) - Respects inline and file-level codebase:ignore - 16 BATS tests, 10 fixture directories - Reuses lib/usage-parser.sh for directive parsing
The USAGE flag directive declared '--exclude <excludes>' but mise exports usage_exclude (from the flag name), not usage_excludes. The task code correctly reads , but the placeholder was misleading. Caught by the new usage-flag-naming self-hosting check.
…ts in CI Implements KnickKnackLabs#49 — a new lint rule that detects repos with [_.codebase].lint configured but no aggregate codebase lint enforcement in CI workflows. Key features: - Scans workflow YAMLs for direct patterns (codebase lint "$PWD"), mise exec indirection, and indirect delegation via local tasks - Warns on drift-prone hard-coded per-rule loops - --fix mode adds aggregate enforcement step and provisions codebase CLI tooling - Respects codebase:ignore mechanism - 13 BATS tests across 7 fixture scenarios (direct, indirect, missing, hardcoded-loop, loop-only, no-config, ignored, no-workflows) All 232 tests pass (13 ci-lint-enforcement tests at indices 45-57).
This was referenced Jun 26, 2026
Open
This was referenced Jun 26, 2026
Author
|
Closing this stacked batch in favor of individual re-evaluation. See ricon-family/olavo#9 for context. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked batch 4/4. See ricon-family/olavo#9.
Consolidates 3 config/meta lint rules (supersedes #66, #70, #58). Includes the shared
usage-parser.shlibrary and documentation updates.Rules included
usage-flag-namingmise-usage-examplesci-lint-enforcementShared library
lib/usage-parser.shCommits
70da2bdaec74ec334e8ff408355b1118024befa66a2337baf3cb68dcValidation
mise run test— 353 tests passinggit diff --check— clean