Skip to content

Commit

Permalink
Update rubocop to 0.48.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Apr 10, 2017
1 parent dcf004f commit 6f91873
Show file tree
Hide file tree
Showing 57 changed files with 121 additions and 92 deletions.
25 changes: 25 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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'
Expand All @@ -45,6 +67,9 @@ Style/NumericPredicate:
Exclude:
- 'app/controllers/concerns/hyrax/file_sets_controller_behavior.rb'

Style/SymbolArray:
Enabled: false

Style/WordArray:
Enabled: false

Expand Down
13 changes: 0 additions & 13 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/actors/hyrax/actors/apply_permission_template_actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions app/actors/hyrax/actors/file_set_actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions app/actors/hyrax/actors/interpret_visibility_actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/hyrax/parent_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<span class=\"citation-author\">#{text}</span>"
end
# Get Pub Date
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 << "<span class=\"citation-author\">#{format_authors(authors)}</span>"
# setup title
title_info = setup_title_info(work)
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/hyrax/citations_behaviors/title_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/hyrax/collections_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions app/helpers/hyrax/hyrax_helper_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8

module Hyrax
module HyraxHelperBehavior
include Hyrax::CitationsBehavior
Expand Down
6 changes: 3 additions & 3 deletions app/indexers/hyrax/basic_metadata_indexer.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/hyrax/collection_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/hyrax/file_set/belongs_to_works.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/hyrax/proxy_deposit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions app/models/concerns/hyrax/solr_document/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions app/models/concerns/hyrax/solr_document_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- encoding : utf-8 -*-

module Hyrax
module SolrDocumentBehavior
extend ActiveSupport::Concern
Expand Down
2 changes: 1 addition & 1 deletion app/models/hyrax/permission_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/models/hyrax/permission_template_access.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Hyrax
class PermissionTemplateAccess < ActiveRecord::Base
self.table_name = 'permission_template_accesses'
Expand Down
2 changes: 1 addition & 1 deletion app/models/proxy_deposit_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/presenters/hyrax/admin_set_options_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/hyrax/admin_stats_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/hyrax/characterization_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 6f91873

Please sign in to comment.