Skip to content

Commit

Permalink
Upgrade rubocop to 0.85.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne authored and mejackreed committed Aug 28, 2020
1 parent cb921ef commit 2a881c1
Show file tree
Hide file tree
Showing 55 changed files with 265 additions and 132 deletions.
46 changes: 44 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
require: rubocop-rspec
require:
- rubocop-rspec
- rubocop-rails


inherit_from:
- .rubocop_todo.yml

AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.4
TargetRubyVersion: 2.5
Exclude:
- "lib/generators/blacklight/templates/**/*"
- "blacklight.gemspec"
Expand Down Expand Up @@ -62,3 +65,42 @@ Style/StringLiterals:

Style/MethodDefParentheses:
Enabled: false

Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true

Layout/SpaceAroundMethodCallOperator:
Enabled: true

Lint/DeprecatedOpenSSLConstant:
Enabled: true

Lint/MixedRegexpCaptureTypes:
Enabled: true

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

Style/ExponentialNotation:
Enabled: true

Style/HashEachMethods:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

Style/RedundantRegexpCharacterClass:
Enabled: true

Style/RedundantRegexpEscape:
Enabled: true

Style/SlicingWithRange:
Enabled: true
105 changes: 44 additions & 61 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-08-10 16:59:54 UTC using RuboCop version 0.89.1.
# on 2020-08-28 22:51:36 UTC using RuboCop version 0.89.1.
# 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 All @@ -12,22 +12,6 @@ Capybara/CurrentPathExpectation:
Exclude:
- 'spec/features/alternate_controller_spec.rb'

# Offense count: 20
Capybara/VisibilityMatcher:
Exclude:
- 'spec/features/facets_spec.rb'
- 'spec/features/search_filters_spec.rb'
- 'spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb'
- 'spec/helpers/blacklight_helper_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/ArgumentAlignment:
Exclude:
- 'app/views/catalog/_document.atom.builder'

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
Expand All @@ -51,11 +35,11 @@ Layout/EmptyLineAfterMagicComment:

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
# Configuration parameters: AllowAliasSyntax, AllowedMethods.
# AllowedMethods: alias_method, public, protected, private
Layout/EmptyLinesAroundAttributeAccessor:
Exclude:
- 'app/views/catalog/index.atom.builder'
- 'app/presenters/blacklight/field_presenter.rb'

# Offense count: 7
# Cop supports --auto-correct.
Expand Down Expand Up @@ -125,13 +109,12 @@ Layout/SpaceAfterComma:
- 'app/views/catalog/index.atom.builder'
- 'app/views/catalog/opensearch.xml.builder'

# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceBeforeFirstArg:
Exclude:
- 'app/views/catalog/index.atom.builder'
- 'spec/models/blacklight/solr/response/facets_spec.rb'

# Offense count: 7
# Cop supports --auto-correct.
Expand Down Expand Up @@ -182,12 +165,6 @@ Lint/AmbiguousRegexpLiteral:
- 'spec/views/catalog/index.html.erb_spec.rb'
- 'spec/views/catalog/show.html.erb_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Lint/NonDeterministicRequireOrder:
Exclude:
- 'spec/spec_helper.rb'

# Offense count: 29
# Cop supports --auto-correct.
Lint/ParenthesesAsGroupedExpression:
Expand All @@ -199,12 +176,6 @@ Lint/ParenthesesAsGroupedExpression:
- 'spec/lib/blacklight/search_state_spec.rb'
- 'spec/models/blacklight/solr/repository_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Lint/SendWithMixinArgument:
Exclude:
- 'lib/blacklight/engine.rb'

# Offense count: 2
Lint/ShadowingOuterLocalVariable:
Exclude:
Expand Down Expand Up @@ -309,7 +280,7 @@ RSpec/BeforeAfterAll:
RSpec/ContextWording:
Enabled: false

# Offense count: 42
# Offense count: 55
RSpec/DescribeClass:
Enabled: false

Expand All @@ -319,12 +290,6 @@ RSpec/EmptyExampleGroup:
Exclude:
- 'spec/models/blacklight/solr/search_builder_spec.rb'

# Offense count: 108
# Cop supports --auto-correct.
# Configuration parameters: AllowConsecutiveOneLiners.
RSpec/EmptyLineAfterExample:
Enabled: false

