Skip to content

Commit

Permalink
changes bc of upgrade to rubocop 0.52.*
Browse files Browse the repository at this point in the history
  • Loading branch information
Julie Allinson committed Mar 21, 2018
1 parent f6d207f commit 8eea0f2
Show file tree
Hide file tree
Showing 92 changed files with 406 additions and 229 deletions.
8 changes: 7 additions & 1 deletion .rubocop.yml
Expand Up @@ -85,6 +85,9 @@ Rails/FilePath:
Exclude:
- 'spec/routing/**/*'

RSpec/ContextWording:
Enabled: false

RSpec/ExpectActual:
Exclude:
- 'spec/routing/**/*'
Expand All @@ -110,8 +113,11 @@ RSpec/NestedGroups:
RSpec/MultipleExpectations:
Enabled: false

RSpec/ScatteredLet:
Enabled: false

Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'
- 'lib/tasks/*.rake'
- 'app/controllers/catalog_controller.rb'
- 'app/controllers/catalog_controller.rb'
40 changes: 40 additions & 0 deletions .rubocop_todo.yml
Expand Up @@ -23,6 +23,16 @@ RSpec/SubjectStub:
Exclude:
- 'spec/models/solr_endpoint_spec.rb'

RSpec/BeforeAfterAll:
Exclude:
- 'spec/tasks/rake_spec.rb'
- 'spec/models/hyku/group_spec.rb'
- 'spec/models/uploaded_file_spec.rb'

RSpec/IteratedExpectation:
Exclude:
- 'spec/tasks/rake_spec.rb'

# Offense count: 10
RSpec/LeadingSubject:
Exclude:
Expand Down Expand Up @@ -50,3 +60,33 @@ RSpec/LetSetup:
RSpec/NestedGroups:
Exclude:
- 'spec/services/iiif_authorization_service_spec.rb'

RSpec/ExpectInHook:
Exclude:
- 'spec/controllers/sites_controller_spec.rb'
- 'spec/models/uploaded_file_spec.rb'

Style/MixinUsage:
Exclude:
- 'spec/support/devise.rb'
- 'spec/features/create_image_spec.rb'

Naming/HeredocDelimiterNaming:
Exclude:
- 'spec/jobs/import_work_from_purl_job_spec.rb'

Style/FormatStringToken:
Exclude:
- 'app/models/account.rb'
- 'spec/models/account_spec.rb'

Rails/HasManyOrHasOneDependent:
Exclude:
- 'app/models/endpoint.rb'

FactoryBot/DynamicAttributeDefinedStatically:
Exclude:
- 'spec/factories/users.rb'

Rails/ApplicationJob:
Enabled: false
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -48,7 +48,7 @@ group :development, :test do
gem 'solr_wrapper', '~> 1.0'

gem 'rubocop', '~> 0.50', '<= 0.52.1'
gem 'rubocop-rspec', '~> 1.10.0'
gem 'rubocop-rspec', '~> 1.23.0'
end

group :test do
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Expand Up @@ -745,8 +745,8 @@ GEM
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-rspec (1.10.0)
rubocop (>= 0.42.0)
rubocop-rspec (1.23.0)
rubocop (>= 0.52.1)
ruby-box (1.15.0)
addressable
json
Expand Down Expand Up @@ -940,7 +940,7 @@ DEPENDENCIES
rspec
rspec-rails (>= 3.6.0)
rubocop (~> 0.50, <= 0.52.1)
rubocop-rspec (~> 1.10.0)
rubocop-rspec (~> 1.23.0)
sass-rails (~> 5.0)
scss_lint
secure_headers
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/groups_controller.rb
@@ -1,6 +1,6 @@
module Admin
class GroupsController < AdminController
before_action :load_group, only: [:edit, :update, :remove, :destroy]
before_action :load_group, only: %i[edit update remove destroy]

# rubocop:disable Metrics/AbcSize
def index
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/catalog_controller.rb
Expand Up @@ -14,7 +14,7 @@ def self.modified_field
end

configure_blacklight do |config|
config.view.gallery.partials = [:index_header, :index]
config.view.gallery.partials = %i[index_header index]
config.view.masonry.partials = [:index]
config.view.slideshow.partials = [:index]

Expand All @@ -30,7 +30,7 @@ def self.modified_field
config.search_builder_class = Hyrax::CatalogSearchBuilder

# Show gallery view
config.view.gallery.partials = [:index_header, :index]
config.view.gallery.partials = %i[index_header index]
config.view.slideshow.partials = [:index]

## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/proprietor/accounts_controller.rb
Expand Up @@ -83,8 +83,8 @@ def ensure_admin!
def account_params
params.require(:account).permit(:name, :cname, :title,
admin_emails: [],
solr_endpoint_attributes: [:id, :url],
fcrepo_endpoint_attributes: [:id, :url, :base_path])
solr_endpoint_attributes: %i[id url],
fcrepo_endpoint_attributes: %i[id url base_path])
end
end
end
2 changes: 1 addition & 1 deletion app/forms/hyrax/generic_work_form.rb
Expand Up @@ -4,7 +4,7 @@ module Hyrax
class GenericWorkForm < Hyrax::Forms::WorkForm
self.model_class = ::GenericWork
include HydraEditor::Form::Permissions
self.terms += [:resource_type, :rendering_ids]
self.terms += %i[resource_type rendering_ids]

def secondary_terms
super - [:rendering_ids]
Expand Down
2 changes: 1 addition & 1 deletion app/forms/hyrax/image_form.rb
Expand Up @@ -3,7 +3,7 @@
module Hyrax
class ImageForm < Hyrax::Forms::WorkForm
self.model_class = ::Image
self.terms += [:resource_type, :extent, :rendering_ids]
self.terms += %i[resource_type extent rendering_ids]

def secondary_terms
super - [:rendering_ids]
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/cleanup_account_job.rb
Expand Up @@ -25,7 +25,7 @@ def cleanup_solr(account)

def cleanup_database(account)
Apartment::Tenant.drop(account.tenant)
rescue
rescue StandardError
nil # ignore if account.tenant missing
end
end
22 changes: 11 additions & 11 deletions app/jobs/import_work_from_purl_job.rb
Expand Up @@ -53,17 +53,17 @@ def process_attributes(attributes)
end

class_attribute :attributes_to_keep
self.attributes_to_keep = [:title,
:description,
:subject,
:language,
:resource_type,
:location,
:rights,
:visibility,
:id,
:collection,
:files]
self.attributes_to_keep = %i[title
description
subject
language
resource_type
location
rights
visibility
id
collection
files]

def process_collection(attributes)
# rename :collection to :member_of_collection_ids
Expand Down
8 changes: 4 additions & 4 deletions app/models/ability.rb
Expand Up @@ -2,10 +2,10 @@ class Ability
include Hydra::Ability
include Hyrax::Ability

