Skip to content

Commit

Permalink
Standardize the style for spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Nov 1, 2016
1 parent acf1bcc commit e5883e4
Show file tree
Hide file tree
Showing 71 changed files with 271 additions and 421 deletions.
138 changes: 0 additions & 138 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,141 +324,3 @@ Style/PredicateName:
# Cop supports --auto-correct.
Style/RedundantSelf:
Enabled: false

# Offense count: 16
# Cop supports --auto-correct.
Style/SpaceAfterComma:
Exclude:
- 'app/controllers/concerns/blacklight/search_context.rb'
- 'app/helpers/blacklight/configuration_helper_behavior.rb'
- 'app/helpers/blacklight/facets_helper_behavior.rb'
- 'app/helpers/blacklight/render_constraints_helper_behavior.rb'
- 'app/models/concerns/blacklight/document/dublin_core.rb'
- 'lib/blacklight/configuration/fields.rb'
- 'lib/blacklight/parameters.rb'
- 'lib/blacklight/solr/response/facets.rb'
- 'lib/blacklight/solr/search_builder_behavior.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleInsidePipes, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundBlockParameters:
Exclude:
- 'app/controllers/concerns/blacklight/catalog.rb'
- 'app/models/concerns/blacklight/document/extensions.rb'

# Offense count: 23
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundEqualsInParameterDefault:
Exclude:
- 'app/controllers/concerns/blacklight/search_helper.rb'
- 'app/helpers/blacklight/blacklight_helper_behavior.rb'
- 'app/helpers/blacklight/component_helper_behavior.rb'
- 'app/helpers/blacklight/configuration_helper_behavior.rb'
- 'app/helpers/blacklight/facets_helper_behavior.rb'
- 'app/helpers/blacklight/url_helper_behavior.rb'
- 'app/models/concerns/blacklight/document.rb'
- 'app/presenters/blacklight/index_presenter.rb'
- 'app/presenters/blacklight/show_presenter.rb'
- 'lib/blacklight/search_state.rb'

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Style/SpaceAroundOperators:
Exclude:
- 'app/controllers/concerns/blacklight/request_builders.rb'
- 'app/helpers/blacklight/blacklight_helper_behavior.rb'
- 'app/helpers/blacklight/url_helper_behavior.rb'
- 'lib/blacklight/configuration.rb'
- 'lib/blacklight/solr/repository.rb'
- 'lib/blacklight/solr/response/spelling.rb'
- 'tasks/blacklight.rake'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceBeforeBlockBraces:
Exclude:
- 'lib/blacklight/solr/response.rb'

# Offense count: 15
# Cop supports --auto-correct.
Style/SpaceBeforeComma:
Exclude:
- 'app/helpers/blacklight/search_history_constraints_helper_behavior.rb'
- 'lib/generators/blacklight/controller_generator.rb'
- 'lib/generators/blacklight/document_generator.rb'
- 'lib/generators/blacklight/install_generator.rb'
- 'lib/generators/blacklight/search_builder_generator.rb'
- 'lib/generators/blacklight/user_generator.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Style/SpaceBeforeFirstArg:
Exclude:
- 'lib/generators/blacklight/controller_generator.rb'
- 'lib/generators/blacklight/document_generator.rb'
- 'lib/generators/blacklight/search_builder_generator.rb'

# Offense count: 15
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
Style/SpaceInsideBlockBraces:
Exclude:
- 'app/controllers/concerns/blacklight/bookmarks.rb'
- 'app/controllers/concerns/blacklight/controller.rb'
- 'app/controllers/concerns/blacklight/search_helper.rb'
- 'app/helpers/blacklight/catalog_helper_behavior.rb'
- 'app/helpers/blacklight/facets_helper_behavior.rb'
- 'lib/blacklight/search_builder.rb'
- 'lib/blacklight/solr/request.rb'
- 'lib/blacklight/solr/response.rb'
- 'lib/blacklight/solr/response/group.rb'

# Offense count: 8
# Cop supports --auto-correct.
Style/SpaceInsideBrackets:
Exclude:
- 'lib/blacklight/configuration/fields.rb'

# Offense count: 19
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
# SupportedStyles: space, no_space, compact
Style/SpaceInsideHashLiteralBraces:
Exclude:
- 'app/controllers/concerns/blacklight/bookmarks.rb'
- 'app/controllers/concerns/blacklight/catalog.rb'
- 'app/controllers/concerns/blacklight/search_context.rb'
- 'app/helpers/blacklight/render_constraints_helper_behavior.rb'
- 'app/helpers/blacklight/url_helper_behavior.rb'
- 'app/models/concerns/blacklight/document/extensions.rb'
- 'lib/blacklight/configuration.rb'
- 'lib/blacklight/solr/repository.rb'

