Class: Dependabot::Nuget::UpdateChecker::VersionFinder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/nuget/update_checker/version_finder.rb

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

NUGET_RANGE_REGEX =
/[\(\[].*,.*[\)\]]/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, dependency_files:, credentials:, ignored_versions:, security_advisories:, repo_contents_path:, raise_on_ignored: false) ⇒ VersionFinder

Returns a new instance of VersionFinder.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 35

def initialize(dependency:,
               dependency_files:,
               credentials:,
               ignored_versions:,
               security_advisories:,
               repo_contents_path:,
               raise_on_ignored: false)
  @dependency          = dependency
  @dependency_files    = dependency_files
  @credentials         = credentials
  @ignored_versions    = ignored_versions
  @raise_on_ignored    = raise_on_ignored
  @security_advisories = security_advisories
  @repo_contents_path  = repo_contents_path
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



97
98
99
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 97

def credentials
  @credentials
end

#dependencyObject (readonly)

Returns the value of attribute dependency.



91
92
93
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 91

def dependency
  @dependency
end

#dependency_filesObject (readonly)

Returns the value of attribute dependency_files.



94
95
96
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 94

def dependency_files
  @dependency_files
end

#ignored_versionsObject (readonly)

Returns the value of attribute ignored_versions.



100
101
102
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 100

def ignored_versions
  @ignored_versions
end

#repo_contents_pathObject (readonly)

Returns the value of attribute repo_contents_path.



106
107
108
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 106

def repo_contents_path
  @repo_contents_path
end

#security_advisoriesObject (readonly)

Returns the value of attribute security_advisories.



103
104
105
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 103

def security_advisories
  @security_advisories
end

Instance Method Details

#latest_version_detailsObject



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

def latest_version_details
  @latest_version_details ||=
    T.let(
      begin
        possible_versions = versions
        possible_versions = filter_prereleases(possible_versions)
        possible_versions = filter_ignored_versions(possible_versions)

        find_highest_compatible_version(possible_versions)
      end,
      T.nilable(T::Hash[Symbol, T.untyped])
    )
end

#lowest_security_fix_version_detailsObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 67

def lowest_security_fix_version_details
  @lowest_security_fix_version_details ||=
    T.let(
      begin
        possible_versions = versions
        possible_versions = filter_prereleases(possible_versions)
        possible_versions = Dependabot::UpdateCheckers::VersionFilters.filter_vulnerable_versions(
          possible_versions, security_advisories
        )
        possible_versions = filter_ignored_versions(possible_versions)
        possible_versions = filter_lower_versions(possible_versions)

        find_lowest_compatible_version(possible_versions)
      end,
      T.nilable(T::Hash[Symbol, T.untyped])
    )
end

#versionsObject



86
87
88
# File 'lib/dependabot/nuget/update_checker/version_finder.rb', line 86

def versions
  available_v3_versions + available_v2_versions
end