Skip to content

Commit

Permalink
🧹 Rubocop'd lengths and other low hanging fruit
Browse files Browse the repository at this point in the history
Various length metrics were disabled in this commit.  Also other various
cops that were easy to fix.
Kirk Wang committed Dec 14, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 6859d73 commit 59626ef
Showing 34 changed files with 102 additions and 17 deletions.
2 changes: 2 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

# rubocop:disable Metrics/ClassLength, Metrics/BlockLength
class CatalogController < ApplicationController
include BlacklightAdvancedSearch::Controller
include BlacklightRangeLimit::ControllerOverride
@@ -449,3 +450,4 @@ def show
render json: @document.to_h
end
end
# rubocop:enable Metrics/ClassLength, Metrics/BlockLength
2 changes: 2 additions & 0 deletions app/controllers/concerns/hyrax/works_controller_behavior.rb
Original file line number Diff line number Diff line change
@@ -333,6 +333,7 @@ def decide_layout
# hopefully this can be refactored to be more reusable.
#
# Add uploaded_files to the parameters received by the actor.
# rubocop:disable Metrics/MethodLength
def attributes_for_actor
raw_params = params[hash_key_for_curation_concern]
attributes = if raw_params
@@ -360,6 +361,7 @@ def attributes_for_actor
browse_everything_urls
attributes
end
# rubocop:enable Metrics/MethodLength

def after_create_response
respond_to do |wants|
2 changes: 2 additions & 0 deletions app/controllers/hyku/invitations_controller.rb
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ def after_invite_path_for(_resource)

# override the standard invite so that accounts are added properly
# if they already exist on another tenant and invited if they do not
# rubocop:disable Metrics/AbcSize
def create
authorize! :grant_admin_role, User if params[:user][:role] == ::RolesService::ADMIN_ROLE
self.resource = User.find_by(email: params[:user][:email]) || invite_resource
@@ -27,6 +28,7 @@ def create
respond_with resource, location: after_invite_path_for(current_inviter, resource)
end
end
# rubocop:enable Metrics/AbcSize

protected

2 changes: 2 additions & 0 deletions app/controllers/hyrax/contact_form_controller.rb
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ def new
@announcement_text = ContentBlock.for(:announcement)
end

# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def create
# not spam, form is valid, and captcha is valid
@captcha.values[:category] = params[:contact_form][:category]
@@ -65,6 +66,7 @@ def create
rescue RuntimeError => exception
handle_create_exception(exception)
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize

