Skip to content

Modernize to Ruby 3.3 syntax#196

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/update-ruby-version-and-syntax
Draft

Modernize to Ruby 3.3 syntax#196
Copilot wants to merge 3 commits intomainfrom
copilot/update-ruby-version-and-syntax

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 26, 2025

Updates codebase to Ruby 3.3.6 and refactors to modern syntax patterns.

Configuration

  • Bumped required_ruby_version from >= 2.6 to >= 3.3 in gemspec
  • Updated RuboCop target from 2.6 to 3.3
  • Migrated RuboCop config from deprecated require: to plugins: syntax

Code Changes

Replaced named block parameters with numbered parameters across 5 methods:

# Before
all.find { |airport| airport.iata == iata_code }
parsed_data.values.map { |airport_data| airport_data["icao"] }

# After
all.find { _1.iata == iata_code }
parsed_data.values.map { _1["icao"] }

Converted check_for_empty_data in Rakefile to endless method definition:

# Before (7 lines)
def check_for_empty_data(field)
  if field == "\\N"
    nil
  else
    field
  end
end

# After (1 line)
def check_for_empty_data(field) = field == "\\N" ? nil : field

Removed obsolete TODO comment about transform_keys (feature already implemented).

Original prompt

Update Ruby to the latest version and upgrade syntax to latest

TITLE: Ruby Version Upgrade and Syntax Modernization

USER INTENT:
The user wants to update their project to use the latest Ruby version and refactor the codebase to utilize the latest Ruby syntax features.

TASK DESCRIPTION:

  • Upgrade the Ruby version used in the project to the most recent stable release.
  • Refactor existing code to adopt modern Ruby syntax and best practices, ensuring compatibility with the new Ruby version.
  • Address any deprecations or incompatibilities that arise from the upgrade.
  • Update relevant configuration files (e.g., .ruby-version, Gemfile) to reflect the new Ruby version.

EXISTING:

  • The project currently uses an older Ruby version (exact version not specified).
  • The codebase may contain legacy syntax or patterns that are outdated in the context of the latest Ruby release.
  • Configuration files such as .ruby-version and Gemfile are present but reference the old Ruby version.

PENDING:

  • Update .ruby-version and Gemfile to specify the latest Ruby version (e.g., 3.3.0 as of June 2024).
  • Refactor code files to use new syntax features (e.g., numbered parameters, safe navigation operator, pattern matching, endless method definitions, etc.).
  • Run the test suite to ensure all functionality works as expected after the upgrade.
  • Address any syntax errors, deprecations, or gem incompatibilities that arise.
  • Update documentation to reflect the new Ruby version and syntax changes.

CODE STATE:
Files discussed or to be modified:

  • .ruby-version
    Before:
    2.6.3
    
    After:
    3.3.0
    
  • Gemfile
    Before:
    ruby '2.6.3'
    
    After:
    ruby '3.3.0'
    
  • Application code files (e.g., app/models/.rb, app/controllers/.rb, lib/**/*.rb)
    • Refactor examples:
      • Replace Proc.new { |x| x * 2 } with ->(x) { x * 2 }
      • Use safe navigation: user&.profile&.email
      • Use numbered parameters: .map { _1 * 2 }
      • Use endless method definitions: def square(x) = x * x
      • Use pattern matching where appropriate

RELEVANT CODE/DOCUMENTATION SNIPPETS:

  • .ruby-version:
    3.3.0
    
  • Gemfile:
    ruby '3.3.0'
    
  • Example syntax upgrades:
    • Before:
      users.map { |user| user.name }
      
      After:
      users.map { _1.name }
      
    • Before:
      def foo(x)
        x * 2
      end
      
      After:
      def foo(x) = x * 2
      
    • Before:
      user && user.profile && user.profile.email
      
      After:
      user&.profile&.email
      

OTHER NOTES:

  • Ensure all gems are compatible with Ruby 3.3.0; update or replace gems as needed.
  • Run bundle update after changing the Ruby version.
  • Consider using automated tools like RuboCop with the latest Ruby target to help identify and autocorrect outdated syntax.
  • Update CI/CD pipelines to use the new Ruby version.
  • Communicate these changes to the team and update onboarding documentation if necessary.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits October 26, 2025 20:31
Co-authored-by: timrogers <116134+timrogers@users.noreply.github.com>
Co-authored-by: timrogers <116134+timrogers@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Ruby to latest version and refactor syntax Modernize to Ruby 3.3 syntax Oct 26, 2025
Copilot AI requested a review from timrogers October 26, 2025 20:46
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.

2 participants