diff --git a/.rubocop.yml b/.rubocop.yml
index cffa6afb30..5183fdac23 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -13,16 +13,34 @@ AllCops:
- 'vendor/**/*'
- 'lib/hyrax/specs/**/*'
+Bundler/DuplicatedGem: # This doesn't work with engine_cart
+ Enabled: false
+
Lint/ImplicitStringConcatenation:
Exclude:
- 'lib/generators/hyrax/**/*'
+Lint/AmbiguousBlockAssociation:
+ Enabled: false
+
Metrics/LineLength:
Max: 200
Metrics/AbcSize:
Max: 28
+Metrics/BlockLength:
+ ExcludedMethods: ['included']
+ Exclude:
+ - 'hyrax.gemspec'
+ - 'app/services/hyrax/workflow/workflow_schema.rb'
+ - 'config/initializers/simple_form.rb'
+ - 'config/routes.rb'
+ - 'lib/generators/hyrax/templates/catalog_controller.rb'
+ - 'lib/generators/hyrax/templates/config/initializers/simple_form_bootstrap.rb'
+ - 'lib/hyrax/rails/routes.rb'
+ - 'spec/**/*.rb'
+
Metrics/MethodLength:
Max: 14
@@ -37,6 +55,10 @@ Style/CollectionMethods:
detect: 'find'
find_all: 'select'
+Style/FileName: # https://github.com/bbatsov/rubocop/issues/2973
+ Exclude:
+ - 'Gemfile'
+
Style/MethodMissing:
Exclude:
- 'app/models/concerns/hyrax/file_set/characterization.rb'
@@ -45,6 +67,9 @@ Style/NumericPredicate:
Exclude:
- 'app/controllers/concerns/hyrax/file_sets_controller_behavior.rb'
+Style/SymbolArray:
+ Enabled: false
+
Style/WordArray:
Enabled: false
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 083cae999f..2832865e03 100755
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -4,19 +4,6 @@ Security/MarshalLoad:
Exclude:
- 'app/models/concerns/hyrax/user.rb'
-Metrics/BlockLength:
- Exclude:
- - 'app/controllers/concerns/hyrax/collections_controller_behavior.rb'
- - 'app/models/concerns/hyrax/basic_metadata.rb'
- - 'app/models/concerns/hyrax/admin_set_behavior.rb'
- - 'app/services/hyrax/workflow/workflow_schema.rb'
- - 'config/initializers/simple_form.rb'
- - 'config/routes.rb'
- - 'lib/generators/hyrax/templates/catalog_controller.rb'
- - 'lib/generators/hyrax/templates/config/initializers/simple_form_bootstrap.rb'
- - 'lib/hyrax/rails/routes.rb'
- - 'spec/**/*'
-
Metrics/ClassLength:
Exclude:
- 'app/forms/hyrax/forms/permission_template_form.rb'
diff --git a/Gemfile b/Gemfile
index de454d63a3..1a6710d3e7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -4,10 +4,10 @@ source 'https://rubygems.org'
gemspec
group :development, :test do
- gem "simplecov", require: false
gem 'coveralls', require: false
gem 'pry' unless ENV['CI']
gem 'pry-byebug' unless ENV['CI']
+ gem "simplecov", require: false
end
# BEGIN ENGINE_CART BLOCK
@@ -36,9 +36,9 @@ else
case ENV['RAILS_VERSION']
when /^4.2/
+ gem 'coffee-rails', '~> 4.2.0'
gem 'responders', '~> 2.0'
gem 'sass-rails', '>= 5.0'
- gem 'coffee-rails', '~> 4.2.0'
when /^4.[01]/
gem 'sass-rails', '< 5.0'
end
diff --git a/app/actors/hyrax/actors/apply_permission_template_actor.rb b/app/actors/hyrax/actors/apply_permission_template_actor.rb
index 3056cfe7db..3742343de3 100644
--- a/app/actors/hyrax/actors/apply_permission_template_actor.rb
+++ b/app/actors/hyrax/actors/apply_permission_template_actor.rb
@@ -11,7 +11,7 @@ def create(attributes)
protected
def add_edit_users(attributes)
- return unless attributes[:admin_set_id].present?
+ return if attributes[:admin_set_id].blank?
template = Hyrax::PermissionTemplate.find_by!(admin_set_id: attributes[:admin_set_id])
curation_concern.edit_users += template.agent_ids_for(agent_type: 'user', access: 'manage')
curation_concern.edit_groups += template.agent_ids_for(agent_type: 'group', access: 'manage')
diff --git a/app/actors/hyrax/actors/file_set_actor.rb b/app/actors/hyrax/actors/file_set_actor.rb
index 7601008f11..d9501994bf 100644
--- a/app/actors/hyrax/actors/file_set_actor.rb
+++ b/app/actors/hyrax/actors/file_set_actor.rb
@@ -126,7 +126,7 @@ def save
end
def assign_visibility?(file_set_params = {})
- !((file_set_params || {}).keys.map(&:to_s) & %w(visibility embargo_release_date lease_expiration_date)).empty?
+ !((file_set_params || {}).keys.map(&:to_s) & %w[visibility embargo_release_date lease_expiration_date]).empty?
end
# copy visibility from source_concern to destination_concern
@@ -135,12 +135,12 @@ def copy_visibility(source_concern, destination_concern)
end
def set_representative(work, file_set)
- return unless work.representative_id.blank?
+ return if work.representative_id.present?
work.representative = file_set
end
def set_thumbnail(work, file_set)
- return unless work.thumbnail_id.blank?
+ return if work.thumbnail_id.present?
work.thumbnail = file_set
end
diff --git a/app/actors/hyrax/actors/interpret_visibility_actor.rb b/app/actors/hyrax/actors/interpret_visibility_actor.rb
index f412381042..6d6dd2b897 100644
--- a/app/actors/hyrax/actors/interpret_visibility_actor.rb
+++ b/app/actors/hyrax/actors/interpret_visibility_actor.rb
@@ -137,7 +137,7 @@ def validate_release_type(template)
# Validate visibility complies with AdminSet template requirements
def validate_visibility(attributes, template)
# NOTE: For embargo/lease, attributes[:visibility] will be nil (see sanitize_params), so visibility will be validated as part of embargo/lease
- return true unless attributes[:visibility].present?
+ return true if attributes[:visibility].blank?
# Validate against template's visibility requirements
return true if validate_template_visibility(attributes[:visibility], template)
@@ -157,7 +157,7 @@ def validate_embargo(attributes, template)
valid_template_embargo_date?(embargo_release_date, template) &&
valid_template_visibility_after_embargo?(attributes, template)
- curation_concern.errors.add(:visibility, 'When setting visibility to "embargo" you must also specify embargo release date.') unless embargo_release_date.present?
+ curation_concern.errors.add(:visibility, 'When setting visibility to "embargo" you must also specify embargo release date.') if embargo_release_date.blank?
false
end
@@ -171,7 +171,7 @@ def valid_future_date?(date, attribute_name: :embargo_release_date)
# Validate an embargo date against permission template restrictions
def valid_template_embargo_date?(date, template)
- return true unless template.present?
+ return true if template.blank?
# Validate against template's release_date requirements
return true if template.valid_release_date?(date)
@@ -191,7 +191,7 @@ def valid_template_visibility_after_embargo?(attributes, template)
# Validate that a given visibility value satisfies template requirements
def validate_template_visibility(visibility, template)
- return true unless template.present?
+ return true if template.blank?
template.valid_visibility?(visibility)
end
diff --git a/app/controllers/concerns/hyrax/parent_container.rb b/app/controllers/concerns/hyrax/parent_container.rb
index b8d4fa5bbf..f3f64e1550 100644
--- a/app/controllers/concerns/hyrax/parent_container.rb
+++ b/app/controllers/concerns/hyrax/parent_container.rb
@@ -29,7 +29,7 @@ def parent_id
protected
def new_or_create?
- %w(create new).include? action_name
+ %w[create new].include? action_name
end
end
end
diff --git a/app/controllers/concerns/hyrax/users_controller_behavior.rb b/app/controllers/concerns/hyrax/users_controller_behavior.rb
index e128277dce..8a86b468eb 100644
--- a/app/controllers/concerns/hyrax/users_controller_behavior.rb
+++ b/app/controllers/concerns/hyrax/users_controller_behavior.rb
@@ -34,7 +34,7 @@ def notifications_number
def search(query)
clause = query.blank? ? nil : "%" + query.downcase + "%"
base = User.where(*base_query)
- unless clause.blank?
+ if clause.present?
base = base.where("#{Devise.authentication_keys.first} like lower(?) OR display_name like lower(?)", clause, clause)
end
base.registered
diff --git a/app/helpers/hyrax/citations_behaviors/formatters/apa_formatter.rb b/app/helpers/hyrax/citations_behaviors/formatters/apa_formatter.rb
index 58165cf0b7..e60013a7e4 100644
--- a/app/helpers/hyrax/citations_behaviors/formatters/apa_formatter.rb
+++ b/app/helpers/hyrax/citations_behaviors/formatters/apa_formatter.rb
@@ -19,7 +19,7 @@ def format(work)
def authors_text_for(work)
# setup formatted author list
- authors_list = author_list(work).select { |author| !author.blank? }
+ authors_list = author_list(work).reject(&:blank?)
author_text = format_authors(authors_list)
if author_text.blank?
author_text
diff --git a/app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb b/app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb
index cc9281d15e..2398b83b94 100644
--- a/app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb
+++ b/app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb
@@ -11,7 +11,7 @@ def format(work)
# setup formatted author list
authors_list = all_authors(work)
text << format_authors(authors_list)
- unless text.blank?
+ if text.present?
text = "#{text}"
end
# Get Pub Date
@@ -21,7 +21,7 @@ def format(work)
text << format_title(work.to_s)
pub_info = setup_pub_info(work, false)
- text << " #{pub_info}." unless pub_info.blank?
+ text << " #{pub_info}." if pub_info.present?
text.html_safe
end
diff --git a/app/helpers/hyrax/citations_behaviors/formatters/mla_formatter.rb b/app/helpers/hyrax/citations_behaviors/formatters/mla_formatter.rb
index 4a80bffedb..2777a62ab8 100644
--- a/app/helpers/hyrax/citations_behaviors/formatters/mla_formatter.rb
+++ b/app/helpers/hyrax/citations_behaviors/formatters/mla_formatter.rb
@@ -9,7 +9,7 @@ def format(work)
text = ''
# setup formatted author list
- authors = author_list(work).select { |author| !author.blank? }
+ authors = author_list(work).reject(&:blank?)
text << "#{format_authors(authors)}"
# setup title
title_info = setup_title_info(work)
@@ -18,7 +18,7 @@ def format(work)
# Publication
pub_info = clean_end_punctuation(setup_pub_info(work, true))
- text << pub_info unless pub_info.blank?
+ text << pub_info if pub_info.present?
text << "." unless text.blank? || text =~ /\.$/
text.html_safe
end
@@ -27,7 +27,7 @@ def format_authors(authors_list = [])
return "" if authors_list.blank?
authors_list = Array.wrap(authors_list)
text = concatenate_authors_from(authors_list)
- unless text.blank?
+ if text.present?
text << "." unless text =~ /\.$/
text << " "
end
diff --git a/app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb b/app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
index 87d81b5348..6a301128d7 100644
--- a/app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
+++ b/app/helpers/hyrax/citations_behaviors/formatters/open_url_formatter.rb
@@ -13,7 +13,7 @@ def format(work)
export_text << "rft.#{kev}=#{CGI.escape(value.to_s)}"
end
end
- export_text.join('&') unless export_text.blank?
+ export_text.join('&') if export_text.present?
end
FIELD_MAP = {
diff --git a/app/helpers/hyrax/citations_behaviors/publication_behavior.rb b/app/helpers/hyrax/citations_behaviors/publication_behavior.rb
index b9eba33a16..9d50dc87c3 100644
--- a/app/helpers/hyrax/citations_behaviors/publication_behavior.rb
+++ b/app/helpers/hyrax/citations_behaviors/publication_behavior.rb
@@ -4,7 +4,7 @@ module PublicationBehavior
include Hyrax::CitationsBehaviors::CommonBehavior
def setup_pub_date(work)
first_date = work.date_created.first if work.date_created
- unless first_date.blank?
+ if first_date.present?
first_date = CGI.escapeHTML(first_date)
date_value = first_date.gsub(/[^0-9|n\.d\.]/, "")[0, 4]
return nil if date_value.nil?
diff --git a/app/helpers/hyrax/citations_behaviors/title_behavior.rb b/app/helpers/hyrax/citations_behaviors/title_behavior.rb
index 57488359a5..ba1736e7ca 100644
--- a/app/helpers/hyrax/citations_behaviors/title_behavior.rb
+++ b/app/helpers/hyrax/citations_behaviors/title_behavior.rb
@@ -38,7 +38,7 @@ def process_title_parts(title_text, &block)
def setup_title_info(work)
text = ''
title = work.to_s
- unless title.blank?
+ if title.present?
title = CGI.escapeHTML(title)
title_info = clean_end_punctuation(title.strip)
text << title_info
diff --git a/app/helpers/hyrax/collections_helper.rb b/app/helpers/hyrax/collections_helper.rb
index 0714ca08f6..4f5c7dc4a3 100644
--- a/app/helpers/hyrax/collections_helper.rb
+++ b/app/helpers/hyrax/collections_helper.rb
@@ -11,7 +11,7 @@ def render_collection_links(solr_doc)
# @return [Boolean]
def has_collection_search_parameters?
- !params[:cq].blank?
+ params[:cq].present?
end
def button_for_remove_from_collection(collection, document, label = 'Remove From Collection')
diff --git a/app/helpers/hyrax/hyrax_helper_behavior.rb b/app/helpers/hyrax/hyrax_helper_behavior.rb
index e411fffb8c..1e0549d28e 100644
--- a/app/helpers/hyrax/hyrax_helper_behavior.rb
+++ b/app/helpers/hyrax/hyrax_helper_behavior.rb
@@ -1,4 +1,5 @@
# coding: utf-8
+
module Hyrax
module HyraxHelperBehavior
include Hyrax::CitationsBehavior
diff --git a/app/indexers/hyrax/basic_metadata_indexer.rb b/app/indexers/hyrax/basic_metadata_indexer.rb
index db86e74fb5..648a1a247b 100644
--- a/app/indexers/hyrax/basic_metadata_indexer.rb
+++ b/app/indexers/hyrax/basic_metadata_indexer.rb
@@ -1,9 +1,9 @@
module Hyrax
class BasicMetadataIndexer < ActiveFedora::RDF::IndexingService
class_attribute :stored_and_facetable_fields, :stored_fields, :symbol_fields
- self.stored_and_facetable_fields = %i(resource_type creator contributor keyword publisher subject language based_near)
- self.stored_fields = %i(description license rights_statement date_created identifier related_url bibliographic_citation source)
- self.symbol_fields = %i(import_url)
+ self.stored_and_facetable_fields = %i[resource_type creator contributor keyword publisher subject language based_near]
+ self.stored_fields = %i[description license rights_statement date_created identifier related_url bibliographic_citation source]
+ self.symbol_fields = %i[import_url]
protected
diff --git a/app/models/concerns/hyrax/collection_behavior.rb b/app/models/concerns/hyrax/collection_behavior.rb
index b07e0b31c2..94d3b34309 100644
--- a/app/models/concerns/hyrax/collection_behavior.rb
+++ b/app/models/concerns/hyrax/collection_behavior.rb
@@ -18,7 +18,7 @@ module CollectionBehavior
# Add members using the members association.
def add_members(new_member_ids)
- return if new_member_ids.nil? || new_member_ids.empty?
+ return if new_member_ids.blank?
members << ActiveFedora::Base.find(new_member_ids)
end
diff --git a/app/models/concerns/hyrax/file_set/belongs_to_works.rb b/app/models/concerns/hyrax/file_set/belongs_to_works.rb
index a55b06aa6d..310cdb3ffa 100644
--- a/app/models/concerns/hyrax/file_set/belongs_to_works.rb
+++ b/app/models/concerns/hyrax/file_set/belongs_to_works.rb
@@ -28,8 +28,8 @@ def related_files
parent_objects = parents
return [] if parent_objects.empty?
parent_objects.flat_map do |work|
- work.file_sets.select do |file_set|
- file_set.id != id
+ work.file_sets.reject do |file_set|
+ file_set.id == id
end
end
end
diff --git a/app/models/concerns/hyrax/proxy_deposit.rb b/app/models/concerns/hyrax/proxy_deposit.rb
index 4717b72d2b..aefda2fee5 100644
--- a/app/models/concerns/hyrax/proxy_deposit.rb
+++ b/app/models/concerns/hyrax/proxy_deposit.rb
@@ -16,7 +16,7 @@ module ProxyDeposit
end
def create_transfer_request
- return unless on_behalf_of.present?
+ return if on_behalf_of.blank?
ContentDepositorChangeEventJob.perform_later(self,
::User.find_by_user_key(on_behalf_of))
end
diff --git a/app/models/concerns/hyrax/solr_document/metadata.rb b/app/models/concerns/hyrax/solr_document/metadata.rb
index 4acbc2e270..a06ee1bfdb 100644
--- a/app/models/concerns/hyrax/solr_document/metadata.rb
+++ b/app/models/concerns/hyrax/solr_document/metadata.rb
@@ -43,7 +43,6 @@ def self.coerce(input)
end
end
- # rubocop:disable Metrics/BlockLength
included do
attribute :identifier, Solr::Array, solr_name('identifier')
attribute :based_near, Solr::Array, solr_name('based_near')
@@ -81,7 +80,6 @@ def self.coerce(input)
attribute :embargo_release_date, Solr::Date, Hydra.config.permissions.embargo.release_date
attribute :lease_expiration_date, Solr::Date, Hydra.config.permissions.lease.expiration_date
end
- # rubocop:enable Metrics/BlockLength
end
end
end
diff --git a/app/models/concerns/hyrax/solr_document_behavior.rb b/app/models/concerns/hyrax/solr_document_behavior.rb
index 238fb5037c..500f61288f 100644
--- a/app/models/concerns/hyrax/solr_document_behavior.rb
+++ b/app/models/concerns/hyrax/solr_document_behavior.rb
@@ -1,4 +1,5 @@
# -*- encoding : utf-8 -*-
+
module Hyrax
module SolrDocumentBehavior
extend ActiveSupport::Concern
diff --git a/app/models/hyrax/permission_template.rb b/app/models/hyrax/permission_template.rb
index d894bbe72a..94756c6413 100644
--- a/app/models/hyrax/permission_template.rb
+++ b/app/models/hyrax/permission_template.rb
@@ -106,7 +106,7 @@ def valid_release_date?(date)
# @param [String] value - visibility value to validate
def valid_visibility?(value)
# If template doesn't specify a visiblity (i.e. is "varies"), then any visibility is valid
- return true unless visibility.present?
+ return true if visibility.blank?
# Validate that passed in value matches visibility requirement exactly
visibility == value
diff --git a/app/models/hyrax/permission_template_access.rb b/app/models/hyrax/permission_template_access.rb
index ffc79e9ad9..cf973220fc 100644
--- a/app/models/hyrax/permission_template_access.rb
+++ b/app/models/hyrax/permission_template_access.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Hyrax
class PermissionTemplateAccess < ActiveRecord::Base
self.table_name = 'permission_template_accesses'
diff --git a/app/models/proxy_deposit_request.rb b/app/models/proxy_deposit_request.rb
index 8f5fb9a4e2..346e97e0b5 100644
--- a/app/models/proxy_deposit_request.rb
+++ b/app/models/proxy_deposit_request.rb
@@ -91,7 +91,7 @@ def send_request_transfer_message_as_part_of_create
def send_request_transfer_message_as_part_of_update
message = "Your transfer request was #{status}."
- message += " Comments: #{receiver_comment}" unless receiver_comment.blank?
+ message += " Comments: #{receiver_comment}" if receiver_comment.present?
User.batch_user.send_message(sending_user, message, "Ownership Change #{status}")
end
diff --git a/app/presenters/hyrax/admin_set_options_presenter.rb b/app/presenters/hyrax/admin_set_options_presenter.rb
index 5e5f8b8445..2b57fb6530 100644
--- a/app/presenters/hyrax/admin_set_options_presenter.rb
+++ b/app/presenters/hyrax/admin_set_options_presenter.rb
@@ -30,9 +30,9 @@ def data_attributes(admin_set)
def attributes_for(permission_template:)
{}.tap do |attrs|
attrs['data-sharing'] = sharing?(permission_template: permission_template)
- attrs['data-release-date'] = permission_template.release_date unless permission_template.release_date.blank?
+ attrs['data-release-date'] = permission_template.release_date if permission_template.release_date.present?
attrs['data-release-before-date'] = true if permission_template.release_before_date?
- attrs['data-visibility'] = permission_template.visibility unless permission_template.visibility.blank?
+ attrs['data-visibility'] = permission_template.visibility if permission_template.visibility.present?
end
end
diff --git a/app/presenters/hyrax/admin_stats_presenter.rb b/app/presenters/hyrax/admin_stats_presenter.rb
index 2ba803c45c..030ce2f3d7 100644
--- a/app/presenters/hyrax/admin_stats_presenter.rb
+++ b/app/presenters/hyrax/admin_stats_presenter.rb
@@ -18,7 +18,7 @@ def end_date
private
def extract_date_from_stats_filters(key:, as_of:)
- return unless stats_filters[key].present?
+ return if stats_filters[key].blank?
Time.zone.parse(stats_filters[key]).public_send(as_of)
end
diff --git a/app/presenters/hyrax/characterization_behavior.rb b/app/presenters/hyrax/characterization_behavior.rb
index 7918fc01bf..aa3a442674 100644
--- a/app/presenters/hyrax/characterization_behavior.rb
+++ b/app/presenters/hyrax/characterization_behavior.rb
@@ -76,7 +76,7 @@ def truncate_all(values)
def build_characterization_metadata
self.class.characterization_terms.each do |term|
value = send(term)
- additional_characterization_metadata[term.to_sym] = value unless value.blank?
+ additional_characterization_metadata[term.to_sym] = value if value.present?
end
additional_characterization_metadata
end
diff --git a/app/renderers/hyrax/renderers/attribute_renderer.rb b/app/renderers/hyrax/renderers/attribute_renderer.rb
index ff4fbe711e..c51c39529f 100644
--- a/app/renderers/hyrax/renderers/attribute_renderer.rb
+++ b/app/renderers/hyrax/renderers/attribute_renderer.rb
@@ -23,7 +23,7 @@ def initialize(field, values, options = {})
def render
markup = ''
- return markup if !values.present? && !options[:include_empty]
+ return markup if values.blank? && !options[:include_empty]
markup << %(
#{label} | \n)
attributes = microdata_object_attributes(field).merge(class: "attribute #{field}")
Array(values).each do |value|
@@ -57,7 +57,7 @@ def html_attributes(attributes)
buffer = ""
attributes.each do |k, v|
buffer << " #{k}"
- buffer << %(="#{v}") unless v.blank?
+ buffer << %(="#{v}") if v.present?
end
buffer
end
diff --git a/app/services/hyrax/admin_set_service.rb b/app/services/hyrax/admin_set_service.rb
index 1069456a57..8aadceda9a 100644
--- a/app/services/hyrax/admin_set_service.rb
+++ b/app/services/hyrax/admin_set_service.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Hyrax
# Returns AdminSets that the current user has permission to use.
class AdminSetService
diff --git a/app/services/hyrax/analytics.rb b/app/services/hyrax/analytics.rb
index b9c532f369..16d2fe3166 100644
--- a/app/services/hyrax/analytics.rb
+++ b/app/services/hyrax/analytics.rb
@@ -27,7 +27,7 @@ def self.load_from_yaml
new yaml.fetch('analytics')
end
- REQUIRED_KEYS = %w(app_name app_version privkey_path privkey_secret client_email).freeze
+ REQUIRED_KEYS = %w[app_name app_version privkey_path privkey_secret client_email].freeze
def initialize(config)
@config = config
diff --git a/app/services/hyrax/collection_thumbnail_path_service.rb b/app/services/hyrax/collection_thumbnail_path_service.rb
index 121822d036..e74e85d8c1 100644
--- a/app/services/hyrax/collection_thumbnail_path_service.rb
+++ b/app/services/hyrax/collection_thumbnail_path_service.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Hyrax
class CollectionThumbnailPathService < Hyrax::ThumbnailPathService
class << self
diff --git a/app/services/hyrax/statistics/depositors/summary.rb b/app/services/hyrax/statistics/depositors/summary.rb
index dc9bc7fa64..1a93c4b36c 100644
--- a/app/services/hyrax/statistics/depositors/summary.rb
+++ b/app/services/hyrax/statistics/depositors/summary.rb
@@ -47,7 +47,7 @@ def query
end
def date_query
- Hyrax::QueryService.new.build_date_query(start_dt, end_dt) unless start_dt.blank?
+ Hyrax::QueryService.new.build_date_query(start_dt, end_dt) if start_dt.present?
end
end
end
diff --git a/app/services/hyrax/user_stat_importer.rb b/app/services/hyrax/user_stat_importer.rb
index b14f49b3a5..3cc9d5a00c 100644
--- a/app/services/hyrax/user_stat_importer.rb
+++ b/app/services/hyrax/user_stat_importer.rb
@@ -50,10 +50,10 @@ def process_files(stats, user, start_date)
file_ids_for_user(user).each do |file_id|
file = ::FileSet.find(file_id)
view_stats = extract_stats_for(object: file, from: FileViewStat, start_date: start_date, user: user)
- stats = tally_results(view_stats, :views, stats) unless view_stats.blank?
+ stats = tally_results(view_stats, :views, stats) if view_stats.present?
delay
dl_stats = extract_stats_for(object: file, from: FileDownloadStat, start_date: start_date, user: user)
- stats = tally_results(dl_stats, :downloads, stats) unless dl_stats.blank?
+ stats = tally_results(dl_stats, :downloads, stats) if dl_stats.present?
delay
end
end
@@ -62,7 +62,7 @@ def process_works(stats, user, start_date)
work_ids_for_user(user).each do |work_id|
work = Hyrax::WorkRelation.new.find(work_id)
work_stats = extract_stats_for(object: work, from: WorkViewStat, start_date: start_date, user: user)
- stats = tally_results(work_stats, :work_views, stats) unless work_stats.blank?
+ stats = tally_results(work_stats, :work_views, stats) if work_stats.present?
delay
end
end
diff --git a/app/services/hyrax/workflow/permission_generator.rb b/app/services/hyrax/workflow/permission_generator.rb
index a46e8021f1..8da600051a 100644
--- a/app/services/hyrax/workflow/permission_generator.rb
+++ b/app/services/hyrax/workflow/permission_generator.rb
@@ -67,7 +67,7 @@ def create_action_and_permission_for_actions(workflow_role)
def create_action_and_permission_for(action_name, workflow_role)
workflow_action = Sipity::WorkflowAction.find_or_create_by!(workflow: workflow, name: action_name)
- return unless workflow_state.present?
+ return if workflow_state.blank?
state_action = Sipity::WorkflowStateAction.find_or_create_by!(
workflow_action: workflow_action, originating_workflow_state: workflow_state
)
diff --git a/app/services/hyrax/workflow/permission_query.rb b/app/services/hyrax/workflow/permission_query.rb
index 2a6b528931..66c4bbf6df 100644
--- a/app/services/hyrax/workflow/permission_query.rb
+++ b/app/services/hyrax/workflow/permission_query.rb
@@ -153,7 +153,7 @@ def authorized_for_processing?(user:, entity:, action:)
# @param user [User]
# @return [ActiveRecord::Relation]
def scope_processing_agents_for(user:)
- return Sipity::Agent.none unless user.present?
+ return Sipity::Agent.none if user.blank?
return Sipity::Agent.none unless user.persisted?
user_agent = PowerConverter.convert_to_sipity_agent(user)
group_agents = user.groups.map do |g|
diff --git a/app/services/hyrax/workflow/workflow_action_service.rb b/app/services/hyrax/workflow/workflow_action_service.rb
index 01411262e2..735c347161 100644
--- a/app/services/hyrax/workflow/workflow_action_service.rb
+++ b/app/services/hyrax/workflow/workflow_action_service.rb
@@ -25,12 +25,12 @@ def run
protected
def update_sipity_workflow_state
- return true unless action.resulting_workflow_state_id.present?
+ return true if action.resulting_workflow_state_id.blank?
subject.entity.update!(workflow_state_id: action.resulting_workflow_state_id)
end
def create_sipity_comment
- return true unless comment_text.present?
+ return true if comment_text.blank?
Sipity::Comment.create!(entity: subject.entity, agent: subject.agent, comment: comment_text)
end
diff --git a/app/uploaders/hyrax/avatar_uploader.rb b/app/uploaders/hyrax/avatar_uploader.rb
index e88b4a0a77..04902c37e1 100644
--- a/app/uploaders/hyrax/avatar_uploader.rb
+++ b/app/uploaders/hyrax/avatar_uploader.rb
@@ -11,6 +11,6 @@ class Hyrax::AvatarUploader < CarrierWave::Uploader::Base
end
def extension_whitelist
- %w(jpg jpeg png gif bmp tif tiff)
+ %w[jpg jpeg png gif bmp tif tiff]
end
end
diff --git a/app/views/hyrax/base/show.json.jbuilder b/app/views/hyrax/base/show.json.jbuilder
index 7ea107dbc0..267e1a1837 100644
--- a/app/views/hyrax/base/show.json.jbuilder
+++ b/app/views/hyrax/base/show.json.jbuilder
@@ -1,2 +1,2 @@
-json.extract! @curation_concern, *[:id] + @curation_concern.class.fields.select {|f| ![:has_model].include? f}
+json.extract! @curation_concern, *[:id] + @curation_concern.class.fields.reject { |f| [:has_model].include? f }
json.version @curation_concern.etag
diff --git a/config/routes.rb b/config/routes.rb
index e92a2d63ac..5aeb808521 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -207,7 +207,7 @@
get 'help' => 'pages#show', id: 'help_page'
# Static page routes
- %w(terms zotero mendeley agreement).each do |action|
+ %w[terms zotero mendeley agreement].each do |action|
get action, controller: 'static', action: action, as: action
end
end
diff --git a/hyrax.gemspec b/hyrax.gemspec
index 30652a4296..4d2206c1d9 100644
--- a/hyrax.gemspec
+++ b/hyrax.gemspec
@@ -1,4 +1,5 @@
# -*- encoding: utf-8 -*-
+
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'hyrax/version'
@@ -7,7 +8,14 @@ Gem::Specification.new do |spec|
spec.authors = ["Justin Coyne", 'Michael J. Giarlo', "Carolyn Cole", "Matt Zumwalt", 'Jeremy Friesen', 'Trey Pendragon', 'Esmé Cowles']
spec.email = ["jcoyne85@stanford.edu", 'mjgiarlo@stanford.edu', 'cam156@psu.edu', 'matt@databindery.com', "jeremy.n.friesen@gmail.com", 'tpendragon@princeton.edu', 'escowles@ticklefish.org']
spec.description = 'Hyrax is a featureful Hydra front-end based on the latest and greatest Hydra software components.'
- spec.summary = "Hyrax is a front-end based on the robust Hydra framework, providing a user interface for common repository features. Hyrax offers the ability to create repository object types on demand, to deposit content via multiple workflows, and to describe content with flexible metadata. Numerous optional features may be turned on in the administrative dashboard or added through plugins."
+ spec.summary = <<-EOF
+ Hyrax is a front-end based on the robust Hydra framework, providing a user
+ interface for common repository features. Hyrax offers the ability to create
+ repository object types on demand, to deposit content via multiple workflows,
+ and to describe content with flexible metadata. Numerous optional features may
+ be turned on in the administrative dashboard or added through plugins.
+EOF
+
spec.homepage = "http://github.com/projecthydra-labs/hyrax"
spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
@@ -77,7 +85,7 @@ Gem::Specification.new do |spec|
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.47.0'
+ spec.add_development_dependency 'rubocop', '~> 0.48.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/lib/generators/hyrax/assets_generator.rb b/lib/generators/hyrax/assets_generator.rb
index 4c15fc2b1b..5cfb3b6d27 100644
--- a/lib/generators/hyrax/assets_generator.rb
+++ b/lib/generators/hyrax/assets_generator.rb
@@ -1,4 +1,5 @@
# -*- encoding : utf-8 -*-
+
require 'rails/generators'
class Hyrax::AssetsGenerator < Rails::Generators::Base
diff --git a/lib/generators/hyrax/clamav_generator.rb b/lib/generators/hyrax/clamav_generator.rb
index e296c5b451..261e8c4ee8 100644
--- a/lib/generators/hyrax/clamav_generator.rb
+++ b/lib/generators/hyrax/clamav_generator.rb
@@ -1,4 +1,5 @@
# -*- encoding : utf-8 -*-
+
require 'rails/generators'
class Hyrax::ClamavGenerator < Rails::Generators::Base
diff --git a/lib/generators/hyrax/config_generator.rb b/lib/generators/hyrax/config_generator.rb
index d160c3ea9a..a11ba1230d 100644
--- a/lib/generators/hyrax/config_generator.rb
+++ b/lib/generators/hyrax/config_generator.rb
@@ -1,4 +1,5 @@
# -*- encoding : utf-8 -*-
+
require 'rails/generators'
class Hyrax::ConfigGenerator < Rails::Generators::Base
diff --git a/lib/hyrax/collections/search_service.rb b/lib/hyrax/collections/search_service.rb
index 7f0ddea618..5e531c2522 100644
--- a/lib/hyrax/collections/search_service.rb
+++ b/lib/hyrax/collections/search_service.rb
@@ -31,7 +31,7 @@ def apply_gated_search(solr_parameters, _user_parameters)
user_access_filters << "#{solr_access_control_suffix(:group)}:public"
# Grant access based on user id & role
- unless @user_key.blank?
+ if @user_key.present?
# for roles
::User.group_service.roles(@user_key).each do |role|
user_access_filters << "#{solr_access_control_suffix(:group)}:#{escape_slashes(role)}"
diff --git a/lib/hyrax/engine.rb b/lib/hyrax/engine.rb
index 34c2711584..88ee636856 100644
--- a/lib/hyrax/engine.rb
+++ b/lib/hyrax/engine.rb
@@ -15,10 +15,10 @@ class Engine < ::Rails::Engine
require 'legato'
# Force these models to be added to Legato's registry in development mode
- config.eager_load_paths += %W(
+ config.eager_load_paths += %W[
#{config.root}/app/models/hyrax/download.rb
#{config.root}/app/models/hyrax/pageview.rb
- )
+ ]
config.action_dispatch.rescue_responses.merge!(
"ActiveFedora::ObjectNotFoundError" => :not_found, # We can remove this when we use ActiveFedora 11.2
@@ -85,7 +85,7 @@ class Engine < ::Rails::Engine
app.config.assets.paths << config.root.join('app', 'assets', 'images', 'site_images')
app.config.assets.precompile << /fontawesome-webfont\.(?:svg|ttf|woff)$/
- app.config.assets.precompile += %w(*.png *.jpg *.ico *.gif *.svg)
+ app.config.assets.precompile += %w[*.png *.jpg *.ico *.gif *.svg]
Sprockets::ES6.configuration = { 'modules' => 'amd', 'moduleIds' => true }
# When we upgrade to Sprockets 4, we can ditch sprockets-es6 and config AMD
diff --git a/spec/controllers/hyrax/accepts_batches_controller_spec.rb b/spec/controllers/hyrax/accepts_batches_controller_spec.rb
index 7b98315cd0..cc52ae65b4 100644
--- a/spec/controllers/hyrax/accepts_batches_controller_spec.rb
+++ b/spec/controllers/hyrax/accepts_batches_controller_spec.rb
@@ -7,8 +7,8 @@ class AcceptsBatchesController < ApplicationController
RSpec.describe AcceptsBatchesController, type: :controller do
describe 'batch' do
it 'accepts batch from parameters' do
- controller.params['batch_document_ids'] = %w(abc xyz)
- expect(controller.batch).to eq(%w(abc xyz))
+ controller.params['batch_document_ids'] = %w[abc xyz]
+ expect(controller.batch).to eq(%w[abc xyz])
end
describe ':all' do
let(:current_user) { double(user_key: 'vanessa') }
@@ -59,7 +59,7 @@ class AcceptsBatchesController < ApplicationController
end
it 'checks for empty' do
- controller.batch = %w(77826928 94120425)
+ controller.batch = %w[77826928 94120425]
expect(controller.check_for_empty_batch?).to eq(false)
controller.batch = []
expect(controller.check_for_empty_batch?).to eq(true)
diff --git a/spec/factories/file_sets.rb b/spec/factories/file_sets.rb
index f135bd50e7..50a8e5e153 100644
--- a/spec/factories/file_sets.rb
+++ b/spec/factories/file_sets.rb
@@ -29,7 +29,7 @@
initialize_with { new(id: id) }
read_groups ["public"]
resource_type ["Dissertation"]
- subject %w(lorem ipsum dolor sit amet)
+ subject %w[lorem ipsum dolor sit amet]
title ["fake_document.pdf"]
before(:create) do |fs|
fs.title = ["Fake PDF Title"]
@@ -40,7 +40,7 @@
id "fixturemp3"
end
initialize_with { new(id: id) }
- subject %w(consectetur adipisicing elit)
+ subject %w[consectetur adipisicing elit]
title ["Test Document MP3.mp3"]
read_groups ["public"]
end
@@ -52,7 +52,7 @@
resource_type ["Audio", "Dataset"]
read_groups ["public"]
title ["Fake Wav File.wav"]
- subject %w(sed do eiusmod tempor incididunt ut labore)
+ subject %w[sed do eiusmod tempor incididunt ut labore]
end
factory :file_with_work do
diff --git a/spec/features/browse_dashboard_works_spec.rb b/spec/features/browse_dashboard_works_spec.rb
index d82dd0a362..64f297319c 100644
--- a/spec/features/browse_dashboard_works_spec.rb
+++ b/spec/features/browse_dashboard_works_spec.rb
@@ -1,10 +1,10 @@
RSpec.describe "Browse Dashboard", type: :feature do
let(:user) { create(:user) }
let!(:dissertation) do
- create(:public_work, user: user, title: ["Fake PDF Title"], subject: %w(lorem ipsum dolor sit amet))
+ create(:public_work, user: user, title: ["Fake PDF Title"], subject: %w[lorem ipsum dolor sit amet])
end
let!(:mp3_work) do
- create(:public_work, user: user, title: ["Test Document MP3"], subject: %w(consectetur adipisicing elit))
+ create(:public_work, user: user, title: ["Test Document MP3"], subject: %w[consectetur adipisicing elit])
end
before do
@@ -16,7 +16,7 @@
agent_id: user.user_key)
sign_in user
- create(:public_work, user: user, title: ["Fake Wav Files"], subject: %w(sed do eiusmod tempor incididunt ut labore))
+ create(:public_work, user: user, title: ["Fake Wav Files"], subject: %w[sed do eiusmod tempor incididunt ut labore])
visit "/dashboard/my/works"
end
diff --git a/spec/helpers/hyrax_helper_spec.rb b/spec/helpers/hyrax_helper_spec.rb
index 6c0dc853c8..cda6d267b3 100644
--- a/spec/helpers/hyrax_helper_spec.rb
+++ b/spec/helpers/hyrax_helper_spec.rb
@@ -1,4 +1,5 @@
# coding: utf-8
+
def new_state
Blacklight::SearchState.new({}, CatalogController.blacklight_config)
end
diff --git a/spec/models/file_set_spec.rb b/spec/models/file_set_spec.rb
index 003afe8da5..e40d7c0e27 100644
--- a/spec/models/file_set_spec.rb
+++ b/spec/models/file_set_spec.rb
@@ -58,9 +58,9 @@
describe 'attributes' do
it 'has a set of permissions' do
- subject.read_groups = %w(group1 group2)
+ subject.read_groups = %w[group1 group2]
subject.edit_users = ['user1']
- subject.read_users = %w(user2 user3)
+ subject.read_users = %w[user2 user3]
expect(subject.permissions.map(&:to_hash)).to match_array [
{ type: 'group', access: 'read', name: 'group1' },
{ type: 'group', access: 'read', name: 'group2' },
@@ -172,7 +172,7 @@ class AltFile < ActiveFedora::Base
end
it 'supports multi-valued fields in solr' do
- subject.keyword = %w(keyword1 keyword2)
+ subject.keyword = %w[keyword1 keyword2]
expect { subject.save }.not_to raise_error
subject.delete
end
@@ -281,7 +281,7 @@ class AltFile < ActiveFedora::Base
subject.read_groups_string = 'umg/up.dlt.staff, group-3'
expect(subject.read_groups).to eq ['umg/up.dlt.staff', 'group-3']
expect(subject.edit_groups).to eq ['group-8']
- expect(subject.read_users).to eq %w(person1 person2)
+ expect(subject.read_users).to eq %w[person1 person2]
expect(subject.edit_users).to eq ['jcoyne']
end
@@ -290,7 +290,7 @@ class AltFile < ActiveFedora::Base
# 'group-7' is not eligible to be revoked
expect(subject.read_groups).to match_array ['group-2', 'group-3', 'group-7']
expect(subject.edit_groups).to eq ['group-8']
- expect(subject.read_users).to match_array %w(person1 person2)
+ expect(subject.read_users).to match_array %w[person1 person2]
expect(subject.edit_users).to eq ['jcoyne']
end
end
@@ -450,7 +450,7 @@ def paranoid_edit_permissions
describe '#to_s' do
it 'uses the provided titles' do
# The title property would return the terms in random order, so stub the behavior:
- subject.title = %w(Hello World)
+ subject.title = %w[Hello World]
expect(subject.to_s).to include 'Hello'
expect(subject.to_s).to include 'World'
end
diff --git a/spec/models/hyrax/permissions/readable_permissions_spec.rb b/spec/models/hyrax/permissions/readable_permissions_spec.rb
index 73aafc9252..3319dfd173 100644
--- a/spec/models/hyrax/permissions/readable_permissions_spec.rb
+++ b/spec/models/hyrax/permissions/readable_permissions_spec.rb
@@ -9,18 +9,18 @@ class SubjectClass
describe '#public?' do
it 'returns true for public items' do
- subject.read_groups = %w(public othergroup)
+ subject.read_groups = %w[public othergroup]
expect(subject).to be_public
end
it 'returns fale for non-public items' do
- subject.read_groups = %w(notpublic othergroup)
+ subject.read_groups = %w[notpublic othergroup]
expect(subject).not_to be_public
end
end
describe '#registered?' do
it 'returns true for registered items' do
- subject.read_groups = %w(registered othergroup)
+ subject.read_groups = %w[registered othergroup]
expect(subject).to be_registered
end
it 'returns fale for non-registered items' do
diff --git a/spec/models/hyrax/work_behavior_spec.rb b/spec/models/hyrax/work_behavior_spec.rb
index be5b9bf1f7..c667b885c6 100644
--- a/spec/models/hyrax/work_behavior_spec.rb
+++ b/spec/models/hyrax/work_behavior_spec.rb
@@ -24,7 +24,7 @@ class EssentialWork < ActiveFedora::Base
end
describe '#to_s' do
it 'uses the provided titles' do
- subject.title = %w(Hello World)
+ subject.title = %w[Hello World]
expect(subject.to_s).to include 'Hello'
expect(subject.to_s).to include 'World'
end
diff --git a/spec/support/controller_level_helpers.rb b/spec/support/controller_level_helpers.rb
index 4c746579c7..528bb1450d 100644
--- a/spec/support/controller_level_helpers.rb
+++ b/spec/support/controller_level_helpers.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module ControllerLevelHelpers
# This provides some common mock methods for view tests.
# These are normally provided by the controller.
diff --git a/spec/views/_flash_msg.html.erb_spec.rb b/spec/views/_flash_msg.html.erb_spec.rb
index 6940aa8941..64cfffe050 100644
--- a/spec/views/_flash_msg.html.erb_spec.rb
+++ b/spec/views/_flash_msg.html.erb_spec.rb
@@ -1,4 +1,5 @@
# coding: utf-8
+
RSpec.describe '/_flash_msg.html.erb', type: :view do
before do
allow(view).to receive(:flash).and_return(flash)
diff --git a/spec/views/hyrax/base/show.json.jbuilder_spec.rb b/spec/views/hyrax/base/show.json.jbuilder_spec.rb
index bad0febf9e..0a1c2b4a0a 100644
--- a/spec/views/hyrax/base/show.json.jbuilder_spec.rb
+++ b/spec/views/hyrax/base/show.json.jbuilder_spec.rb
@@ -13,7 +13,7 @@
json = JSON.parse(rendered)
expect(json['id']).to eq curation_concern.id
expect(json['title']).to match_array curation_concern.title
- expected_fields = curation_concern.class.fields.select { |f| ![:has_model, :create_date].include? f }
+ expected_fields = curation_concern.class.fields.reject { |f| [:has_model, :create_date].include? f }
expected_fields << :date_created
expected_fields.each do |field_symbol|
expect(json).to have_key(field_symbol.to_s)
diff --git a/tasks/hyrax-dev.rake b/tasks/hyrax_dev.rake
similarity index 92%
rename from tasks/hyrax-dev.rake
rename to tasks/hyrax_dev.rake
index 7818bd9abd..7b8b0e61cc 100644
--- a/tasks/hyrax-dev.rake
+++ b/tasks/hyrax_dev.rake
@@ -13,7 +13,7 @@ end
RSpec::Core::RakeTask.new(:spec)
desc 'Spin up test servers and run specs'
-task :spec_with_app_load do
+task :spec_with_app_load do
with_test_server do
Rake::Task['spec'].invoke
end
@@ -25,7 +25,7 @@ task :i18n_sorter do
locales = Dir.glob(File.expand_path('../../config/locales/**/*.yml', __FILE__))
locales.each do |locale_path|
sorted_contents = File.open(locale_path) { |f| I18nYamlSorter::Sorter.new(f).sort }
- File.open(locale_path, 'w') { |f| f << sorted_contents}
+ File.open(locale_path, 'w') { |f| f << sorted_contents }
abort("Bad I18n conversion!") unless Psych.load_file(locale_path).is_a?(Hash)
end
end
|
---|