diff --git a/.rubocop.yml b/.rubocop.yml index dbbde17a9f..b48e5cd59a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,11 @@ -require: rubocop-rspec +inherit_gem: + bixby: bixby_default.yml + inherit_from: .rubocop_fixme.yml AllCops: TargetRubyVersion: 2.1 DisplayCopNames: true - Include: - - '**/Rakefile' - - '**/config.ru' Exclude: - 'db/**/*' - 'script/**/*' @@ -14,25 +13,10 @@ AllCops: - 'vendor/**/*' - 'lib/hyrax/specs/**/*' -Bundler/DuplicatedGem: # This doesn't work with engine_cart - Enabled: false - -Layout/IndentationConsistency: - EnforcedStyle: rails - Lint/ImplicitStringConcatenation: Exclude: - 'lib/generators/hyrax/**/*' -Lint/AmbiguousBlockAssociation: - Enabled: false - -Metrics/LineLength: - Max: 200 - -Metrics/AbcSize: - Max: 26 - Metrics/BlockLength: ExcludedMethods: ['included'] Exclude: @@ -47,12 +31,9 @@ Metrics/BlockLength: - 'lib/tasks/*.rake' - 'spec/**/*.rb' -Metrics/MethodLength: - Max: 13 - -Naming/FileName: # https://github.com/bbatsov/rubocop/issues/2973 - Exclude: - - 'Gemfile' +# Naming/FileName: # https://github.com/bbatsov/rubocop/issues/2973 +# Exclude: +# - 'Gemfile' Style/AsciiComments: Enabled: false @@ -76,21 +57,9 @@ Style/NumericPredicate: Style/SymbolArray: Enabled: false -Style/WordArray: - Enabled: false - -Style/RegexpLiteral: - Enabled: false - -Style/StringLiterals: - Enabled: false - Style/ClassAndModuleChildren: Enabled: false -Style/Documentation: - Enabled: false - Style/SingleLineBlockParams: Enabled: false @@ -98,9 +67,6 @@ Style/ZeroLengthPredicate: Exclude: - 'app/controllers/hyrax/file_sets_controller.rb' -Rails: - Enabled: true - Rails/ApplicationJob: Enabled: false @@ -141,12 +107,9 @@ RSpec/DescribeClass: - 'spec/tasks/rake_spec.rb' - 'spec/views/**/*' -RSpec/ContextWording: - Enabled: false - -# By default RSpec/MessageSpies has the following: -# Prefer have_received for setting message expectations. Setup form as a spy using allow or instance_spy. -# The default assumes EnforcedStyle is 'have_received'. Most of our specs are 'receive' +# # By default RSpec/MessageSpies has the following: +# # Prefer have_received for setting message expectations. Setup form as a spy using allow or instance_spy. +# # The default assumes EnforcedStyle is 'have_received'. Most of our specs are 'receive' RSpec/MessageSpies: Enabled: false @@ -163,9 +126,6 @@ RSpec/LetSetup: RSpec/MessageExpectation: Enabled: false -RSpec/MultipleExpectations: - Enabled: false - RSpec/NestedGroups: Enabled: false diff --git a/Gemfile b/Gemfile index 03172e0439..33c5f0f4eb 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,7 @@ group :development, :test do gem "simplecov", require: false end +# rubocop:disable Bundler/DuplicatedGem # BEGIN ENGINE_CART BLOCK # engine_cart: 1.1.0 # engine_cart stanza: 0.10.0 @@ -44,7 +45,6 @@ else end end # END ENGINE_CART BLOCK +# rubocop:enable Bundler/DuplicatedGem -unless File.exist?(file) - eval_gemfile File.expand_path('spec/test_app_templates/Gemfile.extra', File.dirname(__FILE__)) -end +eval_gemfile File.expand_path('spec/test_app_templates/Gemfile.extra', File.dirname(__FILE__)) unless File.exist?(file) diff --git a/app/actors/hyrax/actors/file_set_actor.rb b/app/actors/hyrax/actors/file_set_actor.rb index 05434570b8..36be7f37ff 100644 --- a/app/actors/hyrax/actors/file_set_actor.rb +++ b/app/actors/hyrax/actors/file_set_actor.rb @@ -147,7 +147,6 @@ def assign_visibility?(file_set_params = {}) # Must clear the fileset from the thumbnail_id, representative_id and rendering_ids fields on the work # and force it to be re-solrized. # Although ActiveFedora clears the children nodes it leaves those fields in Solr populated. - # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/CyclomaticComplexity def unlink_from_work work = file_set.parent diff --git a/app/actors/hyrax/actors/interpret_visibility_actor.rb b/app/actors/hyrax/actors/interpret_visibility_actor.rb index 3430e7bd27..aefcae6382 100644 --- a/app/actors/hyrax/actors/interpret_visibility_actor.rb +++ b/app/actors/hyrax/actors/interpret_visibility_actor.rb @@ -114,9 +114,7 @@ def validate(env, intention, attributes) def apply_visibility(env, intention) result = apply_lease(env, intention) && apply_embargo(env, intention) - if env.attributes[:visibility] - env.curation_concern.visibility = env.attributes[:visibility] - end + env.curation_concern.visibility = env.attributes[:visibility] if env.attributes[:visibility] result end diff --git a/app/actors/hyrax/actors/model_actor.rb b/app/actors/hyrax/actors/model_actor.rb index 94024f8cb7..a7fc4ce9ed 100644 --- a/app/actors/hyrax/actors/model_actor.rb +++ b/app/actors/hyrax/actors/model_actor.rb @@ -2,6 +2,9 @@ module Hyrax module Actors # This is a proxy for the model specific actor class ModelActor < AbstractActor + # See: https://github.com/bbatsov/rubocop/issues/5393 + # rubocop:disable Rails/Delegate + # @param [Hyrax::Actors::Environment] env # @return [Boolean] true if update was successful def update(env) @@ -19,6 +22,7 @@ def create(env) def destroy(env) model_actor(env).destroy(env) end + # rubocop:enable Rails/Delegate private diff --git a/app/controllers/concerns/hyrax/works_controller_behavior.rb b/app/controllers/concerns/hyrax/works_controller_behavior.rb index 5796427962..c2d138538f 100644 --- a/app/controllers/concerns/hyrax/works_controller_behavior.rb +++ b/app/controllers/concerns/hyrax/works_controller_behavior.rb @@ -154,12 +154,10 @@ def presenter end def parent_presenter + return @parent_presenter unless params[:parent_id] + @parent_presenter ||= - begin - if params[:parent_id] - @parent_presenter ||= show_presenter.new(search_result_document(id: params[:parent_id]), current_ability, request) - end - end + show_presenter.new(search_result_document(id: params[:parent_id]), current_ability, request) end # Include 'hyrax/base' in the search path for views, while prefering diff --git a/app/controllers/hyrax/api/items_controller.rb b/app/controllers/hyrax/api/items_controller.rb index c7b5f294d3..3ad0a4e978 100644 --- a/app/controllers/hyrax/api/items_controller.rb +++ b/app/controllers/hyrax/api/items_controller.rb @@ -34,13 +34,9 @@ def show def my_load_and_authorize_resource @work = Hyrax::WorkRelation.new.find(params[:id]) - unless user.can? :edit, @work - return render plain: "#{user} lacks access to #{@work}", status: :unauthorized - end + return render plain: "#{user} lacks access to #{@work}", status: :unauthorized unless user.can? :edit, @work - if @work.arkivo_checksum.nil? - return render plain: "Forbidden: #{@work} not deposited via Arkivo", status: :forbidden - end + return render plain: "Forbidden: #{@work} not deposited via Arkivo", status: :forbidden if @work.arkivo_checksum.nil? rescue ActiveFedora::ObjectNotFoundError return render plain: "id '#{params[:id]}' not found", status: :not_found end diff --git a/app/controllers/hyrax/transfers_controller.rb b/app/controllers/hyrax/transfers_controller.rb index ab836bfe90..7da2d2fb14 100644 --- a/app/controllers/hyrax/transfers_controller.rb +++ b/app/controllers/hyrax/transfers_controller.rb @@ -46,9 +46,7 @@ def index # any existing edit permissions on the work. def accept @proxy_deposit_request.transfer!(params[:reset]) - if params[:sticky] - current_user.can_receive_deposits_from << @proxy_deposit_request.sending_user - end + current_user.can_receive_deposits_from << @proxy_deposit_request.sending_user if params[:sticky] redirect_to hyrax.transfers_path, notice: "Transfer complete" end diff --git a/app/controllers/hyrax/users_controller.rb b/app/controllers/hyrax/users_controller.rb index 2617cddecc..2d0cff961f 100644 --- a/app/controllers/hyrax/users_controller.rb +++ b/app/controllers/hyrax/users_controller.rb @@ -24,9 +24,7 @@ def show def search(query) clause = query.blank? ? nil : "%" + query.downcase + "%" base = ::User.where(*base_query) - if clause.present? - base = base.where("#{Hydra.config.user_key_field} like lower(?) OR display_name like lower(?)", clause, clause) - end + base = base.where("#{Hydra.config.user_key_field} like lower(?) OR display_name like lower(?)", clause, clause) if clause.present? base.registered .where("#{Hydra.config.user_key_field} not in (?)", [::User.batch_user_key, ::User.audit_user_key]) diff --git a/app/forms/hyrax/forms/permission_template_form.rb b/app/forms/hyrax/forms/permission_template_form.rb index c27a341d12..245611c2a3 100644 --- a/app/forms/hyrax/forms/permission_template_form.rb +++ b/app/forms/hyrax/forms/permission_template_form.rb @@ -45,7 +45,6 @@ def initialize(model) # @return [Hash{Symbol => String, Boolean}] { :content_tab (for confirmation message), # :updated (true/false), # :error_code (for flash error lookup) } - # rubocop:disable Metrics/MethodLength def update(attributes) @attributes = attributes return_info = { content_tab: tab_to_update } @@ -219,9 +218,7 @@ def managers_updated? def grants_as_collection return [] unless attributes[:access_grants_attributes] attributes_collection = attributes[:access_grants_attributes] - if attributes_collection.respond_to?(:permitted?) - attributes_collection = attributes_collection.to_h - end + attributes_collection = attributes_collection.to_h if attributes_collection.respond_to?(:permitted?) if attributes_collection.is_a? Hash attributes_collection = attributes_collection .sort_by { |i, _| i.to_i } diff --git a/app/forms/hyrax/forms/work_form.rb b/app/forms/hyrax/forms/work_form.rb index 5c39c50189..094a310b54 100644 --- a/app/forms/hyrax/forms/work_form.rb +++ b/app/forms/hyrax/forms/work_form.rb @@ -160,9 +160,7 @@ def collections_for_select # are going into a mediated deposit workflow. def self.sanitize_params(form_params) admin_set_id = form_params[:admin_set_id] - if admin_set_id && workflow_for(admin_set_id: admin_set_id).allows_access_grant? - return super - end + return super if admin_set_id && workflow_for(admin_set_id: admin_set_id).allows_access_grant? params_without_permissions = permitted_params.reject { |arg| arg.respond_to?(:key?) && arg.key?(:permissions_attributes) } form_params.permit(*params_without_permissions) end diff --git a/app/helpers/hyrax/citations_behaviors/common_behavior.rb b/app/helpers/hyrax/citations_behaviors/common_behavior.rb index 1d56d75b88..46bac2e9e0 100644 --- a/app/helpers/hyrax/citations_behaviors/common_behavior.rb +++ b/app/helpers/hyrax/citations_behaviors/common_behavior.rb @@ -6,9 +6,7 @@ def persistent_url(work) end def clean_end_punctuation(text) - if text && ([".", ",", ":", ";", "/"].include? text[-1, 1]) - return text[0, text.length - 1] - end + return text[0, text.length - 1] if text && ([".", ",", ":", ";", "/"].include? text[-1, 1]) text end end diff --git a/app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb b/app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb index a773e4df18..42fceadfa7 100644 --- a/app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb +++ b/app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb @@ -4,17 +4,13 @@ module Formatters class ChicagoFormatter < BaseFormatter include Hyrax::CitationsBehaviors::PublicationBehavior include Hyrax::CitationsBehaviors::TitleBehavior - - # rubocop:disable Metrics/MethodLength def format(work) text = "" # setup formatted author list authors_list = all_authors(work) text << format_authors(authors_list) - if text.present? - text = "#{text}" - end + text = "#{text}" if text.present? # Get Pub Date pub_date = setup_pub_date(work) text << " #{pub_date}." unless pub_date.nil? diff --git a/app/helpers/hyrax/file_set_helper.rb b/app/helpers/hyrax/file_set_helper.rb index 97aca312f9..a5f819ca7e 100644 --- a/app/helpers/hyrax/file_set_helper.rb +++ b/app/helpers/hyrax/file_set_helper.rb @@ -15,7 +15,6 @@ def media_display(presenter, locals = {}) locals.merge(file_set: presenter) end - # rubocop:disable Metrics/MethodLength def media_display_partial(file_set) 'hyrax/file_sets/media_display/' + if file_set.image? diff --git a/app/helpers/hyrax/hyrax_helper_behavior.rb b/app/helpers/hyrax/hyrax_helper_behavior.rb index 5f8e98e77b..fdec1a0e82 100644 --- a/app/helpers/hyrax/hyrax_helper_behavior.rb +++ b/app/helpers/hyrax/hyrax_helper_behavior.rb @@ -273,7 +273,6 @@ def count_classes_for(unread_count) end end - # rubocop:disable Metrics/MethodLength def search_action_for_dashboard case params[:controller] when "hyrax/my/collections" diff --git a/app/helpers/hyrax/trophy_helper.rb b/app/helpers/hyrax/trophy_helper.rb index 9b14bf2ee6..dbd69bf606 100644 --- a/app/helpers/hyrax/trophy_helper.rb +++ b/app/helpers/hyrax/trophy_helper.rb @@ -1,6 +1,5 @@ module Hyrax module TrophyHelper - # rubocop:disable Metrics/MethodLength def display_trophy_link(user, id, args = {}, &_block) return unless user trophy = user.trophies.where(work_id: id).exists? diff --git a/app/inputs/multi_value_select_input.rb b/app/inputs/multi_value_select_input.rb index 25ed6d8c80..73ebd501f1 100644 --- a/app/inputs/multi_value_select_input.rb +++ b/app/inputs/multi_value_select_input.rb @@ -39,9 +39,7 @@ def build_field_options(value) def build_field(value, index) render_options = select_options html_options = build_field_options(value) - if options[:item_helper] - (render_options, html_options) = options[:item_helper].call(value, index, render_options, html_options) - end + (render_options, html_options) = options[:item_helper].call(value, index, render_options, html_options) if options[:item_helper] template.select_tag(attribute_name, template.options_for_select(render_options, value), html_options) end end diff --git a/app/models/admin_set.rb b/app/models/admin_set.rb index e8118c8682..b687307d3e 100644 --- a/app/models/admin_set.rb +++ b/app/models/admin_set.rb @@ -38,8 +38,6 @@ class AdminSet < ActiveFedora::Base property :creator, predicate: ::RDF::Vocab::DC11.creator do |index| index.as :symbol end - - # rubocop:disable Rails/HasManyOrHasOneDependent has_many :members, predicate: Hyrax.config.admin_set_predicate, class_name: 'ActiveFedora::Base' @@ -58,9 +56,7 @@ def default_set? # Creates the default AdminSet and an associated PermissionTemplate with workflow def self.find_or_create_default_admin_set_id - unless exists?(DEFAULT_ID) - Hyrax::AdminSetCreateService.create_default_admin_set(admin_set_id: DEFAULT_ID, title: DEFAULT_TITLE) - end + Hyrax::AdminSetCreateService.create_default_admin_set(admin_set_id: DEFAULT_ID, title: DEFAULT_TITLE) unless exists?(DEFAULT_ID) DEFAULT_ID end diff --git a/app/models/concerns/hyrax/ability.rb b/app/models/concerns/hyrax/ability.rb index a2beff6a29..707362f053 100644 --- a/app/models/concerns/hyrax/ability.rb +++ b/app/models/concerns/hyrax/ability.rb @@ -112,9 +112,7 @@ def proxy_deposit_abilities end end - if Flipflop.proxy_deposit? && registered_user? - can :create, ProxyDepositRequest - end + can :create, ProxyDepositRequest if Flipflop.proxy_deposit? && registered_user? can :accept, ProxyDepositRequest, receiving_user_id: current_user.id, status: 'pending' can :reject, ProxyDepositRequest, receiving_user_id: current_user.id, status: 'pending' diff --git a/app/models/concerns/hyrax/suppressible.rb b/app/models/concerns/hyrax/suppressible.rb index 837b646b4d..e52aca0e13 100644 --- a/app/models/concerns/hyrax/suppressible.rb +++ b/app/models/concerns/hyrax/suppressible.rb @@ -15,11 +15,7 @@ module Suppressible # Override this method if you have some criteria by which records should not display in the search results. def suppressed? return false if state.nil? - # This is a clumsy check only needed under RDF < 2.0 where there - # is a bug with `AT::Resource#==` - if RDF::VERSION.to_s < '2.0' - return state.rdf_subject == Vocab::FedoraResourceStatus.inactive - end + state == Vocab::FedoraResourceStatus.inactive end diff --git a/app/models/featured_work_list.rb b/app/models/featured_work_list.rb index d6d49ebf38..43b7abf80c 100644 --- a/app/models/featured_work_list.rb +++ b/app/models/featured_work_list.rb @@ -3,9 +3,7 @@ class FeaturedWorkList # @param [ActionController::Parameters] a collection of nested perameters def featured_works_attributes=(attributes_collection) - if attributes_collection.respond_to?(:permitted?) - attributes_collection = attributes_collection.to_h - end + attributes_collection = attributes_collection.to_h if attributes_collection.respond_to?(:permitted?) attributes_collection = attributes_collection.sort_by { |i, _| i.to_i }.map { |_, attributes| attributes } if attributes_collection.is_a? Hash attributes_collection.each do |attributes| raise "Missing id" if attributes['id'].blank? diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index d401c7bd0b..115572d6b9 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -194,9 +194,7 @@ def manifest_helper end def featured? - if @featured.nil? - @featured = FeaturedWork.where(work_id: solr_document.id).exists? - end + @featured = FeaturedWork.where(work_id: solr_document.id).exists? if @featured.nil? @featured end diff --git a/app/services/hyrax/admin_set_create_service.rb b/app/services/hyrax/admin_set_create_service.rb index ae9b8d0e7a..ddbd640e78 100644 --- a/app/services/hyrax/admin_set_create_service.rb +++ b/app/services/hyrax/admin_set_create_service.rb @@ -72,9 +72,7 @@ def access_grants_attributes { agent_type: 'group', agent_id: admin_group_name, access: Hyrax::PermissionTemplateAccess::MANAGE } ].tap do |attribute_list| # Grant manage access to the creating_user if it exists. Should exist for all but default Admin Set - if creating_user - attribute_list << { agent_type: 'user', agent_id: creating_user.user_key, access: Hyrax::PermissionTemplateAccess::MANAGE } - end + attribute_list << { agent_type: 'user', agent_id: creating_user.user_key, access: Hyrax::PermissionTemplateAccess::MANAGE } if creating_user end end diff --git a/app/services/hyrax/analytics.rb b/app/services/hyrax/analytics.rb index 16d2fe3166..e56bb94cae 100644 --- a/app/services/hyrax/analytics.rb +++ b/app/services/hyrax/analytics.rb @@ -57,9 +57,7 @@ def self.oauth_client end def self.auth_client(scope) - unless File.exist?(config.privkey_path) - raise "Private key file for Google analytics was expected at '#{config.privkey_path}', but no file was found." - end + raise "Private key file for Google analytics was expected at '#{config.privkey_path}', but no file was found." unless File.exist?(config.privkey_path) private_key = File.read(config.privkey_path) Signet::OAuth2::Client.new token_credential_uri: 'https://accounts.google.com/o/oauth2/token', audience: 'https://accounts.google.com/o/oauth2/token', diff --git a/app/services/hyrax/collection_types/create_service.rb b/app/services/hyrax/collection_types/create_service.rb index 8cf7cb3888..ece7e3d708 100644 --- a/app/services/hyrax/collection_types/create_service.rb +++ b/app/services/hyrax/collection_types/create_service.rb @@ -133,7 +133,7 @@ def self.add_participants(collection_type_id, participants) agent_id = p.fetch(:agent_id) access = p.fetch(:access) Hyrax::CollectionTypeParticipant.create!(hyrax_collection_type_id: collection_type_id, agent_type: agent_type, agent_id: agent_id, access: access) - rescue => e # rubocop:disable Lint/RescueWithoutErrorClass + rescue => e Rails.logger.error "Participant not created for collection type #{collection_type_id}: #{agent_type}, #{agent_id}, #{access} -- reason: #{e.class.name} - #{e.message}\n" end end diff --git a/app/services/hyrax/collections/permissions_create_service.rb b/app/services/hyrax/collections/permissions_create_service.rb index 03a56d54d6..fd6ac6dc7f 100644 --- a/app/services/hyrax/collections/permissions_create_service.rb +++ b/app/services/hyrax/collections/permissions_create_service.rb @@ -30,9 +30,7 @@ def self.access_grants_attributes(collection_type:, creating_user:, grants:) { agent_type: 'group', agent_id: admin_group_name, access: Hyrax::PermissionTemplateAccess::MANAGE } ].tap do |attribute_list| # Grant manage access to the creating_user if it exists - if creating_user - attribute_list << { agent_type: 'user', agent_id: creating_user.user_key, access: Hyrax::PermissionTemplateAccess::MANAGE } - end + attribute_list << { agent_type: 'user', agent_id: creating_user.user_key, access: Hyrax::PermissionTemplateAccess::MANAGE } if creating_user end + managers_of_collection_type(collection_type: collection_type) + grants end private_class_method :access_grants_attributes diff --git a/hyrax.gemspec b/hyrax.gemspec index 7b2af80020..cb3014f621 100644 --- a/hyrax.gemspec +++ b/hyrax.gemspec @@ -93,21 +93,11 @@ SUMMARY spec.add_development_dependency 'rspec-rails', '~> 3.1' spec.add_development_dependency "selenium-webdriver" spec.add_development_dependency 'solr_wrapper', '~> 1.1' - # Pin rubocop and rubocop-rspec tightly. Minor-level version bumps - # in these gems cause Rubocop violations, and those violations cause - # continuous integration builds to fail, and those failures prevent - # us from merging pull requests. As a community, we have decided - # that it is not reasonable to manage style violations to be dealt - # with in a pull request *unless* said pull request's intent is to - # bring the codebase in further alignment with community style - # conventions. This allows us to take a managed approach to code - # style -- we choose to update style when we wish, not when a - # minor-level version bump in a dependency comes out. spec.add_development_dependency 'i18n-debug' if ENV['I18N_DEBUG'] spec.add_development_dependency 'i18n_yaml_sorter' unless ENV['TRAVIS'] spec.add_development_dependency 'rails-controller-testing', '~> 1' - spec.add_development_dependency 'rubocop', '~> 0.51.0' - spec.add_development_dependency 'rubocop-rspec', '~> 1.20.1' + # the hyrax style guide is based on `bixby`. see `.rubocop.yml` + spec.add_development_dependency 'bixby', '~> 1.0.0' spec.add_development_dependency 'shoulda-callback-matchers', '~> 1.1.1' spec.add_development_dependency 'shoulda-matchers', '~> 3.1' spec.add_development_dependency 'webmock' diff --git a/lib/generators/hyrax/models_generator.rb b/lib/generators/hyrax/models_generator.rb index 97640b6129..2067a15bc0 100644 --- a/lib/generators/hyrax/models_generator.rb +++ b/lib/generators/hyrax/models_generator.rb @@ -17,7 +17,6 @@ def copy_migrations end # Add behaviors to the user model - # rubocop:disable Metrics/MethodLength def inject_user_behavior file_path = "app/models/#{model_name.underscore}.rb" if File.exist?(file_path) diff --git a/lib/hyrax/configuration.rb b/lib/hyrax/configuration.rb index 1d61fb55ea..926739fecb 100644 --- a/lib/hyrax/configuration.rb +++ b/lib/hyrax/configuration.rb @@ -206,9 +206,7 @@ def whitelisted_ingest_dirs # @param [Array,Symbol] curation_concern_types def register_curation_concern(*curation_concern_types) Array.wrap(curation_concern_types).flatten.compact.each do |cc_type| - unless @registered_concerns.include?(cc_type) - @registered_concerns << cc_type - end + @registered_concerns << cc_type unless @registered_concerns.include?(cc_type) end end diff --git a/spec/factories/file_sets.rb b/spec/factories/file_sets.rb index c4496fee4a..3c139e843b 100644 --- a/spec/factories/file_sets.rb +++ b/spec/factories/file_sets.rb @@ -9,9 +9,7 @@ end after(:create) do |file, evaluator| - if evaluator.content - Hydra::Works::UploadFileToFileSet.call(file, evaluator.content) - end + Hydra::Works::UploadFileToFileSet.call(file, evaluator.content) if evaluator.content end trait :public do @@ -27,9 +25,7 @@ file.title = ['testfile'] end after(:create) do |file, evaluator| - if evaluator.content - Hydra::Works::UploadFileToFileSet.call(file, evaluator.content) - end + Hydra::Works::UploadFileToFileSet.call(file, evaluator.content) if evaluator.content create(:work, user: evaluator.user).members << file end end diff --git a/spec/helpers/hyrax/ability_helper_spec.rb b/spec/helpers/hyrax/ability_helper_spec.rb index 0bfb358141..665a51ba57 100644 --- a/spec/helpers/hyrax/ability_helper_spec.rb +++ b/spec/helpers/hyrax/ability_helper_spec.rb @@ -6,7 +6,7 @@ Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC => "Public", Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED => - "%s", + "%s", Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE => "Private", Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO => @@ -17,7 +17,7 @@ context value do let(:visibility) { value } - it { expect(subject).to eql(output % t('hyrax.institution_name')) } + it { expect(subject).to eql(format(output, name: t('hyrax.institution_name'))) } end end end diff --git a/spec/services/hyrax/qa_select_service_spec.rb b/spec/services/hyrax/qa_select_service_spec.rb index b98c388c77..1edc2d5dae 100644 --- a/spec/services/hyrax/qa_select_service_spec.rb +++ b/spec/services/hyrax/qa_select_service_spec.rb @@ -1,7 +1,6 @@ RSpec.describe Hyrax::QaSelectService do let(:authority) do # Implementing an ActiveRecord interface as required for this spec - # rubocop:disable RSpec/InstanceVariable Class.new do def initialize(map) @map = map diff --git a/tasks/hyrax_dev.rake b/tasks/hyrax_dev.rake index 3253a0fb81..a7052e8470 100644 --- a/tasks/hyrax_dev.rake +++ b/tasks/hyrax_dev.rake @@ -45,9 +45,7 @@ if Gem.loaded_specs.key? 'engine_cart' task :after_generate do puts 'Creating default collection type...' EngineCart.within_test_app do - unless system "bundle exec rake hyrax:default_collection_types:create" - raise "EngineCart failed on with: #{$?}" - end + raise "EngineCart failed on with: #{$?}" unless system "bundle exec rake hyrax:default_collection_types:create" end end end