# Offense count: 134
# Configuration parameters: Max.
RSpec/ExampleLength:
Expand All @@ -340,7 +305,7 @@ RSpec/ExpectInHook:
- 'spec/helpers/catalog_helper_spec.rb'

# Offense count: 5
# Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Configuration parameters: CustomTransform, IgnoreMethods.
RSpec/FilePath:
Exclude:
- 'spec/controllers/blacklight/catalog/component_configuration_spec.rb'
Expand Down Expand Up @@ -400,6 +365,7 @@ RSpec/MessageSpies:
- 'spec/presenters/thumbnail_presenter_spec.rb'

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

Expand All @@ -426,25 +392,16 @@ RSpec/RepeatedExample:
- 'spec/models/blacklight/solr/document_spec.rb'

# Offense count: 4
RSpec/RepeatedExampleGroupDescription:
Exclude:
- 'spec/helpers/blacklight/facets_helper_behavior_spec.rb'
- 'spec/services/blacklight/search_service_spec.rb'

# Offense count: 4
# Cop supports --auto-correct.
RSpec/ScatteredLet:
Exclude:
- 'spec/helpers/catalog_helper_spec.rb'
- 'spec/models/blacklight/solr/search_builder_spec.rb'
- 'spec/views/catalog/index.atom.builder_spec.rb'

# Offense count: 13
# Offense count: 10
RSpec/SubjectStub:
Exclude:
- 'spec/controllers/catalog_controller_spec.rb'
- 'spec/lib/blacklight/search_state_spec.rb'
- 'spec/models/blacklight/document/cache_key_spec.rb'
- 'spec/models/blacklight/search_builder_spec.rb'
- 'spec/services/blacklight/search_service_spec.rb'

Expand All @@ -458,6 +415,40 @@ RSpec/VoidExpect:
Exclude:
- 'spec/lib/blacklight/configuration/facet_field_spec.rb'

# Offense count: 8
# Cop supports --auto-correct.
Rails/ContentTag:
Exclude:
- 'app/components/blacklight/document_component.rb'
- 'app/components/blacklight/facet_item_pivot_component.rb'

# Offense count: 4
# Configuration parameters: EnforcedStyle.
# SupportedStyles: strict, flexible
Rails/Date:
Exclude:
- 'spec/models/search_spec.rb'

# Offense count: 37
# Configuration parameters: Include.
# Include: app/helpers/**/*.rb
Rails/HelperInstanceVariable:
Exclude:
- 'app/helpers/blacklight/blacklight_helper_behavior.rb'
- 'app/helpers/blacklight/catalog_helper_behavior.rb'
- 'app/helpers/blacklight/component_helper_behavior.rb'
- 'app/helpers/blacklight/facets_helper_behavior.rb'
- 'app/helpers/blacklight/render_partials_helper_behavior.rb'

# Offense count: 11
Rails/OutputSafety:
Exclude:
- 'app/helpers/blacklight/catalog_helper_behavior.rb'
- 'app/helpers/blacklight/configuration_helper_behavior.rb'
- 'app/helpers/blacklight/icon_helper_behavior.rb'
- 'app/helpers/blacklight/url_helper_behavior.rb'
- 'app/presenters/blacklight/rendering/join.rb'

# Offense count: 13
Security/Eval:
Exclude:
Expand Down Expand Up @@ -550,14 +541,6 @@ Style/GuardClause:
Style/IfUnlessModifier:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
Style/MethodDefParentheses:
Exclude:
- 'app/controllers/concerns/blacklight/bookmarks.rb'

# Offense count: 5
# Cop supports --auto-correct.
Style/MultilineIfModifier:
Expand Down
12 changes: 6 additions & 6 deletions app/components/blacklight/facet_item_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def content_from_legacy_view_helper
# @return [String]
# @private
def render_facet_value
content_tag(:span, class: "facet-label") do
tag.span(class: "facet-label") do
link_to_unless(@suppress_link, @label, @href, class: "facet-select")
end + render_facet_count
end
Expand All @@ -85,12 +85,12 @@ def render_facet_value
# @param [String] item
# @private
def render_selected_facet_value
content_tag(:span, class: "facet-label") do
content_tag(:span, @label, class: "selected") +
tag.span(class: "facet-label") do
tag.span(@label, class: "selected") +
# remove link
link_to(@href, class: "remove") do
content_tag(:span, '✖', class: "remove-icon") +
content_tag(:span, '[remove]', class: 'sr-only')
tag.span('✖', class: "remove-icon") +
tag.span('[remove]', class: 'sr-only')
end
end + render_facet_count(classes: ["selected"])
end
Expand All @@ -108,7 +108,7 @@ def render_facet_count(options = {})
return @view_context.render_facet_count(@hits, options) unless @view_context.method(:render_facet_count).owner == Blacklight::FacetsHelperBehavior || explicit_component_configuration?

