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

Set rubocop target ruby version to 3.2 and autocorrect #2420

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
48 changes: 24 additions & 24 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@ name: CI

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ['3.1', '3.2']
ruby: ["3.2", "3.3"]
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-202103-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-202103
- name: Bundle install
run: bundle config path vendor/bundle
- name: Use sidekiq pro
env:
BUNDLE_GEMS__CONTRIBSYS__COM: ${{ secrets.BUNDLE_GEMS__CONTRIBSYS__COM }}
run: bundle config --local gems.contribsys.com ${BUNDLE_GEMS__CONTRIBSYS__COM}
- name: Install dependencies
run: bin/setup && bin/rails db:test:prepare
- name: Run tests
run: bundle exec rake
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-202103-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-202103
- name: Bundle install
run: bundle config path vendor/bundle
- name: Use sidekiq pro
env:
BUNDLE_GEMS__CONTRIBSYS__COM: ${{ secrets.BUNDLE_GEMS__CONTRIBSYS__COM }}
run: bundle config --local gems.contribsys.com ${BUNDLE_GEMS__CONTRIBSYS__COM}
- name: Install dependencies
run: bin/setup && bin/rails db:test:prepare
- name: Run tests
run: bundle exec rake
42 changes: 21 additions & 21 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ require:
- rubocop-rails

AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 3.2
DisplayCopNames: true
Exclude:
- 'bin/**/*'
- 'db/**/*'
- 'config/**/*'
- 'vendor/**/*'
- 'spec/fixtures/**/*'
- "bin/**/*"
- "db/**/*"
- "config/**/*"
- "vendor/**/*"
- "spec/fixtures/**/*"

Rails:
Enabled: true

Layout/LineLength:
Max: 120
Exclude:
- 'app/controllers/concerns/search_across_blacklight_overrides.rb'
- 'app/models/spotlight/dor/indexer.rb'
- 'lib/traject/dor_config.rb'
- 'spec/features/indexing_integration_spec.rb'
- 'spec/models/spotlight/dor/indexer_spec.rb'
- 'spec/features/bibliography_formatting_spec.rb'
- "app/controllers/concerns/search_across_blacklight_overrides.rb"
- "app/models/spotlight/dor/indexer.rb"
- "lib/traject/dor_config.rb"
- "spec/features/indexing_integration_spec.rb"
- "spec/models/spotlight/dor/indexer_spec.rb"
- "spec/features/bibliography_formatting_spec.rb"

Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%i': '()'
'%w': '()'
"%i": "()"
"%w": "()"

Style/StringLiterals:
Enabled: true
Expand All @@ -51,7 +51,7 @@ Style/HashTransformValues:

Metrics/ClassLength:
Exclude:
- 'app/controllers/catalog_controller.rb'
- "app/controllers/catalog_controller.rb"

RSpec/Capybara:
Enabled: false
Expand All @@ -68,21 +68,21 @@ Bundler/OrderedGems:
RSpec/ExampleLength:
Max: 10
Exclude:
- 'spec/features/indexing_integration_spec.rb'
- "spec/features/indexing_integration_spec.rb"

RSpec/MultipleMemoizedHelpers:
Enabled: false

Metrics/BlockLength:
Exclude:
- 'app/controllers/catalog_controller.rb'
- 'app/controllers/search_across_controller.rb'
- 'app/models/spotlight/dor/indexer.rb'
- 'spec/**/*'
- "app/controllers/catalog_controller.rb"
- "app/controllers/search_across_controller.rb"
- "app/models/spotlight/dor/indexer.rb"
- "spec/**/*"

Performance/RedundantBlockCall:
Exclude:
- 'lib/traject/macros/**/*'
- "lib/traject/macros/**/*"
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
Layout/SpaceAroundMethodCallOperator:
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ GEM
net-ssh (7.2.3)
newrelic_rpm (9.8.0)
nio4r (2.7.1)
nokogiri (1.16.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.4-x86_64-linux)
Expand Down Expand Up @@ -710,6 +712,7 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.7.3-arm64-darwin)
sqlite3 (1.7.3-x86_64-darwin)
sqlite3 (1.7.3-x86_64-linux)
sshkit (1.22.1)
Expand Down Expand Up @@ -795,6 +798,7 @@ GEM
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-23
x86_64-darwin-19
x86_64-darwin-20
x86_64-darwin-21
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/concerns/search_across_blacklight_overrides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def render_grouped_document_index(response = @response)
view_context.render_document_index(exhibits)
end

