Class: Dependabot::Gradle::UpdateChecker::VersionFinder

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

Constant Summary collapse

KOTLIN_PLUGIN_REPO_PREFIX =
"org.jetbrains.kotlin"
TYPE_SUFFICES =
%w(jre android java native_mt agp).freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of VersionFinder.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/dependabot/gradle/update_checker/version_finder.rb', line 36

def initialize(
  dependency:,
  dependency_files:,
  credentials:,
  ignored_versions:,
  security_advisories:,
  raise_on_ignored: false,
  cooldown_options: nil
)
  @security_advisories = security_advisories
  @dependency          = dependency
  @dependency_files    = dependency_files
  @credentials         = credentials
  @raise_on_ignored    = raise_on_ignored
  @forbidden_urls      = T.let([], T::Array[T.untyped])
  @ignored_versions    = ignored_versions

  super(
    dependency: dependency,
    dependency_files: dependency_files,
    credentials: credentials,
    ignored_versions: ignored_versions,
    security_advisories: security_advisories,
    cooldown_options: cooldown_options,
    raise_on_ignored: raise_on_ignored,
    options: {}
  )
end

Instance Method Details

#cooldown_enabled?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/dependabot/gradle/update_checker/version_finder.rb', line 89

def cooldown_enabled?
  true
end

#latest_version_detailsObject



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

def latest_version_details
  possible_versions = package_release(versions)

  possible_versions = filter_prerelease_versions(possible_versions)
  possible_versions = filter_date_based_versions(possible_versions)
  possible_versions = filter_version_types(possible_versions)
  possible_versions = filter_ignored_versions(possible_versions)

  possible_versions = filter_cooldown_versions(possible_versions)

  return unless possible_versions.any?

  version_max = possible_versions.max_by(&:version)&.version

  url = possible_versions.select do |v| # rubocop:disable Performance/Detect
    v.version.to_s == version_max.to_s
  end.last&.url

  { version: version_max,
    source_url: url }
end

#lowest_security_fix_version_detailsObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/dependabot/gradle/update_checker/version_finder.rb', line 94

def lowest_security_fix_version_details
  possible_versions = package_release(versions)

  possible_versions = filter_prerelease_versions(possible_versions)
  possible_versions = filter_date_based_versions(possible_versions)
  possible_versions = filter_version_types(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)

  return unless possible_versions.any?

  version_min = possible_versions.min_by(&:version)&.version

  url = possible_versions.select do |v| # rubocop:disable Performance/Detect
    v.version.to_s == version_min.to_s
  end.last&.url

  { version: version_min,
    source_url: url }
end

#versionsObject



120
121
122
123
124
125
126
127
# File 'lib/dependabot/gradle/update_checker/version_finder.rb', line 120

def versions
  Package::PackageDetailsFetcher.new(
    dependency: dependency,
    dependency_files: dependency_files,
    credentials: credentials,
    forbidden_urls: forbidden_urls
  ).fetch_available_versions
end