Skip to content

fix(ruby): fix Rubocop Naming/VariableNumber and Lint/Void offenses in generated SDKs#14181

Open
fern-support wants to merge 7 commits intomainfrom
devin/1774557060-fix-ruby-rubocop-linting
Open

fix(ruby): fix Rubocop Naming/VariableNumber and Lint/Void offenses in generated SDKs#14181
fern-support wants to merge 7 commits intomainfrom
devin/1774557060-fix-ruby-rubocop-linting

Conversation

@fern-support
Copy link
Copy Markdown
Collaborator

@fern-support fern-support commented Mar 27, 2026

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.yml enforces normalcase, which disallows this.

  • Added rubyPropertyName() helper in AbstractRubyGeneratorContext.ts that uses the existing rubySnakeCase() function (which does not treat letter→digit as a word boundary) and preserves any reserved-word suffix the IR adds
  • Exported rubySnakeCase so SDK-layer code can use it for non-property names (e.g. auth parameter names)
  • Replaced all snakeCase.safeName / snakeCase.unsafeName usages for property/field names across 8 generator files:
    • generateFields.ts, UnionGenerator.ts, HttpEndpointGenerator.ts, WrappedEndpointRequest.ts, FileUploadEndpointRequest.ts, RootClientGenerator.ts, SubPackageClientGenerator.ts

Fix 2: Lint/Void (3 offenses)

Static runtime template files had bare value expressions in void context (other branches used explicit return, so the case return value was discarded).

  • boolean.Template.rb:20valuereturn value
  • utils.Template.rb:84,87valuereturn value (two locations)

Fix 3: Hyphen handling in rubySnakeCase

The custom rubySnakeCase function 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-numberfavorite-number instead of favorite_number, nested-no-authdef nested-no-auth which is a syntax error).

  • Added .replace(/[-\s]+/g, "_") as the first step in rubySnakeCase to normalize hyphens and spaces to underscores before case conversion

Seed snapshots

  • Updated all ruby-sdk-v2 seed snapshots (113/114 pass; the one failure exhaustive:extra-deps is a pre-existing expected failure)

  • Updated versions.yml with v1.1.6 changelog entry

  • Updated README.md generator (if applicable) — N/A

Testing

  • pnpm run check passes clean (lint + typecheck)
  • All ruby-sdk-v2 seed tests pass locally (113/114, 1 expected failure)
  • Manual testing with schematic-fern-config (requires FERN_TOKEN — can be verified post-merge by running fern generate --group ruby-sdk --preview then bundle exec rubocop)

Human Review Checklist

  • Verify rubySnakeCase handles all separators that could appear in IR originalName values. Currently handles hyphens, spaces, camelCase, and ALLCAPS boundaries — but are there other separators (dots, slashes, etc.) that the IR's built-in snakeCase handles that this regex doesn't?
  • Verify rubyPropertyName correctly handles reserved-word suffixes — the function assumes IR appends a suffix to unsafeName to produce safeName and that safeName.startsWith(unsafeName). Check edge cases where this assumption could break.
  • Confirm seed snapshot diffs are correct — note that diffs also include changes merged from main (v1.1.4 Basic Auth, v1.1.5 security headers) which are unrelated to this PR's generator changes.
  • Spot-check generated output for names with consecutive digits or mixed separators (e.g. x-api-v2-key → should become x_api_v2_key).

Link to Devin session: https://app.devin.ai/sessions/229bc98388514f0c85d801e4d53cefa8

devin-ai-integration bot and others added 2 commits March 26, 2026 20:37
…n generated SDKs

Co-Authored-By: blank <blank@buildwithfern.com>
Co-Authored-By: blank <blank@buildwithfern.com>
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions
Copy link
Copy Markdown
Contributor

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI
  • Postman

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.

@devin-ai-integration devin-ai-integration bot changed the title Devin/1774557060 fix ruby rubocop linting fix(ruby): fix Rubocop Naming/VariableNumber and Lint/Void offenses in generated SDKs Mar 27, 2026
Co-Authored-By: blank <blank@buildwithfern.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

The seed-test-results (ruby-sdk-v2) failure was due to 1 runner being cancelled (infrastructure issue, not a code failure). All 11 other ruby-sdk-v2 jobs passed. Could someone re-run the cancelled job (ruby-sdk-v2 (audiences, circular-references-advanced, enum, file-upload, imdb, multi-url-environm...)) to get CI green?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant