Skip to content

Commit

Permalink
Merge pull request #9643 from dependabot/dependabot-core-issue-npe-co…
Browse files Browse the repository at this point in the history
…mposer-fileparser

Dependabot core issue npe composer fileparser
  • Loading branch information
GarryHurleyJr authored May 3, 2024
2 parents 4bcb262 + d322cd2 commit d38e419
Show file tree
Hide file tree
Showing 4 changed files with 301 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer/lib/dependabot/composer/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def git_dependency_details(package_details, requirement)

def lockfile_details(name:, type:)
key = lockfile_key(type)
parsed_lockfile.fetch(key, []).find { |d| d["name"] == name }
parsed_lockfile.fetch(key, [])&.find { |d| d["name"] == name }
end

def lockfile_key(type)
Expand Down
10 changes: 10 additions & 0 deletions composer/spec/dependabot/composer/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
end
end

context "null dependencies with lockfile" do
let(:project_name) { "null_dependencies_with_lockfile" }
let(:name) { "phpunit/phpunit" }
let(:type) { "development" }
describe "no dependencies" do
subject { dependencies }
its(:length) { is_expected.to be >= 0 }
end
end

context "with a version specified (composer v1)" do
let(:project_name) { "v1/minor_version" }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "joshuaestes/server-tools",
"description": "Collection of command line tools to help with server management and maintenance",
"keywords": [],
"homepage": "https://github.com/JoshuaEstes/ServerTools",
"license": "MIT",
"authors": [
{
"name": "Joshua Estes",
"homepage": "http://joshuaestes.me"
},
{
"name": "Contributors",
"homepage": "https://github.com/JoshuaEstes/ServerTools/graphs/contributors"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.2",
"symfony/console": ">=2.1,<=2.3@dev",
"symfony/process": ">=2.1,<=2.3@dev",
"symfony/yaml": ">=2.1,<=2.3@dev",
"symfony/finder": ">=2.1,<=2.3@dev",
"symfony/filesystem": ">=2.1,<=2.3@dev"
},
"replace": {
"JoshuaEstes/ServerTools": "self.version"
},
"require-dev": {
"phpunit/phpunit": "*",
"mikey179/vfsStream": "*"
},
"autoload": {
"psr-0": { "": "src/" }
},
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d38e419

Please sign in to comment.