Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/workos/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ class BaseClient
RETRY_BACKOFF_BASE = 0.5
LOG_SEVERITY = {debug: 0, info: 1, warn: 2, error: 3, unknown: 4}.freeze

USER_AGENT = "workos-ruby/#{WorkOS::VERSION} ruby/#{RUBY_VERSION} (#{RUBY_PLATFORM})"
USER_AGENT = [
"WorkOS",
"#{defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"}/#{RUBY_VERSION}",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 RUBY_ENGINE guard is redundant in modern Ruby

RUBY_ENGINE has been a built-in constant in every Ruby implementation (MRI, JRuby, TruffleRuby) since Ruby 1.9, so defined?(::RUBY_ENGINE) will always be truthy in any supported version of this gem. The fallback "ruby" string can never be reached. The guard is harmless but adds noise.

Suggested change
"#{defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"}/#{RUBY_VERSION}",
"#{::RUBY_ENGINE}/#{RUBY_VERSION}",

RUBY_PLATFORM,
"v#{WorkOS::VERSION}"
].join("; ").freeze

attr_reader :api_key, :base_url, :client_id, :timeout, :max_retries, :logger, :log_level

Expand Down