Skip to content

Commit

Permalink
change empty version to nil
Browse files Browse the repository at this point in the history
  • Loading branch information
kbukum1 committed Dec 25, 2024
1 parent 38ecbbb commit c104809
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bundler/lib/dependabot/bundler/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def imported_ruby_files
def bundler_raw_version
return bundler_raw_version if defined?(@bundler_raw_version)

package_manager = PackageManager.new(bundler_version, "")
package_manager = PackageManager.new(bundler_version, nil)

# If the selected version is unsupported, an unsupported error will be raised,
# so there’s no need to attempt retrieving the raw version.
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/dependabot/bundler/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Language < Dependabot::Ecosystem::VersionManager
def initialize(raw_version, requirement = nil)
super(
LANGUAGE,
Version.new(""),
nil,
Version.new(raw_version),
[],
[],
Expand Down
2 changes: 1 addition & 1 deletion cargo/lib/dependabot/cargo/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Language < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
LANGUAGE,
Version.new(""),
nil,
Version.new(raw_version)
)
end
Expand Down
2 changes: 1 addition & 1 deletion cargo/lib/dependabot/cargo/package_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PackageManager < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
PACKAGE_MANAGER,
Version.new(""),
nil,
Version.new(raw_version),
DEPRECATED_CARGO_VERSIONS,
SUPPORTED_CARGO_VERSIONS
Expand Down
16 changes: 10 additions & 6 deletions common/lib/dependabot/ecosystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ class VersionManager
end
def initialize( # rubocop:disable Metrics/ParameterLists
name,
detected_version = Dependabot::Version.new(""),
version = Dependabot::Version.new(""),
detected_version = nil,
version = nil,
deprecated_versions = [],
supported_versions = [],
requirement = nil
)
@name = T.let(name, String)
@detected_version = T.let(T.must(detected_version), Dependabot::Version)
@version = T.let(T.must(version), Dependabot::Version)
@detected_version = T.let(detected_version, T.nilable(Dependabot::Version))
@version = T.let(version, T.nilable(Dependabot::Version))
@deprecated_versions = T.let(deprecated_versions, T::Array[Dependabot::Version])
@supported_versions = T.let(supported_versions, T::Array[Dependabot::Version])
@requirement = T.let(requirement, T.nilable(Dependabot::Requirement))
Expand All @@ -59,13 +59,13 @@ def initialize( # rubocop:disable Metrics/ParameterLists
# The current version of the package manager or language.
# @example
# version #=> Dependabot::Version.new("2")
sig { returns(Dependabot::Version) }
sig { returns(T.nilable(Dependabot::Version)) }
attr_reader :detected_version

# The current version of the package manager or language.
# @example
# version #=> Dependabot::Version.new("2.1.4")
sig { returns(Dependabot::Version) }
sig { returns(T.nilable(Dependabot::Version)) }
attr_reader :version

# Returns an array of deprecated versions of the package manager.
Expand All @@ -92,6 +92,8 @@ def initialize( # rubocop:disable Metrics/ParameterLists
# deprecated? #=> true
sig { returns(T::Boolean) }
def deprecated?
return false if detected_version

# If the version is unsupported, the unsupported error is getting raised separately.
return false if unsupported?

Expand All @@ -113,6 +115,8 @@ def unsupported?
# If the version is unsupported, it raises a ToolVersionNotSupported error.
sig { void }
def raise_if_unsupported!
return unless detected_version

return unless unsupported?

# Example: v2.*, v3.*
Expand Down
2 changes: 1 addition & 1 deletion composer/lib/dependabot/composer/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Language < Dependabot::Ecosystem::VersionManager
def initialize(raw_version, requirement: nil)
super(
NAME,
Version.new(""),
nil,
Version.new(raw_version),
[],
[],
Expand Down
2 changes: 1 addition & 1 deletion devcontainers/lib/dependabot/devcontainers/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Language < Dependabot::Ecosystem::VersionManager

sig { params(raw_version: String).void }
def initialize(raw_version)
super(LANGUAGE, Version.new(raw_version))
super(LANGUAGE, nil, Version.new(raw_version))
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PackageManager < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
PACKAGE_MANAGER,
Version.new(""),
nil,
Version.new(raw_version),
DEPRECATED_DEVCONTAINER_VERSIONS,
SUPPORTED_DEVCONTAINER_VERSIONS
Expand Down
2 changes: 1 addition & 1 deletion elm/lib/dependabot/elm/package_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PackageManager < Dependabot::Ecosystem::VersionManager
def initialize(raw_version, requirement = nil)
super(
PACKAGE_MANAGER,
Version.new("0"),
nil,
Version.new(raw_version),
DEPRECATED_ELM_VERSIONS,
SUPPORTED_ELM_VERSIONS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PackageManager < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
PACKAGE_MANAGER,
Version.new(""),
nil,
Version.new(raw_version),
DEPRECATED_GIT_VERSIONS,
SUPPORTED_GIT_VERSIONS
Expand Down
2 changes: 1 addition & 1 deletion go_modules/lib/dependabot/go_modules/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Language < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
LANGUAGE,
Version.new(""),
nil,
Version.new(raw_version)
)
end
Expand Down
2 changes: 1 addition & 1 deletion go_modules/lib/dependabot/go_modules/package_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PackageManager < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
PACKAGE_MANAGER,
Version.new(""),
nil,
Version.new(raw_version),
DEPRECATED_GO_VERSIONS,
SUPPORTED_GO_VERSIONS
Expand Down
2 changes: 1 addition & 1 deletion gradle/lib/dependabot/gradle/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Language < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
LANGUAGE,
Version.new(""),
nil,
Version.new(raw_version)
)
end
Expand Down
2 changes: 1 addition & 1 deletion gradle/lib/dependabot/gradle/package_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PackageManager < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
PACKAGE_MANAGER,
Version.new(""),
nil,
Version.new(raw_version),
DEPRECATED_GRADLE_VERSIONS,
SUPPORTED_GRADLE_VERSIONS
Expand Down
2 changes: 1 addition & 1 deletion hex/lib/dependabot/hex/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Language < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
LANGUAGE,
Version.new(""),
nil,
Version.new(raw_version)
)
end
Expand Down
2 changes: 1 addition & 1 deletion pub/lib/dependabot/pub/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Language < Dependabot::Ecosystem::VersionManager

sig { params(raw_version: String).void }
def initialize(raw_version)
super(LANGUAGE, Version.new(raw_version))
super(LANGUAGE, nil, Version.new(raw_version))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion pub/lib/dependabot/pub/package_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PubPackageManager < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
NAME,
Version.new(""),
nil,
Version.new(raw_version),
SUPPORTED_VERSIONS,
DEPRECATED_VERSIONS
Expand Down
1 change: 1 addition & 0 deletions swift/lib/dependabot/swift/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Language < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
LANGUAGE,
nil,
Version.new(raw_version)
)
end
Expand Down
2 changes: 1 addition & 1 deletion swift/lib/dependabot/swift/package_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PackageManager < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
PACKAGE_MANAGER,
Version.new(""),
nil,
Version.new(raw_version),
DEPRECATED_SWIFT_VERSIONS,
SUPPORTED_SWIFT_VERSIONS
Expand Down
2 changes: 1 addition & 1 deletion terraform/lib/dependabot/terraform/package_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PackageManager < Dependabot::Ecosystem::VersionManager
def initialize(raw_version)
super(
PACKAGE_MANAGER,
Version.new(""),
nil,
Version.new(raw_version),
DEPRECATED_TERRAFORM_VERSIONS,
SUPPORTED_TERRAFORM_VERSIONS
Expand Down

0 comments on commit c104809

Please sign in to comment.