From 604095f4dfcf203eb7084d5f76a59f3789f730aa Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 14 Aug 2024 11:21:40 -0700 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A7=B9=20updates=20rubocop=20and=20ad?= =?UTF-8?q?d=20rubocop-factory=5Fbot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit regenerate rubocop_todo and ruboco_fixme --- .rubocop_fixme.yml | 644 ++++++++++++++++++++++++++++++++------------- .rubocop_todo.yml | 603 +++++++++++++++++++++++++++++++++++++++++- Gemfile | 6 +- Gemfile.lock | 51 ++-- 4 files changed, 1091 insertions(+), 213 deletions(-) diff --git a/.rubocop_fixme.yml b/.rubocop_fixme.yml index 964bae6dc..abe4d96c0 100644 --- a/.rubocop_fixme.yml +++ b/.rubocop_fixme.yml @@ -1,201 +1,473 @@ -Security/MarshalLoad: - Exclude: - - 'app/models/concerns/hyrax/user.rb' +# This configuration was generated by +# `rubocop --auto-gen-config --exclude-limit 0` +# on 2024-08-14 18:07:37 UTC using RuboCop version 1.61.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 +# versions of RuboCop, may require this file to be generated again. +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment. +Layout/CommentIndentation: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Enabled: false + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLines: + Enabled: false + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Enabled: false + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLinesAroundMethodBody: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Enabled: false + +# Offense count: 11 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, indented_internal_methods +Layout/IndentationConsistency: + Enabled: false + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Width, AllowedPatterns. +Layout/IndentationWidth: + Enabled: false + +# Offense count: 20 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. +Layout/LeadingCommentSpace: + Enabled: false + +# Offense count: 11 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# URISchemes: http, https +Layout/LineLength: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Layout/MultilineMethodCallIndentation: + Enabled: false + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAfterComma: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleInsidePipes. +# SupportedStylesInsidePipes: space, no_space +Layout/SpaceAroundBlockParameters: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Enabled: false + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment. +Layout/SpaceBeforeFirstArg: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Enabled: false + +# Offense count: 7 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, compact, no_space +Layout/SpaceInsideParens: + Enabled: false + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingEmptyLines: + Enabled: false + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Enabled: false + +# Offense count: 4 +# Configuration parameters: DebuggerMethods. +Lint/Debugger: + Enabled: false + +# Offense count: 1 +Lint/DuplicateMethods: + Enabled: false + +# Offense count: 2 +Lint/IneffectiveAccessModifier: + Enabled: false + +# Offense count: 3 +# Configuration parameters: AllowedParentClasses. +Lint/MissingSuper: + Enabled: false + +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Lint/NestedMethodDefinition: + Enabled: false + +# Offense count: 1 +Lint/NonLocalExitFromIterator: + Enabled: false + +# Offense count: 1 +# Configuration parameters: AllowComments, AllowNil. +Lint/SuppressedException: + Enabled: false + +# Offense count: 1 +Lint/UnreachableCode: + Enabled: false + +# Offense count: 40 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. +Lint/UnusedMethodArgument: + Enabled: false + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. +Lint/UselessAssignment: + Enabled: false + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects. +Lint/Void: + Enabled: false + +# Offense count: 3 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. +Metrics/AbcSize: + Enabled: false + +# Offense count: 115 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +# AllowedMethods: refine +Metrics/BlockLength: + Max: 191 + +# Offense count: 1 +# Configuration parameters: CountBlocks. +Metrics/BlockNesting: + Max: 5 + +# Offense count: 5 +# Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Exclude: - - 'app/controllers/hyrax/dashboard/collections_controller.rb' - - 'app/controllers/hyrax/admin/admin_sets_controller.rb' - - 'app/controllers/hyrax/batch_edits_controller.rb' - - 'app/controllers/hyrax/downloads_controller.rb' - - 'app/controllers/hyrax/file_sets_controller.rb' - - 'app/forms/hyrax/forms/permission_template_form.rb' - - 'app/presenters/hyrax/work_show_presenter.rb' - - 'app/presenters/hyrax/collection_presenter.rb' - - 'app/services/hyrax/user_stat_importer.rb' - - 'lib/generators/hyrax/templates/catalog_controller.rb' - - 'lib/generators/hyrax/install_generator.rb' - - 'lib/hyrax/configuration.rb' - -Metrics/ParameterLists: - Exclude: - - 'app/jobs/batch_create_job.rb' - -Metrics/ModuleLength: - Exclude: - - 'app/controllers/concerns/hyrax/works_controller_behavior.rb' - - 'app/helpers/hyrax/hyrax_helper_behavior.rb' - - 'app/models/concerns/hyrax/ability.rb' - - 'app/services/hyrax/workflow/permission_query.rb' - - 'spec/services/hyrax/workflow/permission_query_spec.rb' - # TODO: extract CollectionAccessControls or something, so we don't have to skip this check? - - 'app/models/concerns/hyrax/collection_behavior.rb' - -RSpec/NamedSubject: + Max: 183 + +# Offense count: 2 +# Configuration parameters: AllowedMethods, AllowedPatterns, Max. +Metrics/CyclomaticComplexity: Enabled: false -RSpec/ExampleLength: - Max: 9 - Exclude: - - 'spec/actors/hyrax/actors/file_set_actor_spec.rb' - - 'spec/actors/hyrax/actors/generic_work_actor_spec.rb' - - 'spec/controllers/hyrax/api/items_controller_spec.rb' - - 'spec/controllers/hyrax/batch_edits_controller_spec.rb' - - 'spec/controllers/hyrax/batch_uploads_controller_spec.rb' - - 'spec/controllers/hyrax/file_sets_controller_spec.rb' - - 'spec/controllers/hyrax/generic_works_controller_spec.rb' - - 'spec/controllers/hyrax/my/highlights_controller_spec.rb' - - 'spec/controllers/hyrax/transfers_controller_spec.rb' - - 'spec/forms/hyrax/forms/collection_form_spec.rb' - - 'spec/forms/hyrax/forms/batch_edit_form_spec.rb' - - 'spec/forms/hyrax/forms/batch_upload_form_spec.rb' - - 'spec/forms/hyrax/forms/file_set_edit_form_spec.rb' - - 'spec/features/**/*' - - 'spec/helpers/hyrax/charts_helper_spec.rb' - - 'spec/helpers/dashboard_helper_spec.rb' - - 'spec/helpers/hyrax_helper_spec.rb' - - 'spec/indexers/hyrax/file_set_indexer_spec.rb' - - 'spec/javascripts/jasmine_spec.rb' - - 'spec/jobs/file_set_attached_event_job_spec.rb' - - 'spec/jobs/batch_create_job_spec.rb' - - 'spec/jobs/create_work_job_spec.rb' - - 'spec/jobs/content_update_event_job_spec.rb' - - 'spec/jobs/content_restored_version_event_job_spec.rb' - - 'spec/jobs/content_new_version_event_job_spec.rb' - - 'spec/jobs/content_depositor_change_event_job_spec.rb' - - 'spec/jobs/change_depositor_event_job_spec.rb' - - 'spec/jobs/content_deposit_event_job_spec.rb' - - 'spec/jobs/content_delete_event_job_spec.rb' - - 'spec/jobs/ingest_file_job_spec.rb' - - 'spec/lib/hyrax/arkivo/actor_spec.rb' - - 'spec/lib/hyrax/resource_sync/capability_list_writer_spec.rb' - - 'spec/models/checksum_audit_log_spec.rb' - - 'spec/models/featured_work_spec.rb' - - 'spec/models/file_set_spec.rb' - - 'spec/models/generic_work_spec.rb' - - 'spec/presenters/hyrax/inspect_work_presenter_spec.rb' - - 'spec/services/hyrax/actor_factory_spec.rb' - - 'spec/services/hyrax/admin_set_create_service_spec.rb' - - 'spec/services/hyrax/default_middleware_stack_spec.rb' - - 'spec/services/hyrax/graph_exporter_spec.rb' - - 'spec/services/hyrax/user_stat_importer_spec.rb' - - 'spec/services/hyrax/workflow/activate_object_spec.rb' - - 'spec/services/hyrax/workflow/deactivate_object_spec.rb' - - 'spec/services/hyrax/workflow/permission_generator_spec.rb' - - 'spec/services/hyrax/workflow/permission_query_spec.rb' - - 'spec/services/hyrax/workflow/state_machine_generator_spec.rb' - - 'spec/services/hyrax/workflow/workflow_importer_spec.rb' - - 'spec/views/**/*' - - 'spec/wings/valkyrie/persister_spec.rb' - -RSpec/VerifiedDoubles: - Enabled: false - -RSpec/SubjectStub: - Exclude: - - 'spec/actors/hyrax/actors/generic_work_actor_spec.rb' - - 'spec/controllers/hyrax/file_sets_controller_spec.rb' - - 'spec/models/file_set_spec.rb' - - 'spec/models/hyrax/work_behavior_spec.rb' - - 'spec/search_builders/hyrax/file_set_search_builder_spec.rb' - - 'spec/models/hyrax/operation_spec.rb' - - 'spec/controllers/hyrax/accepts_batches_controller_spec.rb' - - 'spec/indexers/hyrax/repository_reindexer_spec.rb' - - 'spec/lib/hyrax/analytics_spec.rb' - - 'spec/models/job_io_wrapper_spec.rb' - - 'spec/search_builders/hyrax/abstract_type_relation_spec.rb' - - 'spec/services/hyrax/database_migrator_spec.rb' +# Offense count: 35 +# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Enabled: false + +# Offense count: 2 +# Configuration parameters: AllowedMethods, AllowedPatterns, Max. +Metrics/PerceivedComplexity: + Enabled: false +# Offense count: 1 +Naming/AccessorMethodName: + Enabled: false + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Performance/RegexpMatch: + Enabled: false + +# Offense count: 4 RSpec/AnyInstance: - Exclude: - - 'spec/actors/hyrax/actors/generic_work_actor_spec.rb' - - 'spec/controllers/hyrax/api/items_controller_spec.rb' - - 'spec/controllers/hyrax/api/zotero_controller_spec.rb' - - 'spec/controllers/hyrax/batch_edits_controller_spec.rb' - - 'spec/controllers/hyrax/stats_controller_spec.rb' - - 'spec/controllers/hyrax/users_controller_spec.rb' - - 'spec/hyrax/transactions/steps/delete_access_control_spec.rb' - - 'spec/hyrax/transactions/steps/save_access_control_spec.rb' - - 'spec/jobs/content_restored_version_event_job_spec.rb' - - 'spec/jobs/file_set_attached_event_job_spec.rb' - - 'spec/jobs/hyrax/grant_edit_to_members_job_spec.rb' - - 'spec/jobs/hyrax/grant_read_to_members_job_spec.rb' - - 'spec/jobs/hyrax/revoke_edit_from_members_job_spec.rb' - - 'spec/lib/hyrax/arkivo/create_subscription_job_spec.rb' - - 'spec/presenters/hyrax/file_usage_spec.rb' - - 'spec/presenters/hyrax/work_usage_spec.rb' - - 'spec/services/hyrax/repository_fixity_check_service_spec.rb' - - 'spec/services/hyrax/workflow/permission_generator_spec.rb' - - 'spec/services/hyrax/workflow/sipity_actions_generator_spec.rb' - - 'spec/services/hyrax/workflow/state_machine_generator_spec.rb' - - 'spec/services/hyrax/workflow/workflow_permissions_generator_spec.rb' - - 'spec/controllers/hyrax/homepage_controller_spec.rb' - - 'spec/controllers/hyrax/my/collections_controller_spec.rb' - - 'spec/controllers/hyrax/my/works_controller_spec.rb' - - 'spec/presenters/hyrax/admin/repository_object_presenter_spec.rb' - -# Offense count: 51 -RSpec/ExpectInHook: - Enabled: false - -# Offense count: 27 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: and_return, block -RSpec/ReturnFromStub: - Exclude: - - 'spec/controllers/hyrax/api/items_controller_spec.rb' - - 'spec/controllers/hyrax/file_sets_controller_spec.rb' - - 'spec/lib/hyrax/arkivo/create_subscription_job_spec.rb' - - 'spec/models/file_set_spec.rb' - - 'spec/presenters/hyrax/admin_set_options_presenter_spec.rb' - - 'spec/routing/api_route_spec.rb' - - 'spec/views/_user_util_links.html.erb_spec.rb' - - 'spec/views/hyrax/base/_attributes.html.erb_spec.rb' - - 'spec/views/hyrax/base/_form.html.erb_spec.rb' - - 'spec/views/hyrax/base/file_manager.html.erb_spec.rb' - - 'spec/views/hyrax/dashboard/profiles/edit.html.erb_spec.rb' - - 'spec/views/hyrax/users/_user_info.html.erb_spec.rb' + Enabled: false -# Offense count: 26 -RSpec/RepeatedDescription: - Exclude: - - 'spec/models/sipity/agent_spec.rb' - - 'spec/models/sipity/comment_spec.rb' - - 'spec/models/sipity/entity_spec.rb' - - 'spec/models/sipity/entity_specific_responsibility_spec.rb' - - 'spec/models/sipity/role_spec.rb' - - 'spec/models/sipity/workflow_action_spec.rb' - - 'spec/models/sipity/workflow_responsibility_spec.rb' - - 'spec/models/sipity/workflow_role_spec.rb' - - 'spec/models/sipity/workflow_state_action_permission_spec.rb' - - 'spec/models/sipity/workflow_state_action_spec.rb' - - 'spec/models/sipity/workflow_state_spec.rb' +# Offense count: 10 +# Configuration parameters: Max. +RSpec/ExampleLength: + Enabled: false + +# Offense count: 4 +# Configuration parameters: Include. +# Include: db/migrate/*.rb +Rails/CreateTableWithTimestamps: + Enabled: false + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, AllowToTime. +# SupportedStyles: strict, flexible +Rails/Date: + Enabled: false + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb +Rails/Exit: + Enabled: false # Offense count: 2 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: slashes, arguments +Rails/FilePath: + Enabled: false + +# Offense count: 1 # Configuration parameters: Include. # Include: app/models/**/*.rb -Rails/HasManyOrHasOneDependent: - Exclude: - - 'app/models/admin_set.rb' - - 'app/models/hyrax/permission_template.rb' +Rails/HasAndBelongsToMany: + Enabled: false # Offense count: 1 -Rails/SkipsModelValidations: - Exclude: - - 'app/services/hyrax/works/migration_service.rb' +# This cop supports safe autocorrection (--autocorrect). +Rails/IndexBy: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Rails/IndexWith: + Enabled: false # Offense count: 12 -Lint/MissingSuper: - Exclude: - - 'app/actors/hyrax/actors/interpret_visibility_actor.rb' - - 'app/actors/hyrax/actors/ordered_members_actor.rb' - - 'app/models/concerns/hyrax/file_set/characterization.rb' - - 'app/presenters/hyrax/file_usage.rb' - - 'app/presenters/hyrax/work_usage.rb' - - 'app/services/hyrax/batch_create_failure_service.rb' - - 'app/services/hyrax/batch_create_success_service.rb' - - 'app/services/hyrax/collection_types/create_service.rb' - - 'app/services/hyrax/solr_query_service.rb' - - 'lib/hyrax/form_fields.rb' - - 'lib/hyrax/health_checks/solr_check.rb' - - 'lib/hyrax/schema.rb' +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb +Rails/Output: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. +Rails/Present: + Enabled: false + +# Offense count: 13 +# Configuration parameters: Include. +# Include: db/**/*.rb +Rails/ReversibleMigration: + Enabled: false + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/TimeZone: + Enabled: false + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/UniqueValidationWithoutIndex: + Enabled: false + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Security/JSONLoad: + Enabled: false + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Security/YAMLLoad: + Enabled: false + +# Offense count: 11 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: is_a?, kind_of? +Style/ClassCheck: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Keywords, RequireColon. +# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE +Style/CommentAnnotation: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/EachWithObject: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/EmptyLiteral: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: format, sprintf, percent +Style/FormatString: + Enabled: false + +# Offense count: 94 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 30 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. +Style/GuardClause: + Enabled: false + +# Offense count: 32 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never, either, consistent +Style/HashSyntax: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/IfUnlessModifier: + Enabled: false + +# Offense count: 19 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns. +Style/NumericLiterals: + MinDigits: 15 + +# Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantBegin: + Enabled: false + +# Offense count: 26 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantParentheses: + Enabled: false + +# Offense count: 15 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Enabled: false + +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Enabled: false + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: RequireEnglish, EnforcedStyle. +# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names +Style/SpecialGlobalVars: + Enabled: false + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiteralsInInterpolation: + Enabled: false + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ZeroLengthPredicate: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0e6bce964..082adc6c5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,607 @@ # This configuration was generated by -# `rubocop --auto-gen-config --no-auto-gen-timestamp` -# using RuboCop version 1.28.2. +# `rubocop --auto-gen-config` +# on 2024-08-14 18:20:26 UTC using RuboCop version 1.61.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 # versions of RuboCop, may require this file to be generated again. +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment. +Layout/CommentIndentation: + Exclude: + - 'gems/bulkrax/spec/test_app/db/migrate/20190628050656_create_mailboxer.mailboxer_engine.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'gems/iiif_print/app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLines: + Exclude: + - 'gems/bulkrax/spec/test_app/app/models/solr_document.rb' + - 'gems/bulkrax/spec/test_app/bin/setup' + - 'gems/hyrax/lib/hyrax/specs/shared_specs/workflow_method.rb' + - 'gems/hyrax/spec/spec_helper.rb' + - 'gems/order_already/spec/order_already_spec.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'gems/bulkrax/spec/test_app/config/environments/test.rb' + - 'gems/bulkrax/spec/test_app/config/initializers/mailboxer.rb' + - 'gems/bulkrax/spec/test_app/db/schema.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Exclude: + - 'gems/bulkrax/db/migrate/20191212155530_change_entry_last_error.rb' + - 'gems/bulkrax/spec/test_app/app/models/site.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLinesAroundMethodBody: + Exclude: + - 'gems/bulkrax/db/migrate/20190601221109_add_status_to_entry.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'gems/bulkrax/spec/test_app/app/helpers/application_helper.rb' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'gems/bulkrax/spec/test_app/db/migrate/20190628065945_create_sipity.hyrax.rb' + - 'gems/hyrax/lib/hyrax/specs/shared_specs/change_set.rb' + - 'gems/hyrax/lib/hyrax/specs/shared_specs/indexers.rb' + - 'gems/iiif_print/db/migrate/20231110163052_add_model_details_to_iiif_print_pending_relationships.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, indented_internal_methods +Layout/IndentationConsistency: + Exclude: + - 'gems/bulkrax/spec/test_app/app/models/site.rb' + - 'gems/hyrax/app/services/hyrax/work_uploads_handler.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Width, AllowedPatterns. +Layout/IndentationWidth: + Exclude: + - 'gems/bulkrax/db/migrate/20190731114016_change_importer_and_exporter_to_polymorphic.rb' + - 'gems/bulkrax/spec/test_app/app/models/site.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628065965_add_badge_color_to_collection_types.hyrax.rb' + +# Offense count: 20 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. +Layout/LeadingCommentSpace: + Exclude: + - 'gems/bulkrax/spec/test_app/config/initializers/mailboxer.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628050656_create_mailboxer.mailboxer_engine.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# URISchemes: http, https +Layout/LineLength: + Exclude: + - 'gems/allinson_flex/lib/generators/allinson_flex/install_generator.rb' + - 'gems/hyrax/lib/hyrax/specs/shared_specs/hydra_works.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Layout/MultilineMethodCallIndentation: + Exclude: + - 'gems/hyrax/lib/hyrax/specs/shared_specs/indexers.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAfterComma: + Exclude: + - 'gems/bulkrax/db/migrate/20191212155530_change_entry_last_error.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628050656_create_mailboxer.mailboxer_engine.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleInsidePipes. +# SupportedStylesInsidePipes: space, no_space +Layout/SpaceAroundBlockParameters: + Exclude: + - 'gems/bulkrax/db/migrate/20191212155530_change_entry_last_error.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Exclude: + - 'gems/hyrax/lib/hyrax/specs/shared_specs/workflow_method.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'gems/bulkrax/spec/test_app/config/environments/production.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Exclude: + - 'gems/hyrax/lib/hyrax/specs/shared_specs/hydra_works.rb' + +# Offense count: 7 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'gems/bulkrax/db/migrate/20181011230228_create_bulkrax_importer_runs.rb' + - 'gems/bulkrax/db/migrate/20190325183136_create_bulkrax_entries.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628065959_create_collection_type_participants.hyrax.rb' + - 'gems/questioning_authority/spec/services/linked_data/response_header_service_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, compact, no_space +Layout/SpaceInsideParens: + Exclude: + - 'gems/bulkrax/db/migrate/20240209070952_update_identifier_index.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingEmptyLines: + Exclude: + - 'gems/bulkrax/spec/test_app/app/models/account.rb' + - 'gems/bulkrax/spec/test_app/config/initializers/mime_types.rb' + - 'gems/bulkrax/spec/test_app/spec/models/search_builder_spec.rb' + - 'gems/order_already/lib/order_already/spec_helper.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'gems/bulkrax/db/migrate/20191212155530_change_entry_last_error.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628050407_create_bookmarks.blacklight.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628050408_add_polymorphic_type_to_bookmarks.blacklight.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628065928_create_proxy_deposit_rights.hyrax.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628065929_create_proxy_deposit_requests.hyrax.rb' + - 'gems/iiif_print/app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb' + +# Offense count: 4 +# Configuration parameters: DebuggerMethods. +Lint/Debugger: + Exclude: + - 'gems/hyrax/app/services/hyrax/work_uploads_handler.rb' + - 'gems/iiif_print/app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb' + - 'gems/valkyrie/lib/valkyrie/persistence/postgres/orm_converter.rb' + +# Offense count: 1 +Lint/DuplicateMethods: + Exclude: + - 'gems/allinson_flex/app/services/allinson_flex/importer.rb' + +# Offense count: 2 +Lint/IneffectiveAccessModifier: + Exclude: + - 'gems/allinson_flex/app/services/allinson_flex/importer.rb' + +# Offense count: 2 +# Configuration parameters: AllowedParentClasses. +Lint/MissingSuper: + Exclude: + - 'gems/gems/spec/presenters/hyrax/presenter_factory_spec.rb' + - 'gems/hyrax/spec/presenters/hyrax/presenter_factory_spec.rb' + +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Lint/NestedMethodDefinition: + Exclude: + - 'gems/iiif_print/app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb' + +# Offense count: 1 +Lint/NonLocalExitFromIterator: + Exclude: + - 'gems/allinson_flex/lib/generators/allinson_flex/works_generator.rb' + # Offense count: 1 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# Configuration parameters: AllowComments, AllowNil. +Lint/SuppressedException: + Exclude: + - 'gems/allinson_flex/lib/allinson_flex.rb' + +# Offense count: 1 +Lint/UnreachableCode: + Exclude: + - 'gems/allinson_flex/app/services/allinson_flex/validator.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. +Lint/UselessAssignment: + Exclude: + - 'gems/allinson_flex/app/models/concerns/allinson_flex/dynamic_metadata_behavior.rb' + - 'gems/allinson_flex/app/services/allinson_flex/dynamic_schema_service.rb' + - 'gems/allinson_flex/lib/generators/allinson_flex/works_generator.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects. +Lint/Void: + Exclude: + - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' + - 'gems/order_already/lib/order_already/spec_helper.rb' + +# Offense count: 3 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. +Metrics/AbcSize: + Exclude: + - 'gems/allinson_flex/app/controllers/concerns/allinson_flex/dynamic_catalog_behavior.rb' + - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628065945_create_sipity.hyrax.rb' + +# Offense count: 114 +# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. +# AllowedMethods: refine +Metrics/BlockLength: + Enabled: false + +# Offense count: 1 +# Configuration parameters: CountBlocks, Max. +Metrics/BlockNesting: + Exclude: + - 'gems/allinson_flex/app/models/concerns/allinson_flex/dynamic_solr_document.rb' + +# Offense count: 5 +# Configuration parameters: CountComments, Max, CountAsOne. +Metrics/ClassLength: + Exclude: + - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' + - 'gems/allinson_flex/app/services/allinson_flex/dynamic_schema_service.rb' + - 'gems/allinson_flex/lib/generators/allinson_flex/install_generator.rb' + - 'gems/allinson_flex/lib/generators/allinson_flex/works_generator.rb' + - 'gems/iiif_print/lib/iiif_print/data/work_files.rb' + +# Offense count: 2 +# Configuration parameters: AllowedMethods, AllowedPatterns, Max. +Metrics/CyclomaticComplexity: + Exclude: + - 'gems/allinson_flex/app/controllers/concerns/allinson_flex/dynamic_catalog_behavior.rb' + - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' + +# Offense count: 22 +# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 21 + Enabled: false + +# Offense count: 2 +# Configuration parameters: AllowedMethods, AllowedPatterns, Max. +Metrics/PerceivedComplexity: + Exclude: + - 'gems/allinson_flex/app/controllers/concerns/allinson_flex/dynamic_catalog_behavior.rb' + - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Performance/RegexpMatch: + Exclude: + - 'gems/bulkrax/bin/rspec' + - 'gems/bulkrax/bin/rubocop' + - 'gems/bulkrax/db/migrate/20230608153601_add_indices_to_bulkrax.rb' + - 'gems/valkyrie/bin/rspec' + +# Offense count: 4 +RSpec/AnyInstance: + Exclude: + - 'gems/gems/spec/controllers/hyrax/dashboard/collections_controller_spec.rb' + - 'gems/gems/spec/views/catalog/_index_list_default.html.erb_spec.rb' + - 'gems/hyrax/spec/controllers/hyrax/dashboard/collections_controller_spec.rb' + - 'gems/hyrax/spec/views/catalog/_index_list_default.html.erb_spec.rb' + +# Offense count: 9 +# Configuration parameters: Max. +RSpec/ExampleLength: + Exclude: + - 'spec/features/collection_type_spec.rb' + +# Offense count: 4 +# Configuration parameters: Include. +# Include: db/migrate/*.rb +Rails/CreateTableWithTimestamps: + Exclude: + - 'gems/allinson_flex/db/migrate/20190926000206_create_allinson_flex_profile_texts.rb' + - 'gems/bulkrax/db/migrate/20190729134158_create_bulkrax_exporter_runs.rb' + - 'gems/questioning_authority/db/migrate/20130917200611_create_qa_subject_mesh_terms.rb' + - 'gems/questioning_authority/db/migrate/20130917201026_create_qa_mesh_tree.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, AllowToTime. +# SupportedStyles: strict, flexible +Rails/Date: + Exclude: + - 'gems/allinson_flex/app/controllers/allinson_flex/profiles_controller.rb' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb +Rails/Exit: + Exclude: + - 'gems/allinson_flex/lib/generators/allinson_flex/works_generator.rb' + +# Offense count: 2 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: slashes, arguments +Rails/FilePath: + Exclude: + - 'gems/allinson_flex/app/services/allinson_flex/importer.rb' + - 'gems/bulkrax/spec/test_app/config/environments/development.rb' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/HasAndBelongsToMany: + Exclude: + - 'gems/allinson_flex/app/models/allinson_flex/profile_class.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Rails/IndexBy: + Exclude: + - 'gems/iiif_print/lib/iiif_print/data/work_derivatives.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Rails/IndexWith: + Exclude: + - 'gems/valkyrie/lib/valkyrie/resource.rb' + +# Offense count: 12 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb +Rails/Output: + Exclude: + - 'gems/gems/db/seeds.rb' + - 'gems/gems/lib/hyrax/specs/capybara.rb' + - 'gems/hyrax/db/seeds.rb' + - 'gems/hyrax/lib/hyrax/specs/capybara.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. +Rails/Present: + Exclude: + - 'gems/iiif_print/lib/iiif_print/text_extraction/hocr_reader.rb' + +# Offense count: 13 +# Configuration parameters: Include. +# Include: db/**/*.rb +Rails/ReversibleMigration: + Exclude: + - 'gems/bulkrax/db/migrate/20190731114016_change_importer_and_exporter_to_polymorphic.rb' + - 'gems/bulkrax/db/migrate/20210806044408_remove_unused_last_error.rb' + - 'gems/bulkrax/db/migrate/20210806065737_increase_text_sizes.rb' + - 'gems/bulkrax/db/migrate/20211004170708_change_bulkrax_statuses_error_message_column_type_to_text.rb' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/UniqueValidationWithoutIndex: + Exclude: + - 'gems/gems/app/models/hyrax/collection_type.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Security/JSONLoad: + Exclude: + - 'gems/allinson_flex/app/controllers/allinson_flex/profiles_controller.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Security/YAMLLoad: + Exclude: + - 'gems/bulkrax/spec/test_app/config/initializers/redis_config.rb' + +# Offense count: 11 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: is_a?, kind_of? +Style/ClassCheck: + Exclude: + - 'gems/hyrax/lib/hyrax/specs/shared_specs/indexers.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Keywords, RequireColon. +# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE +Style/CommentAnnotation: + Exclude: + - 'gems/iiif_print/lib/iiif_print/data/work_derivatives.rb' + - 'gems/iiif_print/spec/test_app_templates/lib/generators/test_app_generator.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/EachWithObject: + Exclude: + - 'gems/derivative_rodeo/lib/derivative_rodeo/storage_locations/sqs_location.rb' + - 'gems/space_stone-serverless/awslambda/derivative_rodeo/lib/derivative_rodeo/storage_locations/sqs_location.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/EmptyLiteral: + Exclude: + - 'gems/bulkrax/spec/test_app/spec/models/search_builder_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: format, sprintf, percent +Style/FormatString: + Exclude: + - 'gems/gems/lib/hyrax/specs/capybara.rb' + - 'gems/hyrax/lib/hyrax/specs/capybara.rb' + +# Offense count: 59 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 30 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. +Style/GuardClause: + Enabled: false + +# Offense count: 29 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never, either, consistent +Style/HashSyntax: + Exclude: + - 'gems/bulkrax/spec/test_app/db/migrate/20190628050656_create_mailboxer.mailboxer_engine.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628050657_add_conversation_optout.mailboxer_engine.rb' + - 'gems/bulkrax/spec/test_app/db/migrate/20190628065959_create_collection_type_participants.hyrax.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/IfUnlessModifier: + Exclude: + - 'gems/hyrax/lib/hyrax/specs/shared_specs/workflow_method.rb' + +# Offense count: 19 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns. +Style/NumericLiterals: + MinDigits: 15 + +# Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'gems/allinson_flex/app/models/allinson_flex/profile.rb' + - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' + - 'gems/gems/spec/javascripts/jasmine_spec.rb' + - 'gems/hyrax/spec/javascripts/jasmine_spec.rb' + - 'gems/hyrax/spec/services/hyrax/quick_classification_query_spec.rb' + - 'gems/iiif_print/spec/iiif_print/text_extraction/page_ocr_spec.rb' + - 'gems/iiif_print/spec/services/iiif_print/text_extraction_derivative_service_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'gems/bulkrax/spec/test_app/config/spring.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantBegin: + Exclude: + - 'gems/bulkrax/spec/test_app/bin/yarn' + - 'gems/bulkrax/spec/test_app/config/initializers/hyrax.rb' + +# Offense count: 24 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantParentheses: + Enabled: false + +# Offense count: 14 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' + - 'gems/gems/app/controllers/hyrax/api/items_controller.rb' + - 'gems/gems/app/controllers/hyrax/dashboard/collection_members_controller.rb' + - 'gems/gems/app/controllers/hyrax/dashboard/collections_controller.rb' + - 'gems/gems/app/forms/hyrax/forms/permission_template_form.rb' + - 'gems/gems/lib/wings/hydra/works/services/add_file_to_file_set.rb' + - 'gems/hyrax/app/controllers/hyrax/api/items_controller.rb' + - 'gems/hyrax/app/controllers/hyrax/dashboard/collection_members_controller.rb' + - 'gems/hyrax/app/controllers/hyrax/dashboard/collections_controller.rb' + - 'gems/hyrax/app/forms/hyrax/forms/permission_template_form.rb' + - 'gems/hyrax/lib/wings/hydra/works/services/add_file_to_file_set.rb' + - 'gems/valkyrie/lib/valkyrie/persistence/solr/model_converter.rb' + +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'gems/gems/app/presenters/hyrax/stats_usage_presenter.rb' + - 'gems/gems/app/renderers/hyrax/renderers/attribute_renderer.rb' + - 'gems/hyrax/app/presenters/hyrax/stats_usage_presenter.rb' + - 'gems/hyrax/app/renderers/hyrax/renderers/attribute_renderer.rb' + - 'gems/valkyrie/Rakefile' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'gems/gems/spec/valkyrie/indexing_adapter_spec.rb' + - 'gems/hyrax/spec/valkyrie/indexing_adapter_spec.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiteralsInInterpolation: + Exclude: + - 'gems/bulkrax/spec/test_app/bin/yarn' + - 'gems/gems/spec/views/hyrax/users/show.html.erb_spec.rb' + - 'gems/hyrax/spec/views/hyrax/users/show.html.erb_spec.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ZeroLengthPredicate: + Exclude: + - 'gems/gems/lib/wings/hydra/works/services/add_file_to_file_set.rb' + - 'gems/hyrax/lib/wings/hydra/works/services/add_file_to_file_set.rb' + - 'gems/questioning_authority/lib/qa/authorities/linked_data/search_query.rb' diff --git a/Gemfile b/Gemfile index ef543ae38..28cf55b2d 100644 --- a/Gemfile +++ b/Gemfile @@ -18,10 +18,11 @@ gem 'rails', '~> 6.0', github: 'rails/rails', branch: '6-1-stable', ref: 'd16199 gem 'active_elastic_job', github: 'active-elastic-job/active-elastic-job', ref: 'ec51c5d9dedc4a1b47f2db41f26d5fceb251e979', group: %i[aws] gem 'active-fedora', '~> 14.0' gem 'activerecord-nulldb-adapter' +gem 'activesupport', '>= 4.2.0', group: %i[development test] gem 'addressable', '2.8.1' # remove once https://github.com/postrank-labs/postrank-uri/issues/49 is fixed gem 'apartment', github: 'scientist-softserv/apartment', branch: 'development' gem 'aws-sdk-sqs', group: %i[aws] -gem 'bixby', '~> 5.0', '>= 5.0.2', group: %i[development test] +gem 'bixby', group: %i[development test] gem 'blacklight', '~> 7.29' gem 'blacklight_advanced_search' gem 'blacklight_oai_provider', '~> 7.0' @@ -94,7 +95,8 @@ gem 'rspec-its', group: %i[test] gem 'rspec_junit_formatter', group: %i[test] gem 'rspec-rails', '>= 3.6.0', group: %i[development test] gem 'rspec-retry', group: %i[test] -gem 'rubocop', '1.28.2', group: %i[development test] +gem 'rubocop', '~> 1.61.0', group: %i[development test] +gem 'rubocop-factory_bot', group: %i[development test] gem 'rubocop-rails', '~> 2.15', group: %i[development test] gem 'rubocop-rspec', '~> 1.22', '<= 1.22.2', group: %i[development test] gem 'sass-rails', '~> 6.0' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index 349a5b285..4ee167d78 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,12 +66,6 @@ GIT activesupport (= 6.1.7.6) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.6) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) rails (6.1.7.6) actioncable (= 6.1.7.6) actionmailbox (= 6.1.7.6) @@ -269,6 +263,12 @@ GEM activerecord (>= 4.2) activerecord-nulldb-adapter (1.0.1) activerecord (>= 5.2.0, < 7.2) + activesupport (6.1.7.6) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) aes_key_wrap (1.1.0) @@ -326,8 +326,8 @@ GEM bigdecimal (3.1.5) bindata (2.4.15) bindex (0.8.1) - bixby (5.0.2) - rubocop (= 1.28.2) + bixby (5.0.0) + rubocop (>= 1, < 2) rubocop-ast rubocop-performance rubocop-rails @@ -815,6 +815,7 @@ GEM kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) language_list (1.2.1) + language_server-protocol (3.17.0.3) latex-decode (0.4.0) launchy (2.5.2) addressable (~> 2.8) @@ -1010,7 +1011,7 @@ GEM os (1.1.4) ostruct (0.6.0) parallel (1.23.0) - parser (3.2.2.4) + parser (3.3.4.2) ast (~> 2.4.1) racc parslet (2.0.0) @@ -1076,6 +1077,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + rbs (2.8.4) rdf (3.3.1) bcp47_spec (~> 0.2) link_header (~> 0.0, >= 0.0.8) @@ -1212,17 +1214,21 @@ GEM rspec-support (3.12.1) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.28.2) + rubocop (1.61.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.17.0, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) + unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.30.0) parser (>= 3.2.1.0) + rubocop-factory_bot (2.26.1) + rubocop (~> 1.61) rubocop-performance (1.19.1) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) @@ -1306,18 +1312,19 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) - solargraph (0.48.0) + solargraph (0.50.0) backport (~> 1.2) benchmark - bundler (>= 1.17.2) + bundler (~> 2.0) diff-lcs (~> 1.4) e2mmap jaro_winkler (~> 1.5) kramdown (~> 2.3) kramdown-parser-gfm (~> 1.1) parser (~> 3.0) - reverse_markdown (>= 1.0.5, < 3) - rubocop (>= 0.52) + rbs (~> 2.0) + reverse_markdown (~> 2.0) + rubocop (~> 1.38) thor (~> 1.0) tilt (~> 2.0) yard (~> 0.9, >= 0.9.24) @@ -1389,7 +1396,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) - unicode-display_width (1.8.0) + unicode-display_width (2.5.0) unicode-types (1.9.0) unicode_utils (1.4.0) validatable (1.6.7) @@ -1460,10 +1467,11 @@ DEPENDENCIES active-fedora (~> 14.0) active_elastic_job! activerecord-nulldb-adapter + activesupport (>= 4.2.0) addressable (= 2.8.1) apartment! aws-sdk-sqs - bixby (~> 5.0, >= 5.0.2) + bixby blacklight (~> 7.29) blacklight_advanced_search blacklight_oai_provider (~> 7.0) @@ -1537,7 +1545,8 @@ DEPENDENCIES rspec-rails (>= 3.6.0) rspec-retry rspec_junit_formatter - rubocop (= 1.28.2) + rubocop (~> 1.61.0) + rubocop-factory_bot rubocop-rails (~> 2.15) rubocop-rspec (~> 1.22, <= 1.22.2) sass-rails (~> 6.0) From e33b424d45201475ea77116e6db0d400da8d439e Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 14 Aug 2024 15:15:23 -0700 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=92=84=20updates=20for=20rubocop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop.yml | 8 +- .rubocop_fixme.yml | 468 +------------- .rubocop_todo.yml | 585 +----------------- Gemfile | 1 + Gemfile.lock | 3 + .../collections_controller_decorator.rb | 2 + app/models/sushi/item_report.rb | 50 +- app/models/sushi/platform_report.rb | 93 +-- app/models/sushi/platform_usage_report.rb | 62 +- 9 files changed, 170 insertions(+), 1102 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 628d2b42b..3a38a9376 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,11 +5,16 @@ inherit_from: inherit_gem: bixby: bixby_default.yml +Layout/IndentationWidth: + Width: 2 + AllCops: NewCops: disable TargetRubyVersion: 3.2.2 DisplayCopNames: true + SuggestExtensions: false Exclude: + - 'gems/**/*' - 'db/**/*' - 'script/**/*' - 'spec/test_app_templates/**/*' @@ -17,6 +22,7 @@ AllCops: - 'lib/hyrax/specs/**/*' - 'bin/graph' - 'bin/import_from_purl' + - 'spec/features/**/*' Lint/ImplicitStringConcatenation: Exclude: @@ -27,7 +33,7 @@ Rails/Output: - 'lib/generators/**/*' Metrics/BlockLength: - IgnoredMethods: ['included'] + AllowedMethods: ['included'] Exclude: - 'hyrax.gemspec' - 'app/models/concerns/hyrax/content_block_behavior.rb' diff --git a/.rubocop_fixme.yml b/.rubocop_fixme.yml index abe4d96c0..539c8101e 100644 --- a/.rubocop_fixme.yml +++ b/.rubocop_fixme.yml @@ -1,473 +1,7 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 0` -# on 2024-08-14 18:07:37 UTC using RuboCop version 1.61.0. +# on 2024-08-14 22:12:29 UTC using RuboCop version 1.61.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 # versions of RuboCop, may require this file to be generated again. - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/CommentIndentation: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Enabled: false - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLines: - Enabled: false - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Enabled: false - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only -Layout/EmptyLinesAroundClassBody: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLinesAroundMethodBody: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines -Layout/EmptyLinesAroundModuleBody: - Enabled: false - -# Offense count: 11 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: normal, indented_internal_methods -Layout/IndentationConsistency: - Enabled: false - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns. -Layout/IndentationWidth: - Enabled: false - -# Offense count: 20 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. -Layout/LeadingCommentSpace: - Enabled: false - -# Offense count: 11 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. -# URISchemes: http, https -Layout/LineLength: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Enabled: false - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAfterComma: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleInsidePipes. -# SupportedStylesInsidePipes: space, no_space -Layout/SpaceAroundBlockParameters: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Enabled: false - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Enabled: false - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, compact, no_space -Layout/SpaceInsideParens: - Enabled: false - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingEmptyLines: - Enabled: false - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Enabled: false - -# Offense count: 4 -# Configuration parameters: DebuggerMethods. -Lint/Debugger: - Enabled: false - -# Offense count: 1 -Lint/DuplicateMethods: - Enabled: false - -# Offense count: 2 -Lint/IneffectiveAccessModifier: - Enabled: false - -# Offense count: 3 -# Configuration parameters: AllowedParentClasses. -Lint/MissingSuper: - Enabled: false - -# Offense count: 1 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Lint/NestedMethodDefinition: - Enabled: false - -# Offense count: 1 -Lint/NonLocalExitFromIterator: - Enabled: false - -# Offense count: 1 -# Configuration parameters: AllowComments, AllowNil. -Lint/SuppressedException: - Enabled: false - -# Offense count: 1 -Lint/UnreachableCode: - Enabled: false - -# Offense count: 40 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. -Lint/UnusedMethodArgument: - Enabled: false - -# Offense count: 4 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect. -Lint/UselessAssignment: - Enabled: false - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects. -Lint/Void: - Enabled: false - -# Offense count: 3 -# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. -Metrics/AbcSize: - Enabled: false - -# Offense count: 115 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -# AllowedMethods: refine -Metrics/BlockLength: - Max: 191 - -# Offense count: 1 -# Configuration parameters: CountBlocks. -Metrics/BlockNesting: - Max: 5 - -# Offense count: 5 -# Configuration parameters: CountComments, CountAsOne. -Metrics/ClassLength: - Max: 183 - -# Offense count: 2 -# Configuration parameters: AllowedMethods, AllowedPatterns, Max. -Metrics/CyclomaticComplexity: - Enabled: false - -# Offense count: 35 -# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. -Metrics/MethodLength: - Enabled: false - -# Offense count: 2 -# Configuration parameters: AllowedMethods, AllowedPatterns, Max. -Metrics/PerceivedComplexity: - Enabled: false - -# Offense count: 1 -Naming/AccessorMethodName: - Enabled: false - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Performance/RegexpMatch: - Enabled: false - -# Offense count: 4 -RSpec/AnyInstance: - Enabled: false - -# Offense count: 10 -# Configuration parameters: Max. -RSpec/ExampleLength: - Enabled: false - -# Offense count: 4 -# Configuration parameters: Include. -# Include: db/migrate/*.rb -Rails/CreateTableWithTimestamps: - Enabled: false - -# Offense count: 1 -# Configuration parameters: EnforcedStyle, AllowToTime. -# SupportedStyles: strict, flexible -Rails/Date: - Enabled: false - -# Offense count: 1 -# Configuration parameters: Include. -# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb -Rails/Exit: - Enabled: false - -# Offense count: 2 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: slashes, arguments -Rails/FilePath: - Enabled: false - -# Offense count: 1 -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/HasAndBelongsToMany: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Rails/IndexBy: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Rails/IndexWith: - Enabled: false - -# Offense count: 12 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Include. -# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb -Rails/Output: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. -Rails/Present: - Enabled: false - -# Offense count: 13 -# Configuration parameters: Include. -# Include: db/**/*.rb -Rails/ReversibleMigration: - Enabled: false - -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: strict, flexible -Rails/TimeZone: - Enabled: false - -# Offense count: 1 -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/UniqueValidationWithoutIndex: - Enabled: false - -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -Security/JSONLoad: - Enabled: false - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Security/YAMLLoad: - Enabled: false - -# Offense count: 11 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: is_a?, kind_of? -Style/ClassCheck: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Keywords, RequireColon. -# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE -Style/CommentAnnotation: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/EachWithObject: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/EmptyLiteral: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: format, sprintf, percent -Style/FormatString: - Enabled: false - -# Offense count: 94 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, always_true, never -Style/FrozenStringLiteralComment: - Enabled: false - -# Offense count: 30 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. -Style/GuardClause: - Enabled: false - -# Offense count: 32 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent -Style/HashSyntax: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/IfUnlessModifier: - Enabled: false - -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns. -Style/NumericLiterals: - MinDigits: 15 - -# Offense count: 7 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. -# SupportedStyles: predicate, comparison -Style/NumericPredicate: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantBegin: - Enabled: false - -# Offense count: 26 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantParentheses: - Enabled: false - -# Offense count: 15 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Enabled: false - -# Offense count: 5 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. -# AllowedMethods: present?, blank?, presence, try, try! -Style/SafeNavigation: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowAsExpressionSeparator. -Style/Semicolon: - Enabled: false - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: RequireEnglish, EnforcedStyle. -# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names -Style/SpecialGlobalVars: - Enabled: false - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiteralsInInterpolation: - Enabled: false - -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/ZeroLengthPredicate: - Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 082adc6c5..f7babfc71 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,607 +1,74 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-08-14 18:20:26 UTC using RuboCop version 1.61.0. +# on 2024-08-14 22:12:52 UTC using RuboCop version 1.61.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 # versions of RuboCop, may require this file to be generated again. -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/CommentIndentation: - Exclude: - - 'gems/bulkrax/spec/test_app/db/migrate/20190628050656_create_mailboxer.mailboxer_engine.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Exclude: - - 'gems/iiif_print/app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLines: - Exclude: - - 'gems/bulkrax/spec/test_app/app/models/solr_document.rb' - - 'gems/bulkrax/spec/test_app/bin/setup' - - 'gems/hyrax/lib/hyrax/specs/shared_specs/workflow_method.rb' - - 'gems/hyrax/spec/spec_helper.rb' - - 'gems/order_already/spec/order_already_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'gems/bulkrax/spec/test_app/config/environments/test.rb' - - 'gems/bulkrax/spec/test_app/config/initializers/mailboxer.rb' - - 'gems/bulkrax/spec/test_app/db/schema.rb' - # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only -Layout/EmptyLinesAroundClassBody: - Exclude: - - 'gems/bulkrax/db/migrate/20191212155530_change_entry_last_error.rb' - - 'gems/bulkrax/spec/test_app/app/models/site.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLinesAroundMethodBody: - Exclude: - - 'gems/bulkrax/db/migrate/20190601221109_add_status_to_entry.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines -Layout/EmptyLinesAroundModuleBody: - Exclude: - - 'gems/bulkrax/spec/test_app/app/helpers/application_helper.rb' - -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. Layout/ExtraSpacing: Exclude: - - 'gems/bulkrax/spec/test_app/db/migrate/20190628065945_create_sipity.hyrax.rb' - - 'gems/hyrax/lib/hyrax/specs/shared_specs/change_set.rb' - - 'gems/hyrax/lib/hyrax/specs/shared_specs/indexers.rb' - - 'gems/iiif_print/db/migrate/20231110163052_add_model_details_to_iiif_print_pending_relationships.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: normal, indented_internal_methods -Layout/IndentationConsistency: - Exclude: - - 'gems/bulkrax/spec/test_app/app/models/site.rb' - - 'gems/hyrax/app/services/hyrax/work_uploads_handler.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns. -Layout/IndentationWidth: - Exclude: - - 'gems/bulkrax/db/migrate/20190731114016_change_importer_and_exporter_to_polymorphic.rb' - - 'gems/bulkrax/spec/test_app/app/models/site.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628065965_add_badge_color_to_collection_types.hyrax.rb' - -# Offense count: 20 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. -Layout/LeadingCommentSpace: - Exclude: - - 'gems/bulkrax/spec/test_app/config/initializers/mailboxer.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628050656_create_mailboxer.mailboxer_engine.rb' + - 'spec/models/account_spec.rb' # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. -# URISchemes: http, https -Layout/LineLength: - Exclude: - - 'gems/allinson_flex/lib/generators/allinson_flex/install_generator.rb' - - 'gems/hyrax/lib/hyrax/specs/shared_specs/hydra_works.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'gems/hyrax/lib/hyrax/specs/shared_specs/indexers.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAfterComma: - Exclude: - - 'gems/bulkrax/db/migrate/20191212155530_change_entry_last_error.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628050656_create_mailboxer.mailboxer_engine.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleInsidePipes. -# SupportedStylesInsidePipes: space, no_space -Layout/SpaceAroundBlockParameters: - Exclude: - - 'gems/bulkrax/db/migrate/20191212155530_change_entry_last_error.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Exclude: - - 'gems/hyrax/lib/hyrax/specs/shared_specs/workflow_method.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideArrayLiteralBrackets: - Exclude: - - 'gems/bulkrax/spec/test_app/config/environments/production.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: +# Configuration parameters: AllowForAlignment. +Layout/SpaceBeforeFirstArg: Exclude: - - 'gems/hyrax/lib/hyrax/specs/shared_specs/hydra_works.rb' + - 'spec/models/account_spec.rb' # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'gems/bulkrax/db/migrate/20181011230228_create_bulkrax_importer_runs.rb' - - 'gems/bulkrax/db/migrate/20190325183136_create_bulkrax_entries.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628065959_create_collection_type_participants.hyrax.rb' - - 'gems/questioning_authority/spec/services/linked_data/response_header_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, compact, no_space -Layout/SpaceInsideParens: - Exclude: - - 'gems/bulkrax/db/migrate/20240209070952_update_identifier_index.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingEmptyLines: - Exclude: - - 'gems/bulkrax/spec/test_app/app/models/account.rb' - - 'gems/bulkrax/spec/test_app/config/initializers/mime_types.rb' - - 'gems/bulkrax/spec/test_app/spec/models/search_builder_spec.rb' - - 'gems/order_already/lib/order_already/spec_helper.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: Exclude: - - 'gems/bulkrax/db/migrate/20191212155530_change_entry_last_error.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628050407_create_bookmarks.blacklight.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628050408_add_polymorphic_type_to_bookmarks.blacklight.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628065928_create_proxy_deposit_rights.hyrax.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628065929_create_proxy_deposit_requests.hyrax.rb' - - 'gems/iiif_print/app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb' - -# Offense count: 4 -# Configuration parameters: DebuggerMethods. -Lint/Debugger: - Exclude: - - 'gems/hyrax/app/services/hyrax/work_uploads_handler.rb' - - 'gems/iiif_print/app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb' - - 'gems/valkyrie/lib/valkyrie/persistence/postgres/orm_converter.rb' + - 'app/models/sushi/item_report.rb' + - 'app/models/sushi/platform_report.rb' # Offense count: 1 -Lint/DuplicateMethods: - Exclude: - - 'gems/allinson_flex/app/services/allinson_flex/importer.rb' - -# Offense count: 2 -Lint/IneffectiveAccessModifier: - Exclude: - - 'gems/allinson_flex/app/services/allinson_flex/importer.rb' - -# Offense count: 2 # Configuration parameters: AllowedParentClasses. Lint/MissingSuper: Exclude: - - 'gems/gems/spec/presenters/hyrax/presenter_factory_spec.rb' - - 'gems/hyrax/spec/presenters/hyrax/presenter_factory_spec.rb' - -# Offense count: 1 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Lint/NestedMethodDefinition: - Exclude: - - 'gems/iiif_print/app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb' - -# Offense count: 1 -Lint/NonLocalExitFromIterator: - Exclude: - - 'gems/allinson_flex/lib/generators/allinson_flex/works_generator.rb' - -# Offense count: 1 -# Configuration parameters: AllowComments, AllowNil. -Lint/SuppressedException: - Exclude: - - 'gems/allinson_flex/lib/allinson_flex.rb' - -# Offense count: 1 -Lint/UnreachableCode: - Exclude: - - 'gems/allinson_flex/app/services/allinson_flex/validator.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. -Lint/UnusedMethodArgument: - Exclude: - - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' + - 'spec/services/iiif_print/tenant_config_spec.rb' -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect. -Lint/UselessAssignment: - Exclude: - - 'gems/allinson_flex/app/models/concerns/allinson_flex/dynamic_metadata_behavior.rb' - - 'gems/allinson_flex/app/services/allinson_flex/dynamic_schema_service.rb' - - 'gems/allinson_flex/lib/generators/allinson_flex/works_generator.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects. -Lint/Void: - Exclude: - - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' - - 'gems/order_already/lib/order_already/spec_helper.rb' - -# Offense count: 3 -# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. -Metrics/AbcSize: - Exclude: - - 'gems/allinson_flex/app/controllers/concerns/allinson_flex/dynamic_catalog_behavior.rb' - - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628065945_create_sipity.hyrax.rb' - -# Offense count: 114 -# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. -# AllowedMethods: refine -Metrics/BlockLength: - Enabled: false - -# Offense count: 1 -# Configuration parameters: CountBlocks, Max. -Metrics/BlockNesting: - Exclude: - - 'gems/allinson_flex/app/models/concerns/allinson_flex/dynamic_solr_document.rb' - -# Offense count: 5 -# Configuration parameters: CountComments, Max, CountAsOne. -Metrics/ClassLength: - Exclude: - - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' - - 'gems/allinson_flex/app/services/allinson_flex/dynamic_schema_service.rb' - - 'gems/allinson_flex/lib/generators/allinson_flex/install_generator.rb' - - 'gems/allinson_flex/lib/generators/allinson_flex/works_generator.rb' - - 'gems/iiif_print/lib/iiif_print/data/work_files.rb' - -# Offense count: 2 -# Configuration parameters: AllowedMethods, AllowedPatterns, Max. -Metrics/CyclomaticComplexity: - Exclude: - - 'gems/allinson_flex/app/controllers/concerns/allinson_flex/dynamic_catalog_behavior.rb' - - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' - -# Offense count: 22 +# Offense count: 12 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Enabled: false - -# Offense count: 2 -# Configuration parameters: AllowedMethods, AllowedPatterns, Max. -Metrics/PerceivedComplexity: - Exclude: - - 'gems/allinson_flex/app/controllers/concerns/allinson_flex/dynamic_catalog_behavior.rb' - - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Performance/RegexpMatch: - Exclude: - - 'gems/bulkrax/bin/rspec' - - 'gems/bulkrax/bin/rubocop' - - 'gems/bulkrax/db/migrate/20230608153601_add_indices_to_bulkrax.rb' - - 'gems/valkyrie/bin/rspec' - -# Offense count: 4 -RSpec/AnyInstance: - Exclude: - - 'gems/gems/spec/controllers/hyrax/dashboard/collections_controller_spec.rb' - - 'gems/gems/spec/views/catalog/_index_list_default.html.erb_spec.rb' - - 'gems/hyrax/spec/controllers/hyrax/dashboard/collections_controller_spec.rb' - - 'gems/hyrax/spec/views/catalog/_index_list_default.html.erb_spec.rb' - -# Offense count: 9 -# Configuration parameters: Max. -RSpec/ExampleLength: - Exclude: - - 'spec/features/collection_type_spec.rb' - -# Offense count: 4 -# Configuration parameters: Include. -# Include: db/migrate/*.rb -Rails/CreateTableWithTimestamps: - Exclude: - - 'gems/allinson_flex/db/migrate/20190926000206_create_allinson_flex_profile_texts.rb' - - 'gems/bulkrax/db/migrate/20190729134158_create_bulkrax_exporter_runs.rb' - - 'gems/questioning_authority/db/migrate/20130917200611_create_qa_subject_mesh_terms.rb' - - 'gems/questioning_authority/db/migrate/20130917201026_create_qa_mesh_tree.rb' - -# Offense count: 1 -# Configuration parameters: EnforcedStyle, AllowToTime. -# SupportedStyles: strict, flexible -Rails/Date: - Exclude: - - 'gems/allinson_flex/app/controllers/allinson_flex/profiles_controller.rb' - -# Offense count: 1 -# Configuration parameters: Include. -# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb -Rails/Exit: - Exclude: - - 'gems/allinson_flex/lib/generators/allinson_flex/works_generator.rb' - -# Offense count: 2 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: slashes, arguments -Rails/FilePath: - Exclude: - - 'gems/allinson_flex/app/services/allinson_flex/importer.rb' - - 'gems/bulkrax/spec/test_app/config/environments/development.rb' - -# Offense count: 1 -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/HasAndBelongsToMany: - Exclude: - - 'gems/allinson_flex/app/models/allinson_flex/profile_class.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Rails/IndexBy: - Exclude: - - 'gems/iiif_print/lib/iiif_print/data/work_derivatives.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Rails/IndexWith: - Exclude: - - 'gems/valkyrie/lib/valkyrie/resource.rb' - -# Offense count: 12 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Include. -# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb -Rails/Output: - Exclude: - - 'gems/gems/db/seeds.rb' - - 'gems/gems/lib/hyrax/specs/capybara.rb' - - 'gems/hyrax/db/seeds.rb' - - 'gems/hyrax/lib/hyrax/specs/capybara.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. -Rails/Present: - Exclude: - - 'gems/iiif_print/lib/iiif_print/text_extraction/hocr_reader.rb' - -# Offense count: 13 -# Configuration parameters: Include. -# Include: db/**/*.rb -Rails/ReversibleMigration: - Exclude: - - 'gems/bulkrax/db/migrate/20190731114016_change_importer_and_exporter_to_polymorphic.rb' - - 'gems/bulkrax/db/migrate/20210806044408_remove_unused_last_error.rb' - - 'gems/bulkrax/db/migrate/20210806065737_increase_text_sizes.rb' - - 'gems/bulkrax/db/migrate/20211004170708_change_bulkrax_statuses_error_message_column_type_to_text.rb' - -# Offense count: 1 -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/UniqueValidationWithoutIndex: - Exclude: - - 'gems/gems/app/models/hyrax/collection_type.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Security/JSONLoad: - Exclude: - - 'gems/allinson_flex/app/controllers/allinson_flex/profiles_controller.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Security/YAMLLoad: - Exclude: - - 'gems/bulkrax/spec/test_app/config/initializers/redis_config.rb' - -# Offense count: 11 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: is_a?, kind_of? -Style/ClassCheck: - Exclude: - - 'gems/hyrax/lib/hyrax/specs/shared_specs/indexers.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Keywords, RequireColon. -# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE -Style/CommentAnnotation: Exclude: - - 'gems/iiif_print/lib/iiif_print/data/work_derivatives.rb' - - 'gems/iiif_print/spec/test_app_templates/lib/generators/test_app_generator.rb' + - 'app/controllers/application_controller.rb' + - 'app/controllers/hyrax/dashboard/collections_controller_decorator.rb' + - 'app/controllers/identity_providers_controller.rb' + - 'app/controllers/users/omniauth_callbacks_controller.rb' + - 'app/helpers/blacklight/catalog_helper_behavior_decorator.rb' + - 'app/jobs/batch_email_notification_job.rb' + - 'app/jobs/reindex_works_job.rb' + - 'app/models/sort_title.rb' + - 'app/models/sushi.rb' + - 'lib/reprocessor.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/EachWithObject: - Exclude: - - 'gems/derivative_rodeo/lib/derivative_rodeo/storage_locations/sqs_location.rb' - - 'gems/space_stone-serverless/awslambda/derivative_rodeo/lib/derivative_rodeo/storage_locations/sqs_location.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/EmptyLiteral: - Exclude: - - 'gems/bulkrax/spec/test_app/spec/models/search_builder_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: format, sprintf, percent -Style/FormatString: - Exclude: - - 'gems/gems/lib/hyrax/specs/capybara.rb' - - 'gems/hyrax/lib/hyrax/specs/capybara.rb' - -# Offense count: 59 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, always_true, never -Style/FrozenStringLiteralComment: - Enabled: false - -# Offense count: 30 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. -Style/GuardClause: - Enabled: false - -# Offense count: 29 +# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys # SupportedShorthandSyntax: always, never, either, consistent Style/HashSyntax: Exclude: - - 'gems/bulkrax/spec/test_app/db/migrate/20190628050656_create_mailboxer.mailboxer_engine.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628050657_add_conversation_optout.mailboxer_engine.rb' - - 'gems/bulkrax/spec/test_app/db/migrate/20190628065959_create_collection_type_participants.hyrax.rb' + - 'app/controllers/roles_controller.rb' + - 'spec/views/hyrax/base/_relationships.html.erb_spec.rb' # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). -Style/IfUnlessModifier: - Exclude: - - 'gems/hyrax/lib/hyrax/specs/shared_specs/workflow_method.rb' - -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns. -Style/NumericLiterals: - MinDigits: 15 - -# Offense count: 7 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. -# SupportedStyles: predicate, comparison -Style/NumericPredicate: +Style/RedundantParentheses: Exclude: - - 'gems/allinson_flex/app/models/allinson_flex/profile.rb' - - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' - - 'gems/gems/spec/javascripts/jasmine_spec.rb' - - 'gems/hyrax/spec/javascripts/jasmine_spec.rb' - - 'gems/hyrax/spec/services/hyrax/quick_classification_query_spec.rb' - - 'gems/iiif_print/spec/iiif_print/text_extraction/page_ocr_spec.rb' - - 'gems/iiif_print/spec/services/iiif_print/text_extraction_derivative_service_spec.rb' + - 'app/models/hydra/access_controls/embargo_decorator.rb' + - 'app/models/hydra/access_controls/lease_decorator.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Exclude: - - 'gems/bulkrax/spec/test_app/config/spring.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantBegin: - Exclude: - - 'gems/bulkrax/spec/test_app/bin/yarn' - - 'gems/bulkrax/spec/test_app/config/initializers/hyrax.rb' - -# Offense count: 24 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantParentheses: - Enabled: false - -# Offense count: 14 -# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: Exclude: - - 'gems/allinson_flex/app/services/allinson_flex/allinson_flex_constructor.rb' - - 'gems/gems/app/controllers/hyrax/api/items_controller.rb' - - 'gems/gems/app/controllers/hyrax/dashboard/collection_members_controller.rb' - - 'gems/gems/app/controllers/hyrax/dashboard/collections_controller.rb' - - 'gems/gems/app/forms/hyrax/forms/permission_template_form.rb' - - 'gems/gems/lib/wings/hydra/works/services/add_file_to_file_set.rb' - - 'gems/hyrax/app/controllers/hyrax/api/items_controller.rb' - - 'gems/hyrax/app/controllers/hyrax/dashboard/collection_members_controller.rb' - - 'gems/hyrax/app/controllers/hyrax/dashboard/collections_controller.rb' - - 'gems/hyrax/app/forms/hyrax/forms/permission_template_form.rb' - - 'gems/hyrax/lib/wings/hydra/works/services/add_file_to_file_set.rb' - - 'gems/valkyrie/lib/valkyrie/persistence/solr/model_converter.rb' - -# Offense count: 5 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. -# AllowedMethods: present?, blank?, presence, try, try! -Style/SafeNavigation: - Exclude: - - 'gems/gems/app/presenters/hyrax/stats_usage_presenter.rb' - - 'gems/gems/app/renderers/hyrax/renderers/attribute_renderer.rb' - - 'gems/hyrax/app/presenters/hyrax/stats_usage_presenter.rb' - - 'gems/hyrax/app/renderers/hyrax/renderers/attribute_renderer.rb' - - 'gems/valkyrie/Rakefile' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowAsExpressionSeparator. -Style/Semicolon: - Exclude: - - 'gems/gems/spec/valkyrie/indexing_adapter_spec.rb' - - 'gems/hyrax/spec/valkyrie/indexing_adapter_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiteralsInInterpolation: - Exclude: - - 'gems/bulkrax/spec/test_app/bin/yarn' - - 'gems/gems/spec/views/hyrax/users/show.html.erb_spec.rb' - - 'gems/hyrax/spec/views/hyrax/users/show.html.erb_spec.rb' - -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/ZeroLengthPredicate: - Exclude: - - 'gems/gems/lib/wings/hydra/works/services/add_file_to_file_set.rb' - - 'gems/hyrax/lib/wings/hydra/works/services/add_file_to_file_set.rb' - - 'gems/questioning_authority/lib/qa/authorities/linked_data/search_query.rb' + - 'app/helpers/application_helper.rb' diff --git a/Gemfile b/Gemfile index 28cf55b2d..b859869eb 100644 --- a/Gemfile +++ b/Gemfile @@ -96,6 +96,7 @@ gem 'rspec_junit_formatter', group: %i[test] gem 'rspec-rails', '>= 3.6.0', group: %i[development test] gem 'rspec-retry', group: %i[test] gem 'rubocop', '~> 1.61.0', group: %i[development test] +gem 'rubocop-capybara', group: %i[development test] gem 'rubocop-factory_bot', group: %i[development test] gem 'rubocop-rails', '~> 2.15', group: %i[development test] gem 'rubocop-rspec', '~> 1.22', '<= 1.22.2', group: %i[development test] diff --git a/Gemfile.lock b/Gemfile.lock index 4ee167d78..2d847a7fa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1227,6 +1227,8 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.30.0) parser (>= 3.2.1.0) + rubocop-capybara (2.21.0) + rubocop (~> 1.41) rubocop-factory_bot (2.26.1) rubocop (~> 1.61) rubocop-performance (1.19.1) @@ -1546,6 +1548,7 @@ DEPENDENCIES rspec-retry rspec_junit_formatter rubocop (~> 1.61.0) + rubocop-capybara rubocop-factory_bot rubocop-rails (~> 2.15) rubocop-rspec (~> 1.22, <= 1.22.2) diff --git a/app/controllers/hyrax/dashboard/collections_controller_decorator.rb b/app/controllers/hyrax/dashboard/collections_controller_decorator.rb index a4891ed86..8424eceb0 100644 --- a/app/controllers/hyrax/dashboard/collections_controller_decorator.rb +++ b/app/controllers/hyrax/dashboard/collections_controller_decorator.rb @@ -21,6 +21,7 @@ def show end # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/MethodLength def update_valkyrie_collection return after_update_errors(form_err_msg(form)) unless form.validate(collection_params) @@ -42,6 +43,7 @@ def update_valkyrie_collection after_update_response end # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/MethodLength def edit form diff --git a/app/models/sushi/item_report.rb b/app/models/sushi/item_report.rb index e10ce8860..26f0e8a4d 100644 --- a/app/models/sushi/item_report.rb +++ b/app/models/sushi/item_report.rb @@ -127,22 +127,7 @@ def as_json(_options = {}) def report_items data_for_resource_types.map do |record| { - 'Items' => [{ - 'Attribute_Performance' => [{ - 'Data_Type' => record.resource_type.titleize, - # We are only supporting the 'Regular' access method at this time. If that changes, we will need to update this. - 'Access_Method' => 'Regular', - 'Performance' => performance(record) - }], - 'Authors' => Sushi::AuthorCoercion.deserialize(record.author).map { |author| { 'Name:' => author } }, - 'Item' => record.work_id.to_s, - 'Publisher' => '', - 'Platform' => account.cname, - 'Item_ID' => { - 'Proprietary': record.work_id.to_s, - 'URI': "https://#{account.cname}/concern/#{record.worktype.underscore}s/#{record.work_id}" - } - }] + 'Items' => [item_attributes(record)] } end end @@ -184,6 +169,39 @@ def data_for_resource_types relation end # rubocop:enable Metrics/MethodLength + + private + + def item_attributes(record) + { + 'Attribute_Performance' => attribute_performance(record), + 'Authors' => authors(record), + 'Item' => record.work_id.to_s, + 'Publisher' => '', + 'Platform' => account.cname, + 'Item_ID' => item_id(record) + } + end + + def attribute_performance(record) + [{ + 'Data_Type' => record.resource_type.titleize, + # We are only supporting the 'Regular' access method at this time. If that changes, we will need to update this. + 'Access_Method' => 'Regular', + 'Performance' => performance(record) + }] + end + + def authors(record) + Sushi::AuthorCoercion.deserialize(record.author).map { |author| { 'Name:' => author } } + end + + def item_id(record) + { + 'Proprietary': record.work_id.to_s, + 'URI': "https://#{account.cname}/concern/#{record.worktype.underscore}s/#{record.work_id}" + } + end end # rubocop:enable Metrics/ClassLength end diff --git a/app/models/sushi/platform_report.rb b/app/models/sushi/platform_report.rb index 264ab04f5..514180c7f 100644 --- a/app/models/sushi/platform_report.rb +++ b/app/models/sushi/platform_report.rb @@ -141,23 +141,13 @@ def attribute_performance_for_resource_types end def attribute_performance_for_platform - return [] if metric_type_in_params && metric_types.exclude?("Searches_Platform") - return [] if data_type_in_params && !data_types.find { |dt| dt.casecmp("Platform").zero? } - + return [] if exclude_based_on_metric_type? + return [] if exclude_based_on_data_type? + [{ "Data_Type" => "Platform", "Access_Method" => "Regular", - "Performance" => { - "Searches_Platform" => if granularity == 'Totals' - total_for_platform = data_for_platform.sum(&:total_item_investigations) - { "Totals" => total_for_platform } - else - data_for_platform.each_with_object({}) do |record, hash| - hash[record.year_month.strftime("%Y-%m")] = record.total_item_investigations - hash - end - end - } + "Performance" => performance_for_platform }] end @@ -187,28 +177,9 @@ def performance(record) # see the docs for counting unique items here: https://cop5.projectcounter.org/en/5.1/07-processing/03-counting-unique-items.html # rubocop:disable Layout/LineLength def data_for_resource_types - # We're capturing this relation/query because in some cases, we need to chain another where - # clause onto the relation. - relation = Hyrax::CounterMetric - .select(:resource_type, :worktype, - %((SELECT To_json(Array_agg(Row_to_json(t))) - FROM - (SELECT - -- The AS field_name needs to be double quoted so as to preserve case structure. - SUM(total_item_investigations) as "Total_Item_Investigations", - SUM(total_item_requests) as "Total_Item_Requests", - COUNT(DISTINCT CASE WHEN total_item_investigations IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Investigations", - COUNT(DISTINCT CASE WHEN total_item_requests IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Requests", - -- We need to coerce the month from a single digit to two digits (e.g. August's "8" into "08") - CONCAT(DATE_PART('year', date_trunc('month', date)), '-', to_char(DATE_PART('month', date_trunc('month', date)), 'fm00')) AS year_month - FROM hyrax_counter_metrics AS aggr - WHERE #{Hyrax::CounterMetric.sanitize_sql_for_conditions(['aggr.resource_type = hyrax_counter_metrics.resource_type AND date >= ? AND date <= ?', begin_date, end_date])} - GROUP BY date_trunc('month', date)) t) as performance)) - .where("date >= ? AND date <= ?", begin_date, end_date) - .order(resource_type: :asc) - .group(:resource_type, :worktype) + relation = build_base_relation return relation if data_types.blank? - + relation.where("LOWER(resource_type) IN (?)", data_types) end # rubocop:enable Layout/LineLength @@ -222,6 +193,58 @@ def data_for_platform .order("year_month") .group("date_trunc('month', date)") end + + private + + def exclude_based_on_metric_type? + metric_type_in_params && metric_types.exclude?("Searches_Platform") + end + + def exclude_based_on_data_type? + data_type_in_params && !data_types.any? { |dt| dt.casecmp("Platform").zero? } + end + + def performance_for_platform + if granularity == 'Totals' + { "Totals" => total_for_platform } + else + performance_by_month + end + end + + def total_for_platform + data_for_platform.sum(&:total_item_investigations) + end + + def performance_by_month + data_for_platform.each_with_object({}) do |record, hash| + hash[record.year_month.strftime("%Y-%m")] = record.total_item_investigations + end + end + + def build_base_relation + Hyrax::CounterMetric + .select(:resource_type, :worktype, performance_query) + .where("date >= ? AND date <= ?", begin_date, end_date) + .order(resource_type: :asc) + .group(:resource_type, :worktype) + end + + def performance_query + %((SELECT To_json(Array_agg(Row_to_json(t))) + FROM + (SELECT + -- The AS field_name needs to be double quoted so as to preserve case structure. + SUM(total_item_investigations) as "Total_Item_Investigations", + SUM(total_item_requests) as "Total_Item_Requests", + COUNT(DISTINCT CASE WHEN total_item_investigations IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Investigations", + COUNT(DISTINCT CASE WHEN total_item_requests IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Requests", + -- We need to coerce the month from a single digit to two digits (e.g. August's "8" into "08") + CONCAT(DATE_PART('year', date_trunc('month', date)), '-', to_char(DATE_PART('month', date_trunc('month', date)), 'fm00')) AS year_month + FROM hyrax_counter_metrics AS aggr + WHERE #{Hyrax::CounterMetric.sanitize_sql_for_conditions(['aggr.resource_type = hyrax_counter_metrics.resource_type AND date >= ? AND date <= ?', begin_date, end_date])} + GROUP BY date_trunc('month', date)) t) as performance) + end end # rubocop:enable Metrics/ClassLength end diff --git a/app/models/sushi/platform_usage_report.rb b/app/models/sushi/platform_usage_report.rb index ef45f323d..8e0eed74a 100644 --- a/app/models/sushi/platform_usage_report.rb +++ b/app/models/sushi/platform_usage_report.rb @@ -125,30 +125,8 @@ def attribute_performance_for_platform # month). # rubocop:disable Layout/LineLength def data_for_resource_types - # We're capturing this relation/query because in some cases, we need to chain another where - # clause onto the relation. - relation = Hyrax::CounterMetric - .select(:resource_type, :worktype, - %((SELECT To_json(Array_agg(Row_to_json(t))) - FROM - (SELECT - -- The AS field_name needs to be double quoted so as to preserve case structure. - SUM(total_item_investigations) as "Total_Item_Investigations", - SUM(total_item_requests) as "Total_Item_Requests", - COUNT(DISTINCT CASE WHEN total_item_investigations IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Investigations", - COUNT(DISTINCT CASE WHEN total_item_requests IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Requests", - -- We need to coerce the month from a single digit to two digits (e.g. August's "8" into "08") - CONCAT(DATE_PART('year', date_trunc('month', date)), '-', to_char(DATE_PART('month', date_trunc('month', date)), 'fm00')) AS year_month - FROM hyrax_counter_metrics AS aggr - WHERE #{Hyrax::CounterMetric.sanitize_sql_for_conditions(['aggr.resource_type = hyrax_counter_metrics.resource_type AND date >= ? AND date <= ?', begin_date, end_date])} - GROUP BY date_trunc('month', date)) t) as performance)) - .where("date >= ? AND date <= ?", begin_date, end_date) - .order(resource_type: :asc) - .group(:resource_type, :worktype) - - return relation if data_types.blank? - - relation.where("LOWER(resource_type) IN (?)", data_types) + relation = build_base_relation + filter_by_data_types(relation) end # rubocop:enable Layout/LineLength @@ -161,6 +139,42 @@ def data_for_platform .order("year_month") .group("date_trunc('month', date)") end + + private + + def build_base_relation + Hyrax::CounterMetric + .select(:resource_type, :worktype, performance_query) + .where("date >= ? AND date <= ?", begin_date, end_date) + .order(resource_type: :asc) + .group(:resource_type, :worktype) + end + + def performance_query + %((SELECT To_json(Array_agg(Row_to_json(t))) + FROM + (SELECT + -- The AS field_name needs to be double quoted so as to preserve case structure. + SUM(total_item_investigations) as "Total_Item_Investigations", + SUM(total_item_requests) as "Total_Item_Requests", + COUNT(DISTINCT CASE WHEN total_item_investigations IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Investigations", + COUNT(DISTINCT CASE WHEN total_item_requests IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Requests", + -- We need to coerce the month from a single digit to two digits (e.g. August's "8" into "08") + CONCAT(DATE_PART('year', date_trunc('month', date)), '-', to_char(DATE_PART('month', date_trunc('month', date)), 'fm00')) AS year_month + FROM hyrax_counter_metrics AS aggr + WHERE #{conditions_for_performance_query} + GROUP BY date_trunc('month', date)) t) as performance) + end + + def conditions_for_performance_query + Hyrax::CounterMetric.sanitize_sql_for_conditions(['aggr.resource_type = hyrax_counter_metrics.resource_type AND date >= ? AND date <= ?', begin_date, end_date]) + end + + def filter_by_data_types(relation) + return relation if data_types.blank? + + relation.where("LOWER(resource_type) IN (?)", data_types) + end end # rubocop:enable Metrics/ClassLength end From d2957c952da085bd1943685873fdd17b85187417 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Thu, 15 Aug 2024 07:54:35 -0700 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=92=84=20replaces=20deprecated=20rubo?= =?UTF-8?q?cop=20statements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop_fixme.yml | 43 +++++++- .rubocop_todo.yml | 69 +------------ Gemfile | 2 +- .../catalog_helper_behavior_decorator.rb | 4 +- app/models/concerns/pdf_behavior.rb | 2 +- app/models/featured_collection_list.rb | 2 +- app/models/sushi.rb | 16 +-- app/models/sushi/item_report.rb | 52 ++++------ app/models/sushi/platform_report.rb | 97 ++++++++----------- app/models/sushi/platform_usage_report.rb | 64 +++++------- app/models/sushi/report_list.rb | 4 +- app/services/iiif_print/tenant_config.rb | 2 +- app/services/import_counter_metrics.rb | 2 +- lib/tasks/tenantize_task.rake | 2 +- .../admin_set_form_participants_tab_spec.rb | 2 +- spec/features/appearance_theme_spec.rb | 2 +- spec/features/create_generic_work_spec.rb | 2 +- spec/features/create_image_spec.rb | 2 +- spec/features/work_editor_role_spec.rb | 2 +- spec/models/sushi_spec.rb | 2 +- spec/models/uploaded_file_spec.rb | 2 +- .../featured_collections_route_spec.rb | 2 +- 22 files changed, 155 insertions(+), 222 deletions(-) diff --git a/.rubocop_fixme.yml b/.rubocop_fixme.yml index 539c8101e..d0437d517 100644 --- a/.rubocop_fixme.yml +++ b/.rubocop_fixme.yml @@ -1,7 +1,48 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 0` -# on 2024-08-14 22:12:29 UTC using RuboCop version 1.61.0. +# on 2024-08-15 14:53:42 UTC using RuboCop version 1.61.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 # versions of RuboCop, may require this file to be generated again. + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Enabled: false + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment. +Layout/SpaceBeforeFirstArg: + Enabled: false + +# Offense count: 1 +# Configuration parameters: AllowedParentClasses. +Lint/MissingSuper: + Enabled: false + +# Offense count: 8 +# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Enabled: false + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never, either, consistent +Style/HashSyntax: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantParentheses: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f7babfc71..a37fbaf56 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,74 +1,7 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-08-14 22:12:52 UTC using RuboCop version 1.61.0. +# on 2024-08-15 14:54:14 UTC using RuboCop version 1.61.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 # versions of RuboCop, may require this file to be generated again. - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'spec/models/account_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Exclude: - - 'spec/models/account_spec.rb' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'app/models/sushi/item_report.rb' - - 'app/models/sushi/platform_report.rb' - -# Offense count: 1 -# Configuration parameters: AllowedParentClasses. -Lint/MissingSuper: - Exclude: - - 'spec/services/iiif_print/tenant_config_spec.rb' - -# Offense count: 12 -# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. -Metrics/MethodLength: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/controllers/hyrax/dashboard/collections_controller_decorator.rb' - - 'app/controllers/identity_providers_controller.rb' - - 'app/controllers/users/omniauth_callbacks_controller.rb' - - 'app/helpers/blacklight/catalog_helper_behavior_decorator.rb' - - 'app/jobs/batch_email_notification_job.rb' - - 'app/jobs/reindex_works_job.rb' - - 'app/models/sort_title.rb' - - 'app/models/sushi.rb' - - 'lib/reprocessor.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent -Style/HashSyntax: - Exclude: - - 'app/controllers/roles_controller.rb' - - 'spec/views/hyrax/base/_relationships.html.erb_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantParentheses: - Exclude: - - 'app/models/hydra/access_controls/embargo_decorator.rb' - - 'app/models/hydra/access_controls/lease_decorator.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Exclude: - - 'app/helpers/application_helper.rb' diff --git a/Gemfile b/Gemfile index b859869eb..362ae28ff 100644 --- a/Gemfile +++ b/Gemfile @@ -146,4 +146,4 @@ gem 'willow_sword', github: 'scientist-softserv/willow_sword', branch: 'main' # of the time use the `samvera-labs/hyku_knapsack` remote branch. gem 'hyku_knapsack', github: 'samvera-labs/hyku_knapsack', branch: 'required_for_knapsack_instances' -# rubocop:enable Layout/LineLength +# rubocop:enable Metrics/MethodLength diff --git a/app/helpers/blacklight/catalog_helper_behavior_decorator.rb b/app/helpers/blacklight/catalog_helper_behavior_decorator.rb index 08e796181..31c68679e 100644 --- a/app/helpers/blacklight/catalog_helper_behavior_decorator.rb +++ b/app/helpers/blacklight/catalog_helper_behavior_decorator.rb @@ -3,6 +3,7 @@ # OVERRIDE blacklight 6 to allow full url for show links for shared search thumbnail module Blacklight module CatalogHelperBehaviorDecorator + # rubocop:disable Metrics/MethodLength def render_thumbnail_tag(document, image_options = {}, url_options = {}) value = if blacklight_config.view_config(document_index_view_type).thumbnail_method send(blacklight_config.view_config(document_index_view_type).thumbnail_method, document, image_options) @@ -15,7 +16,7 @@ def render_thumbnail_tag(document, image_options = {}, url_options = {}) if value if url_options == false Deprecation.warn(self, "passing false as the second argument to render_thumbnail_tag is deprecated. Use suppress_link: true instead. This behavior will be removed in Blacklight 7") - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength url_options = { suppress_link: true } end if url_options[:suppress_link] @@ -30,6 +31,7 @@ def render_thumbnail_tag(document, image_options = {}, url_options = {}) end # rubocop:enable Style/GuardClause end + # rubocop:enable Metrics/MethodLength end end diff --git a/app/models/concerns/pdf_behavior.rb b/app/models/concerns/pdf_behavior.rb index 8bb19287b..a4a61e7ee 100644 --- a/app/models/concerns/pdf_behavior.rb +++ b/app/models/concerns/pdf_behavior.rb @@ -22,7 +22,7 @@ module PdfBehavior property :show_pdf_download_button, predicate: RDF::CustomShowPdfDownloadButtonTerm.show_pdf_download_button, multiple: false do |index| index.as :stored_searchable end - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength after_initialize :set_default_show_pdf_viewer, :set_default_show_pdf_download_button end diff --git a/app/models/featured_collection_list.rb b/app/models/featured_collection_list.rb index 5a8de22f8..eefb4f6b3 100644 --- a/app/models/featured_collection_list.rb +++ b/app/models/featured_collection_list.rb @@ -13,7 +13,7 @@ def featured_collections_attributes=(attributes_collection) existing_record = FeaturedCollection.find(attributes['id']) existing_record.update(attributes.except('id')) end - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength end def featured_collections diff --git a/app/models/sushi.rb b/app/models/sushi.rb index f20eb6630..7df08af90 100644 --- a/app/models/sushi.rb +++ b/app/models/sushi.rb @@ -24,7 +24,7 @@ def validate_date_format(dates = []) # rubocop:disable Layout/LineLength info << Sushi::Info.new(data: date.to_s, message: "The day of the month is not taken into consideration when providing metrics. The date provided was amended to account for the full month.").as_json if match[2] - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength end true @@ -195,14 +195,14 @@ def coerce_dates(params = {}) if @begin_date < earliest_date # rubocop:disable Layout/LineLength raise Sushi::Error::UsageNoLongerAvailableForRequestedDatesError.new(data: "Unable to complete the request because the begin_date of #{params[:begin_date]} is for a month that has incomplete data. That month's data starts on #{earliest_date.iso8601}.") - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength end latest_date = Hyrax::CounterMetric.order(date: :desc).first.date if @end_date > latest_date # rubocop:disable Layout/LineLength raise Sushi::Error::UsageNotReadyForRequestedDatesError.new(data: "Unable to complete the request because the end_date of #{params[:end_date]} is for a month that has incomplete data. That month's data ends on #{latest_date.iso8601}.") - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength end rescue ActionController::ParameterMissing, KeyError => e raise Sushi::Error::InsufficientInformationToProcessRequestError.new(data: e.message) @@ -234,6 +234,7 @@ module MetricTypeCoercion attr_reader :metric_types, :metric_type_in_params end + # rubocop:disable Metrics/MethodLength def coerce_metric_types(params = {}, allowed_types: ALLOWED_METRIC_TYPES) metric_types_from_params = Array.wrap(params[:metric_type]&.split('|')) return @metric_types = allowed_types if metric_types_from_params.empty? @@ -256,6 +257,7 @@ def coerce_metric_types(params = {}, allowed_types: ALLOWED_METRIC_TYPES) metric_type.titleize.tr(' ', '_') if allowed_types.any? { |allowed_type| allowed_type.downcase == normalized_metric_type } end.compact end + # rubocop:enable Metrics/MethodLength end module AccessMethodCoercion @@ -304,7 +306,7 @@ def coerce_item_id(params = {}) # rubocop:disable Layout/LineLength raise Sushi::Error::InvalidReportFilterValueError.new(data: "The given parameter `item_id=#{params[:item_id]}` does not exist. Please provide an existing item_id, or none at all.") unless Hyrax::CounterMetric.exists?(work_id: params[:item_id]) - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength @item_id = params[:item_id] @item_id_in_params = true @@ -421,7 +423,7 @@ def coerce_author(params = {}) # rubocop:disable Layout/LineLength raise Sushi::Error::InvalidReportFilterValueError.new(data: "The given author #{author.inspect} was not found in the metrics.") unless Hyrax::CounterMetric.where(author_as_where_parameters).exists? - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength @author_in_params = true end @@ -465,6 +467,7 @@ module YearOfPublicationCoercion # @note No special consideration is made for date ranges that start with a later date and end with # an earlier date (e.g. "1999-1994" will be "date >= 1999 AND date <= 1994"; which will # return no entries.) + # rubocop:disable Metrics/MethodLength def coerce_yop(params = {}) return unless params.key?(:yop) @@ -491,7 +494,8 @@ def coerce_yop(params = {}) rescue ArgumentError # rubocop:disable Layout/LineLength raise Sushi::Error::InvalidDateArgumentError.new(data: "The given parameter `yop=#{yop}` was malformed. You can provide a range (e.g. 'YYYY-YYYY') or a single date (e.g. 'YYYY'). You can separate ranges/values with a '|'.") - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength end + # rubocop: Metrics/MethodLength end end diff --git a/app/models/sushi/item_report.rb b/app/models/sushi/item_report.rb index 26f0e8a4d..042b8a13b 100644 --- a/app/models/sushi/item_report.rb +++ b/app/models/sushi/item_report.rb @@ -124,13 +124,30 @@ def as_json(_options = {}) alias to_hash as_json + # rubocop:disable Metrics/MethodLength def report_items data_for_resource_types.map do |record| { - 'Items' => [item_attributes(record)] + 'Items' => [{ + 'Attribute_Performance' => [{ + 'Data_Type' => record.resource_type.titleize, + # We are only supporting the 'Regular' access method at this time. If that changes, we will need to update this. + 'Access_Method' => 'Regular', + 'Performance' => performance(record) + }], + 'Authors' => Sushi::AuthorCoercion.deserialize(record.author).map { |author| { 'Name:' => author } }, + 'Item' => record.work_id.to_s, + 'Publisher' => '', + 'Platform' => account.cname, + 'Item_ID' => { + 'Proprietary': record.work_id.to_s, + 'URI': "https://#{account.cname}/concern/#{record.worktype.underscore}s/#{record.work_id}" + } + }] } end end + # rubocop:enable Metrics/MethodLength def performance(record) metric_types.index_with do |metric_type| @@ -169,39 +186,6 @@ def data_for_resource_types relation end # rubocop:enable Metrics/MethodLength - - private - - def item_attributes(record) - { - 'Attribute_Performance' => attribute_performance(record), - 'Authors' => authors(record), - 'Item' => record.work_id.to_s, - 'Publisher' => '', - 'Platform' => account.cname, - 'Item_ID' => item_id(record) - } - end - - def attribute_performance(record) - [{ - 'Data_Type' => record.resource_type.titleize, - # We are only supporting the 'Regular' access method at this time. If that changes, we will need to update this. - 'Access_Method' => 'Regular', - 'Performance' => performance(record) - }] - end - - def authors(record) - Sushi::AuthorCoercion.deserialize(record.author).map { |author| { 'Name:' => author } } - end - - def item_id(record) - { - 'Proprietary': record.work_id.to_s, - 'URI': "https://#{account.cname}/concern/#{record.worktype.underscore}s/#{record.work_id}" - } - end end # rubocop:enable Metrics/ClassLength end diff --git a/app/models/sushi/platform_report.rb b/app/models/sushi/platform_report.rb index 514180c7f..21c259ba2 100644 --- a/app/models/sushi/platform_report.rb +++ b/app/models/sushi/platform_report.rb @@ -140,16 +140,28 @@ def attribute_performance_for_resource_types end end + # rubocop:disable Metrics/MethodLength def attribute_performance_for_platform - return [] if exclude_based_on_metric_type? - return [] if exclude_based_on_data_type? - + return [] if metric_type_in_params && metric_types.exclude?("Searches_Platform") + return [] if data_type_in_params && !data_types.find { |dt| dt.casecmp("Platform").zero? } + [{ "Data_Type" => "Platform", "Access_Method" => "Regular", - "Performance" => performance_for_platform + "Performance" => { + "Searches_Platform" => if granularity == 'Totals' + total_for_platform = data_for_platform.sum(&:total_item_investigations) + { "Totals" => total_for_platform } + else + data_for_platform.each_with_object({}) do |record, hash| + hash[record.year_month.strftime("%Y-%m")] = record.total_item_investigations + hash + end + end + } }] end + # rubocop:enable Metrics/MethodLength def performance(record) metric_types.each_with_object({}) do |metric_type, returning_hash| @@ -176,13 +188,34 @@ def performance(record) # also, note that unique_item_requests and unique_item_investigations should be counted for Hyrax::CounterMetrics that have unique dates, and unique work IDs. # see the docs for counting unique items here: https://cop5.projectcounter.org/en/5.1/07-processing/03-counting-unique-items.html # rubocop:disable Layout/LineLength + # rubocop:disable Metrics/MethodLength def data_for_resource_types - relation = build_base_relation + # We're capturing this relation/query because in some cases, we need to chain another where + # clause onto the relation. + relation = Hyrax::CounterMetric + .select(:resource_type, :worktype, + %((SELECT To_json(Array_agg(Row_to_json(t))) + FROM + (SELECT + -- The AS field_name needs to be double quoted so as to preserve case structure. + SUM(total_item_investigations) as "Total_Item_Investigations", + SUM(total_item_requests) as "Total_Item_Requests", + COUNT(DISTINCT CASE WHEN total_item_investigations IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Investigations", + COUNT(DISTINCT CASE WHEN total_item_requests IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Requests", + -- We need to coerce the month from a single digit to two digits (e.g. August's "8" into "08") + CONCAT(DATE_PART('year', date_trunc('month', date)), '-', to_char(DATE_PART('month', date_trunc('month', date)), 'fm00')) AS year_month + FROM hyrax_counter_metrics AS aggr + WHERE #{Hyrax::CounterMetric.sanitize_sql_for_conditions(['aggr.resource_type = hyrax_counter_metrics.resource_type AND date >= ? AND date <= ?', begin_date, end_date])} + GROUP BY date_trunc('month', date)) t) as performance)) + .where("date >= ? AND date <= ?", begin_date, end_date) + .order(resource_type: :asc) + .group(:resource_type, :worktype) return relation if data_types.blank? - + relation.where("LOWER(resource_type) IN (?)", data_types) end # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength def data_for_platform Hyrax::CounterMetric @@ -193,58 +226,6 @@ def data_for_platform .order("year_month") .group("date_trunc('month', date)") end - - private - - def exclude_based_on_metric_type? - metric_type_in_params && metric_types.exclude?("Searches_Platform") - end - - def exclude_based_on_data_type? - data_type_in_params && !data_types.any? { |dt| dt.casecmp("Platform").zero? } - end - - def performance_for_platform - if granularity == 'Totals' - { "Totals" => total_for_platform } - else - performance_by_month - end - end - - def total_for_platform - data_for_platform.sum(&:total_item_investigations) - end - - def performance_by_month - data_for_platform.each_with_object({}) do |record, hash| - hash[record.year_month.strftime("%Y-%m")] = record.total_item_investigations - end - end - - def build_base_relation - Hyrax::CounterMetric - .select(:resource_type, :worktype, performance_query) - .where("date >= ? AND date <= ?", begin_date, end_date) - .order(resource_type: :asc) - .group(:resource_type, :worktype) - end - - def performance_query - %((SELECT To_json(Array_agg(Row_to_json(t))) - FROM - (SELECT - -- The AS field_name needs to be double quoted so as to preserve case structure. - SUM(total_item_investigations) as "Total_Item_Investigations", - SUM(total_item_requests) as "Total_Item_Requests", - COUNT(DISTINCT CASE WHEN total_item_investigations IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Investigations", - COUNT(DISTINCT CASE WHEN total_item_requests IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Requests", - -- We need to coerce the month from a single digit to two digits (e.g. August's "8" into "08") - CONCAT(DATE_PART('year', date_trunc('month', date)), '-', to_char(DATE_PART('month', date_trunc('month', date)), 'fm00')) AS year_month - FROM hyrax_counter_metrics AS aggr - WHERE #{Hyrax::CounterMetric.sanitize_sql_for_conditions(['aggr.resource_type = hyrax_counter_metrics.resource_type AND date >= ? AND date <= ?', begin_date, end_date])} - GROUP BY date_trunc('month', date)) t) as performance) - end end # rubocop:enable Metrics/ClassLength end diff --git a/app/models/sushi/platform_usage_report.rb b/app/models/sushi/platform_usage_report.rb index 8e0eed74a..4b8e30eab 100644 --- a/app/models/sushi/platform_usage_report.rb +++ b/app/models/sushi/platform_usage_report.rb @@ -124,11 +124,35 @@ def attribute_performance_for_platform # query result value would be "2023-01-01T00:00" (e.g. the first moment of the first of the # month). # rubocop:disable Layout/LineLength + # rubocop:disable Metrics/MethodLength def data_for_resource_types - relation = build_base_relation - filter_by_data_types(relation) + # We're capturing this relation/query because in some cases, we need to chain another where + # clause onto the relation. + relation = Hyrax::CounterMetric + .select(:resource_type, :worktype, + %((SELECT To_json(Array_agg(Row_to_json(t))) + FROM + (SELECT + -- The AS field_name needs to be double quoted so as to preserve case structure. + SUM(total_item_investigations) as "Total_Item_Investigations", + SUM(total_item_requests) as "Total_Item_Requests", + COUNT(DISTINCT CASE WHEN total_item_investigations IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Investigations", + COUNT(DISTINCT CASE WHEN total_item_requests IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Requests", + -- We need to coerce the month from a single digit to two digits (e.g. August's "8" into "08") + CONCAT(DATE_PART('year', date_trunc('month', date)), '-', to_char(DATE_PART('month', date_trunc('month', date)), 'fm00')) AS year_month + FROM hyrax_counter_metrics AS aggr + WHERE #{Hyrax::CounterMetric.sanitize_sql_for_conditions(['aggr.resource_type = hyrax_counter_metrics.resource_type AND date >= ? AND date <= ?', begin_date, end_date])} + GROUP BY date_trunc('month', date)) t) as performance)) + .where("date >= ? AND date <= ?", begin_date, end_date) + .order(resource_type: :asc) + .group(:resource_type, :worktype) + + return relation if data_types.blank? + + relation.where("LOWER(resource_type) IN (?)", data_types) end # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength def data_for_platform Hyrax::CounterMetric @@ -139,42 +163,6 @@ def data_for_platform .order("year_month") .group("date_trunc('month', date)") end - - private - - def build_base_relation - Hyrax::CounterMetric - .select(:resource_type, :worktype, performance_query) - .where("date >= ? AND date <= ?", begin_date, end_date) - .order(resource_type: :asc) - .group(:resource_type, :worktype) - end - - def performance_query - %((SELECT To_json(Array_agg(Row_to_json(t))) - FROM - (SELECT - -- The AS field_name needs to be double quoted so as to preserve case structure. - SUM(total_item_investigations) as "Total_Item_Investigations", - SUM(total_item_requests) as "Total_Item_Requests", - COUNT(DISTINCT CASE WHEN total_item_investigations IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Investigations", - COUNT(DISTINCT CASE WHEN total_item_requests IS NOT NULL THEN CONCAT(work_id, '_', date::text) END) as "Unique_Item_Requests", - -- We need to coerce the month from a single digit to two digits (e.g. August's "8" into "08") - CONCAT(DATE_PART('year', date_trunc('month', date)), '-', to_char(DATE_PART('month', date_trunc('month', date)), 'fm00')) AS year_month - FROM hyrax_counter_metrics AS aggr - WHERE #{conditions_for_performance_query} - GROUP BY date_trunc('month', date)) t) as performance) - end - - def conditions_for_performance_query - Hyrax::CounterMetric.sanitize_sql_for_conditions(['aggr.resource_type = hyrax_counter_metrics.resource_type AND date >= ? AND date <= ?', begin_date, end_date]) - end - - def filter_by_data_types(relation) - return relation if data_types.blank? - - relation.where("LOWER(resource_type) IN (?)", data_types) - end end # rubocop:enable Metrics/ClassLength end diff --git a/app/models/sushi/report_list.rb b/app/models/sushi/report_list.rb index 1c68e4e1d..939f30d0b 100644 --- a/app/models/sushi/report_list.rb +++ b/app/models/sushi/report_list.rb @@ -3,7 +3,7 @@ # counter compliant format for ReportList: https://countermetrics.stoplight.io/docs/counter-sushi-api/af75bac10e789-report-list module Sushi class ReportList - # rubocop:disable Layout/MethodLength, Layout/LineLength + # rubocop:disable Metrics/MethodLength, Layout/LineLength def as_json(_options = nil) [ { @@ -50,6 +50,6 @@ def as_json(_options = nil) ] end alias to_hash as_json - # rubocop:enable Layout/MethodLength, Layout/LineLength + # rubocop:enable Metrics/MethodLength, Layout/LineLength end end diff --git a/app/services/iiif_print/tenant_config.rb b/app/services/iiif_print/tenant_config.rb index 4ec49e382..c8c390cfa 100644 --- a/app/services/iiif_print/tenant_config.rb +++ b/app/services/iiif_print/tenant_config.rb @@ -210,4 +210,4 @@ def iiif_presentable_member_presenters end end end -# rubocop:enable Layout/LineLength +# rubocop:enable Metrics/MethodLength diff --git a/app/services/import_counter_metrics.rb b/app/services/import_counter_metrics.rb index 953342189..ea1981fc2 100644 --- a/app/services/import_counter_metrics.rb +++ b/app/services/import_counter_metrics.rb @@ -4,7 +4,7 @@ # Currently, this only imports the first resource type. Additional work would need to be done for works with multiple resource types. # The resource_type field in the counter_metrics table is single value and not an array. class ImportCounterMetrics - # rubocop:disable Metrics/MethodLength, BlockLength + # rubocop:disable Metrics/MethodLength, Metrics/BlockLength def self.import_investigations(csv_path) CSV.foreach(csv_path, headers: true) do |row| work = ActiveFedora::Base.where(bulkrax_identifier_tesim: row['eprintid']).first diff --git a/lib/tasks/tenantize_task.rake b/lib/tasks/tenantize_task.rake index 9f73ba95b..78a2c856f 100644 --- a/lib/tasks/tenantize_task.rake +++ b/lib/tasks/tenantize_task.rake @@ -17,4 +17,4 @@ namespace :tenantize do end end end -# rubocop:enable Layout/LineLength +# rubocop:enable Metrics/MethodLength diff --git a/spec/features/admin_set_form_participants_tab_spec.rb b/spec/features/admin_set_form_participants_tab_spec.rb index 34df3e32d..ca6f4bcc8 100644 --- a/spec/features/admin_set_form_participants_tab_spec.rb +++ b/spec/features/admin_set_form_participants_tab_spec.rb @@ -138,7 +138,7 @@ expect(manager_row_html).to include('Repository Administrators') # rubocop:disable Layout/LineLength expect(manager_row_html).to include('') - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength end it 'shows an enabled remove button next to Repository Administrator group as a Depositor' do diff --git a/spec/features/appearance_theme_spec.rb b/spec/features/appearance_theme_spec.rb index ecbf4ef80..c6397a3e8 100644 --- a/spec/features/appearance_theme_spec.rb +++ b/spec/features/appearance_theme_spec.rb @@ -71,7 +71,7 @@ select('Gallery view', from: 'Search Results Page Theme') # rubocop:disable Layout/LineLength expect(page).to have_content('This will select a default view for the search results page. Users can select their preferred views on the search results page that will override this selection') - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength find('body').click click_on('Save') site = Site.last diff --git a/spec/features/create_generic_work_spec.rb b/spec/features/create_generic_work_spec.rb index b3cd7d721..c649a2a8a 100644 --- a/spec/features/create_generic_work_spec.rb +++ b/spec/features/create_generic_work_spec.rb @@ -66,7 +66,7 @@ page.choose('generic_work_visibility_open') # 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 Layout/LineLength + # rubocop:enable Metrics/MethodLength find('#agreement').click click_on('Save') diff --git a/spec/features/create_image_spec.rb b/spec/features/create_image_spec.rb index c1729340e..15238fb05 100644 --- a/spec/features/create_image_spec.rb +++ b/spec/features/create_image_spec.rb @@ -66,7 +66,7 @@ page.choose('image_visibility_open') # 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 Layout/LineLength + # rubocop:enable Metrics/MethodLength find('#agreement').click click_on('Save') diff --git a/spec/features/work_editor_role_spec.rb b/spec/features/work_editor_role_spec.rb index a363d1387..8e70092c7 100644 --- a/spec/features/work_editor_role_spec.rb +++ b/spec/features/work_editor_role_spec.rb @@ -107,7 +107,7 @@ # 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 Layout/LineLength + # rubocop:enable Metrics/MethodLength find('#agreement').click expect { click_on('Save') } diff --git a/spec/models/sushi_spec.rb b/spec/models/sushi_spec.rb index 3c9f3f871..747783d64 100644 --- a/spec/models/sushi_spec.rb +++ b/spec/models/sushi_spec.rb @@ -272,6 +272,6 @@ def initialize(params = {}) end end end - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength end end diff --git a/spec/models/uploaded_file_spec.rb b/spec/models/uploaded_file_spec.rb index 2221959a1..6a5971944 100644 --- a/spec/models/uploaded_file_spec.rb +++ b/spec/models/uploaded_file_spec.rb @@ -110,4 +110,4 @@ end end end -# rubocop:enable Layout/LineLength +# rubocop:enable Metrics/MethodLength diff --git a/spec/routing/featured_collections_route_spec.rb b/spec/routing/featured_collections_route_spec.rb index e1e0551ff..2b34cf0d0 100644 --- a/spec/routing/featured_collections_route_spec.rb +++ b/spec/routing/featured_collections_route_spec.rb @@ -15,5 +15,5 @@ expect(featured_collection_lists_path).to eq '/featured_collections' expect(post: '/featured_collections').to route_to(controller: 'hyrax/featured_collection_lists', action: 'create') end - # rubocop:enable Layout/LineLength + # rubocop:enable Metrics/MethodLength end