Skip to content

Commit

Permalink
Update rubocop ~> to 0.60.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Nov 2, 2018
1 parent 908fab0 commit a5d8605
Show file tree
Hide file tree
Showing 30 changed files with 94 additions and 89 deletions.
40 changes: 24 additions & 16 deletions .rubocop.yml
Expand Up @@ -10,8 +10,18 @@ AllCops:
- "lib/generators/blacklight/templates/**/*"
- "blacklight.gemspec"

Rails:
Enabled: true
# engine_cart block includes conditional, not duplication
Bundler/DuplicatedGem:
Exclude:
- 'Gemfile'

# engine_cart block is following default Rails order
Bundler/OrderedGems:
Exclude:
- 'Gemfile'

Layout/IndentationConsistency:
EnforcedStyle: normal

Metrics/BlockLength:
Exclude:
Expand All @@ -29,28 +39,26 @@ Metrics/LineLength:
Exclude:
- 'spec/**/*'

Style/StringLiterals:
Naming/HeredocDelimiterNaming:
Enabled: false

Layout/IndentationConsistency:
EnforcedStyle: normal
Naming/PredicateName:
NamePrefixBlacklist:
- is_

Rails:
Enabled: true

Rails/OutputSafety:
Enabled: false

# https://github.com/rubocop-hq/rubocop/issues/6439
Style/AccessModifierDeclarations:
Enabled: false

Style/MissingRespondToMissing:
Exclude:
- 'lib/blacklight/nested_open_struct_with_hash_access.rb'

# engine_cart block includes conditional, not duplication
Bundler/DuplicatedGem:
Exclude:
- 'Gemfile'

# engine_cart block is following default Rails order
Bundler/OrderedGems:
Exclude:
- 'Gemfile'

Naming/HeredocDelimiterNaming:
Style/StringLiterals:
Enabled: false
81 changes: 25 additions & 56 deletions .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-07-26 14:07:15 -0700 using RuboCop version 0.56.0.
# on 2018-10-31 21:34:01 -0500 using RuboCop version 0.60.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -110,13 +110,6 @@ Layout/SpaceAfterComma:
- 'app/views/catalog/index.atom.builder'
- 'app/views/catalog/opensearch.xml.builder'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceAroundOperators:
Exclude:
- 'app/views/catalog/index.atom.builder'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Expand Down Expand Up @@ -184,23 +177,23 @@ Lint/ParenthesesAsGroupedExpression:
- 'spec/lib/blacklight/search_state_spec.rb'
- 'spec/models/blacklight/solr/repository_spec.rb'

# Offense count: 3
# Offense count: 2
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'spec/models/blacklight/configuration_spec.rb'
- 'spec/models/blacklight/solr/search_builder_spec.rb'

# Offense count: 1
Lint/UselessComparison:
Exclude:
- 'spec/models/blacklight/document/active_model_shim_spec.rb'

# Offense count: 59
# Offense count: 57
Metrics/AbcSize:
Max: 49

# Offense count: 2
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 30

Expand All @@ -218,8 +211,8 @@ Metrics/ClassLength:
Metrics/CyclomaticComplexity:
Max: 12

# Offense count: 48
# Configuration parameters: CountComments.
# Offense count: 46
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 35

Expand All @@ -238,26 +231,18 @@ Metrics/PerceivedComplexity:
Max: 14

# Offense count: 4
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Exclude:
- 'app/helpers/blacklight/blacklight_helper_behavior.rb'
- 'app/helpers/blacklight/render_partials_helper_behavior.rb'
- 'app/models/concerns/blacklight/document/semantic_fields.rb'
- 'lib/blacklight/solr/response.rb'

# Offense count: 8
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
NamePrefixBlacklist:
- is_

# Offense count: 14
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at
# AllowedNames: io, id, to, by, on, in, at, ip, db
Naming/UncommunicativeMethodParamName:
Exclude:
- 'app/models/blacklight/facet_paginator.rb'
Expand All @@ -279,14 +264,6 @@ Naming/VariableNumber:
- 'spec/views/catalog/_index.html.erb_spec.rb'
- 'spec/views/catalog/_show.html.erb_spec.rb'