def handle_create_exception(exception)
logger.error("Contact form failed to send: #{exception.inspect}")
15 changes: 11 additions & 4 deletions app/controllers/hyrax/dashboard/collections_controller.rb
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ def edit
form
collection_type
# Gets original filename of an uploaded thumbnail. See #update
if ::SolrDocument.find(@collection.id).thumbnail_path.include? "uploaded_collection_thumbnails" and uploaded_thumbnail?
if ::SolrDocument.find(@collection.id).thumbnail_path.include? "uploaded_collection_thumbnails" && uploaded_thumbnail?
@thumbnail_filename = File.basename(uploaded_thumbnail_files.reject { |f| File.basename(f).include? @collection.id }.first)
end
end
@@ -209,17 +209,21 @@ def collection
# Renders a JSON response with a list of files in this collection
# This is used by the edit form to populate the thumbnail_id dropdown
# OVERRIDE: Hyrax 2.9 to use work titles for collection thumbnail select & to add an option to reset to the default thumbnail
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def files
params[:q] = '' unless params[:q]
builder = Hyrax::CollectionMemberSearchBuilder.new(scope: self, collection: collection, search_includes_models: :works)
# get the default work image because we do not want to show any works in this dropdown that only have the default work image. this indicates that they have no files attached, and will throw an error if selected.
# get the default work image because we do not want to show any works in this
# dropdown that only have the default work image. this indicates that they have
# no files attached, and will throw an error if selected.
default_work_thumbnail_path = Site.instance.default_work_image&.url.presence || ActionController::Base.helpers.image_path('default.png')
work_with_no_files_thumbnail_path = ActionController::Base.helpers.image_path('work.png')
response = repository.search(builder.where(params[:q]).query)
# only return the works that have files, because these will be the only ones with a viable thumbnail
result = response.documents.reject do |document|
document["thumbnail_path_ss"].blank? || document["thumbnail_path_ss"].include?(default_work_thumbnail_path) || document["thumbnail_path_ss"].include?(work_with_no_files_thumbnail_path)
end .map do |document|
document["thumbnail_path_ss"].blank? || document["thumbnail_path_ss"].include?(default_work_thumbnail_path) ||
document["thumbnail_path_ss"].include?(work_with_no_files_thumbnail_path)
end.map do |document|
{ id: document["thumbnail_path_ss"].split('/').last.gsub(/\?.*/, ''), text: document["title_tesim"].first }
end
reset_thumbnail_option = {
@@ -229,6 +233,7 @@ def files
result << reset_thumbnail_option
render json: result
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize

private

@@ -704,6 +709,7 @@ def after_update_errors(errors) # for valkyrie
end
end

# rubocop:disable Metrics/MethodLength
def process_uploaded_thumbnail(uploaded_file)
dir_name = UploadedCollectionThumbnailPathService.upload_dir(@collection)
saved_file = Rails.root.join(dir_name, uploaded_file.original_filename)
@@ -723,6 +729,7 @@ def process_uploaded_thumbnail(uploaded_file)
File.chmod(0o664, "#{dir_name}/#{@collection.id}_thumbnail.jpg")
File.chmod(0o664, "#{dir_name}/#{@collection.id}_card.jpg")
end
# rubocop:enable Metrics/MethodLength

## OVERRIDE Hyrax 3.4.0 handle file locations
def process_file_location(f)
2 changes: 2 additions & 0 deletions app/controllers/hyrax/homepage_controller.rb
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ def search_builder_class
layout 'homepage'
helper Hyrax::ContentBlockHelper

# rubocop:disable Metrics/MethodLength
def index
# BEGIN copy Hyrax prime's Hyrax::HomepageController#index
@presenter = presenter_class.new(current_ability, collections)
@@ -77,6 +78,7 @@ def index
document_export_formats(format)
end
end
# rubocop:enable Metrics/MethodLength

def browserconfig; end

2 changes: 2 additions & 0 deletions app/controllers/proprietor/users_controller.rb
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@ def ensure_admin!
authorize! :read, :admin_dashboard
end

# rubocop:disable Metrics/MethodLength
def user_params
# remove blank passwords
params[:user].delete(:password) if params[:user] && params[:user][:password].blank?
@@ -117,6 +118,7 @@ def user_params
:preferred_locale,
role_ids: [])
end
# rubocop:enable Metrics/MethodLength

def find_user
@user ||= ::User.from_url_component(params[:id])
2 changes: 2 additions & 0 deletions app/forms/hyrax/forms/admin/appearance.rb
Original file line number Diff line number Diff line change
@@ -371,6 +371,7 @@ def update!
end

# A list of parameters that are related to customizations
# rubocop:disable Metrics/MethodLength
def self.customization_params
%i[
body_font
@@ -400,6 +401,7 @@ def self.customization_params
default_work_image_text
]
end
# rubocop:enable Metrics/MethodLength

def font_import_body_url
body = body_font.split('|').first.to_s.tr(" ", "+")
2 changes: 2 additions & 0 deletions app/models/account.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

# Customer organization account
# rubocop:disable Metrics/ClassLength
class Account < ApplicationRecord
include AccountEndpoints
include AccountSettings
@@ -144,3 +145,4 @@ def cache_api?
cache_api
end
end
# rubocop:enable Metrics/ClassLength
6 changes: 6 additions & 0 deletions app/models/concerns/account_settings.rb
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
# All settings have a presedence order as follows
# Per Tenant Setting > ENV['HYKU_SETTING_NAME'] > ENV['HYRAX_SETTING_NAME'] > default

