Skip to content

Commit

Permalink
Merge pull request #4554 from sul-dlss/rubocop-updates
Browse files Browse the repository at this point in the history
Rubocop updates
  • Loading branch information
justinlittman authored Aug 15, 2023
2 parents c93c2c4 + c6e5d32 commit df97aa4
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 29 deletions.
56 changes: 53 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ AllCops:
- 'results/**/*'
- 'tmp/**/*'
- 'vendor/**/*'
SuggestExtensions: false

Rails:
Enabled: true
Expand Down Expand Up @@ -456,7 +457,7 @@ Style/MapToHash: # new in 1.24
Enabled: true
Performance/StringIdentifierArgument: # new in 1.13
Enabled: true
RSpec/FactoryBot/SyntaxMethods: # new in 2.7
FactoryBot/SyntaxMethods: # new in 2.7
Enabled: true
Rails/CompactBlank: # new in 2.13
Enabled: true
Expand Down Expand Up @@ -572,7 +573,7 @@ Capybara/NegationMatcher: # new in 2.14
Enabled: true
Capybara/SpecificActions: # new in 2.14
Enabled: true
RSpec/FactoryBot/ConsistentParenthesesStyle: # new in 2.14
FactoryBot/ConsistentParenthesesStyle: # new in 2.14
Enabled: true
RSpec/Rails/InferredSpecType: # new in 2.14
Enabled: true
Expand Down Expand Up @@ -609,7 +610,7 @@ RSpec/DuplicatedMetadata: # new in 2.16
Enabled: true
RSpec/PendingWithoutReason: # new in 2.16
Enabled: true
RSpec/FactoryBot/FactoryNameStyle: # new in 2.16
FactoryBot/FactoryNameStyle: # new in 2.16
Enabled: true
RSpec/Rails/MinitestAssertions: # new in 2.17
Enabled: true
Expand All @@ -630,3 +631,52 @@ RSpec/Rails/TravelAround: # new in 2.19
Enabled: true
Rails/ResponseParsedBody: # new in 2.18
Enabled: true

Lint/DuplicateMatchPattern: # new in 1.50
Enabled: true
Lint/MixedCaseRange: # new in 1.53
Enabled: true
Lint/RedundantRegexpQuantifiers: # new in 1.53
Enabled: true
Style/DataInheritance: # new in 1.49
Enabled: true
Style/ExactRegexpMatch: # new in 1.51
Enabled: true
Style/RedundantArrayConstructor: # new in 1.52
Enabled: true
Style/RedundantCurrentDirectoryInPath: # new in 1.53
Enabled: true
Style/RedundantFilterChain: # new in 1.52
Enabled: true
Style/RedundantLineContinuation: # new in 1.49
Enabled: true
Style/RedundantRegexpArgument: # new in 1.53
Enabled: true
Style/RedundantRegexpConstructor: # new in 1.52
Enabled: true
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
Enabled: true
Style/YAMLFileRead: # new in 1.53
Enabled: true
Performance/MapMethodChain: # new in 1.19
Enabled: true
FactoryBot/AssociationStyle: # new in 2.23
Enabled: true
FactoryBot/FactoryAssociationWithStrategy: # new in 2.23
Enabled: true
FactoryBot/RedundantFactoryOption: # new in 2.23
Enabled: true
RSpec/BeEmpty: # new in 2.20
Enabled: true
RSpec/ContainExactly: # new in 2.19
Enabled: true
RSpec/IndexedLet: # new in 2.20
Enabled: false
RSpec/MatchArray: # new in 2.19
Enabled: true
RSpec/ReceiveMessages: # new in 2.23
Enabled: true
RSpec/Rails/NegationBeValid: # new in 2.23
Enabled: true
Rails/ThreeStateBooleanColumn: # new in 2.19
Enabled: true
4 changes: 2 additions & 2 deletions app/services/create_object_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def cocina_from_request(cocina_request_object, druid, assign_doi)
# This is specifically for H2, but could be utilized by any client that provides preferred citation.
doi = assign_doi ? "https://doi.org/#{Doi.for(druid:)}." : ''
Array(props[:description][:note]).each do |note|
note[:value] = note[:value].gsub(/:link:/, purl) if note[:type] == 'preferred citation' && note[:value]
note[:value] = note[:value].gsub(/:doi:/, doi) if note[:type] == 'preferred citation' && note[:value]
note[:value] = note[:value].gsub(':link:', purl) if note[:type] == 'preferred citation' && note[:value]
note[:value] = note[:value].gsub(':doi:', doi) if note[:type] == 'preferred citation' && note[:value]
end
end

Expand Down
11 changes: 3 additions & 8 deletions spec/requests/start_accession_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@

context 'when newly registered object that has not been accessioned yet' do
before do
allow(VersionService).to receive(:in_accessioning?).and_return(false)
allow(VersionService).to receive(:can_open?).and_return(false)
allow(VersionService).to receive(:open?).and_return(false)
allow(VersionService).to receive_messages(in_accessioning?: false, can_open?: false, open?: false)
end

