Skip to content

Commit

Permalink
💄 Fixing linting for Adventist Valkyrie
Browse files Browse the repository at this point in the history
This commit updates depricated Rubocop syntax. `IgnoredMethods` for
`Metrics/BlockLength` in the file `rubocop.yml` is replaced with
`AllowedMethods`. `Metrics/LineLength` is replaced with
`Layout/LineLength` in all appropriate files.

Ref:
- #741
  • Loading branch information
sjproctor committed Aug 19, 2024
1 parent 2a0fe2e commit b474be9
Show file tree
Hide file tree
Showing 27 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Layout/HashAlignment:
- app/forms/hyrax/forms/admin/adl_appearance_decorator.rb

Metrics/BlockLength:
IgnoredMethods: ['included', 'describe', 'it', 'context']
AllowedMethods: ['included', 'describe', 'it', 'context']
Exclude:
- "spec/**/*.rb"
- app/controllers/catalog_controller_decorator.rb
Expand Down
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Metrics/CyclomaticComplexity:
# Offense count: 14
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Layout/LineLength:
Max: 161

# Offense count: 24
Expand Down
4 changes: 2 additions & 2 deletions app/actors/hyrax/actors/collections_membership_actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def assign_nested_attributes_for_collection(env)
return true unless attributes_collection

# OVERRIDE Hyrax 3.5.0 to skip permission checks if importing
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
return false unless env.importing ||
valid_membership?(env,
collection_ids: attributes_collection.map { |_, attributes| attributes['id'] })

# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
attributes_collection = attributes_collection.sort_by { |i, _| i.to_i }.map { |_, attributes| attributes }
# checking for existing works to avoid rewriting/loading works that are already attached
existing_collections = env.curation_concern.member_of_collection_ids
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def attach!
add_ordered_members! if ordered
true
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