def opensearch_catalog_url(*args)
view_context.spotlight.opensearch_search_across_url(*args)
def opensearch_catalog_url(*)
view_context.spotlight.opensearch_search_across_url(*)
end

def start_over_path(*_args)
Expand Down Expand Up @@ -107,11 +107,11 @@ def page_entries_info(collection, entry_name: nil)

case collection.total_count
when 0
t('search_across.pagination_info.no_items_found', entry_name: entry_name).html_safe
t('search_across.pagination_info.no_items_found', entry_name:).html_safe
when 1
t('search_across.pagination_info.single_item_found', entry_name: entry_name).html_safe
t('search_across.pagination_info.single_item_found', entry_name:).html_safe
else
t('search_across.pagination_info.pages', entry_name: entry_name,
t('search_across.pagination_info.pages', entry_name:,
current_page: collection.current_page,
num_pages: collection.total_pages,
start_num: view_context.number_with_delimiter(collection.offset_value + 1),
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/spotlight/exhibits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
module Spotlight
# Override the upstream HomePagesController in order to inject range limit behaviors
class ExhibitsController
def search_action_url(*args)
main_app.search_search_across_url(*args)
def search_action_url(*)
main_app.search_search_across_url(*)
end

def blacklight_config
Expand Down
12 changes: 6 additions & 6 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def document_leaflet_map(document:, **)
##
# @param [String] manifest
def iiif_drag_n_drop(manifest, width: '40')
link_url = format Settings.iiif_dnd_base_url, query: { manifest: manifest }.to_query
link_url = format Settings.iiif_dnd_base_url, query: { manifest: }.to_query
link_to link_url, class: 'iiif-dnd float-right', data: { turbolinks: false } do
image_tag 'iiif-drag-n-drop.svg', width: width, alt: 'IIIF Drag-n-drop'
image_tag 'iiif-drag-n-drop.svg', width:, alt: 'IIIF Drag-n-drop'
end
end

Expand All @@ -36,10 +36,10 @@ def render_viewer_in_context(document, block)
canvas = choose_canvas_id(block)
if params[:controller] == 'spotlight/catalog'
render partial: current_exhibit.required_viewer.to_partial_path,
locals: { document: document, block: block, canvas: canvas }
locals: { document:, block:, canvas: }
else
render partial: current_exhibit.required_viewer.default_viewer_path,
locals: { document: document, block: block, canvas: canvas }
locals: { document:, block:, canvas: }
end
end

Expand All @@ -52,8 +52,8 @@ def custom_render_oembed_tag_async(document, canvas_id, block)

content_tag :div, '', data: {
embed_url: blacklight_oembed_engine.embed_url(
url: url,
canvas_id: canvas_id,
url:,
canvas_id:,
search: params[:search],
maxheight: block&.maxheight.presence || '600',
suggested_search: (current_search_session&.query_params || {})[:q]
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/catalog_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def table_of_contents_separator(options = {})

contents = safe_join(contents.map { |v| "<li>#{v}</li>".html_safe }) # rubocop:disable Rails/OutputSafety
id = options[:document].id
render partial: 'catalog/table_of_contents', locals: { contents: contents, collapse_id: "collapseToc-#{id}" }
render partial: 'catalog/table_of_contents', locals: { contents:, collapse_id: "collapseToc-#{id}" }
end

def manuscript_link(options = {})
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/send_publish_state_change_notification_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# A background job to send notifications via the ExhibitBot about the published state of an exhibit changing
class SendPublishStateChangeNotificationJob < ApplicationJob
def perform(exhibit:, published:)
ExhibitBot.message(text: message_text(exhibit: exhibit, published: published))
ExhibitBot.message(text: message_text(exhibit:, published:))
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/bibliography.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def to_html

# Renders a *sorted* bibliography
def render(format = 'html')
cp = CiteProc::Processor.new style: 'chicago-author-date', format: format
cp = CiteProc::Processor.new(style: 'chicago-author-date', format:)
cp.import bibliography.to_citeproc
cp.bibliography.join
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/exhibit_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def required_viewer
def send_publish_state_change_notification
return unless saved_changes.key?('published')

SendPublishStateChangeNotificationJob.perform_later(exhibit: self, published: published)
SendPublishStateChangeNotificationJob.perform_later(exhibit: self, published:)
end

def index_exhibit_metadata
Expand Down
2 changes: 1 addition & 1 deletion app/models/dor_harvester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def on_error(resource, exception_or_message)
else
exception_or_message.to_s
end.truncate(1.megabyte)
RecordIndexStatusJob.perform_later(self, resource.bare_druid, ok: false, message: message)
RecordIndexStatusJob.perform_later(self, resource.bare_druid, ok: false, message:)
end

def trigger_update_resource_metadata
Expand Down
2 changes: 1 addition & 1 deletion app/models/exhibit_bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class << self
end

def message(channel: default_channel, as_user: true, text:)
client.chat_postMessage(channel: channel, as_user: as_user, text: text)
client.chat_postMessage(channel:, as_user:, text:)
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/iiif_canvas_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def index_canvases
# Don't bother to index unless there is an annotationList content to do so.
next unless other_content['@type'] == ANNOTATION_LIST

canvas_resource = CanvasResource.find_or_initialize_by(url: other_content['@id'], exhibit: exhibit)
canvas_resource = CanvasResource.find_or_initialize_by(url: other_content['@id'], exhibit:)
# We need to pass some more information to the canvas indexer, and we
# so we do this by enhancing the stored Hash with needed fields.
enhanced_canvas = JSON.parse(canvas.to_json)
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/bibliography_resources_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe BibliographyResourcesController, type: :controller do
let(:resource) { double }
let(:exhibit) { create(:exhibit) }
let(:user) { create(:exhibit_admin, exhibit: exhibit) }
let(:user) { create(:exhibit_admin, exhibit:) }
let(:fixture_file) { fixture_file_upload('spec/fixtures/bibliography/article.bib') }
let(:attributes) { { bibtex_file: fixture_file } }

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/dor_harvester_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe DorHarvesterController, type: :controller do
let(:resource) { double }
let(:exhibit) { create(:exhibit) }
let(:user) { create(:exhibit_admin, exhibit: exhibit) }
let(:user) { create(:exhibit_admin, exhibit:) }
let(:attributes) { { druid_list: '' } }

before do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/search_across_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
let(:exhibit) do
create(:exhibit, slug: 'mine', published: true, tag_list: ['bar'])
end
let(:user) { create(:exhibit_admin, exhibit: exhibit) }
let(:user) { create(:exhibit_admin, exhibit:) }

before do
sign_in user
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/spotlight/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
routes { Spotlight::Engine.routes }

let(:exhibit) { create(:exhibit) }
let(:user) { create(:exhibit_admin, exhibit: exhibit) }
let(:user) { create(:exhibit_admin, exhibit:) }

before do
sign_in user
Expand Down
12 changes: 6 additions & 6 deletions spec/features/adding_items_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

RSpec.feature 'Adding items to an exhibit', type: :feature do
let(:exhibit) { create(:exhibit) }
let(:user) { create(:exhibit_admin, exhibit: exhibit) }
let(:user) { create(:exhibit_admin, exhibit:) }
let(:number_of_resources) { 5 }
let(:resource) { DorHarvester.create(exhibit: exhibit) }
let(:resource) { DorHarvester.create(exhibit:) }

before do
sign_in user

number_of_resources.times do |i|
Spotlight::SolrDocumentSidecar.create(
exhibit: exhibit,
resource: resource,
exhibit:,
resource:,
document: SolrDocument.new(id: "abc#{i}"),
index_status: { ok: true }
)
Expand Down Expand Up @@ -62,8 +62,8 @@
context 'when an indexing error occurs' do
before do
Spotlight::SolrDocumentSidecar.create(
exhibit: exhibit,
resource: resource,
exhibit:,
resource:,
document: SolrDocument.new(id: 'xyz'),
index_status: { ok: false, message: 'There was a problem indexing' }
)
Expand Down
2 changes: 1 addition & 1 deletion spec/features/bibliography_display_manuscript_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end.join("\n")

# we index some bibliography records that have links to our resource
bib = BibliographyResource.new(bibtex_file: bibtex_data, exhibit: exhibit)
bib = BibliographyResource.new(bibtex_file: bibtex_data, exhibit:)
bib.save_and_index

# render the resource show page
Expand Down
2 changes: 1 addition & 1 deletion spec/features/bibliography_indexing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

RSpec.feature 'Bibliography indexing', type: :feature do
let(:exhibit) { create(:exhibit) }
let(:curator) { create(:exhibit_admin, exhibit: exhibit) }
let(:curator) { create(:exhibit_admin, exhibit:) }

before do
sign_in curator
Expand Down
Loading
Loading