Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rubocop and autocorrect #3112

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 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 2023-10-06 15:10:31 UTC using RuboCop version 1.56.4.
# on 2023-12-05 17:55:17 UTC using RuboCop version 1.58.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 @@ -190,7 +190,7 @@ RSpec/BeforeAfterAll:
- 'spec/models/blacklight/document/dublin_core_spec.rb'
- 'spec/models/blacklight/solr/document_spec.rb'

# Offense count: 103
# Offense count: 104
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Expand All @@ -202,7 +202,7 @@ RSpec/EmptyExampleGroup:
Exclude:
- 'spec/models/blacklight/solr/search_builder_spec.rb'

# Offense count: 134
# Offense count: 135
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 33
Expand Down Expand Up @@ -278,7 +278,7 @@ RSpec/MessageSpies:
- 'spec/presenters/blacklight/field_presenter_spec.rb'
- 'spec/presenters/thumbnail_presenter_spec.rb'

# Offense count: 379
# Offense count: 382
RSpec/MultipleExpectations:
Max: 16

Expand Down Expand Up @@ -481,7 +481,7 @@ Style/GuardClause:
- 'app/helpers/blacklight/catalog_helper_behavior.rb'
- 'lib/blacklight/solr/search_builder_behavior.rb'

# Offense count: 27
# Offense count: 29
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Enabled: false
Expand Down Expand Up @@ -549,6 +549,21 @@ Style/PercentLiteralDelimiters:
- 'lib/blacklight/engine.rb'
- 'lib/blacklight/solr/request.rb'

# Offense count: 15
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantParentheses:
Exclude:
- 'app/components/blacklight/advanced_search_form_component.rb'
- 'app/components/blacklight/document/actions_component.rb'
- 'app/components/blacklight/document_component.rb'
- 'app/components/blacklight/document_metadata_component.rb'
- 'app/components/blacklight/metadata_field_layout_component.rb'
- 'app/components/blacklight/system/dropdown_component.rb'
- 'app/views/catalog/_document.atom.builder'
- 'lib/blacklight/search_state/pivot_filter_field.rb'
- 'lib/railties/blacklight.rake'
- 'spec/models/blacklight/solr/search_builder_spec.rb'

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def initialize_search_field_controls
def initialize_search_filter_controls
fields = blacklight_config.facet_fields.select { |_k, v| v.include_in_advanced_search || v.include_in_advanced_search.nil? }

fields.each do |_k, config|
fields.each_value do |config|
display_facet = @response.aggregations[config.field]
with_search_filter_control(config: config, display_facet: display_facet)
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/blacklight/icons/legacy_icon_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(name:, classes: '', aria_hidden: false, label: true, role: 'img',
end

def call
tag.span(svg&.html_safe || default_icon, # rubocop:disable Rails/OutputSafety
tag.span(svg&.html_safe || default_icon, # rubocop:disable Rails/OutputSafety
class: "blacklight-icons blacklight-icon-#{@name} #{@classes}".strip,
'aria-hidden': (true if @aria_hidden))
end
Expand Down
2 changes: 1 addition & 1 deletion lib/blacklight/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ def show_fields_for(display_types)

# @!visibility private
def freeze
each { |_k, v| v.is_a?(OpenStruct) && v.freeze }
each { |_k, v| v.is_a?(OpenStruct) && v.freeze } # rubocop:disable Style/HashEachMethods
super
end

Expand Down
2 changes: 1 addition & 1 deletion lib/blacklight/solr/response/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def facet_field_aggregation_options(facet_field_name)
defaults = {
sort: single_valued_param(:'facet.sort'),
limit: single_valued_param(:'facet.limit')&.to_i || 100,
offset: single_valued_param(:'facet.offset')&.to_i || 0,
offset: single_valued_param(:'facet.offset').to_i,
prefix: single_valued_param(:'facet.prefix')
}

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
it "has no docs or facet values for query without results", integration: true do
get :index, params: { q: 'sadfdsafasdfsadfsadfsadf' } # query for no results
expect(assigns(:response).docs).to be_empty
assigns(:response).aggregations.each do |_key, facet|
assigns(:response).aggregations.each_value do |facet|
expect(facet.items).to be_empty
end
end
Expand Down Expand Up @@ -815,7 +815,7 @@ def export_as_mock
def assert_facets_have_values(aggregations)
expect(aggregations).not_to be_empty
# should have at least one value for each facet
aggregations.each do |_key, facet|
aggregations.each_value do |facet|
expect(facet.items).to have_at_least(1).item
end
end
2 changes: 1 addition & 1 deletion spec/models/blacklight/solr/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

expect(received).to eq expected

r.aggregations.each do |_key, facet|
r.aggregations.each_value do |facet|
expect(facet).to respond_to :name
expect(facet).to respond_to :sort
expect(facet).to respond_to :offset
Expand Down