feat(mapper): map literal Rails routes#102
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb0f1f0fdf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| function railsLineBlockDelta(line: string): number { | ||
| const code = rubyLineWithoutStrings(line); | ||
| return rubyTokenCount(code, "do") - rubyTokenCount(code, "end"); | ||
| } |
There was a problem hiding this comment.
Track brace-delimited route blocks before parsing nested routes
The block-depth guard only counts do/end, so unsupported Rails DSL blocks written with { ... } are never marked as skipped. In files that use brace-style scope/namespace blocks across multiple lines, inner get/post/... lines are parsed as if they were top-level routes, producing incorrect route seeds (for example missing scoped prefixes like /api). This breaks the “skip unsupported nested DSL conservatively” behavior and can yield inaccurate feature mappings for valid routes.rb syntax.
Useful? React with 👍 / 👎.
|
Addressed in 91fec30: brace-delimited route DSL blocks are now skipped conservatively, while top-level routes with multiline option hashes and regex constraints remain mapped. Added regressions for brace scopes, multiline option hashes, regex braces, and hash-rocket regex constraints. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat(mapper): map literal Rails routes This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ae06e2bc4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| function railsLineBlockDelta(line: string): number { | ||
| const code = rubyLineWithoutStrings(line); | ||
| return rubyTokenCount(code, "do") - rubyTokenCount(code, "end") + rubyBraceDelta(code); |
There was a problem hiding this comment.
Count non-do Ruby blocks when tracking route nesting
railsLineBlockDelta only increments depth for do and {, but decrements for every end, so common route wrappers like if ... end inside Rails.application.routes.draw desynchronize drawBlockDepth. In that case, nested routes can be incorrectly emitted as top-level and the parser can stop before later valid top-level routes, because the first conditional end can prematurely bring draw depth to zero.
Useful? React with 👍 / 👎.
Summary
rootand HTTP verb declarations inconfig/routes.rbWhy
Rails apps currently get broad config/view/database seeds but no focused route-level entries. Literal routes are a useful, low-risk starting point because they map directly from
config/routes.rbto controller handlers without needing to infer scoped DSL composition.Tests
./node_modules/.bin/vitest run src/mapper.test.ts -t 'Rails route'./node_modules/.bin/vitest run src/mapper.test.ts./node_modules/.bin/tsc -p tsconfig.json --noEmit./node_modules/.bin/oxlint . --config oxlint.json./node_modules/.bin/oxfmt --check src/mappers/ruby.ts src/mapper.test.tsgit diff --check./node_modules/.bin/vitest run./node_modules/.bin/tsc -p tsconfig.build.json