Skip to content

Commit

Permalink
Merge pull request #11076 from dependabot/dev/brettfo/nuget-remove-ol…
Browse files Browse the repository at this point in the history
…d-update-checker

remove old update checker and stale code
  • Loading branch information
randhircs authored Dec 9, 2024
2 parents 7b68937 + 5edc7a1 commit fa9831f
Show file tree
Hide file tree
Showing 42 changed files with 469 additions and 4,068 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

require "dependabot/dependency"
require "dependabot/nuget/analysis/dependency_analysis"
require "dependabot/nuget/native_discovery/native_discovery_json_reader"
require "dependabot/nuget/discovery/discovery_json_reader"
require "json"
require "sorbet-runtime"

Expand Down
6 changes: 3 additions & 3 deletions nuget/lib/dependabot/nuget/analysis/dependency_analysis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.from_json(json)
T::Boolean)
updated_dependencies = T.let(json.fetch("UpdatedDependencies"),
T::Array[T::Hash[String, T.untyped]]).map do |dep|
NativeDependencyDetails.from_json(dep)
DependencyDetails.from_json(dep)
end

DependencyAnalysis.new(
Expand All @@ -35,7 +35,7 @@ def self.from_json(json)
params(updated_version: String,
can_update: T::Boolean,
version_comes_from_multi_dependency_property: T::Boolean,
updated_dependencies: T::Array[NativeDependencyDetails]).void
updated_dependencies: T::Array[DependencyDetails]).void
end
def initialize(updated_version:, can_update:, version_comes_from_multi_dependency_property:,
updated_dependencies:)
Expand All @@ -54,7 +54,7 @@ def initialize(updated_version:, can_update:, version_comes_from_multi_dependenc
sig { returns(T::Boolean) }
attr_reader :version_comes_from_multi_dependency_property

sig { returns(T::Array[NativeDependencyDetails]) }
sig { returns(T::Array[DependencyDetails]) }
attr_reader :updated_dependencies

sig { returns(Dependabot::Nuget::Version) }
Expand Down
13 changes: 10 additions & 3 deletions nuget/lib/dependabot/nuget/discovery/dependency_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def self.from_json(json)
is_transitive = T.let(json.fetch("IsTransitive"), T::Boolean)
is_override = T.let(json.fetch("IsOverride"), T::Boolean)
is_update = T.let(json.fetch("IsUpdate"), T::Boolean)
info_url = T.let(json.fetch("InfoUrl"), T.nilable(String))

DependencyDetails.new(name: name,
version: version,
Expand All @@ -32,7 +33,8 @@ def self.from_json(json)
is_direct: is_direct,
is_transitive: is_transitive,
is_override: is_override,
is_update: is_update)
is_update: is_update,
info_url: info_url)
end

sig do
Expand All @@ -45,10 +47,11 @@ def self.from_json(json)
is_direct: T::Boolean,
is_transitive: T::Boolean,
is_override: T::Boolean,
is_update: T::Boolean).void
is_update: T::Boolean,
info_url: T.nilable(String)).void
end
def initialize(name:, version:, type:, evaluation:, target_frameworks:, is_dev_dependency:, is_direct:,
is_transitive:, is_override:, is_update:)
is_transitive:, is_override:, is_update:, info_url:)
@name = name
@version = version
@type = type
Expand All @@ -59,6 +62,7 @@ def initialize(name:, version:, type:, evaluation:, target_frameworks:, is_dev_d
@is_transitive = is_transitive
@is_override = is_override
@is_update = is_update
@info_url = info_url
end

sig { returns(String) }
Expand Down Expand Up @@ -90,6 +94,9 @@ def initialize(name:, version:, type:, evaluation:, target_frameworks:, is_dev_d

sig { returns(T::Boolean) }
attr_reader :is_update

sig { returns(T.nilable(String)) }
attr_reader :info_url
end
end
end
20 changes: 8 additions & 12 deletions nuget/lib/dependabot/nuget/discovery/dependency_file_discovery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ module Nuget
class DependencyFileDiscovery
extend T::Sig

sig { params(json: T.nilable(T::Hash[String, T.untyped])).returns(T.nilable(DependencyFileDiscovery)) }
def self.from_json(json)
sig do
params(json: T.nilable(T::Hash[String, T.untyped]),
directory: String).returns(T.nilable(DependencyFileDiscovery))
end
def self.from_json(json, directory)
return nil if json.nil?

file_path = T.let(json.fetch("FilePath"), String)
file_path = File.join(directory, T.let(json.fetch("FilePath"), String))
dependencies = T.let(json.fetch("Dependencies"), T::Array[T::Hash[String, T.untyped]]).map do |dep|
DependencyDetails.from_json(dep)
end
Expand All @@ -38,7 +41,7 @@ def initialize(file_path:, dependencies:)
attr_reader :dependencies

sig { overridable.returns(Dependabot::FileParsers::Base::DependencySet) }
def dependency_set # rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity,Metrics/AbcSize
def dependency_set # rubocop:disable Metrics/PerceivedComplexity
dependency_set = Dependabot::FileParsers::Base::DependencySet.new

file_name = Pathname.new(file_path).cleanpath.to_path
Expand All @@ -62,14 +65,7 @@ def dependency_set # rubocop:disable Metrics/PerceivedComplexity,Metrics/Cycloma
# Exclude any dependencies which reference an item type
next if dependency.name.include?("@(")

dependency_file_name = file_name
if dependency.type == "PackagesConfig"
dir_name = File.dirname(file_name)
dependency_file_name = "packages.config"
dependency_file_name = File.join(dir_name, "packages.config") unless dir_name == "."
end

dependency_set << build_dependency(dependency_file_name, dependency)
dependency_set << build_dependency(file_name, dependency)
end

dependency_set
Expand Down

This file was deleted.

Loading

0 comments on commit fa9831f

Please sign in to comment.