classes = (options[:classes] || []) << "facet-count"
content_tag("span", t('blacklight.search.facets.count', number: number_with_delimiter(@hits)), class: classes)
tag.span(t('blacklight.search.facets.count', number: number_with_delimiter(@hits)), class: classes)
end

private
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 @@ -71,9 +71,9 @@ def track
if params[:redirect] && (params[:redirect].starts_with?('/') || params[:redirect] =~ URI::DEFAULT_PARSER.make_regexp)
uri = URI.parse(params[:redirect])
path = uri.query ? "#{uri.path}?#{uri.query}" : uri.path
redirect_to path, status: 303
redirect_to path, status: :see_other
else
redirect_to({ action: :show, id: params[:id] }, status: 303)
redirect_to({ action: :show, id: params[:id] }, status: :see_other)
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/blacklight/component_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def render_nav_actions(options = {}, &block)
def render_index_doc_actions(document, options = {})
wrapping_class = options.delete(:wrapping_class) || "index-document-functions"
rendered = render_filtered_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }.merge(options))
content_tag("div", rendered, class: wrapping_class) if rendered.present?
tag.div(rendered, class: wrapping_class) if rendered.present?
end

##
Expand All @@ -51,7 +51,7 @@ def render_index_doc_actions(document, options = {})
def render_results_collection_tools(options = {})
wrapping_class = options.delete(:wrapping_class) || "search-widgets"
rendered = render_filtered_partials(blacklight_config.view_config(document_index_view_type).collection_actions, options)
content_tag("div", rendered, class: wrapping_class) if rendered.present?
tag.div(rendered, class: wrapping_class) if rendered.present?
end

##
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/blacklight/facets_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def render_selected_facet_value(facet_field, item)
def render_facet_count(num, options = {})
deprecated_method(:render_facet_count)
classes = (options[:classes] || []) << "facet-count"
content_tag("span", t('blacklight.search.facets.count', number: number_with_delimiter(num)), class: classes)
tag.span(t('blacklight.search.facets.count', number: number_with_delimiter(num)), class: classes)
end

##
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/blacklight/icon_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Blacklight::IconHelperBehavior
def blacklight_icon(icon_name, options = {})
Rails.cache.fetch([:blacklight_icons, icon_name, options]) do
icon = Blacklight::Icon.new(icon_name, **options)
content_tag(:span, icon.svg.html_safe, icon.options)
tag.span(icon.svg.html_safe, icon.options)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,33 @@ def render_search_to_s_filters(params)
safe_join(value_list.collect do |value|
render_filter_value(value, facet_field)
end,
content_tag(:span, " #{t('blacklight.and')} ", class: 'filter-separator')))
tag.span(" #{t('blacklight.and')} ", class: 'filter-separator')))
end, " \n ")
end

# value can be Array, in which case elements are joined with
# 'and'. Pass in option :escape_value => false to pass in pre-rendered
# html for value. key with escape_key if needed.
def render_search_to_s_element(key, value, _options = {})
content_tag(:span,
render_filter_name(key) + content_tag(:span, value, class: 'filter-values'),
class: 'constraint')
tag.span(render_filter_name(key) + tag.span(value, class: 'filter-values'),
class: 'constraint')
end

##
# Render the name of the facet
def render_filter_name name
return "".html_safe if name.blank?

content_tag(:span,
t('blacklight.search.filters.label', label: name),
class: 'filter-name')
tag.span(t('blacklight.search.filters.label', label: name),
class: 'filter-name')
end

##
# Render the value of the facet
def render_filter_value value, key = nil
display_value = value
display_value = facet_display_value(key, value) if key
content_tag(:span,
h(display_value),
class: 'filter-value')
tag.span(h(display_value),
class: 'filter-value')
end
end
Loading

0 comments on commit 2a881c1

Please sign in to comment.