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/property_value_finder.rb
Defined Under Namespace
Classes: PropertyValueFinder, RepositoriesFinder
Constant Summary
collapse
- SUPPORTED_BUILD_FILE_NAMES =
%w(build.gradle build.gradle.kts settings.gradle settings.gradle.kts).freeze
- PROPERTY_REGEX =
/
(?:\$\{property\((?<property_name>[^:\s]*?)\)\})|
(?:\$\{(?<property_name>[^:\s]*?)\})|
(?:\$(?<property_name>[^:\s"']*))
/x
- PART =
%r{[^\s,@'":/\\]+}
- VSN_PART =
%r{[^\s,'":/\\]+}
- DEPENDENCY_DECLARATION_REGEX =
/(?:\(|\s)\s*['"](?<declaration>#{PART}:#{PART}:#{VSN_PART})['"]/
- DEPENDENCY_SET_DECLARATION_REGEX =
/(?:^|\s)dependencySet\((?<arguments>[^\)]+)\)\s*\{/
- DEPENDENCY_SET_ENTRY_REGEX =
/entry\s+['"](?<name>#{PART})['"]/
- PLUGIN_BLOCK_DECLARATION_REGEX =
/(?:^|\s)plugins\s*\{/
- PLUGIN_ID_REGEX =
/['"](?<id>#{PART})['"]/
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.find_include_names(buildfile) ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/dependabot/gradle/file_parser.rb', line 61
def self.find_include_names(buildfile)
return [] unless buildfile
buildfile.content
.scan(/apply(\(| )\s*from(\s+=|:)\s+['"]([^'"]+)['"]/)
.map { |match| match[2] }
end
|
.find_includes(buildfile, dependency_files) ⇒ Object
69
70
71
72
|
# File 'lib/dependabot/gradle/file_parser.rb', line 69
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
#parse ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/dependabot/gradle/file_parser.rb', line 45
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
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
|