Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #582 from sul-dlss/cleanup
Browse files Browse the repository at this point in the history
Cleanup the rubocop configuration
  • Loading branch information
justinlittman authored Apr 22, 2019
2 parents a623ca0 + 3cc2660 commit 0ed77e4
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 37 deletions.
16 changes: 1 addition & 15 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,10 @@ AllCops:
TargetRubyVersion: 2.3

Naming/FileName:
Enabled: true
Exclude:
- 'lib/dor/migrations/identifiable/assert_adminPolicy.rb'
- 'lib/dor-services.rb'
- 'spec/dor/releaseable_no_VCR_spec.rb'

# rspec expect{...} is conventional
Layout/SpaceBeforeBlockBraces:
Exclude:
- 'spec/**/*_spec.rb'

Layout/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true
Exclude:
- lib/dor/models/editable.rb
- lib/dor/models/governable.rb


# Offense count: 201
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Expand All @@ -42,5 +28,5 @@ Metrics/LineLength:

Style/SymbolProc:
Exclude:
# causes "Can't create Binding from C level Proc"
# causes "Can't create Binding from C level Proc" https://github.com/rubocop-hq/rubocop/issues/6540
- lib/dor/datastreams/events_ds.rb
2 changes: 1 addition & 1 deletion spec/datastreams/content_metadata_ds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

it 'raises error if same ID resource is added twice' do
@cm.add_resource(@files, 'resource', 1)
expect{ @cm.add_resource(@files, 'resource', 1) }.to raise_error StandardError
expect { @cm.add_resource(@files, 'resource', 1) }.to raise_error StandardError
end

it 'adds multiple resources' do
Expand Down
12 changes: 6 additions & 6 deletions spec/datastreams/identity_metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@
end

it 'raises ArgumentError on malformed sourceIDs' do
expect{ @dsdoc.sourceId = 'NotEnoughColons' }.to raise_exception(ArgumentError)
expect{ @dsdoc.sourceId = ':EmptyFirstPart' }.to raise_exception(ArgumentError)
expect{ @dsdoc.sourceId = 'WhitespaceSecondPart: ' }.to raise_exception(ArgumentError)
expect{ @dsdoc.sourceId = 'WhitespaceSecondPart: ' }.to raise_exception(ArgumentError)
expect { @dsdoc.sourceId = 'NotEnoughColons' }.to raise_exception(ArgumentError)
expect { @dsdoc.sourceId = ':EmptyFirstPart' }.to raise_exception(ArgumentError)
expect { @dsdoc.sourceId = 'WhitespaceSecondPart: ' }.to raise_exception(ArgumentError)
expect { @dsdoc.sourceId = 'WhitespaceSecondPart: ' }.to raise_exception(ArgumentError)
end

it 'does not raise error on a sourceId with multiple colons' do
expect{ @dsdoc.sourceId = 'Too:Many:Parts' }.not_to raise_exception
expect{ @dsdoc.sourceId = 'Too::ManyColons' }.not_to raise_exception
expect { @dsdoc.sourceId = 'Too:Many:Parts' }.not_to raise_exception
expect { @dsdoc.sourceId = 'Too::ManyColons' }.not_to raise_exception
end

it 'creates a simple default with #new' do
Expand Down
2 changes: 1 addition & 1 deletion spec/datastreams/version_metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
ds = described_class.from_xml(five_versions_xml)
allow(ds).to receive(:pid).and_return('druid:ab123cd4567')

