Skip to content

Commit

Permalink
chore: Use idiomatic fetch instead of conditional assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
arielvalentin committed Nov 21, 2021
1 parent 8f61287 commit 1bb159b
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ def enabled?(config = nil)
# See https://github.com/DataDog/dd-trace-rb/pull/1510
# rubocop:disable Metrics/AbcSize
def compatible_version?
instrumentation_spec = Gem.loaded_specs[instrumentation_gem_name] || Gem::Specification.find_by_name(instrumentation_gem_name)
library_spec = Gem.loaded_specs[library_name] || Gem::Specification.find_by_name(library_name)
instrumentation_spec = Gem.loaded_specs.fetch(instrumentation_gem_name) { Gem::Specification.find_by_name(instrumentation_gem_name) }
library_spec = Gem.loaded_specs.fetch(library_name) { Gem::Specification.find_by_name(library_name) }

dependency = instrumentation_spec.development_dependencies.find { |spec| spec.name == library_name }
dependency&.requirement&.satisfied_by?(library_spec&.version) == true
Expand Down

0 comments on commit 1bb159b

Please sign in to comment.