Class: Dependabot::Nuget::UpdateChecker

Inherits:
UpdateCheckers::Base
  • Object
show all
Defined in:
lib/dependabot/nuget/update_checker.rb,
lib/dependabot/nuget/update_checker/version_finder.rb,
lib/dependabot/nuget/update_checker/property_updater.rb,
lib/dependabot/nuget/update_checker/repository_finder.rb,
lib/dependabot/nuget/update_checker/requirements_updater.rb

Defined Under Namespace

Classes: PropertyUpdater, RepositoryFinder, RequirementsUpdater, VersionFinder

Instance Method Summary collapse

Instance Method Details

#latest_resolvable_versionObject



18
19
20
21
22
23
# File 'lib/dependabot/nuget/update_checker.rb', line 18

def latest_resolvable_version
  # TODO: Check version resolution!
  return nil if version_comes_from_multi_dependency_property?

  latest_version
end

#latest_resolvable_version_with_no_unlockObject



31
32
33
34
# File 'lib/dependabot/nuget/update_checker.rb', line 31

def latest_resolvable_version_with_no_unlock
  # Irrelevant, since Nuget has a single dependency file
  nil
end

#latest_versionObject



14
15
16
# File 'lib/dependabot/nuget/update_checker.rb', line 14

def latest_version
  @latest_version = latest_version_details&.fetch(:version)
end

#lowest_resolvable_security_fix_versionObject



25
26
27
28
29
# File 'lib/dependabot/nuget/update_checker.rb', line 25

def lowest_resolvable_security_fix_version
  return nil if version_comes_from_multi_dependency_property?

  lowest_security_fix_version_details&.fetch(:version)
end

#requirements_unlocked_or_can_be?Boolean

Returns:

  • (Boolean)


54
55
56
57
58
59
60
61
62
# File 'lib/dependabot/nuget/update_checker.rb', line 54

def requirements_unlocked_or_can_be?
  # If any requirements have an uninterpolated property in them then
  # that property couldn't be found, and the requirement therefore
  # cannot be unlocked (since we can't update that property)
  namespace = Nuget::FileParser::PropertyValueFinder
  dependency.requirements.none? do |req|
    req.fetch(:requirement)&.match?(namespace::PROPERTY_REGEX)
  end
end

#up_to_date?Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
# File 'lib/dependabot/nuget/update_checker.rb', line 45

def up_to_date?
  # If any requirements have an uninterpolated property in them then
  # that property couldn't be found, and we assume that the dependency
  # is up-to-date
  return true unless requirements_unlocked_or_can_be?

  super
end

#updated_requirementsObject



36
37
38
39
40
41
42
43
# File 'lib/dependabot/nuget/update_checker.rb', line 36

def updated_requirements
  RequirementsUpdater.new(
    requirements: dependency.requirements,
    latest_version: preferred_resolvable_version&.to_s,
    source_details: preferred_version_details&.
                    slice(:nuspec_url, :repo_url, :source_url)
  ).updated_requirements
end