# rubocop:disable Metrics/ModuleLength
module AccountSettings
extend ActiveSupport::Concern
# rubocop:disable Metrics/BlockLength
@@ -79,6 +80,7 @@ def setting(name, args)
end
end

# rubocop:disable Metrics/MethodLength
def solr_collection_options
{
async: nil,
@@ -99,6 +101,7 @@ def solr_collection_options
snitch: nil
}
end
# rubocop:disable Metrics/MethodLength
end
# rubocop:enable Metrics/BlockLength

@@ -154,6 +157,7 @@ def set_smtp_settings
)
end

# rubocop:disable Metrics/AbcSize
def reload_library_config
Hyrax.config do |config|
config.contact_email = contact_email
@@ -188,4 +192,6 @@ def reload_library_config
ActionMailer::Base.default_url_options ||= {}
ActionMailer::Base.default_url_options[:protocol] = 'https'
end
# rubocop:enable Metrics/AbcSize
end
# rubocop:enable Metrics/ModuleLength
4 changes: 3 additions & 1 deletion app/models/concerns/account_switch.rb
Original file line number Diff line number Diff line change
@@ -3,9 +3,10 @@
module AccountSwitch
extend ActiveSupport::Concern

DOMAIN_REGEXP = %r{^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,8}(:[0-9]{1,5})?(/.*)?$}ix
DOMAIN_REGEXP = %r{^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,8}(:[0-9]{1,5})?(/.*)?$}ix.freeze

class_methods do
# rubocop:disable Metrics/MethodLength
def switch!(cname_or_name_or_account)
account = if cname_or_name_or_account.is_a?(Account)
cname_or_name_or_account
@@ -26,6 +27,7 @@ def switch!(cname_or_name_or_account)
Rails.logger.info "It looks like we're in single tenant mode. No tenant found for #{cname_or_name_or_account}"
end
end
# rubocop:enable Metrics/MethodLength
end

def switch!(cname_or_name_or_account)
6 changes: 6 additions & 0 deletions app/models/concerns/hyrax/ability/collection_ability.rb
Original file line number Diff line number Diff line change
@@ -3,10 +3,13 @@
# OVERRIDE Hyrax v3.4.2 Alter abilities for Groups with Roles feature
module Hyrax
module Ability
# rubocop:disable Metrics/ModuleLength
module CollectionAbility
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/BlockLength
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/PerceivedComplexity
# rubocop:disable Metrics/CyclomaticComplexity
def collection_abilities
models = [Hyrax::PcdmCollection, Hyrax.config.collection_class].uniq
if admin?
@@ -157,6 +160,9 @@ def collection_roles
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/BlockLength
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/PerceivedComplexity
# rubocop:enable Metrics/CyclomaticComplexity
end
# rubocop:enable Metrics/ModuleLength
end
end
2 changes: 2 additions & 0 deletions app/models/concerns/hyrax/ability/solr_document_ability.rb
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
module Hyrax
module Ability
module SolrDocumentAbility
# rubocop:disable Metrics/MethodLength
def solr_document_abilities
if admin?
can [:manage], ::SolrDocument
@@ -27,6 +28,7 @@ def solr_document_abilities
end
end
end
# rubocop:enable Metrics/MethodLength
end
end
end
2 changes: 2 additions & 0 deletions app/models/content_block.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

# OVERRIDE Hyrax v3.4.0 to add home_text to registry
# and getter/setter methods - Adding themes
# rubocop:disable Metrics/ClassLength
class ContentBlock < ApplicationRecord
# The keys in this registry are "public" names for collaborator
# objects, and the values are reserved names of ContentBlock
@@ -159,3 +160,4 @@ def default_terms_text
end
end
end
# rubocop:enable Metrics/ClassLength
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ def image_content
image_content_v3(url)
end

