Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions lib/rubygems/specification_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,30 +132,6 @@ def validate_dependencies # :nodoc:
warning_messages << "prerelease dependency on #{dep} is not recommended" if
prerelease_dep && !version.prerelease?

overly_strict = dep.requirement.requirements.length == 1 &&
dep.requirement.requirements.any? do |op, version|
op == '~>' and
not version.prerelease? and
version.segments.length > 2 and
version.segments.first != 0
end

if overly_strict then
_, dep_version = dep.requirement.requirements.first

base = dep_version.segments.first 2
upper_bound = dep_version.segments.first(dep_version.segments.length - 1)
upper_bound[-1] += 1

warning_messages << <<-WARNING
pessimistic dependency on #{dep} may be overly strict
if #{dep.name} is semantically versioned, use:
add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}', '>= #{dep_version}'
if #{dep.name} is not semantically versioned, you can bypass this warning with:
add_#{dep.type}_dependency '#{dep.name}', '>= #{dep_version}', '< #{upper_bound.join '.'}.a'
WARNING
end

open_ended = dep.requirement.requirements.all? do |op, version|
not version.prerelease? and (op == '>' or op == '>=')
end
Expand Down
15 changes: 0 additions & 15 deletions test/rubygems/test_gem_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2697,16 +2697,6 @@ def test_validate_dependencies
expected = <<-EXPECTED
#{w}: prerelease dependency on b (>= 1.0.rc1) is not recommended
#{w}: prerelease dependency on c (>= 2.0.rc2, development) is not recommended
#{w}: pessimistic dependency on d (~> 1.2.3) may be overly strict
if d is semantically versioned, use:
add_runtime_dependency 'd', '~> 1.2', '>= 1.2.3'
if d is not semantically versioned, you can bypass this warning with:
add_runtime_dependency 'd', '>= 1.2.3', '< 1.3.a'
#{w}: pessimistic dependency on e (~> 1.2.3.4) may be overly strict
if e is semantically versioned, use:
add_runtime_dependency 'e', '~> 1.2', '>= 1.2.3.4'
if e is not semantically versioned, you can bypass this warning with:
add_runtime_dependency 'e', '>= 1.2.3.4', '< 1.2.4.a'
#{w}: open-ended dependency on i (>= 1.2) is not recommended
if i is semantically versioned, use:
add_runtime_dependency 'i', '~> 1.2'
Expand All @@ -2719,11 +2709,6 @@ def test_validate_dependencies
#{w}: open-ended dependency on l (> 1.2.3) is not recommended
if l is semantically versioned, use:
add_runtime_dependency 'l', '~> 1.2', '> 1.2.3'
#{w}: pessimistic dependency on m (~> 2.1.0) may be overly strict
if m is semantically versioned, use:
add_runtime_dependency 'm', '~> 2.1', '>= 2.1.0'
if m is not semantically versioned, you can bypass this warning with:
add_runtime_dependency 'm', '>= 2.1.0', '< 2.2.a'
#{w}: See http://guides.rubygems.org/specification-reference/ for help
EXPECTED

Expand Down