expect{ ds.sync_then_increment_version(6) }.to raise_error(Dor::Exception, 'Cannot sync to a version greater than current: 5, requested 6')
expect { ds.sync_then_increment_version(6) }.to raise_error(Dor::Exception, 'Cannot sync to a version greater than current: 5, requested 6')
end
end
end
6 changes: 3 additions & 3 deletions spec/models/concerns/describable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SimpleItem < ActiveFedora::Base
it 'throws an exception if there is content in the descriptive metadata stream' do
# @obj.stub(:descMetadata).and_return(ActiveFedora::OmDatastream.new)
allow(@obj.descMetadata).to receive(:new?).and_return(false)
expect{ @obj.set_desc_metadata_using_label }.to raise_error(StandardError)
expect { @obj.set_desc_metadata_using_label }.to raise_error(StandardError)
end
it 'runs if there is content in the descriptive metadata stream and force is true' do
allow(@obj.descMetadata).to receive(:new?).and_return(false)
Expand All @@ -95,15 +95,15 @@ class SimpleItem < ActiveFedora::Base
it 'fetches Stanford::Mods object' do
expect(@obj.methods).to include(:stanford_mods)
sm = nil
expect{ sm = @obj.stanford_mods }.not_to raise_error
expect { sm = @obj.stanford_mods }.not_to raise_error
expect(sm).to be_kind_of(Stanford::Mods::Record)
expect(sm.format_main).to eq(['Book'])
expect(sm.pub_year_sort_str).to eq('1911')
end
it 'allows override argument(s)' do
sm = nil
nk = Nokogiri::XML('<mods><genre>ape</genre></mods>')
expect{ sm = @obj.stanford_mods(nk, false) }.not_to raise_error
expect { sm = @obj.stanford_mods(nk, false) }.not_to raise_error
expect(sm).to be_kind_of(Stanford::Mods::Record)
expect(sm.genre.text).to eq('ape')
expect(sm.pub_year_sort_str).to be_nil
Expand Down
4 changes: 2 additions & 2 deletions spec/models/concerns/embargoable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@
end
it "raises ArgumentError if the item isn't embargoed" do
embargo_item.release_embargo('application:embargo-release')
expect{ embargo_item.update_embargo(Time.now.utc + 1.month) }.to raise_error(ArgumentError)
expect { embargo_item.update_embargo(Time.now.utc + 1.month) }.to raise_error(ArgumentError)
end
it 'raises ArgumentError if the new date is in the past' do
expect{ embargo_item.update_embargo(1.month.ago) }.to raise_error(ArgumentError)
expect { embargo_item.update_embargo(1.month.ago) }.to raise_error(ArgumentError)
end
end
end
4 changes: 2 additions & 2 deletions spec/models/concerns/governable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

describe 'set_read_rights error handling' do
it 'raises an exception if the rights option doesnt match the accepted values' do
expect{ @item.set_read_rights('"druid:oo201oo0001"', 'Something') }.to raise_error(ArgumentError)
expect { @item.set_read_rights('"druid:oo201oo0001"', 'Something') }.to raise_error(ArgumentError)
end
it 'raises an exception if the rights option doesnt match the accepted values' do
expect{ @item.set_read_rights('mambo') }.to raise_error(ArgumentError)
expect { @item.set_read_rights('mambo') }.to raise_error(ArgumentError)
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/models/concerns/identifiable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class IdentifiableItem < ActiveFedora::Base

describe 'source_id= (AKA set_source_id)' do
it 'raises on unsalvageable values' do
expect{ item.source_id = 'NotEnoughColons' }.to raise_error ArgumentError
expect{ item.source_id = ':EmptyFirstPart' }.to raise_error ArgumentError
expect{ item.source_id = 'WhitespaceSecondPart: ' }.to raise_error ArgumentError
expect { item.source_id = 'NotEnoughColons' }.to raise_error ArgumentError
expect { item.source_id = ':EmptyFirstPart' }.to raise_error ArgumentError
expect { item.source_id = 'WhitespaceSecondPart: ' }.to raise_error ArgumentError
end
it 'sets the source_id' do
item.source_id = 'fake:sourceid'
Expand Down Expand Up @@ -73,7 +73,7 @@ class IdentifiableItem < ActiveFedora::Base
it 'raises an exception if a record of that type already exists' do
item.add_other_Id('mdtoolkit', 'someid123')
expect(item.identityMetadata.otherId('mdtoolkit').first).to eq('someid123')
expect{ item.add_other_Id('mdtoolkit', 'someid123') }.to raise_error(RuntimeError)
expect { item.add_other_Id('mdtoolkit', 'someid123') }.to raise_error(RuntimeError)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/services/suri_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
e = 'thrown exception'
ex = Exception.new(e)
expect(@my_client).to receive(:post).with('').and_raise(ex)
expect{ described_class.mint_id }.to raise_error(Exception, 'thrown exception')
expect { described_class.mint_id }.to raise_error(Exception, 'thrown exception')
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/utils/sdr_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
it 'has the wrong root element' do
stub_request(:get, described_class.client['objects/druid:ab123cd4567/current_version'].url)
.to_return(body: '<wrongRoot>2</wrongRoot>')
expect{ described_class.current_version('druid:ab123cd4567') }
expect { described_class.current_version('druid:ab123cd4567') }
.to raise_error(Exception, 'Unable to parse XML from SDR current_version API call: <wrongRoot>2</wrongRoot>')
end

it 'does not contain an Integer as its text' do
stub_request(:get, described_class.client['objects/druid:ab123cd4567/current_version'].url)
.to_return(body: '<currentVersion>two</currentVersion>')
expect{ described_class.current_version('druid:ab123cd4567') }
expect { described_class.current_version('druid:ab123cd4567') }
.to raise_error(Exception, 'Unable to parse XML from SDR current_version API call: <currentVersion>two</currentVersion>')
end
end
Expand Down

0 comments on commit 0ed77e4

Please sign in to comment.