Skip to content

feat(rules): route-literals keeps HTTP paths in the modules standard.toml lists - #32

Draft
PiquelChips wants to merge 1 commit into
feat/rule-no-json-macrofrom
feat/rule-route-literals
Draft

PiquelChips wants to merge 1 commit into
feat/rule-no-json-macrofrom
feat/rule-route-literals

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What and why

In sourceorigin, routes.rs owns the HTTP paths that routers, discovery, redirects and policy use (SO4). A path written inline in a router can drift from the one discovery or a redirect advertises. route-literals fails on a string literal starting with / passed to Router::route, route_service, nest or nest_service, or to a Redirect constructor (Redirect::to, see_other, …). It skips test code, examples and the modules standard.toml lists:

route-modules = ["my_app::routes"]
  • Opt-in: with no route-modules, nothing is checked, since the rule is sourceorigin's.
  • Exempt:
  • Config: a listed module that no file is fails.
  • PR feat(lints): string_literal_logic keeps string literals to parsing and display #15's string_literal_logic doesn't cover this. It flags literals compared or matched (==, match, starts_with), not literals passed as arguments, so .route("/settings", …) passes it.
  • No --fix: naming the path takes judgement.

Stacked on #31.

Testing

  • Rebased onto the amended chain. just check-changed feat/rule-no-json-macro passes, and re-measuring gives the counts below again.
  • New fixture tests:
    • .route("/settings"), .nest("/api") and Redirect::to("/signed-out") fail.
    • These pass: routes::HOME, an absolute URL, a #[test], the listed app::routes and its child, and an example.
    • An unlisted app::paths fails at its line.
    • Without route-modules, nothing is checked.

Measured on a git archive copy of sourceorigin's origin/main (e99cc0e6b, since removed):

route-modules violations
["auth_service::routes"] 4: the SDK router's /login, /callback, /logout, /backchannel-logout (auth-sdk/src/axum/login/mod.rs); its login/routes.rs holds handlers, not paths
["auth_service::routes", "sourceorigin_auth::axum::login"] 0

auth-service already routes only through routes:: constants. Its 41 inline .route("/…") calls are all in tests, examples and doc comments. piqueld (3 literals in api/http/mod.rs) and DirkEngine don't opt in.

Checklist

  • The crate's README (its documentation on docs.rs) shows the change, and a repository's xtask can still follow it. (just readme, and route-modules in the configuration example.)
  • A change to the public API is noted for the next release, with what each repository's xtask must change. (A new Rule variant and standard.toml key; no xtask change.)
  • just check-changed passes.

Note

Written by Claude Opus 5.5 in Claude Code (via T3 Code)

When route-modules lists modules, code outside them, tests and examples
passes no /… literal to Router::route, route_service, nest or nest_service,
or to a Redirect constructor. The module walk now records whether each file
is production, test or example code to the targets reaching it.
@PiquelChips
PiquelChips force-pushed the feat/rule-route-literals branch from 8cc9f86 to dafb8fa Compare November 22, 2026 22:18
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