Class: Dependabot::Nuget::DependencyFileDiscovery
- Inherits:
-
Object
- Object
- Dependabot::Nuget::DependencyFileDiscovery
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/nuget/discovery/dependency_file_discovery.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#dependency_set ⇒ Object
rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity,Metrics/AbcSize.
-
#initialize(file_path:, dependencies:) ⇒ DependencyFileDiscovery
constructor
A new instance of DependencyFileDiscovery.
Constructor Details
#initialize(file_path:, dependencies:) ⇒ DependencyFileDiscovery
Returns a new instance of DependencyFileDiscovery.
29 30 31 32 |
# File 'lib/dependabot/nuget/discovery/dependency_file_discovery.rb', line 29 def initialize(file_path:, dependencies:) @file_path = file_path @dependencies = dependencies end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
38 39 40 |
# File 'lib/dependabot/nuget/discovery/dependency_file_discovery.rb', line 38 def dependencies @dependencies end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
35 36 37 |
# File 'lib/dependabot/nuget/discovery/dependency_file_discovery.rb', line 35 def file_path @file_path end |
Class Method Details
.from_json(json) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dependabot/nuget/discovery/dependency_file_discovery.rb', line 13 def self.from_json(json) return nil if json.nil? file_path = 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 DependencyFileDiscovery.new(file_path: file_path, dependencies: dependencies) end |
Instance Method Details
#dependency_set ⇒ Object
rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity,Metrics/AbcSize
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/dependabot/nuget/discovery/dependency_file_discovery.rb', line 41 def dependency_set # rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity,Metrics/AbcSize dependency_set = Dependabot::FileParsers::Base::DependencySet.new file_name = Pathname.new(file_path).cleanpath.to_path dependencies.each do |dependency| next if dependency.name.casecmp("Microsoft.NET.Sdk")&.zero? # If the version string was evaluated it must have been successfully resolved if dependency.evaluation && dependency.evaluation&.result_type != "Success" logger.warn "Dependency '#{dependency.name}' excluded due to unparsable version: #{dependency.version}" next end # Exclude any dependencies using version ranges or wildcards next if dependency.version&.include?(",") || dependency.version&.include?("*") # Exclude any dependencies specified using interpolation next if dependency.name.include?("%(") || dependency.version&.include?("%(") # 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) end dependency_set end |