Class: Dependabot::Gradle::UpdateChecker

Inherits:
UpdateCheckers::Base
  • Object
show all
Defined in:
lib/dependabot/gradle/update_checker.rb,
lib/dependabot/gradle/update_checker/version_finder.rb,
lib/dependabot/gradle/update_checker/requirements_updater.rb,
lib/dependabot/gradle/update_checker/multi_dependency_updater.rb

Defined Under Namespace

Classes: MultiDependencyUpdater, RequirementsUpdater, VersionFinder

Instance Method Summary collapse

Instance Method Details

#latest_resolvable_versionObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dependabot/gradle/update_checker.rb', line 21

def latest_resolvable_version
  # TODO: Resolve the build.gradle to find the latest version we could
  # update to without updating any other dependencies at the same time.
  #
  # The above is hard. Currently we just return the latest version and
  # hope (hence this package manager is in beta!)
  return if git_dependency?
  return nil if version_comes_from_multi_dependency_property?
  return nil if version_comes_from_dependency_set?

  latest_version
end

#latest_resolvable_version_with_no_unlockObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/dependabot/gradle/update_checker.rb', line 46

def latest_resolvable_version_with_no_unlock
  # Irrelevant, since Gradle has a single dependency file.
  #
  # For completeness we ought to resolve the build.gradle and return the
  # latest version that satisfies the current constraint AND any
  # constraints placed on it by other dependencies. Seeing as we're
  # never going to take any action as a result, though, we just return
  # nil.
  nil
end

#latest_versionObject



15
16
17
18
19
# File 'lib/dependabot/gradle/update_checker.rb', line 15

def latest_version
  return if git_dependency?

  latest_version_details&.fetch(:version)
end

#lowest_resolvable_security_fix_versionObject



38
39
40
41
42
43
44
# File 'lib/dependabot/gradle/update_checker.rb', line 38

def lowest_resolvable_security_fix_version
  return if git_dependency?
  return nil if version_comes_from_multi_dependency_property?
  return nil if version_comes_from_dependency_set?

  lowest_security_fix_version
end

#lowest_security_fix_versionObject



34
35
36
# File 'lib/dependabot/gradle/update_checker.rb', line 34

def lowest_security_fix_version
  lowest_security_fix_version_details&.fetch(:version)
end

#requirements_unlocked_or_can_be?Boolean

Returns:

  • (Boolean)


70
71
72
73
74
# File 'lib/dependabot/gradle/update_checker.rb', line 70

def requirements_unlocked_or_can_be?
  # If the dependency version come from a property we couldn't
  # interpolate then there's nothing we can do.
  !dependency.version&.include?("$")
end

#updated_requirementsObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/dependabot/gradle/update_checker.rb', line 57

def updated_requirements
  property_names =
    declarations_using_a_property
    .map { |req| req.dig(:metadata, :property_name) }

  RequirementsUpdater.new(
    requirements: dependency.requirements,
    latest_version: preferred_resolvable_version&.to_s,
    source_url: preferred_version_details&.fetch(:source_url),
    properties_to_update: property_names
  ).updated_requirements
end