Skip to content

Commit

Permalink
Merge pull request #820 from pivotal/merged_package_issue
Browse files Browse the repository at this point in the history
Set default value of version in package class to empty string
  • Loading branch information
ohlookadollar authored Apr 9, 2021
2 parents 79bdd72 + 5d933d4 commit 386d8c0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ BlockLength:
ClassLength:
Enabled: false
CyclomaticComplexity:
Max: 10
Max: 15
PerceivedComplexity:
Max: 10
Max: 15
LineLength:
Max: 200
MethodLength:
Expand Down
2 changes: 1 addition & 1 deletion lib/license_finder/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def initialize(name, version = nil, options = {})

## DESCRIPTION
@name = name
@version = version
@version = version || ''
@authors = options[:authors] || ''
@summary = options[:summary] || ''
@description = options[:description] || ''
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/license_finder/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module LicenseFinder
it 'has defaults' do
subject = described_class.new(nil, nil)
expect(subject.name).to be_nil
expect(subject.version).to be_nil
expect(subject.version).to eq ''
expect(subject.authors).to eq ''
expect(subject.summary).to eq ''
expect(subject.description).to eq ''
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/license_finder/reports/merged_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ module LicenseFinder
subject = described_class.new([dep], columns: %w[name licenses license_links])
expect(subject.to_s).to eq("gem_a,MIT,#{mit.url}\n")
end

it 'should not error if there are 2 packages with the same name and the version is nil' do
bar1 = Package.new('bar', nil, spec_licenses: ['MIT'])
bar2 = Package.new('bar', '2.0.0', spec_licenses: ['GPLv2'])

merged_bar1 = MergedPackage.new(bar1, ['path/to/bar1'])
merged_bar2 = MergedPackage.new(bar2, ['path/to/bar2'])

report = MergedReport.new([merged_bar1, merged_bar2])
expect { report.to_s }.not_to raise_error
end
end

context 'when no groups are specified' do
Expand Down

0 comments on commit 386d8c0

Please sign in to comment.