Class: Dependabot::Gradle::FileParser
- Inherits:
-
FileParsers::Base
- Object
- FileParsers::Base
- Dependabot::Gradle::FileParser
show all
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/gradle/file_parser.rb,
lib/dependabot/gradle/file_parser/repositories_finder.rb,
lib/dependabot/gradle/file_parser/distributions_finder.rb,
lib/dependabot/gradle/file_parser/property_value_finder.rb
Overview
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Classes: DistributionsFinder, PropertyValueFinder, RepositoriesFinder
Constant Summary
collapse
- SUPPORTED_BUILD_FILE_NAMES =
T.let(
%w(build.gradle build.gradle.kts settings.gradle settings.gradle.kts).freeze,
T::Array[String]
)
- PROPERTY_REGEX =
T.let(
/
(?:\$\{property\((?<property_name>[^:\s]*?)\)\})|
(?:\$\{(?<property_name>[^:\s]*?)\})|
(?:\$(?<property_name>[^:\s"']*))
/x,
Regexp
)
- PART =
T.let(%r{[^\s,@'":/\\]+}, Regexp)
- VSN_PART =
T.let(%r{[^\s,'":/\\]+}, Regexp)
- DEPENDENCY_DECLARATION_REGEX =
T.let(/(?:\(|\s)\s*['"](?<declaration>#{PART}:#{PART}:#{VSN_PART})['"]/o, Regexp)
- DEPENDENCY_SET_DECLARATION_REGEX =
T.let(/(?:^|\s)dependencySet\((?<arguments>[^\)]+)\)\s*\{/, Regexp)
- DEPENDENCY_SET_ENTRY_REGEX =
T.let(/entry\s+['"](?<name>#{PART})['"]/o, Regexp)
- PLUGIN_BLOCK_DECLARATION_REGEX =
T.let(/(?:^|\s)plugins\s*\{/, Regexp)
- PLUGIN_ID_REGEX =
T.let(/['"](?<id>#{PART})['"]/o, Regexp)
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.find_include_names(buildfile) ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/dependabot/gradle/file_parser.rb', line 77
def self.find_include_names(buildfile)
return [] unless buildfile
T.must(buildfile.content)
.scan(/apply(\(| )\s*from(\s+=|:)\s+['"]([^'"]+)['"]/)
.map { |match| T.must(match[2]) }
end
|
.find_includes(buildfile, dependency_files) ⇒ Object
91
92
93
94
|
# File 'lib/dependabot/gradle/file_parser.rb', line 91
def self.find_includes(buildfile, dependency_files)
FileParser.find_include_names(buildfile)
.filter_map { |f| dependency_files.find { |bf| bf.name == f } }
end
|
Instance Method Details
#ecosystem ⇒ Object
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/dependabot/gradle/file_parser.rb', line 97
def ecosystem
@ecosystem ||= T.let(
Ecosystem.new(
name: ECOSYSTEM,
package_manager: package_manager,
language: language
),
T.nilable(Ecosystem)
)
end
|
#parse ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/dependabot/gradle/file_parser.rb', line 55
def parse
dependency_set = DependencySet.new
buildfiles.each do |buildfile|
dependency_set += buildfile_dependencies(buildfile)
end
script_plugin_files.each do |plugin_file|
dependency_set += buildfile_dependencies(plugin_file)
end
if Experiments.enabled?(:gradle_wrapper_updater)
wrapper_properties_file.each do |properties_file|
dependency_set += wrapper_properties_dependencies(properties_file)
end
end
version_catalog_file.each do |toml_file|
dependency_set += version_catalog_dependencies(toml_file)
end
dependency_set.dependencies.reject do |dependency|
dependency.version == "latest.integration" || dependency.version == "latest.release"
end
end
|