# Offense count: 18
# Cop supports --auto-correct.
Style/SpaceInsideParens:
Exclude:
- 'app/controllers/concerns/blacklight/search_context.rb'
- 'app/helpers/blacklight/catalog_helper_behavior.rb'
- 'app/helpers/blacklight/facets_helper_behavior.rb'
- 'app/helpers/blacklight/search_history_constraints_helper_behavior.rb'
- 'app/helpers/blacklight/url_helper_behavior.rb'
- 'app/models/concerns/blacklight/document/dublin_core.rb'
- 'app/models/concerns/blacklight/document/extensions.rb'
- 'app/models/record_mailer.rb'
- 'lib/blacklight/search_state.rb'
- 'lib/blacklight/solr/search_builder_behavior.rb'

# Offense count: 190
# Cop supports --auto-correct.
Style/TrailingWhitespace:
Enabled: false
4 changes: 2 additions & 2 deletions app/controllers/bookmarks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
class BookmarksController < CatalogController
class BookmarksController < CatalogController
include Blacklight::Bookmarks
end
end
4 changes: 2 additions & 2 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
class CatalogController < ApplicationController
class CatalogController < ApplicationController
include Blacklight::Catalog
end
end
6 changes: 3 additions & 3 deletions app/controllers/concerns/blacklight/bookmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def index
@document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(deprecated_document_list, "The @document_list instance variable is now deprecated and will be removed in Blacklight 8.0")

respond_to do |format|
format.html { }
format.html {}
format.rss { render :layout => false }
format.atom { render :layout => false }
format.json do
Expand Down Expand Up @@ -84,7 +84,7 @@ def create
end

if request.xhr?
success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }}) : render(plain: "", status: "500")
success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(plain: "", status: "500")
else
if @bookmarks.any? && success
flash[:notice] = I18n.t('blacklight.bookmarks.add.success', :count => @bookmarks.length)
Expand All @@ -108,7 +108,7 @@ def destroy

if bookmark && bookmark.delete && bookmark.destroyed?
if request.xhr?
render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }})
render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } })
elsif respond_to? :redirect_back
redirect_back fallback_location: bookmarks_path, notice: I18n.t('blacklight.bookmarks.remove.success')
else
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/blacklight/catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def additional_response_formats format
# Render additional export formats for the show action, as provided by
# the document extension framework. See _Blacklight::Document::Export_
def additional_export_formats(document, format)
document.export_formats.each_key do | format_name |
document.export_formats.each_key do |format_name|
format.send(format_name.to_sym) { render body: document.export_as(format_name), layout: false }
end
end
Expand Down Expand Up @@ -199,7 +199,7 @@ def search_action_url options = {}

# Email Action (this will render the appropriate view on GET requests and process the form and send the email on POST requests)
def email_action documents
mail = RecordMailer.email_record(documents, {:to => params[:to], :message => params[:message]}, url_options)
mail = RecordMailer.email_record(documents, { :to => params[:to], :message => params[:message] }, url_options)
if mail.respond_to? :deliver_now
mail.deliver_now
else
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/concerns/blacklight/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def discard_flash_if_xhr
#
def has_user_authentication_provider?
respond_to? :current_user
end
end

def require_user_authentication_provider
raise ActionController::RoutingError, 'Not Found' unless has_user_authentication_provider?
Expand All @@ -141,12 +141,12 @@ def transfer_guest_user_actions_to_current_user
current_user_searches = current_user.searches.pluck(:query_params)
current_user_bookmarks = current_user.bookmarks.pluck(:document_id)

guest_user.searches.reject { |s| current_user_searches.include?(s.query_params)}.each do |s|
guest_user.searches.reject { |s| current_user_searches.include?(s.query_params) }.each do |s|
current_user.searches << s
s.save!
end

guest_user.bookmarks.reject { |b| current_user_bookmarks.include?(b.document_id)}.each do |b|
guest_user.bookmarks.reject { |b| current_user_bookmarks.include?(b.document_id) }.each do |b|
current_user.bookmarks << b
b.save!
end
Expand All @@ -156,7 +156,7 @@ def transfer_guest_user_actions_to_current_user
end

##
# To handle failed authorization attempts, redirect the user to the
# To handle failed authorization attempts, redirect the user to the
# login form and persist the current request uri as a parameter
def access_denied
# send the user home if the access was previously denied by the same
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/concerns/blacklight/request_builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ def previous_and_next_document_params(index, window = 1)

if index > 0
solr_params[:start] = index - window # get one before
solr_params[:rows] = 2*window + 1 # and one after
solr_params[:rows] = 2 * window + 1 # and one after
else
solr_params[:start] = 0 # there is no previous doc
solr_params[:rows] = 2*window # but there should be one after
solr_params[:rows] = 2 * window # but there should be one after
end

solr_params[:fl] = '*'
solr_params[:facet] = false
solr_params
end

DEFAULT_FACET_LIMIT = 10

# Look up facet limit for given facet_field. Will look at config, and
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/concerns/blacklight/search_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ module Blacklight::SearchContext

# The following code is executed when someone includes blacklight::catalog::search_session in their
# own controller.
included do
included do
helper_method :current_search_session, :search_session
end