# rubocop:disable Metrics/MethodLength
def video_display_content(_url, label = '')
width = solr_document.width&.try(:to_i) || 320
height = solr_document.height&.try(:to_i) || 240
@@ -55,6 +56,7 @@ def video_display_content(_url, label = '')
format: solr_document.mime_type
)
end
# rubocop:enable Metrics/MethodLength

def audio_display_content(_url, label = '')
duration = conformed_duration_in_seconds
2 changes: 2 additions & 0 deletions app/services/hyrax/collection_types/create_service.rb
Original file line number Diff line number Diff line change
@@ -208,6 +208,7 @@ def self.create_user_collection_type
# The same values can be retrieved directly from a passed in ability.
# If calling from Abilities, pass the ability.
# If you try to get the ability from the user, you end up in an infinite loop.
# rubocop:disable Metrics/MethodLength
def self.add_default_participants(collection_type_id)
return unless collection_type_id
default_participants = [{ agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE,
@@ -233,6 +234,7 @@ def self.add_default_participants(collection_type_id)
end
add_participants(collection_type_id, default_participants)
end
# rubocop:enable Metrics/MethodLength

##
# @api public
12 changes: 7 additions & 5 deletions app/services/hyrax/workflow/permission_query.rb
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ def scope_permitted_workflow_actions_available_for_current_state(user:, entity:)
# @param role [Object] that can be converted into a Sipity::Role
# @return [ActiveRecord::Relation<Sipity::Agent>] augmented with
#
def scope_agents_associated_with_entity_and_role(entity:, role:) # rubocop:disable Metrics/AbcSize
def scope_agents_associated_with_entity_and_role(entity:, role:) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
entity = Sipity::Entity(entity)
role = Sipity::Role(role)

@@ -196,7 +196,7 @@ def scope_processing_agents_for(user:)
#
# @return [ActiveRecord::Relation<Sipity::Entity>]
#
def scope_entities_for_the_user(user:) # rubocop:disable Metrics/AbcSize
def scope_entities_for_the_user(user:) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
entities = Sipity::Entity.arel_table
workflow_state_actions = Sipity::WorkflowStateAction.arel_table
workflow_states = Sipity::WorkflowState.arel_table
@@ -251,7 +251,7 @@ def scope_entities_for_the_user(user:) # rubocop:disable Metrics/AbcSize
# @param entity an object that can be converted into a Sipity::Entity
# @return [ActiveRecord::Relation<User>]
#
def scope_users_for_entity_and_roles(entity:, roles:) # rubocop:disable Metrics/AbcSize
def scope_users_for_entity_and_roles(entity:, roles:) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
entity = Sipity::Entity(entity)
role_ids = Array.wrap(roles).map { |role| Sipity::Role(role).id }
user_polymorphic_type = ::User.base_class
@@ -347,7 +347,7 @@ def scope_processing_workflow_roles_for_user_and_workflow(user:, workflow:)
# @param user [User]
# @param entity an object that can be converted into a Sipity::Entity
# @return [ActiveRecord::Relation<Sipity::WorkflowRole>]
def scope_processing_workflow_roles_for_user_and_entity_specific(user:, entity:)
def scope_processing_workflow_roles_for_user_and_entity_specific(user:, entity:) # rubocop:disable Metrics/MethodLength
entity = Sipity::Entity(entity)
agent_scope = scope_processing_agents_for(user: user)

@@ -366,6 +366,7 @@ def scope_processing_workflow_roles_for_user_and_entity_specific(user:, entity:)
)
)
end
# rubocop:enable Metrics/MethodLength