def create_file_from_url(uri, file_name, auth_header, override_default_thumbnail = nil)
import_url = URI.decode_www_form_component(uri.to_s)
Expand All @@ -50,6 +50,6 @@ def create_file_from_url(uri, file_name, auth_header, override_default_thumbnail
end
end

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
Hyrax::Actors::CreateWithRemoteFilesActor::IngestRemoteFilesService.prepend Hyrax::Actors::CreateWithRemoteFilesActorDecorator::IngestRemoteFilesServiceDecorator
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
4 changes: 2 additions & 2 deletions app/indexers/app_indexer_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def generate_solr_document
.join("\n---------------------------\n")

if object.date_created.present?
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
date_created = object.date_created.is_a?(ActiveTriples::Relation) ? object.date_created.first : object.date_created
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
# expects date created to be array with single string in yyyy-mm-dd format
solr_doc['sorted_date_isi'] = date_created.tr('-', '').to_i
solr_doc['sorted_month_isi'] = date_created.tr('-', '').slice(0..5).to_i
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/characterize_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CharacterizeJob < Hyrax::ApplicationJob
# @param [String] file_id identifier for a Hydra::PCDM::File
# @param [String, NilClass] filepath the cached file within the Hyrax.config.working_path
def perform(file_set, file_id, filepath = nil)
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
raise "#{file_set.class.characterization_proxy} was not found for FileSet #{file_set.id}" unless file_set.characterization_proxy?
filepath = Hyrax::WorkingDirectory.find_or_retrieve(file_id, file_set.id) unless filepath && File.exist?(filepath)
Hydra::Works::CharacterizationService.run(file_set.characterization_proxy, filepath, ch12n_tool: :fits_servlet)
Expand All @@ -19,6 +19,6 @@ def perform(file_set, file_id, filepath = nil)
file_set.update_index
file_set.parent&.in_collections&.each(&:update_index)
CreateDerivativesJob.perform_later(file_set, file_id, filepath)
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end
end
4 changes: 2 additions & 2 deletions app/jobs/create_derivatives_job_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def perform(file_set, file_id, filepath = nil)
# We should not be creating derivatives for thumbnails.
FILE_SUFFIXES_TO_SKIP_DERIVATIVE_CREATION = ([] + NON_ARCHIVAL_PDF_SUFFIXES).freeze

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
def self.create_derivative_for?(file_set:)
# Our options appear to be `file_set.label` or `file_set.original_file.original_name`; in
# favoring `#label` we are avoiding a call to Fedora. Is the label likely to be the original
Expand All @@ -26,7 +26,7 @@ def self.create_derivative_for?(file_set:)

true
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end

CreateDerivativesJob.prepend(CreateDerivativesJobDecorator)
4 changes: 2 additions & 2 deletions app/jobs/file_sets_reprocess_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ConditionallyResplitFileSetJob < ApplicationJob
# @return [Symbol] A terse explanation of what was done with this job.
#
# @raise [ActiveFedora::ObjectNotFoundError] when the given FileSet's parent could not be found.
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
def perform(file_set_id:)
file_set = FileSetFinder.find(file_set_id:)

Expand All @@ -109,7 +109,7 @@ def perform(file_set_id:)
IiifPrint::Jobs::RequestSplitPdfJob.perform_later(file_set:, user: User.batch_user)
:requesting_split
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end

##
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/iiif_print/child_works_from_pdf_job_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def resource_types
@parent_work.try(:resource_type)
end
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end

IiifPrint::Jobs::ChildWorksFromPdfJob.prepend(IiifPrint::ChildWorksFromPdfJobDecorator)
4 changes: 2 additions & 2 deletions config/initializers/iiif_print.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
config.additional_tesseract_options = "-l eng_best"

# Reconfigure the title generated by the PDF splitter
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
config.unique_child_title_generator_function = lambda { |original_pdf_path:, parent_work:, page_number:, page_padding:, **|
identifier = parent_work.to_param # ref Slug Bug
filename = File.basename(original_pdf_path)
Expand Down Expand Up @@ -131,7 +131,7 @@

params.merge!(embargo_params).merge!(lease_params).merge!(visibility_params)
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end

require "iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter"
Expand Down
4 changes: 2 additions & 2 deletions lib/dog_biscuits/property_mappings/property_mappings.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/ModuleLength

Expand Down Expand Up @@ -580,6 +580,6 @@ def property_mappings
end
end

# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/ModuleLength
4 changes: 2 additions & 2 deletions lib/hyku_knapsack/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ def self.load_translations!
# In the development environment we may not have AWS credentials. When we do, let's use s3. When
# we don't, we'll use local files (which almost certainly will fail). This means we'd be locally
# using the derivative rodeo's splitting process (which should work without a preprocess lcoation).
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
IiifPrint::DerivativeRodeoService.preprocessed_location_adapter_name = if DerivativeRodeo.config.aws_s3_access_key_id.present? && DerivativeRodeo.config.aws_s3_secret_access_key.present?
's3'
else
'file'
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end
end
# rubocop:enable Metrics/BlockLength
Expand Down
8 changes: 4 additions & 4 deletions sdapi_ingest_scripts/jobs/collection_membership_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class CollectionMembershipJob < ApplicationJob

retry_on StandardError, attempts: 0

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
COLLECTIONS_TO_REMOVE = [
"2487c594-1026-4a91-9ede-6105d5626a41", "67911ae1-8a26-4309-ba89-aca81c2fe3be", "4b298df0-9147-4990-a08d-0f53cbc90ed6", "be482035-fe21-4be0-9704-c422618b4525", "0c0444c4-9642-447d-b912-ae7de4163342", "a68b1cff-47c7-4f4d-9e1c-70c05ba48512", "608cca3c-9780-4842-b5f4-79bfcea8eb02", "36e07892-4167-4cb1-b0a8-986cfd1edbd6", "0b10fed9-51dd-48dd-89e1-dd990e94e1fc", "254bd824-7e53-400b-a74c-189043e02db8", "36b2f7ec-8750-482c-842c-bf02462fbf5b", "280c499e-7026-4427-b41b-1f594978cbf4", "2be7ac3e-786c-42f5-932b-180ac8ec5fee", "a5df1cbc-33eb-4120-ad93-b9d930a26dc7", "c1f28f13-0a97-42fe-b98e-52b14e26194c", "8647cc37-8434-4d9a-bb66-0d898715c264", "d44b5783-e949-40dd-b7fb-d1ed13cafc5f", "ac2a2de7-6aad-45f5-ab9f-0e7afb345855", "63daa10f-0ffa-4566-913c-f35eef9e077d", "07f8dbf8-06f2-472e-b11b-5efa21451e13"
].freeze
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

# rubocop:disable Metrics/MethodLength
def perform(work_type: 'JournalArticle',
Expand Down Expand Up @@ -41,8 +41,8 @@ def perform(work_type: 'JournalArticle',
end
# rubocop:enable Metrics/MethodLength

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
Rails.logger.info("💜💜💜 Collection updates for work type #{work_type}: #{wk_count} processed, #{wk_updated} updated.")
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end
end
4 changes: 2 additions & 2 deletions sdapi_ingest_scripts/jobs/rerun_entry_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def perform(entry_class_name:, entry_id:)
bulkrax_entry.build
bulkrax_entry.save

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
Rails.logger.info("Finished re-submitting entry for for #{bulkrax_entry.class} ID=#{bulkrax_entry.id}. entry status=#{bulkrax_entry.status}")
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,35 @@ def do_it!
logger.info("Starting re-importing #{reimport_logging_context} with entries that had any error.")
relation = relation.where.not(error_class: nil)
else
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
logger.info("Starting re-importing #{reimport_logging_context} with entries that had the following errors: #{error_classes.inspect}.")
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
relation = relation.where(error_class: error_classes)
end

# We need to count before we do the select narrowing; otherwise ActiveRecord will throw a SQL
# error.
relation_count = relation.count
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
logger.info("*****************Found #{relation_count} entries to re-import for #{reimport_logging_context}.*****************")
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

# No sense loading all the fields; we really only need these two values to resubmit the given job.
relation = relation.select('id', 'statusable_id', 'statusable_type')
counter = 0

relation.find_each do |status|
counter += 1
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
logger.info("Enqueuing re-import for #{reimport_logging_context} #{status.statusable_type} ID=#{status.statusable_id} (#{counter} of #{relation_count}).")
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
begin
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
RerunEntryJob.perform_later(entry_class_name: status.statusable_type, entry_id: status.statusable_id)
rescue StandardError => e
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
logger.error("😈😈😈 Error: #{e.message} for #{reimport_logging_context} #{status.statusable_type} ID=#{status.statusable_id}")
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
raise e
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/config/initializers/iiif_print_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
subject { build_manifest_method.source_location[0] }

# Verify that we're using the app services iiif_print decorator
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
it { is_expected.to eq(HykuKnapsack::Engine.root.join('app', 'services', 'iiif_print', 'manifest_builder_service_behavior_decorator.rb').to_s) }
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end

describe 'super_method' do
Expand Down
4 changes: 2 additions & 2 deletions spec/config/initializers/slug_override_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
xit 'deletes via Hyrax::Transactions' do
doc_id = work.to_param

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
expect do
resource = Hyrax.query_service.find_by(id: Valkyrie::ID.new(doc_id))
transactions['collection_resource.destroy']
.with_step_args('collection_resource.delete' => { user: current_user })
.call(resource)
.value!
end.to change { ActiveFedora::SolrService.query("id:\"#{doc_id}\"", fl: "id", method: :post, rows: 1).count }.from(1).to(0)
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/catalog_controller_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

describe 'solr dictionaries' do
it 'does not specified spellcheck.dictionaries' do
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
expect(blacklight_config.search_fields).to(be_none { |_field, config| config&.solr_parameters&.key?('spellcheck.dictionaries'.to_sym) })
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/features/create_conference_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
# its element
find('body').click
choose('conference_item_visibility_open')
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
check('agreement')

click_on('Save')
Expand Down
4 changes: 2 additions & 2 deletions spec/features/create_dataset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
# its element
find('body').click
choose('dataset_visibility_open')
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
check('agreement')
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

click_on('Save')
expect(page).to have_content('My Test Work')
Expand Down
4 changes: 2 additions & 2 deletions spec/features/create_exam_paper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
# its element
find('body').click
choose('exam_paper_visibility_open')
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
check('agreement')
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

click_on('Save')
expect(page).to have_content('My Test Work')
Expand Down
4 changes: 2 additions & 2 deletions spec/features/create_journal_article_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
# its element
find('body').click
choose('journal_article_visibility_open')
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
check('agreement')
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

click_on('Save')
expect(page).to have_content('My Test Work')
Expand Down
4 changes: 2 additions & 2 deletions spec/features/create_published_work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
# its element
find('body').click
choose('published_work_visibility_open')
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
check('agreement')
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

click_on('Save')
expect(page).to have_content('My Test Work')
Expand Down
4 changes: 2 additions & 2 deletions spec/features/create_thesis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
# its element
find('body').click
choose('thesis_visibility_open')
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
expect(page).to have_content('Please note, making something visible to the world (i.e. marking this as Public) may be viewed as publishing which could impact your ability to')
check('agreement')
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

click_on('Save')
expect(page).to have_content('My Test Work')
Expand Down
4 changes: 2 additions & 2 deletions spec/features/facet_by_year_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@
end

it "displays plot after facet is expanded" do
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
visit "/catalog/range_limit?commit=Limit&locale=en&q=&range_end=2021&range_field=sorted_year_isi&range_start=2&search_field=all_fields"
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
expect(page.status_code).to eq 200
end
end
Loading

0 comments on commit b474be9

Please sign in to comment.