diff --git a/.rubocop.yml b/.rubocop.yml index e8fd53eab6..f6bbb5bd5c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,5 @@ -inherit_from: .rubocop_todo.yml +require: rubocop-rspec +inherit_from: .rubocop_fixme.yml AllCops: TargetRubyVersion: 2.1 @@ -16,6 +17,9 @@ AllCops: Bundler/DuplicatedGem: # This doesn't work with engine_cart Enabled: false +Layout/IndentationConsistency: + EnforcedStyle: rails + Lint/ImplicitStringConcatenation: Exclude: - 'lib/generators/hyrax/**/*' @@ -48,9 +52,6 @@ Metrics/MethodLength: Style/AsciiComments: Enabled: false -Style/IndentationConsistency: - EnforcedStyle: rails - Style/CollectionMethods: PreferredMethods: collect: 'map' @@ -99,25 +100,32 @@ Style/ZeroLengthPredicate: Rails: Enabled: true +Rails/ApplicationJob: + Enabled: false + +Rails/ApplicationRecord: + Enabled: false + +Rails/DynamicFindBy: + Enabled: false + +Rails/FilePath: + Exclude: + - 'spec/abilities/**/*' + Rails/OutputSafety: Exclude: - - 'spec/views/hyrax/my/works/_list_works.html.erb_spec.rb' - - 'app/helpers/hyrax/hyrax_helper_behavior.rb' - - 'app/helpers/hyrax/collections_helper.rb' - - 'app/helpers/hyrax/content_block_helper_behavior.rb' - 'app/builders/hyrax/form_builder.rb' - 'app/helpers/hyrax/citations_behaviors/formatters/apa_formatter.rb' - 'app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb' - 'app/helpers/hyrax/citations_behaviors/formatters/mla_formatter.rb' + - 'app/helpers/hyrax/collections_helper.rb' + - 'app/helpers/hyrax/content_block_helper_behavior.rb' + - 'app/helpers/hyrax/hyrax_helper_behavior.rb' + - 'app/presenters/hyrax/fixity_status_presenter.rb' - 'app/presenters/hyrax/presents_attributes.rb' - 'app/renderers/hyrax/renderers/attribute_renderer.rb' - -Rails/DynamicFindBy: - Enabled: false - -Rails/FilePath: - Exclude: - - 'spec/abilities/**/*' + - 'spec/views/hyrax/my/works/_list_works.html.erb_spec.rb' RSpec/DescribeClass: Exclude: diff --git a/.rubocop_todo.yml b/.rubocop_fixme.yml old mode 100755 new mode 100644 similarity index 97% rename from .rubocop_todo.yml rename to .rubocop_fixme.yml index bb66c5023f..808d377aff --- a/.rubocop_todo.yml +++ b/.rubocop_fixme.yml @@ -37,8 +37,8 @@ Metrics/MethodLength: Exclude: - 'app/controllers/concerns/hyrax/api.rb' - 'app/controllers/concerns/hyrax/controller.rb' - - 'app/controllers/hyrax/my_controller.rb' - 'app/controllers/concerns/hyrax/works_controller_behavior.rb' + - 'app/controllers/hyrax/my_controller.rb' - 'app/indexers/hyrax/file_set_indexer.rb' - 'app/inputs/multi_value_select_input.rb' - 'app/models/concerns/hyrax/solr_document/export.rb' @@ -47,6 +47,11 @@ Metrics/MethodLength: - 'lib/hyrax/rails/routes.rb' - 'spec/support/**/*' +# TODO: remove when https://github.com/bbatsov/rubocop/issues/4539 is fixed +Style/FormatStringToken: + Exclude: + - 'config/routes.rb' + Style/LineEndConcatenation: Exclude: - 'spec/test_app_templates/lib/generators/**/*' @@ -143,10 +148,10 @@ RSpec/AnyInstance: - 'spec/jobs/content_new_version_event_job_spec.rb' - 'spec/jobs/content_depositor_change_event_job_spec.rb' - 'spec/jobs/content_deposit_event_job_spec.rb' - - 'spec/lib/hyrax/arkivo/create_subscription_job_spec.rb' - 'spec/lib/hyrax/arkivo/actor_spec.rb' - - 'spec/presenters/hyrax/work_usage_spec.rb' + - 'spec/lib/hyrax/arkivo/create_subscription_job_spec.rb' - 'spec/presenters/hyrax/file_usage_spec.rb' + - 'spec/presenters/hyrax/work_usage_spec.rb' - 'spec/services/hyrax/repository_fixity_check_service_spec.rb' - 'spec/services/hyrax/workflow/permission_generator_spec.rb' - 'spec/services/hyrax/workflow/sipity_actions_generator_spec.rb' diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 diff --git a/hyrax.gemspec b/hyrax.gemspec index 690f622829..e30196be8b 100644 --- a/hyrax.gemspec +++ b/hyrax.gemspec @@ -86,7 +86,7 @@ EOF spec.add_development_dependency "factory_girl_rails", '~> 4.4' spec.add_development_dependency "equivalent-xml", '~> 0.5' spec.add_development_dependency "jasmine", '~> 2.3' - spec.add_development_dependency 'rubocop', '~> 0.48.1' + spec.add_development_dependency 'rubocop', '~> 0.49.1' spec.add_development_dependency 'rubocop-rspec', '~> 1.10.0' spec.add_development_dependency 'shoulda-matchers', '~> 3.1' spec.add_development_dependency 'rails-controller-testing', '~> 0' diff --git a/spec/controllers/hyrax/homepage_controller_spec.rb b/spec/controllers/hyrax/homepage_controller_spec.rb index c208396480..4a7fa21c45 100644 --- a/spec/controllers/hyrax/homepage_controller_spec.rb +++ b/spec/controllers/hyrax/homepage_controller_spec.rb @@ -84,13 +84,13 @@ allow(controller).to receive(:repository).and_return(repository) allow(controller).to receive(:search_results).and_return([nil, ['recent document']]) allow(controller.repository).to receive(:search).with(an_instance_of(Hyrax::CollectionSearchBuilder)) - .and_return(collection_results) + .and_return(collection_results) end it "initializes the presenter with ability and a list of collections" do expect(Hyrax::HomepagePresenter).to receive(:new).with(Ability, ["collection results"]) - .and_return(presenter) + .and_return(presenter) get :index expect(response).to be_success expect(assigns(:presenter)).to eq presenter diff --git a/spec/forms/hyrax/forms/permission_template_form_spec.rb b/spec/forms/hyrax/forms/permission_template_form_spec.rb index eb71b5f5c7..adec9357f2 100644 --- a/spec/forms/hyrax/forms/permission_template_form_spec.rb +++ b/spec/forms/hyrax/forms/permission_template_form_spec.rb @@ -111,7 +111,7 @@ def count_workflow_roles_for(user) it "updates the visibility, release_period=now, release_date=today" do expect { subject } .to change { permission_template.reload.visibility }.from(nil).to('open') - .and change { permission_template.reload.release_period }.from(nil).to(Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_NO_DELAY) + .and change { permission_template.reload.release_period }.from(nil).to(Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_NO_DELAY) expect(permission_template.release_date).to eq(today) end end diff --git a/spec/helpers/hyrax/file_set_helper_spec.rb b/spec/helpers/hyrax/file_set_helper_spec.rb index 28d1af9ad2..0d85984f82 100644 --- a/spec/helpers/hyrax/file_set_helper_spec.rb +++ b/spec/helpers/hyrax/file_set_helper_spec.rb @@ -5,7 +5,7 @@ before do allow(helper).to receive(:media_display_partial).with(file_set) - .and_return('hyrax/file_sets/media_display/image') + .and_return('hyrax/file_sets/media_display/image') end it "renders a partial" do diff --git a/spec/jobs/content_deposit_event_job_spec.rb b/spec/jobs/content_deposit_event_job_spec.rb index f6b5d38cea..bf5eef0ab6 100644 --- a/spec/jobs/content_deposit_event_job_spec.rb +++ b/spec/jobs/content_deposit_event_job_spec.rb @@ -18,7 +18,7 @@ expect do described_class.perform_now(curation_concern, user) end.to change { user.profile_events.length }.by(1) - .and change { curation_concern.events.length }.by(1) + .and change { curation_concern.events.length }.by(1) expect(user.profile_events.first).to eq(event) expect(curation_concern.events.first).to eq(event) diff --git a/spec/jobs/content_depositor_change_event_job_spec.rb b/spec/jobs/content_depositor_change_event_job_spec.rb index 3b71c579ae..1b2e94198b 100644 --- a/spec/jobs/content_depositor_change_event_job_spec.rb +++ b/spec/jobs/content_depositor_change_event_job_spec.rb @@ -17,8 +17,8 @@ expect do described_class.perform_now(generic_work, another_user) end.to change { user.profile_events.length }.by(1) - .and change { another_user.events.length }.by(1) - .and change { generic_work.events.length }.by(1) + .and change { another_user.events.length }.by(1) + .and change { generic_work.events.length }.by(1) expect(user.profile_events.first).to eq(event) expect(another_user.events.first).to eq(event) diff --git a/spec/jobs/content_new_version_event_job_spec.rb b/spec/jobs/content_new_version_event_job_spec.rb index 18178cd474..4fdeb0679a 100644 --- a/spec/jobs/content_new_version_event_job_spec.rb +++ b/spec/jobs/content_new_version_event_job_spec.rb @@ -13,7 +13,7 @@ expect do described_class.perform_now(file_set, user) end.to change { user.profile_events.length }.by(1) - .and change { file_set.events.length }.by(1) + .and change { file_set.events.length }.by(1) expect(user.profile_events.first).to eq(event) expect(file_set.events.first).to eq(event) diff --git a/spec/jobs/content_restored_version_event_job_spec.rb b/spec/jobs/content_restored_version_event_job_spec.rb index d3369b2181..57e760522f 100644 --- a/spec/jobs/content_restored_version_event_job_spec.rb +++ b/spec/jobs/content_restored_version_event_job_spec.rb @@ -19,7 +19,7 @@ expect do described_class.perform_now(file_set, user, 'content.0') end.to change { user.profile_events.length }.by(1) - .and change { file_set.events.length }.by(1) + .and change { file_set.events.length }.by(1) expect(user.profile_events.first).to eq(event) expect(file_set.events.first).to eq(event) diff --git a/spec/jobs/content_update_event_job_spec.rb b/spec/jobs/content_update_event_job_spec.rb index 77596836ef..12b7a6f885 100644 --- a/spec/jobs/content_update_event_job_spec.rb +++ b/spec/jobs/content_update_event_job_spec.rb @@ -18,7 +18,7 @@ expect do described_class.perform_now(curation_concern, user) end.to change { user.profile_events.length }.by(1) - .and change { curation_concern.events.length }.by(1) + .and change { curation_concern.events.length }.by(1) expect(user.profile_events.first).to eq(event) expect(curation_concern.events.first).to eq(event) diff --git a/spec/jobs/file_set_attached_event_job_spec.rb b/spec/jobs/file_set_attached_event_job_spec.rb index 40deb6daeb..f96dde2199 100644 --- a/spec/jobs/file_set_attached_event_job_spec.rb +++ b/spec/jobs/file_set_attached_event_job_spec.rb @@ -23,8 +23,8 @@ expect do described_class.perform_now(file_set, user) end.to change { user.profile_events.length }.by(1) - .and change { file_set.events.length }.by(1) - .and change { curation_concern.events.length }.by(1) + .and change { file_set.events.length }.by(1) + .and change { curation_concern.events.length }.by(1) expect(user.profile_events.first).to eq(event) expect(curation_concern.events.first).to eq(event) diff --git a/spec/services/hyrax/admin_set_create_service_spec.rb b/spec/services/hyrax/admin_set_create_service_spec.rb index c3fa7006c0..4323c377ae 100644 --- a/spec/services/hyrax/admin_set_create_service_spec.rb +++ b/spec/services/hyrax/admin_set_create_service_spec.rb @@ -68,7 +68,7 @@ expect do expect(subject).to be true end.to change { admin_set.persisted? }.from(false).to(true) - .and change { Sipity::WorkflowResponsibility.count }.by(12) + .and change { Sipity::WorkflowResponsibility.count }.by(12) # 12 responsibilities because: # * 2 agents (user + admin group), multiplied by # * 2 available workflows, multiplied by diff --git a/spec/services/hyrax/workflow/changes_required_notification_spec.rb b/spec/services/hyrax/workflow/changes_required_notification_spec.rb index 9d92f301c5..9e5f183d52 100644 --- a/spec/services/hyrax/workflow/changes_required_notification_spec.rb +++ b/spec/services/hyrax/workflow/changes_required_notification_spec.rb @@ -18,8 +18,8 @@ expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) } .to change { depositor.mailbox.inbox.count }.by(1) - .and change { to_user.mailbox.inbox.count }.by(1) - .and change { cc_user.mailbox.inbox.count }.by(1) + .and change { to_user.mailbox.inbox.count }.by(1) + .and change { cc_user.mailbox.inbox.count }.by(1) end context 'without carbon-copied users' do let(:recipients) { { 'to' => [to_user] } } @@ -27,7 +27,7 @@ expect(approver).to receive(:send_message).exactly(2).times.and_call_original expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) } .to change { depositor.mailbox.inbox.count }.by(1) - .and change { to_user.mailbox.inbox.count }.by(1) + .and change { to_user.mailbox.inbox.count }.by(1) end end end diff --git a/spec/services/hyrax/workflow/deposited_notification_spec.rb b/spec/services/hyrax/workflow/deposited_notification_spec.rb index 31e4f0593b..6e12e67d30 100644 --- a/spec/services/hyrax/workflow/deposited_notification_spec.rb +++ b/spec/services/hyrax/workflow/deposited_notification_spec.rb @@ -18,8 +18,8 @@ expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) } .to change { depositor.mailbox.inbox.count }.by(1) - .and change { to_user.mailbox.inbox.count }.by(1) - .and change { cc_user.mailbox.inbox.count }.by(1) + .and change { to_user.mailbox.inbox.count }.by(1) + .and change { cc_user.mailbox.inbox.count }.by(1) end context 'without carbon-copied users' do let(:recipients) { { 'to' => [to_user] } } @@ -27,7 +27,7 @@ expect(approver).to receive(:send_message).exactly(2).times.and_call_original expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) } .to change { depositor.mailbox.inbox.count }.by(1) - .and change { to_user.mailbox.inbox.count }.by(1) + .and change { to_user.mailbox.inbox.count }.by(1) end end end diff --git a/spec/services/hyrax/workflow/notification_generator_spec.rb b/spec/services/hyrax/workflow/notification_generator_spec.rb index 3d0677ae67..de0632c182 100644 --- a/spec/services/hyrax/workflow/notification_generator_spec.rb +++ b/spec/services/hyrax/workflow/notification_generator_spec.rb @@ -16,8 +16,8 @@ module Workflow expect do described_class.call(workflow: workflow, notification_configuration: notification_configuration) end.to change { Sipity::Notification.count }.by(1) - .and change { Sipity::NotificationRecipient.count }.by(3) - .and change { workflow_action.notifiable_contexts.count }.by(1) + .and change { Sipity::NotificationRecipient.count }.by(3) + .and change { workflow_action.notifiable_contexts.count }.by(1) end end end diff --git a/spec/services/hyrax/workflow/pending_review_notification_spec.rb b/spec/services/hyrax/workflow/pending_review_notification_spec.rb index 21ede00e8f..3b3c958023 100644 --- a/spec/services/hyrax/workflow/pending_review_notification_spec.rb +++ b/spec/services/hyrax/workflow/pending_review_notification_spec.rb @@ -17,8 +17,8 @@ expect { described_class.send_notification(entity: entity, user: depositor, comment: comment, recipients: recipients) } .to change { depositor.mailbox.inbox.count }.by(1) - .and change { to_user.mailbox.inbox.count }.by(1) - .and change { cc_user.mailbox.inbox.count }.by(1) + .and change { to_user.mailbox.inbox.count }.by(1) + .and change { cc_user.mailbox.inbox.count }.by(1) end context 'without carbon-copied users' do let(:recipients) { { 'to' => [to_user] } } @@ -26,7 +26,7 @@ expect(depositor).to receive(:send_message).exactly(2).times.and_call_original expect { described_class.send_notification(entity: entity, user: depositor, comment: comment, recipients: recipients) } .to change { depositor.mailbox.inbox.count }.by(1) - .and change { to_user.mailbox.inbox.count }.by(1) + .and change { to_user.mailbox.inbox.count }.by(1) end end end diff --git a/spec/services/hyrax/workflow/permission_generator_spec.rb b/spec/services/hyrax/workflow/permission_generator_spec.rb index 0f3a56a7e3..86b25039ba 100644 --- a/spec/services/hyrax/workflow/permission_generator_spec.rb +++ b/spec/services/hyrax/workflow/permission_generator_spec.rb @@ -17,15 +17,15 @@ module Workflow expect do described_class.call(agents: user, roles: role.name, workflow: workflow) end.to change { Sipity::WorkflowRole.count }.by(1) - .and change { Sipity::WorkflowResponsibility.count }.by(1) + .and change { Sipity::WorkflowResponsibility.count }.by(1) end it 'will grant entity responsiblity to agent as the given role' do expect do described_class.call(agents: user, roles: role.name, workflow: workflow, entity: entity) end.to change { Sipity::WorkflowRole.count }.by(1) - .and change { Sipity::EntitySpecificResponsibility.count }.by(1) - .and change { Sipity::WorkflowResponsibility.count }.by(0) + .and change { Sipity::EntitySpecificResponsibility.count }.by(1) + .and change { Sipity::WorkflowResponsibility.count }.by(0) end it 'will be idempotent' do diff --git a/spec/services/hyrax/workflow/workflow_factory_spec.rb b/spec/services/hyrax/workflow/workflow_factory_spec.rb index 45d0229c7e..428f1a0b2c 100644 --- a/spec/services/hyrax/workflow/workflow_factory_spec.rb +++ b/spec/services/hyrax/workflow/workflow_factory_spec.rb @@ -18,7 +18,7 @@ expect do subject end.to change { Sipity::Entity.count }.by(1) - .and change { Sipity::EntitySpecificResponsibility.count }.by(1) + .and change { Sipity::EntitySpecificResponsibility.count }.by(1) end.not_to change { Sipity::WorkflowResponsibility.count } end end