# @api private
#
@@ -386,7 +387,7 @@ def scope_processing_workflow_roles_for_user_and_entity_specific(user:, entity:)
# @param entity an object that can be converted into a Sipity::Entity
# @return [ActiveRecord::Relation<Sipity::WorkflowStateAction>]
#
def scope_permitted_entity_workflow_state_actions(user:, entity:)
def scope_permitted_entity_workflow_state_actions(user:, entity:) # rubocop:disable Metrics/MethodLength
entity = Sipity::Entity(entity)
workflow_state_actions = Sipity::WorkflowStateAction
permissions = Sipity::WorkflowStateActionPermission
@@ -408,6 +409,7 @@ def scope_permitted_entity_workflow_state_actions(user:, entity:)
)
)
end
# rubocop:enable Metrics/MethodLength

# @api public
#
8 changes: 8 additions & 0 deletions app/services/roles_service.rb
Original file line number Diff line number Diff line change
@@ -98,6 +98,7 @@ def create_default_hyrax_groups_with_roles!
# Because each collection role has some level of access to every Collection within a tenant,
# creating a Hyrax::PermissionTemplateAccess record (combined with Ability#user_groups)
# means all Collections will show up in Blacklight / Solr queries.
# rubocop:disable Metrics/MethodLength
def create_collection_accesses!
Collection.find_each do |c|
pt = Hyrax::PermissionTemplate.find_or_create_by!(source_id: c.id)
@@ -130,9 +131,11 @@ def create_collection_accesses!
c.reset_access_controls! if pt.access_grants.count != original_access_grants_count
end
end
# rubocop:enable Metrics/MethodLength

# Creating a Hyrax::PermissionTemplateAccess record (combined with Ability#user_groups)
# will allow Works in all AdminSets to show up in Blacklight / Solr queries.
# rubocop:disable Metrics/MethodLength
def create_admin_set_accesses!
AdminSet.find_each do |as|
pt = Hyrax::PermissionTemplate.find_or_create_by!(source_id: as.id)
@@ -165,6 +168,7 @@ def create_admin_set_accesses!
as.reset_access_controls! if pt.access_grants.count != original_access_grants_count
end
end
# rubocop:enable Metrics/MethodLength

# Because some of the collection roles have access to every Collection within a tenant, create a
# Hyrax::CollectionTypeParticipant record for them on every Hyrax::CollectionType (except the AdminSet)
@@ -247,6 +251,7 @@ def prune_stale_guest_users
end
end

# rubocop:disable Metrics/MethodLength
def seed_superadmin!
return 'Seed data should not be used in the production environment' if Rails.env.production? || Rails.env.staging?

@@ -270,7 +275,9 @@ def seed_superadmin!

user
end
# rubocop:enable Metrics/MethodLength

# rubocop:disable Metrics/MethodLength
def seed_qa_users!
return 'Seed data should not be used in the production environment' if Rails.env.production? || Rails.env.staging?

@@ -298,5 +305,6 @@ def seed_qa_users!
end
end
end
# rubocop:enable Metrics/MethodLength
end
end
4 changes: 2 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -63,10 +63,10 @@ class Application < Rails::Application

# Add this line to load the lib folder first because we need
# IiifPrint::SplitPdfs::AdventistPagesToJpgsSplitter
config.autoload_paths.unshift("#{Rails.root}/lib")
config.autoload_paths.unshift(Rails.root.join('lib'))

# Add the middleware directory to the eager load paths
config.eager_load_paths << "#{Rails.root}/app/middleware"
config.eager_load_paths << Rails.root.join('app', 'middleware')

##
# @api public
5 changes: 4 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

# rubocop:disable Metrics/BlockLength
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

@@ -18,7 +20,7 @@
config.consider_all_requests_local = true

# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true

config.cache_store = :memory_store
@@ -72,3 +74,4 @@
# adding `.` wildcard to allow for subdomains
config.hosts << "." + ENV['HYKU_ADMIN_HOST']
end
# rubocop:enable Metrics/BlockLength
3 changes: 3 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

# rubocop:disable Metrics/BlockLength
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