self.ability_logic += [
:everyone_can_create_curation_concerns,
:group_permissions,
:superadmin_permissions
self.ability_logic += %i[
everyone_can_create_curation_concerns
group_permissions
superadmin_permissions
]

# Define any customized permissions here.
Expand Down
2 changes: 1 addition & 1 deletion app/models/account.rb
@@ -1,5 +1,5 @@
# Customer organization account
class Account < ActiveRecord::Base
class Account < ApplicationRecord
# @param [String] piece the tenant piece of the canonical name
# @return [String] full canonical name
# @raise [ArgumentError] if piece contains a trailing dot
Expand Down
2 changes: 1 addition & 1 deletion app/models/endpoint.rb
@@ -1,3 +1,3 @@
class Endpoint < ActiveRecord::Base
class Endpoint < ApplicationRecord
has_one :account
end
4 changes: 2 additions & 2 deletions app/models/fcrepo_endpoint.rb
@@ -1,5 +1,5 @@
class FcrepoEndpoint < Endpoint
store :options, accessors: [:url, :base_path]
store :options, accessors: %i[url base_path]

def switch!
ActiveFedora::Fedora.register(options.symbolize_keys)
Expand All @@ -11,7 +11,7 @@ def self.reset!

def ping
ActiveFedora::Fedora.instance.connection.head('/').response.success?
rescue
rescue StandardError
false
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/redis_endpoint.rb
Expand Up @@ -12,7 +12,7 @@ def self.reset!

def ping
redis_instance.ping
rescue
rescue StandardError
false
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/role.rb
@@ -1,4 +1,4 @@
class Role < ActiveRecord::Base
class Role < ApplicationRecord
has_and_belongs_to_many :users, join_table: :users_roles

belongs_to :resource,
Expand All @@ -10,5 +10,5 @@ class Role < ActiveRecord::Base

scopify

scope :site, ->() { where(resource_type: "Site") }
scope :site, -> { where(resource_type: "Site") }
end
1 change: 1 addition & 0 deletions app/models/search_builder.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class SearchBuilder < Blacklight::SearchBuilder
include Blacklight::Solr::SearchBuilderBehavior
include Hydra::AccessControlsEnforcement
Expand Down
2 changes: 1 addition & 1 deletion app/models/site.rb
@@ -1,4 +1,4 @@
class Site < ActiveRecord::Base
class Site < ApplicationRecord
resourcify

validates :application_name, presence: true, allow_nil: true
Expand Down
1 change: 1 addition & 0 deletions app/models/solr_document.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class SolrDocument
include Blacklight::Solr::Document
include Blacklight::Gallery::OpenseadragonSolrDocument
Expand Down
2 changes: 1 addition & 1 deletion app/models/solr_endpoint.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class SolrEndpoint < Endpoint
store :options, accessors: [:url, :collection]
store :options, accessors: %i[url collection]

def connection
# We remove the adapter, otherwise RSolr 2 will try to use it as a Faraday middleware
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
@@ -1,4 +1,4 @@
class User < ActiveRecord::Base
class User < ApplicationRecord
# Includes lib/rolify from the rolify gem
rolify
# Connects this user object to Hydra behaviors.
Expand Down
Expand Up @@ -74,7 +74,7 @@ def metadata_fields
model = solr_document['has_model_ssim'].first

"#{ns}::#{model}Form".constantize.required_fields
rescue
rescue StandardError
[]
end

Expand Down
4 changes: 2 additions & 2 deletions app/presenters/hyku/menu_presenter.rb
Expand Up @@ -4,7 +4,7 @@ class MenuPresenter < Hyrax::MenuPresenter
# Returns true if the current controller happens to be one of the controllers that deals
# with settings. This is used to keep the parent section on the sidebar open.
def settings_section?
%w(appearances content_blocks labels features pages).include?(controller_name)
%w[appearances content_blocks labels features pages].include?(controller_name)
end

# Returns true if the current controller happens to be one of the controllers that deals
Expand All @@ -23,7 +23,7 @@ def roles_and_permissions_section?
# Returns true if the current controller happens to be one of the controllers that deals
# with repository activity This is used to keep the parent section on the sidebar open.
def repository_activity_section?
%w(admin dashboard status).include?(controller_name)
%w[admin dashboard status].include?(controller_name)
end

# Returns true if we ought to show the user the 'Configuration' section
Expand Down
2 changes: 1 addition & 1 deletion app/uploaders/banner_image_uploader.rb
@@ -1,6 +1,6 @@
class BannerImageUploader < CarrierWave::Uploader::Base
# Define valid extensions for site banner image
def extension_white_list
%w(jpg jpeg png gif)
%w[jpg jpeg png gif]
end
end
2 changes: 1 addition & 1 deletion lib/importer/csv_importer.rb
Expand Up @@ -33,7 +33,7 @@ def parser
def factory_class(model)
return model if model.is_a?(Class)
if model.empty?
$stderr.puts 'ERROR: No model was specified'
warn 'ERROR: No model was specified'
exit(1) # rubocop:disable Rails/Exit
end
return Factory.for(model.to_s) if model.respond_to?(:to_s)
Expand Down
10 changes: 5 additions & 5 deletions lib/importer/csv_parser.rb
Expand Up @@ -37,7 +37,7 @@ def validate_headers(row)
# e.g. For an author, author_type might be 'Person'.
difference.delete_if { |h| h.match(type_header_pattern) }

raise "Invalid headers: #{difference.join(', ')}" unless difference.blank?
raise "Invalid headers: #{difference.join(', ')}" if difference.present?

validate_header_pairs(row)
row
Expand All @@ -57,16 +57,16 @@ def validate_header_pairs(row)
errors << "Invalid headers: '#{header}' column must be immediately followed by '#{field_name}' column."
end
end
raise errors.join(', ') unless errors.blank?
raise errors.join(', ') if errors.present?
end
# rubocop:enable Metrics/MethodLength

def valid_headers
GenericWork.attribute_names + %w(id type file) + collection_headers
GenericWork.attribute_names + %w[id type file] + collection_headers
end

def collection_headers
%w(collection_id collection_title collection_accession_number)
%w[collection_id collection_title collection_accession_number]
end

def attributes(headers, row)
Expand Down Expand Up @@ -143,7 +143,7 @@ def update_typed_field(header, val, processed)
end

def update_collection(collection, field, val)
val = [val] unless %w(admin_policy_id id).include? field
val = [val] unless %w[admin_policy_id id].include? field
collection[field.to_sym] = val
end

Expand Down
2 changes: 1 addition & 1 deletion lib/importer/factory/object_factory.rb
Expand Up @@ -119,7 +119,7 @@ def file_paths

# Regardless of what the MODS Parser gives us, these are the properties we are prepared to accept.
def permitted_attributes
klass.properties.keys.map(&:to_sym) + [:id, :edit_users, :edit_groups, :read_groups, :visibility]
klass.properties.keys.map(&:to_sym) + %i[id edit_users edit_groups read_groups visibility]
end
end
end
Expand Down
6 changes: 1 addition & 5 deletions lib/importer/mods_parser.rb
Expand Up @@ -101,11 +101,7 @@ def description
def language
mods.language.languageTerm.map do |term|
uris = term.valueURI.map { |uri| RDF::URI.new(uri) }
if uris.present?
uris
else
term.text
end
uris.presence || term.text
end
end

Expand Down

0 comments on commit 8eea0f2

Please sign in to comment.