it 'does not open or close a version and starts default workflow' do
Expand Down Expand Up @@ -69,8 +67,7 @@

context 'when existing accessioned object that is not currently open' do
before do
allow(VersionService).to receive(:in_accessioning?).and_return(false)
allow(VersionService).to receive(:can_open?).and_return(true)
allow(VersionService).to receive_messages(in_accessioning?: false, can_open?: true)
end

it 'opens and closes a version and starts default workflow' do
Expand All @@ -94,9 +91,7 @@

context 'when existing accessioned object that is currently open' do
before do
allow(VersionService).to receive(:in_accessioning?).and_return(false)
allow(VersionService).to receive(:can_open?).and_return(false)
allow(VersionService).to receive(:open?).and_return(true)
allow(VersionService).to receive_messages(in_accessioning?: false, can_open?: false, open?: true)
end

it 'closes a version and starts default workflow' do
Expand Down
3 changes: 1 addition & 2 deletions spec/requests/update_metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@

before do
allow(AdministrativeTags).to receive(:create)
allow(AdministrativeTags).to receive(:project).and_return(['Google Books'])
allow(AdministrativeTags).to receive(:for).and_return([])
allow(AdministrativeTags).to receive_messages(project: ['Google Books'], for: [])
allow(Cocina::ObjectValidator).to receive(:validate)

allow(EventFactory).to receive(:create)
Expand Down
6 changes: 2 additions & 4 deletions spec/services/constituent_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
let(:virtual_object_druid) { 'druid:bc123df4567' }

before do
allow(ItemQueryService).to receive(:find_combinable_item).and_return(virtual_object)
allow(ItemQueryService).to receive(:validate_combinable_items).and_return(item_errors)
allow(VersionService).to receive(:open?).and_return(open_for_versioning)
allow(VersionService).to receive(:open).and_return(virtual_object)
allow(ItemQueryService).to receive_messages(find_combinable_item: virtual_object, validate_combinable_items: item_errors)
allow(VersionService).to receive_messages(open?: open_for_versioning, open: virtual_object)
allow(VersionService).to receive(:close)
allow(ResetContentMetadataService).to receive(:reset).and_return(virtual_object)
allow(UpdateObjectService).to receive(:update)
Expand Down
3 changes: 1 addition & 2 deletions spec/services/embargo_release_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

before do
allow(CocinaObjectStore).to receive(:find).and_return(cocina_object)
allow(VersionService).to receive(:can_open?).and_return(can_open?)
allow(VersionService).to receive(:open).and_return(open_cocina_object)
allow(VersionService).to receive_messages(can_open?: can_open?, open: open_cocina_object)
allow(VersionService).to receive(:close)
allow(WorkflowClientFactory).to receive(:build).and_return(workflow_client)
allow(service).to receive(:release_cocina_object).and_return(released_cocina_object)
Expand Down
5 changes: 1 addition & 4 deletions spec/services/goobi_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,8 @@
subject(:xml_request) { goobi.send(:xml_request) }

before do
allow(goobi).to receive(:goobi_workflow_name).and_return('goobi_workflow')
allow(goobi).to receive_messages(goobi_workflow_name: 'goobi_workflow', collection_id: 'druid:oo000oo0001', collection_name: 'collection name', project_name: 'Project Name')
allow(AdministrativeTags).to receive(:for).and_return(tags)
allow(goobi).to receive(:collection_id).and_return('druid:oo000oo0001')
allow(goobi).to receive(:collection_name).and_return('collection name')
allow(goobi).to receive(:project_name).and_return('Project Name')
end

context 'without ocr tag present' do
Expand Down
3 changes: 1 addition & 2 deletions spec/services/publish/metadata_transfer_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@
let(:workspace_root) { Dir.mktmpdir }

before do
allow(Settings.stacks).to receive(:local_document_cache_root).and_return(purl_root)
allow(Settings.stacks).to receive(:local_workspace_root).and_return(workspace_root)
allow(Settings.stacks).to receive_messages(local_document_cache_root: purl_root, local_workspace_root: workspace_root)
allow(ThumbnailService).to receive(:new).and_return(thumbnail_service)
end

Expand Down
3 changes: 1 addition & 2 deletions spec/services/shelving_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
allow(WorkflowClientFactory).to receive(:build).and_return(workflow_client)
allow(Settings.stacks).to receive_messages(local_stacks_root: stacks_root, local_workspace_root: workspace_root)
allow(Cocina::ToXml::ContentMetadataGenerator).to receive(:generate).and_return(content_metadata)
allow(Preservation::Client.objects).to receive(:shelve_content_diff).and_return(mock_shelve_diff)
allow(Preservation::Client.objects).to receive(:content_inventory_diff).and_return(content_inventory_diff)
allow(Preservation::Client.objects).to receive_messages(shelve_content_diff: mock_shelve_diff, content_inventory_diff:)
allow(ShelvableFilesStager).to receive(:stage)
allow(DigitalStacksService).to receive(:remove_from_stacks)
allow(DigitalStacksService).to receive(:rename_in_stacks)
Expand Down

0 comments on commit df97aa4

Please sign in to comment.