lib/dependabot/composer/update_checker/requirements_updater.rb in dependabot-composer-0.230.0 vs lib/dependabot/composer/update_checker/requirements_updater.rb in dependabot-composer-0.231.0
- old
+ new
@@ -1,5 +1,6 @@
+# typed: false
# frozen_string_literal: true
################################################################################
# For more details on Composer version constraints, see: #
# https://getcomposer.org/doc/articles/versions.md#writing-version-constraints #
@@ -55,14 +56,14 @@
# rubocop:disable Metrics/PerceivedComplexity
def updated_requirement(req)
req_string = req[:requirement].strip
or_string_reqs = req_string.split(OR_SEPARATOR)
or_separator = req_string.match(OR_SEPARATOR)&.to_s || " || "
- numeric_or_string_reqs = or_string_reqs.
- reject { |r| r.strip.start_with?("dev-") }
- branch_or_string_reqs = or_string_reqs.
- select { |r| r.strip.start_with?("dev-") }
+ numeric_or_string_reqs = or_string_reqs
+ .reject { |r| r.strip.start_with?("dev-") }
+ branch_or_string_reqs = or_string_reqs
+ .select { |r| r.strip.start_with?("dev-") }
return req unless req_string.match?(/\d/)
return req if numeric_or_string_reqs.none?
return updated_alias(req) if req_string.match?(ALIAS_REGEX)
return req if req_satisfied_by_latest_resolvable?(req_string) &&
@@ -134,21 +135,21 @@
req.merge(requirement: updated_requirement)
end
def req_satisfied_by_latest_resolvable?(requirement_string)
- ruby_requirements(requirement_string).
- any? { |r| r.satisfied_by?(latest_resolvable_version) }
+ ruby_requirements(requirement_string)
+ .any? { |r| r.satisfied_by?(latest_resolvable_version) }
end
def update_version_string(req_string)
- req_string.
- sub(VERSION_REGEX) do |old_version|
+ req_string
+ .sub(VERSION_REGEX) do |old_version|
next latest_resolvable_version.to_s unless req_string.match?(/[~*\^]/)
old_parts = old_version.split(".")
- new_parts = latest_resolvable_version.to_s.split(".").
- first(old_parts.count)
+ new_parts = latest_resolvable_version.to_s.split(".")
+ .first(old_parts.count)
new_parts.map.with_index do |part, i|
old_parts[i] == "*" ? "*" : part
end.join(".")
end
end