Skip to content

Noisy Warnings on Ruby 3.4.8#133

Merged
spacechurro merged 3 commits intomainfrom
FEAT-244-dependency-lazy-loading
Feb 25, 2026
Merged

Noisy Warnings on Ruby 3.4.8#133
spacechurro merged 3 commits intomainfrom
FEAT-244-dependency-lazy-loading

Conversation

@hstrowd
Copy link
Collaborator

@hstrowd hstrowd commented Feb 21, 2026

When including this gem in codebases running Ruby 3.4.8, we're seeing warnings like the following pop up anytime the gem is loaded (e.g. running a console, running tests, etc) even when no FeatureMap related functionality, and particularly not the functionality requiring these gems, is exercised:

warning: parser/current is loading parser/ruby34, which recognizes 3.4.0-dev-compliant syntax, but you are running 3.4.8.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.

This set of changes moves rubocop and parser dependencies to be lazy loaded to avoid unnecessarily noisy warnings on Ruby 3.4.8.

Local Validation - 3.4 Ruby on Main Branch

Screenshot 2026-02-21 at 4 14 29 AM

Local Validation - Pre 3.4 Ruby

Screenshot 2026-02-20 at 4 18 16 PM

Local Validation - 3.4 Ruby

Screenshot 2026-02-20 at 4 19 00 PM

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses noisy warnings that appear on Ruby 3.4.8 when the gem is loaded, even when parser/rubocop functionality is not used. The warnings occur because parser/current loads parser/ruby34 which recognizes 3.4.0-dev-compliant syntax but the actual Ruby version is 3.4.8. The solution is to lazy-load the rubocop and parser dependencies only when the code actually needs to use them.

Changes:

  • Moved require 'rubocop' and require 'parser/current' from module-level to method-level lazy loading
  • Added explicit parser dependency to gemspec (previously only transitive through rubocop)
  • Removed unnecessary require 'parser/current' from LinesOfCodeCalculator (not actually used)

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/feature_map/private/lines_of_code_calculator.rb Removed unused require 'parser/current' statement
lib/feature_map/private/feature_metrics_calculator.rb Moved require 'rubocop' to lazy load inside calculate_for_file method
lib/feature_map/private/cyclomatic_complexity_calculator.rb Moved require 'parser/current' to lazy load inside process method
lib/feature_map.rb Removed blank line between require statements
feature_map.gemspec Added explicit parser dependency (~> 3.3) to ensure version compatibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@spacechurro spacechurro merged commit 22a8576 into main Feb 25, 2026
14 checks passed
@spacechurro spacechurro deleted the FEAT-244-dependency-lazy-loading branch February 25, 2026 03:24
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.

4 participants