module ClassMethods
# Save the submitted search parameters in the search session
def record_search_parameters opts = { only: :index}
def record_search_parameters opts = { only: :index }
before_action :set_current_search_session, opts
end
end
Expand Down Expand Up @@ -64,9 +64,9 @@ def start_new_search_session?
end

def find_or_initialize_search_session_from_params params
params_copy = params.reject { |k,v| blacklisted_search_session_params.include?(k.to_sym) || v.blank? }
params_copy = params.reject { |k, v| blacklisted_search_session_params.include?(k.to_sym) || v.blank? }

return if params_copy.reject { |k,_v| [:action, :controller].include? k.to_sym }.blank?
return if params_copy.reject { |k, _v| [:action, :controller].include? k.to_sym }.blank?

saved_search = searches_from_history.find { |x| x.query_params == params_copy }

Expand All @@ -82,7 +82,7 @@ def add_to_search_history search
session[:history].unshift(search.id)

if session[:history].length > blacklight_config.search_history_window
session[:history] = session[:history].slice(0, blacklight_config.search_history_window )
session[:history] = session[:history].slice(0, blacklight_config.search_history_window)
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/concerns/blacklight/search_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# = Search Field blacklight_configuration Hash =
# [:key]
# "title", required, unique key used in search URLs to specify search_field
# "title", required, unique key used in search URLs to specify search_field
# [:label]
# "Title", # user-displayable label, optional, if not supplied :key.titlecase will be used
# [:qt]
Expand All @@ -18,16 +18,16 @@
# { :qf => "$something" } # optional hash of additional parameters that will be passed using Solr LocalParams syntax, that can use dollar sign to reference other solr variables.
# [:include_in_simple_select]
# false. Defaults to true, but you can set to false to have a search field defined for deep-links or BL extensions, but not actually included in the HTML select for simple search choice.
#
#
# Optionally you can supply a :key, which is what Blacklight will use
# to identify this search field in HTTP query params. If no :key is
# supplied, one will be computed from the :label. If that will
# result in a collision of keys, you should supply one explicitly.
# result in a collision of keys, you should supply one explicitly.
#
##
module Blacklight::SearchFields
# Looks up search field config list from blacklight_config[:search_fields], and
# 'normalizes' all field config hashes using normalize_config method.
# 'normalizes' all field config hashes using normalize_config method.
def search_field_list
blacklight_config.search_fields.values
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/blacklight/search_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get_facet_field_response(facet_field, user_params = params || {}, extra_cont

# Get the previous and next document from a search result
# @return [Blacklight::Solr::Response, Array<Blacklight::SolrDocument>] the solr response and a list of the first and last document
def get_previous_and_next_documents_for_search(index, request_params, extra_controller_params={})
def get_previous_and_next_documents_for_search(index, request_params, extra_controller_params = {})
p = previous_and_next_document_params(index)
query = search_builder.with(request_params).start(p.delete(:start)).rows(p.delete(:rows)).merge(extra_controller_params).merge(p)
response = repository.search(query)
Expand All @@ -112,7 +112,7 @@ def get_opensearch_response(field = nil, request_params = params || {}, extra_co
query = search_builder.with(request_params).merge(solr_opensearch_params(field)).merge(extra_controller_params)
response = repository.search(query)

[response.params[:q], response.documents.flat_map {|doc| doc[field] }.uniq]
[response.params[:q], response.documents.flat_map { |doc| doc[field] }.uniq]
end

##
Expand Down
10 changes: 5 additions & 5 deletions app/helpers/blacklight/blacklight_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def render_page_title
# @option options [Boolean] :unique ensures only one link is output for every
# content type, e.g. as required by atom
# @option options [Array<String>] :exclude array of format shortnames to not include in the output
def render_link_rel_alternates(document=@document, options = {})
def render_link_rel_alternates(document = @document, options = {})
return if document.nil?
presenter(document).link_rel_alternates(options)
end
Expand Down Expand Up @@ -67,7 +67,7 @@ def extra_body_classes
# Render the search navbar
# @return [String]
def render_search_bar
render :partial=>'catalog/search_form'
render :partial => 'catalog/search_form'
end

##
Expand Down Expand Up @@ -160,7 +160,7 @@ def render_document_show_field_label *args
#
# @param [SolrDocument] document
# @return [String]
def document_heading document=nil
def document_heading document = nil
document ||= @document
presenter(document).heading
end
Expand All @@ -172,7 +172,7 @@ def document_heading document=nil
# @see #document_heading
# @param [SolrDocument] document
# @return [String]
def document_show_html_title document=nil
def document_show_html_title document = nil
document ||= @document

presenter(document).html_title
Expand Down Expand Up @@ -201,7 +201,7 @@ def render_document_heading(*args)
#
# @param [Hash] query_params the query parameters to check
# @return [Symbol]
def document_index_view_type query_params=params
def document_index_view_type query_params = params
view_param = query_params[:view]
view_param ||= session[:preferred_view]
if view_param && document_index_views.keys.include?(view_param.to_sym)
Expand Down
Loading

0 comments on commit e5883e4

Please sign in to comment.