Skip to content

refactor(cmds): drop module-name stutter from filter fn names - #3912

Open
KuSh wants to merge 1 commit into
rtk-ai:developfrom
KuSh:chore/standardize-filter-fn-names
Open

KuSh wants to merge 1 commit into
rtk-ai:developfrom
KuSh:chore/standardize-filter-fn-names

Conversation

@KuSh

@KuSh KuSh commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

What

Filter functions repeated their own module name, so every cross-module call read as mypy_cmd::filter_mypy_output. The module path already supplies the tool name.

This is not a new convention: .claude/rules/rust-patterns.md has prescribed plain filter_output in its "Module Structure" section all along (lines 231-232). The code had drifted from its own documented house style; this aligns them.

module before after
bun_cmd filter_bun_pkg filter_pkg
filter_bun_pm_ls_json filter_pm_ls_json
filter_bun_pm_ls_text filter_pm_ls_text
filter_bun_pm_ls filter_pm_ls
filter_bun_pm_ls_tree filter_pm_ls_tree
deno_cmd filter_deno_output filter_output
prettier_cmd filter_prettier_output filter_output
artisan_cmd filter_artisan_output filter_output
filter_artisan_test_output filter_test_output
mypy_cmd filter_mypy_output filter_output
ruff_cmd filter_ruff_check_json filter_check_json
filter_ruff_format filter_format
sqlfluff_cmd filter_sqlfluff_lint_json filter_lint_json
json_cmd filter_json_compact filter_compact
filter_json_string filter_schema

Reads better where it matters most — the pipe_cmd registry:

"ruff-check"    => Some(crate::cmds::python::ruff_cmd::filter_check_json),
"sqlfluff-lint" => Some(crate::cmds::python::sqlfluff_cmd::filter_lint_json),

Not a behaviour change

Pure rename. The user-facing rtk pipe -f filter names ("mypy", "ruff-check", "sqlfluff-lint", …) are unchanged, so no CLI surface moves. cargo fmt --all --check, cargo clippy --all-targets and cargo test --all all pass.

Two judgement calls

  • bun_cmd::run_bunx left alone. bunx is a distinct tool from bun, so that is not stutter. Flagging it because a regex-driven pass would have renamed it.
  • json_cmd::filter_json_string → filter_schema is a semantic fix, not just destuttering. It returns a schema representation (types only, no values), so the old name described its input rather than its output. Easy to drop from this PR if you'd rather keep the change purely mechanical.

Doc drift

src/cmds/README.md taught the stuttering pattern in both its worked example and its "Adding a New Command Filter" checklist, which would have pulled the convention straight back on the next filter. Both are updated, and the naming rule is now stated explicitly rather than left implicit.

🤖 Generated with Claude Code

@KuSh
KuSh force-pushed the chore/standardize-filter-fn-names branch 2 times, most recently from e2af7a2 to 6190284 Compare September 7, 2026 23:29
@KuSh
KuSh marked this pull request as ready for review September 7, 2026 23:31
@KuSh
KuSh force-pushed the chore/standardize-filter-fn-names branch 3 times, most recently from 87cf737 to c83f999 Compare September 17, 2026 23:04
@KuSh
KuSh force-pushed the chore/standardize-filter-fn-names branch from c83f999 to 679922a Compare October 7, 2026 16:48
Filter functions repeated their own module name, so every cross-module
call read as mypy_cmd::filter_mypy_output. The module path already
supplies the tool name; .claude/rules/rust-patterns.md has prescribed
plain filter_output as the module-structure convention all along, so
this aligns the code with the documented house style rather than
introducing a new one.

  bun_cmd       filter_bun_pkg            -> filter_pkg
                filter_bun_pm_ls_json     -> filter_pm_ls_json
                filter_bun_pm_ls_text     -> filter_pm_ls_text
                filter_bun_pm_ls          -> filter_pm_ls
                filter_bun_pm_ls_tree     -> filter_pm_ls_tree
  deno_cmd      filter_deno_output        -> filter_output
  prettier_cmd  filter_prettier_output    -> filter_output
  artisan_cmd   filter_artisan_output     -> filter_output
                filter_artisan_test_output-> filter_test_output
  mypy_cmd      filter_mypy_output        -> filter_output
  ruff_cmd      filter_ruff_check_json    -> filter_check_json
                filter_ruff_format        -> filter_format
  sqlfluff_cmd  filter_sqlfluff_lint_json -> filter_lint_json
  json_cmd      filter_json_compact       -> filter_compact
                filter_json_string        -> filter_schema

Test names follow their subject where they name it, e.g.
test_filter_deno_output_empty -> test_filter_output_empty.

Pure rename: no behaviour change, and the user-facing `rtk pipe -f`
filter names ("mypy", "ruff-check", "sqlfluff-lint", ...) are untouched.
pipe_cmd::test_resolve_filter_ruff_format therefore keeps its name --
it asserts resolve_filter("ruff-format"), the user-facing string rather
than the function.

Three judgement calls worth a reviewer's eye:
- bun_cmd::run_bunx is left alone; bunx is a distinct tool from bun,
  not stutter.
- bun_cmd's test_filter_bun_install_* keep their names. They name the
  output being filtered, `bun install`, rather than the function under
  test, which is filter_pkg; there is no filter_install to follow.
- json_cmd::filter_json_string -> filter_schema is a semantic fix, not
  just destuttering: it returns a schema representation (types only, no
  values), so the old name described the input rather than the output.

src/cmds/README.md taught the stuttering pattern in its example and its
"Adding a New Command Filter" checklist, which would have pulled the
convention straight back; both are updated and the naming rule is now
stated explicitly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@KuSh
KuSh force-pushed the chore/standardize-filter-fn-names branch from 679922a to 080fe73 Compare October 21, 2026 00:23
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.

1 participant