# Offense count: 3
# Cop supports --auto-correct.
Performance/RegexpMatch:
Exclude:
- 'app/helpers/blacklight/url_helper_behavior.rb'
- 'lib/blacklight/configuration/fields.rb'
- 'lib/blacklight/solr/search_builder_behavior.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
Expand Down Expand Up @@ -316,7 +293,7 @@ RSpec/BeforeAfterAll:
- 'spec/models/blacklight/document/sms_spec.rb'
- 'spec/models/blacklight/solr/document_spec.rb'

# Offense count: 71
# Offense count: 70
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
RSpec/ContextWording:
Expand All @@ -332,7 +309,7 @@ RSpec/EmptyExampleGroup:
Exclude:
- 'spec/models/blacklight/solr/search_builder_spec.rb'

# Offense count: 120
# Offense count: 126
# Configuration parameters: Max.
RSpec/ExampleLength:
Enabled: false
Expand All @@ -346,19 +323,17 @@ RSpec/ExpectInHook:
- 'spec/helpers/blacklight/suggest_helper_behavior_spec.rb'
- 'spec/helpers/catalog_helper_spec.rb'

# Offense count: 7
# Offense count: 5
# Configuration parameters: CustomTransform, IgnoreMethods.
RSpec/FilePath:
Exclude:
- 'spec/controllers/blacklight/catalog/component_configuration_spec.rb'
- 'spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb'
- 'spec/models/blacklight/solr/search_builder_spec.rb'
- 'spec/presenters/index_presenter_spec.rb'
- 'spec/presenters/pipeline_spec.rb'
- 'spec/presenters/show_presenter_spec.rb'
- 'spec/presenters/thumbnail_presenter_spec.rb'

# Offense count: 179
# Offense count: 194
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Enabled: false
Expand All @@ -377,33 +352,32 @@ RSpec/MessageChain:
- 'spec/presenters/blacklight/show_presenter_spec.rb'
- 'spec/views/shared/_user_util_links.html.erb_spec.rb'

# Offense count: 52
# Offense count: 62
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 325
# Offense count: 339
# Configuration parameters: AggregateFailuresByDefault.
RSpec/MultipleExpectations:
Max: 16

# Offense count: 337
# Offense count: 326
RSpec/NamedSubject:
Enabled: false

# Offense count: 40
RSpec/NestedGroups:
Max: 5

# Offense count: 10
# Offense count: 8
RSpec/RepeatedDescription:
Exclude:
- 'spec/features/search_results_spec.rb'
- 'spec/helpers/blacklight/facets_helper_behavior_spec.rb'
- 'spec/helpers/catalog_helper_spec.rb'
- 'spec/models/blacklight/solr/search_builder_spec.rb'
- 'spec/presenters/blacklight/show_presenter_spec.rb'

# Offense count: 4
RSpec/RepeatedExample:
Expand All @@ -424,8 +398,8 @@ RSpec/SubjectStub:
- 'spec/lib/blacklight/search_state_spec.rb'
- 'spec/services/blacklight/search_service_spec.rb'

# Offense count: 110
# Configuration parameters: IgnoreSymbolicNames.
# Offense count: 117
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Enabled: false

Expand Down Expand Up @@ -529,6 +503,7 @@ Style/ConditionalAssignment:
- 'lib/blacklight/solr/response/spelling.rb'

# Offense count: 1
# Configuration parameters: AllowCoercion.
Style/DateTime:
Exclude:
- 'spec/models/blacklight/solr/search_builder_spec.rb'
Expand Down Expand Up @@ -581,12 +556,12 @@ Style/HashSyntax:
Exclude:
- 'app/helpers/blacklight/url_helper_behavior.rb'

# Offense count: 40
# Offense count: 39
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Enabled: false

# Offense count: 123
# Offense count: 124
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
Expand All @@ -612,9 +587,9 @@ Style/MutableConstant:
Exclude:
- 'lib/blacklight/solr/request.rb'