@@ -114,3 +116,4 @@
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
# rubocop:enable Metrics/BlockLength
2 changes: 2 additions & 0 deletions config/initializers/bulkrax.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

if ENV.fetch('HYKU_BULKRAX_ENABLED', 'true') == 'true'
# rubocop:disable Metrics/BlockLength
Bulkrax.setup do |config|
# Add local parsers
# config.parsers += [
@@ -109,6 +110,7 @@
# Properties that should not be used in imports/exports. They are reserved for use by Hyrax.
# config.reserved_properties += ['my_field']
end
# rubocop:enable Metrics/BlockLength

Bulkrax::CreateRelationshipsJob.update_child_records_works_file_sets = true
end
2 changes: 2 additions & 0 deletions config/initializers/devise.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
# rubocop:disable Metrics/BlockLength
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
@@ -331,3 +332,4 @@
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = '/my_engine/users/auth'
end
# rubocop:enable Metrics/BlockLength
2 changes: 2 additions & 0 deletions config/initializers/file_set_derivatives_overrides.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
# This file contains overrides to Hyrax::FileSetDerivativesService to increase the size of thumbnails

# Hyrax v3.5.0
# rubocop:disable Metrics/BlockLength
Hyrax::FileSetDerivativesService.class_eval do
# @see https://github.com/samvera/hydra-derivatives/blob/main/lib/hydra/derivatives/processors/video/config.rb#L59
DEFAULT_VIDEO_SIZE = '320x240'
@@ -58,3 +59,4 @@ def create_video_derivatives(filename)
url: derivative_url('mp4') }])
end
end
# rubocop:enable Metrics/BlockLength
4 changes: 3 additions & 1 deletion config/initializers/hyrax.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
# Set nested indexer to graph by default. Remove after Hyrax 4.0 upgrade
ENV['HYRAX_USE_SOLR_GRAPH_NESTING'].present? || ENV['HYRAX_USE_SOLR_GRAPH_NESTING'] = "true"

# rubocop:disable Metrics/BlockLength
Hyrax.config do |config|
config.register_curation_concern :generic_work
# Injected via `rails g hyrax:work Image`
@@ -124,7 +125,7 @@

# Location on local file system where derivatives will be stored.
# If you use a multi-server architecture, this MUST be a shared volume.
config.derivatives_path = ENV['HYRAX_DERIVATIVES_PATH'].presence || File.join(Rails.root, 'tmp', 'derivatives')
config.derivatives_path = ENV['HYRAX_DERIVATIVES_PATH'].presence || Rails.root.join('tmp', 'derivatives').to_s

# Should schema.org microdata be displayed?
# config.display_microdata = true
@@ -189,6 +190,7 @@
uri.sub(/\Ahttp:/, 'https:')
end
end
# rubocop:enable Metrics/BlockLength

Date::DATE_FORMATS[:standard] = "%m/%d/%Y"

2 changes: 1 addition & 1 deletion config/initializers/redis_config.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true
config = YAML.load(ERB.new(IO.read(Rails.root + 'config' + 'redis.yml')).result)[Rails.env].with_indifferent_access
config = YAML.safe_load(ERB.new(IO.read(Rails.root + 'config' + 'redis.yml')).result)[Rails.env].with_indifferent_access
sentinels = config[:sentinel] && config[:sentinel][:host].present? ? { sentinels: [config[:sentinel]] } : {}
redis_config = config.except(:sentinel).merge(thread_safe: true).merge(sentinels)
require 'redis'
2 changes: 1 addition & 1 deletion config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
if ENV.fetch('HYRAX_ACTIVE_JOB_QUEUE', 'sidekiq') == 'sidekiq'

config = YAML.load(ERB.new(IO.read(Rails.root + 'config' + 'redis.yml')).result)[Rails.env].with_indifferent_access
config = YAML.safe_load(ERB.new(IO.read(Rails.root + 'config' + 'redis.yml')).result)[Rails.env].with_indifferent_access
redis_config = config.merge(thread_safe: true)

