fix(ruby): fix Rubocop Naming/VariableNumber and Lint/Void offenses in generated SDKs#14181
fix(ruby): fix Rubocop Naming/VariableNumber and Lint/Void offenses in generated SDKs#14181fern-support wants to merge 7 commits intomainfrom
Conversation
…n generated SDKs Co-Authored-By: blank <blank@buildwithfern.com>
Co-Authored-By: blank <blank@buildwithfern.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
Co-Authored-By: blank <blank@buildwithfern.com>
Co-Authored-By: blank <blank@buildwithfern.com>
…it-manager.devin.ai/proxy/github.com/fern-api/fern into devin/1774557060-fix-ruby-rubocop-linting
Co-Authored-By: blank <blank@buildwithfern.com>
|
The |
Description
Fixes 9 Rubocop offenses (6 ×
Naming/VariableNumber, 3 ×Lint/Void) that cause CI failures in generated Ruby SDKs such as Schematic's.Changes Made
Fix 1: Naming/VariableNumber (6 offenses)
The generator's snake_case conversion (via lodash) inserts underscores before trailing digits — e.g.
account_last4→:account_last_4. The generator's own.rubocop.ymlenforcesnormalcase, which disallows this.rubyPropertyName()helper inAbstractRubyGeneratorContext.tsthat uses the existingrubySnakeCase()function (which does not treat letter→digit as a word boundary) and preserves any reserved-word suffix the IR addsrubySnakeCaseso SDK-layer code can use it for non-property names (e.g. auth parameter names)snakeCase.safeName/snakeCase.unsafeNameusages for property/field names across 8 generator files:generateFields.ts,UnionGenerator.ts,HttpEndpointGenerator.ts,WrappedEndpointRequest.ts,FileUploadEndpointRequest.ts,RootClientGenerator.ts,SubPackageClientGenerator.tsFix 2: Lint/Void (3 offenses)
Static runtime template files had bare
valueexpressions in void context (other branches used explicitreturn, so thecasereturn value was discarded).boolean.Template.rb:20—value→return valueutils.Template.rb:84,87—value→return value(two locations)Fix 3: Hyphen handling in
rubySnakeCaseThe custom
rubySnakeCasefunction originally only handled camelCase→snake_case transitions but did not convert hyphens to underscores. This caused invalid Ruby identifiers when IR original names contained hyphens (e.g.favorite-number→favorite-numberinstead offavorite_number,nested-no-auth→def nested-no-authwhich is a syntax error)..replace(/[-\s]+/g, "_")as the first step inrubySnakeCaseto normalize hyphens and spaces to underscores before case conversionSeed snapshots
Updated all ruby-sdk-v2 seed snapshots (113/114 pass; the one failure
exhaustive:extra-depsis a pre-existing expected failure)Updated
versions.ymlwith v1.1.6 changelog entryUpdated README.md generator (if applicable) — N/A
Testing
pnpm run checkpasses clean (lint + typecheck)fern generate --group ruby-sdk --previewthenbundle exec rubocop)Human Review Checklist
rubySnakeCasehandles all separators that could appear in IRoriginalNamevalues. Currently handles hyphens, spaces, camelCase, and ALLCAPS boundaries — but are there other separators (dots, slashes, etc.) that the IR's built-insnakeCasehandles that this regex doesn't?rubyPropertyNamecorrectly handles reserved-word suffixes — the function assumes IR appends a suffix tounsafeNameto producesafeNameand thatsafeName.startsWith(unsafeName). Check edge cases where this assumption could break.main(v1.1.4 Basic Auth, v1.1.5 security headers) which are unrelated to this PR's generator changes.x-api-v2-key→ should becomex_api_v2_key).Link to Devin session: https://app.devin.ai/sessions/229bc98388514f0c85d801e4d53cefa8