# Offense count: 10
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
Expand Down Expand Up @@ -643,12 +618,6 @@ Style/PercentLiteralDelimiters:
- 'lib/blacklight/engine.rb'
- 'lib/blacklight/solr/request.rb'

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

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand Down Expand Up @@ -683,7 +652,7 @@ Style/Semicolon:
- 'spec/models/blacklight/solr/repository_spec.rb'
- 'spec/views/catalog/_paginate_compact.html.erb_spec.rb'

# Offense count: 30
# Offense count: 32
# Cop supports --auto-correct.
# Configuration parameters: MinSize.
# SupportedStyles: percent, brackets
Expand Down
1 change: 1 addition & 0 deletions app/builders/blacklight/action_builder.rb
Expand Up @@ -16,6 +16,7 @@ def initialize(klass, name, opts)
# doesn't already exist or the `:define_method` option is not `false`
def build
return if skip?

callback = opts.fetch(:callback, nil).inspect
validator = opts.fetch(:validator, nil).inspect
klass.class_eval <<EORUBY, __FILE__, __LINE__ + 1
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/concerns/blacklight/catalog.rb
Expand Up @@ -56,6 +56,7 @@ def show
# get a single document from the index
def raw
raise(ActionController::RoutingError, 'Not Found') unless blacklight_config.raw_endpoint.enabled

_, @document = search_service.fetch(params[:id])
render json: @document
end
Expand All @@ -79,6 +80,7 @@ def track
def facet
@facet = blacklight_config.facet_fields[params[:id]]
raise ActionController::RoutingError, 'Not Found' unless @facet

@response = search_service.facet_field_response(@facet.key)
@display_facet = @response.aggregations[@facet.field]
@pagination = facet_paginator(@facet, @display_facet)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/concerns/blacklight/controller.rb
Expand Up @@ -129,6 +129,7 @@ def require_user_authentication_provider
# When a user logs in, transfer any saved searches or bookmarks to the current_user
def transfer_guest_user_actions_to_current_user
return unless respond_to?(:current_user) && respond_to?(:guest_user) && current_user && guest_user

current_user_searches = current_user.searches.pluck(:query_params)
current_user_bookmarks = current_user.bookmarks.pluck(:document_id)

Expand Down
1 change: 1 addition & 0 deletions app/controllers/concerns/blacklight/search_context.rb
Expand Up @@ -74,6 +74,7 @@ def start_new_search_session?
def agent_is_crawler?
crawler_proc = blacklight_config.crawler_detector
return false if crawler_proc.nil? || current_user.present?

crawler_proc.call(request)
end

Expand Down
1 change: 1 addition & 0 deletions app/helpers/blacklight/blacklight_helper_behavior.rb
Expand Up @@ -42,6 +42,7 @@ def render_page_title
# @option options [Array<String>] :exclude array of format shortnames to not include in the output
def render_link_rel_alternates(document = @document, options = {})
return if document.nil?

presenter(document).link_rel_alternates(options)
end

Expand Down
5 changes: 3 additions & 2 deletions app/helpers/blacklight/facets_helper_behavior.rb
Expand Up @@ -38,6 +38,7 @@ def render_facet_partials fields = facet_field_names, options = {}
def render_facet_limit(display_facet, options = {})
field_config = facet_configuration_for_field(display_facet.name)
return unless should_render_facet?(display_facet, field_config)

options = options.dup
options[:partial] ||= facet_partial_name(display_facet)
options[:layout] ||= "facet_layout" unless options.key?(:layout)
Expand Down Expand Up @@ -77,6 +78,7 @@ def render_facet_item(facet_field, item)
# @return [Boolean]
def should_render_facet? display_facet, facet_config = nil
return false if display_facet.items.blank?

# display when show is nil or true
facet_config ||= facet_configuration_for_field(display_facet.name)
should_render_field?(facet_config, display_facet)
Expand Down Expand Up @@ -223,8 +225,7 @@ def facet_display_value field, item
facet_config.query[value][:label]
elsif facet_config.date
localization_options = facet_config.date == true ? {} : facet_config.date

l(value.to_datetime, localization_options)
l(Time.zone.parse(value), localization_options)
else
value
end
Expand Down

0 comments on commit a5d8605

Please sign in to comment.