Sidekiq.configure_server do |s|
2 changes: 2 additions & 0 deletions config/initializers/simple_form_bootstrap.rb
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

# Use this setup block to configure all options available in SimpleForm.

# rubocop:disable Metrics/BlockLength
SimpleForm.setup do |config|
config.error_notification_class = 'alert alert-danger'
config.button_class = 'btn btn-default'
@@ -150,3 +151,4 @@
time: :multi_select
}
end
# rubocop:enable Metrics/BlockLength
3 changes: 3 additions & 0 deletions lib/importer/csv_parser.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

module Importer
# rubocop:disable Metrics/ClassLength
class CSVParser
include Enumerable

@@ -74,6 +75,7 @@ def attributes(headers, row)
end
end

# rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
def extract_field(header, val, processed)
return unless val
case header
@@ -103,6 +105,7 @@ def extract_field(header, val, processed)
end
end
end
# rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity

# Faking a typed field for now.
# TODO: support other types of contributors
2 changes: 2 additions & 0 deletions lib/importer/factory/object_factory.rb
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
require 'importer/log_subscriber'
module Importer
module Factory
# rubocop:disable Metrics/ClassLength
class ObjectFactory
extend ActiveModel::Callbacks
define_model_callbacks :save, :create
@@ -153,5 +154,6 @@ def permitted_attributes
klass.properties.keys.map(&:to_sym) + %i[id edit_users edit_groups read_groups visibility]
end
end
# rubocop:enable Metrics/ClassLength
end
end
2 changes: 2 additions & 0 deletions lib/importer/mods_parser.rb
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ def common_attributes
.merge(relations)
end

# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def description
{
title: untyped_title,
@@ -97,6 +98,7 @@ def description
description_standard: mods.record_info.descriptionStandard.map(&:text)
}
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize

def language
mods.language.languageTerm.map do |term|
4 changes: 4 additions & 0 deletions lib/oai/provider/metadata_format/hyku_dublin_core.rb
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ def initialize
end

# Override to strip namespace and header out
# rubocop:disable Metrics/MethodLength
def encode(model, record)
xml = Builder::XmlMarkup.new
map = model.respond_to?("map_#{prefix}") ? model.send("map_#{prefix}") : {}
@@ -41,7 +42,9 @@ def encode(model, record)
end
xml.target!
end
# rubocop:enable Metrics/MethodLength

# rubocop:disable Metrics/MethodLength
def add_public_file_urls(xml, record)
return if record[:file_set_ids_ssim].blank?

@@ -61,6 +64,7 @@ def add_public_file_urls(xml, record)
xml.tag! 'file_url', file_download_path
end
end
# rubocop:enable Metrics/MethodLength

def header_specification
{
2 changes: 2 additions & 0 deletions lib/oai/provider/model_decorator.rb
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ module OAI
module Provider
module ModelDecorator
# Map Qualified Dublin Core (Terms) fields to PALNI/PALCI fields
# rubocop:disable Metrics/MethodLength
def map_oai_hyku
{
abstract: :abstract,
@@ -33,6 +34,7 @@ def map_oai_hyku
title: :title
}
end
# rubocop:enable Metrics/MethodLength
end
end
end
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ module FindIdsByModelDecorator
# @param ids [Enumerable<#to_s>, Symbol]
#
# @return [Enumerable<Valkyrie::ID>]
def find_ids_by_model(model:, ids: :all)
def find_ids_by_model(model:, ids: :all) # rubocop:disable Metrics/MethodLength
return enum_for(:find_ids_by_model, model: model, ids: ids) unless block_given?
model_name = ModelRegistry.lookup(model).model_name

@@ -37,6 +37,7 @@ def find_ids_by_model(model:, ids: :all)
)['response']
end
end
# rubocop:enable Metrics/MethodLength
end
end
end

0 comments on commit 59626ef

Please sign in to comment.