From bcf53f6343942efc3733d830739e4679756e2934 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2026 11:05:20 +0000 Subject: [PATCH 01/30] Update rubocop to version 1.85.1 --- Gemfile.lock | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c8ad9a573..e4af5fe89 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -283,7 +283,10 @@ GEM prism (>= 1.3.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.18.1) + json (2.19.0) + json-schema (6.2.0) + addressable (~> 2.8) + bigdecimal (>= 3.1, < 5) jsonapi-resources (0.9.0) activerecord (>= 4.1) concurrent-ruby @@ -314,6 +317,8 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.3) + mcp (0.8.0) + json-schema (>= 4.1) memoist3 (1.0.0) method_source (1.1.0) mime-types (3.7.0) @@ -363,7 +368,7 @@ GEM racc (~> 1.4) ostruct (0.6.3) parallel (1.27.0) - parser (3.3.10.1) + parser (3.3.10.2) ast (~> 2.4.1) racc pp (0.6.3) @@ -500,10 +505,11 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.7) - rubocop (1.84.1) + rubocop (1.85.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) + mcp (~> 0.6) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) From 2fffb9494392d20ae1fbf1b0e3db5f98911495ef Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 12:24:10 +0000 Subject: [PATCH 02/30] style: update rubocop todo --- .rubocop_todo.yml | 103 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 17 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 88182357a..c8bab87e1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2026-02-06 14:12:50 UTC using RuboCop version 1.84.1. +# on 2026-03-06 12:21:47 UTC using RuboCop version 1.85.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -49,6 +49,14 @@ Layout/HeredocIndentation: Exclude: - 'db/seeds.rb' +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns. +# SupportedStylesAlignWith: start_of_line, relative_to_receiver +Layout/IndentationWidth: + Exclude: + - 'lib/record_loader/plate_creator_loader.rb' + # Offense count: 12 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment, AllowRBSInlineAnnotation, AllowSteepAnnotation. @@ -65,7 +73,7 @@ Layout/LeadingCommentSpace: - 'spec/models/sample_manifest/uploader_spec.rb' - 'spec/views/labware/show_html_erb_spec.rb' -# Offense count: 18 +# Offense count: 17 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedMethods, AllowedPatterns. Lint/AmbiguousBlockAssociation: @@ -73,7 +81,6 @@ Lint/AmbiguousBlockAssociation: - 'features/support/step_definitions/bulk_submission_steps.rb' - 'spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb' - 'spec/features/studies/accession_all_samples_spec.rb' - - 'spec/lib/accession/study_spec.rb' - 'spec/sample_manifest_excel/worksheet_spec.rb' - 'spec/sequencescape_excel/column_list_spec.rb' - 'spec/sequencescape_excel/column_spec.rb' @@ -599,7 +606,7 @@ RSpec/BeforeAfterAll: - 'spec/sample_manifest_excel/worksheet_spec.rb' - 'spec/sequencescape_excel/worksheet_spec.rb' -# Offense count: 342 +# Offense count: 341 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -619,7 +626,6 @@ RSpec/ContextWording: - 'spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb' - 'spec/features/submissions/bulk_submissions_spec.rb' - 'spec/helpers/assets_helper_spec.rb' - - 'spec/lib/accession/study_spec.rb' - 'spec/lib/label_printer/asset_labels_spec.rb' - 'spec/lib/label_printer/asset_redirect_spec.rb' - 'spec/lib/label_printer/batch_plate_spec.rb' @@ -824,7 +830,7 @@ RSpec/ExampleWording: - 'spec/sequencescape_excel/validation_spec.rb' - 'spec/sequencescape_excel/worksheet_spec.rb' -# Offense count: 257 +# Offense count: 268 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: @@ -872,7 +878,7 @@ RSpec/LeakyLocalVariable: - 'spec/models/well_spec.rb' - 'spec/shared_contexts/it_requires_login.rb' -# Offense count: 39 +# Offense count: 40 RSpec/LetSetup: Exclude: - 'spec/controllers/searches_controller_spec.rb' @@ -892,7 +898,7 @@ RSpec/LetSetup: - 'spec/models/transfer_request_collection_spec.rb' - 'spec/requests/api/v2/comments_spec.rb' -# Offense count: 39 +# Offense count: 38 # Configuration parameters: EnforcedStyle. # SupportedStyles: have_received, receive RSpec/MessageSpies: @@ -905,7 +911,6 @@ RSpec/MessageSpies: - 'spec/features/sample_manifests/create_manifest_spec.rb' - 'spec/features/sample_manifests/track_sample_manifest_updates_spec.rb' - 'spec/insdc/import_countries_spec.rb' - - 'spec/lib/accession/study_spec.rb' - 'spec/lib/method_benchmarking_spec.rb' - 'spec/lib/migration_extensions/encoding_changes_spec.rb' - 'spec/models/external_release_event_spec.rb' @@ -1162,7 +1167,7 @@ RSpec/MultipleExpectations: - 'spec/views/labware/show_chromium_chip_spec.rb' - 'spec/views/samples/index_html_erb_spec.rb' -# Offense count: 246 +# Offense count: 243 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: @@ -1214,11 +1219,6 @@ RSpec/RepeatedDescription: Exclude: - 'spec/sequencescape_excel/conditional_formatting_spec.rb' -# Offense count: 2 -RSpec/RepeatedExample: - Exclude: - - 'spec/models/sample_manifest/uploader_spec.rb' - # Offense count: 2 RSpec/RepeatedExampleGroupBody: Exclude: @@ -1619,6 +1619,13 @@ Style/ExplicitBlockArgument: - 'app/models/submission/flexible_request_graph.rb' - 'features/support/step_definitions/web_steps.rb' +# Offense count: 3 +Style/FileOpen: + Exclude: + - 'spec/lib/accession/sample_spec.rb' + - 'spec/models/stock_stamper_spec.rb' + - 'test/unit/import_fluidigm_data_test.rb' + # Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. @@ -1876,7 +1883,7 @@ Style/NestedParenthesizedCalls: - 'app/controllers/uuids_controller.rb' - 'app/models/parsers/bioanalysis_csv_parser.rb' -# Offense count: 18 +# Offense count: 15 # This cop supports safe autocorrection (--autocorrect). Style/Not: Exclude: @@ -1885,7 +1892,6 @@ Style/Not: - 'app/controllers/studies_controller.rb' - 'app/models/pipeline/batch_validation.rb' - 'app/models/request/change_decision.rb' - - 'app/models/submission/accession_behaviour.rb' - 'app/models/submission/asset_group_behaviour.rb' - 'app/models/submission/project_validation.rb' - 'app/models/user.rb' @@ -1913,6 +1919,29 @@ Style/NumericPredicate: - 'lib/deployed.rb' - 'lib/submission_serializer.rb' +# Offense count: 34 +# Configuration parameters: AllowedClasses. +Style/OneClassPerFile: + Exclude: + - 'app/api/core/service/error_handling.rb' + - 'app/models/bulk_submission.rb' + - 'app/uploaders/polymorphic_uploader.rb' + - 'config/initializers/active_record_validations.rb' + - 'config/initializers/api_routing.rb' + - 'features/support/api.rb' + - 'lib/api_tools.rb' + - 'lib/authenticated_test_helper.rb' + - 'lib/informatics/test/helpers/authentication_helper.rb' + - 'script/support/sample_move.rb' + - 'spec/models/broadcast_event/broadcast_event_spec.rb' + - 'spec/support/api_v2_resource_matchers.rb' + - 'spec/uat_actions/uat_actions_spec.rb' + - 'test/controllers/authentication_controller_test.rb' + - 'test/lib/label_printer/labels_multiplication_test.rb' + - 'test/test_helper.rb' + - 'test/unit/eventful_entry_test.rb' + - 'test/unit/tasks/plate_transfer_task_test.rb' + # Offense count: 18 # Configuration parameters: AllowedMethods. # AllowedMethods: respond_to_missing? @@ -2010,6 +2039,12 @@ Style/PerlBackrefs: - 'features/support/step_definitions/tag_layout_steps.rb' - 'lib/validateable.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/PredicateWithKind: + Exclude: + - 'app/models/presenters/batch_submenu_presenter.rb' + # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. @@ -2027,6 +2062,31 @@ Style/Proc: - 'app/models/lib_pool_norm_tube_generator.rb' - 'app/models/qcable/statemachine.rb' +# Offense count: 20 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ReduceToHash: + Exclude: + - 'app/api/core/io/base/json_formatting_behaviour/input.rb' + - 'app/models/accession_service/base_service.rb' + - 'app/models/attributable.rb' + - 'app/models/heron/factories/concerns/contents.rb' + - 'app/models/heron/factories/concerns/recipients.rb' + - 'app/models/heron/factories/tube_rack.rb' + - 'app/models/labware.rb' + - 'app/models/robot/verification/base.rb' + - 'app/models/transfer/between_plate_and_tubes.rb' + - 'app/models/transfer_request.rb' + - 'app/models/transfer_request_collection.rb' + - 'app/uat_actions/uat_actions/test_submission.rb' + - 'app/uat_actions/uat_actions/tube_submission.rb' + - 'spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb' + - 'spec/models/robot/pick_hash_tester_helper.rb' + - 'spec/models/tag_layout_spec.rb' + - 'test/controllers/workflows_controller_test.rb' + - 'test/functional/pre_cap_groups_test.rb' + - 'test/performance/state_change_test.rb' + - 'test/unit/batch_test.rb' + # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Methods. @@ -2071,6 +2131,15 @@ Style/SafeNavigation: - 'lib/event_factory.rb' - 'test/unit/qc_report_file_test.rb' +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SelectByKind: + Exclude: + - 'app/controllers/studies/asset_groups_controller.rb' + - 'app/models/broadcast_event/order_made.rb' + - 'app/models/lib_pool_norm_tube_generator.rb' + - 'features/support/step_definitions/transfer_steps.rb' + # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SingleArgumentDig: From 03f66902ee0b05c2b71f4d47a7e42406b279ba72 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 12:33:10 +0000 Subject: [PATCH 03/30] build: add ruboclean --- Gemfile | 1 + Gemfile.lock | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index 19a37133e..8cf19d670 100644 --- a/Gemfile +++ b/Gemfile @@ -151,6 +151,7 @@ end group :development, :linting do # Enforces coding styles and detects some bad practices + gem 'ruboclean', require: false gem 'rubocop', require: false gem 'rubocop-capybara', require: false gem 'rubocop-factory_bot', require: false diff --git a/Gemfile.lock b/Gemfile.lock index e4af5fe89..555ff66b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -505,6 +505,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.7) + ruboclean (0.7.1) rubocop (1.85.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) @@ -742,6 +743,7 @@ DEPENDENCIES rspec-json_expectations rspec-longrun rspec-rails (~> 8.0.0) + ruboclean rubocop rubocop-capybara rubocop-factory_bot From de3281b5221bc3bac15c3c976ed21464413e1905 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 12:44:18 +0000 Subject: [PATCH 04/30] style: move comments to own line (ruboclean and pysch limitation) --- .rubocop.yml | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 60a06423b..a11a932a1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,8 +23,10 @@ AllCops: - db/schema.rb - db/views_schema.rb - db/archived_migrations/* - - features/support/env.rb # generated by cucumber-rails - - lib/tasks/cucumber.rake # generated by cucumber-rails + # generated by cucumber-rails + - features/support/env.rb + # generated by cucumber-rails + - lib/tasks/cucumber.rake # CI installs gems in the vendor directory, which causes rubocop to try # and cop our gems. We don't want it to. - vendor/**/* @@ -93,13 +95,15 @@ Style/HashSyntax: Style/NumericLiterals: Enabled: false +# these are generally generated files and don't need excessive linting Style/QuotedSymbols: Exclude: - - "bin/*" # these are generally generated files and don't need excessive linting + - "bin/*" + # these are generally generated files and don't need excessive linting Style/StringLiterals: Exclude: - - "bin/*" # these are generally generated files and don't need excessive linting + - "bin/*" # Blocks are used to structure tests and are part of the shoulda dsl. # The standard BlockLength limits are too stringent for this purpose. @@ -166,8 +170,7 @@ Rails/DynamicFindBy: Rails/Presence: Enabled: false -# Method length limits make little sense when you are describing a table schema -# or a view. +# Method length limits make little sense when you are describing a table schema or a view. Metrics/MethodLength: Exclude: - "db/migrate/*" @@ -188,9 +191,9 @@ Rails/UnknownEnv: - profile - staging +# Aggregate examples can be useful, but the cop gets into nasty battles with +# other Spec cops, and is only really of value in expensive tests. RSpec/AggregateExamples: - # Aggregate examples can be useful, but the cop gets into nasty battles with - # other Spec cops, and is only really of value in expensive tests. Enabled: false # Added exclude because api and feature specs do not have a specific class. @@ -201,6 +204,7 @@ RSpec/DescribeClass: - "spec/features/**/*.rb" - "spec/views/**/*.rb" +# Disable for features, as we might want to step through long processes RSpec/ExampleLength: inherit_mode: merge: @@ -209,10 +213,10 @@ RSpec/ExampleLength: - array - hash - heredoc - # Disable for features, as we might want to step through long processes Exclude: - "spec/features/**/*" +# Disable for features and tests, we want lots of tests Metrics/ClassLength: inherit_mode: merge: @@ -221,10 +225,10 @@ Metrics/ClassLength: - array - hash - heredoc - # Disable for features and tests, we want lots of tests Exclude: - "spec/**/*" - "test/**/*" + RSpecRails/AvoidSetupHook: Exclude: - "test/**/*" @@ -233,9 +237,9 @@ RSpec/MultipleExpectations: Exclude: - "spec/features/**/*" +# Unused keyword arguments are good for maintaining API compatibility, and +# applying an underscore before the keyword name breaks that API. Lint/UnusedMethodArgument: - # Unused keyword arguments are good for maintaining API compatibility, and - # applying an underscore before the keyword name breaks that API. AllowUnusedKeywordArguments: true # This seems to be causing all sorts of issues with failing tests @@ -287,14 +291,15 @@ Rails/ThreeStateBooleanColumn: RSpec/ExpectInHook: Enabled: false -# New in Ruby 3.2 upgrade -# Added to Rubocop Todo and handling from there -RSpec/MultipleMemoizedHelpers: # new in 1.43 - Enabled: false # We don't see a benefit to limiting the number of memoized helpers. +# We don't see a benefit to limiting the number of memoized helpers. +RSpec/MultipleMemoizedHelpers: + Enabled: false -RSpec/NestedGroups: # new in 1.7 - Max: 6 # Set a more reasonable max. We've been happy with our existing nesting. +# Set a more reasonable max. We've been happy with our existing nesting. +RSpec/NestedGroups: + Max: 6 -RSpec/ImplicitSubject: # new in 1.29 - EnforcedStyle: single_statement_only # We want to be able to use `it do ... end` as well as `it { is_expected.to ... }` +# We want to be able to use `it do ... end` as well as `it { is_expected.to ... }` +RSpec/ImplicitSubject: + EnforcedStyle: single_statement_only From e666d72e9d8c8b0e52046c86518fb47e4f6ebade Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 12:47:18 +0000 Subject: [PATCH 05/30] style: move newly introduced cops to todo --- .rubocop.yml | 35 ----- .rubocop_todo.yml | 370 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 369 insertions(+), 36 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a11a932a1..1894a352d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -257,41 +257,6 @@ FactoryBot/FactoryAssociationWithStrategy: Capybara/ClickLinkOrButtonStyle: Enabled: false -# Disabling newly introduced cops until we have time to sort out the offenses -Rails/I18nLocaleTexts: # new in 2.14 - Enabled: false - -RSpecRails/InferredSpecType: # new in 2.14 - Enabled: false - -Lint/NonAtomicFileOperation: # new in 1.31 - Enabled: false - -Rails/ActionControllerTestCase: # new in 2.14 - Enabled: false - -RSpec/NoExpectationExample: # new in 2.13 - Enabled: false - -# New in ruby 3 upgrade -RSpec/IndexedLet: - Enabled: false - -RSpec/SpecFilePathFormat: - Enabled: false - -RSpec/PendingWithoutReason: - Enabled: false - -Performance/MapMethodChain: - Enabled: false - -Rails/ThreeStateBooleanColumn: - Enabled: false - -RSpec/ExpectInHook: - Enabled: false - # We don't see a benefit to limiting the number of memoized helpers. RSpec/MultipleMemoizedHelpers: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c8bab87e1..6314951f9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2026-03-06 12:21:47 UTC using RuboCop version 1.85.1. +# on 2026-03-06 12:51:58 UTC using RuboCop version 1.85.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -221,6 +221,27 @@ Lint/NestedMethodDefinition: Exclude: - 'lib/eventful_record.rb' +# Offense count: 46 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/NonAtomicFileOperation: + Exclude: + - 'lib/tasks/views_schema.rake' + - 'spec/bulk_submission_excel/data_worksheet_spec.rb' + - 'spec/bulk_submission_excel/download_spec.rb' + - 'spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb' + - 'spec/jobs/export_pool_xp_to_traction_job_spec.rb' + - 'spec/models/sample_manifest/uploader_spec.rb' + - 'spec/sample_manifest_excel/download_spec.rb' + - 'spec/sample_manifest_excel/retention_instruction_verification_spec.rb' + - 'spec/sample_manifest_excel/tags_spec.rb' + - 'spec/sample_manifest_excel/test_download_spec.rb' + - 'spec/sample_manifest_excel/upload/data_spec.rb' + - 'spec/sample_manifest_excel/upload/processor_spec.rb' + - 'spec/sample_manifest_excel/upload/rows_spec.rb' + - 'spec/sample_manifest_excel/upload/upload_spec.rb' + - 'spec/sample_manifest_excel/worksheet_spec.rb' + - 'spec/sequencescape_excel/worksheet_spec.rb' + # Offense count: 4 Lint/NonLocalExitFromIterator: Exclude: @@ -234,6 +255,12 @@ Lint/RedundantCopDisableDirective: Exclude: - 'app/models/role/user_role_helper.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/RedundantCopEnableDirective: + Exclude: + - 'spec/models/plate_purpose_spec.rb' + # Offense count: 4 Lint/ReturnInVoidContext: Exclude: @@ -566,6 +593,20 @@ Performance/CollectionLiteralInLoop: - 'features/support/step_definitions/sample_manifest_steps.rb' - 'spec/models/transfer_request_spec.rb' +# Offense count: 10 +Performance/MapMethodChain: + Exclude: + - 'app/api/core/service.rb' + - 'app/helpers/compound_sample_helper.rb' + - 'app/helpers/submissions_helper.rb' + - 'app/models/bait_library_layout.rb' + - 'app/models/lane.rb' + - 'app/models/submission/asset_submission_finder.rb' + - 'features/support/step_definitions/multiplexed_inbox_steps.rb' + - 'features/support/step_definitions/project_steps.rb' + - 'lib/tasks/support/update_library_types.rake' + - 'test/unit/tag_qc/qcable_statemachine_checks.rb' + # Offense count: 25 Performance/MethodObjectAsBlock: Exclude: @@ -830,6 +871,97 @@ RSpec/ExampleWording: - 'spec/sequencescape_excel/validation_spec.rb' - 'spec/sequencescape_excel/worksheet_spec.rb' +# Offense count: 26 +RSpec/ExpectInHook: + Exclude: + - 'spec/controllers/labwhere_receptions_controller_spec.rb' + - 'spec/features/admin/changing_user_roles_spec.rb' + - 'spec/features/asset_information_spec.rb' + - 'spec/features/labware/retention_instruction_spec.rb' + - 'spec/features/retrospective_failure_spec.rb' + - 'spec/features/submissions/bulk_submissions_spec.rb' + - 'spec/jobs/sample_accessioning_job_spec.rb' + - 'spec/lib/accession/sample_spec.rb' + - 'spec/lib/accession/submission_spec.rb' + - 'spec/models/batch_spec.rb' + - 'spec/models/external_release_event_spec.rb' + - 'spec/models/plate_purpose_spec.rb' + - 'spec/models/request_spec.rb' + - 'spec/models/specific_tube_creations_spec.rb' + - 'spec/models/specific_tube_rack_creation_spec.rb' + - 'spec/models/transfer_request_collection_spec.rb' + - 'spec/uat_actions/test_submission_spec.rb' + +# Offense count: 361 +# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns. +RSpec/IndexedLet: + Exclude: + - 'spec/api/extraction_attributes_spec.rb' + - 'spec/controllers/studies/information_controller_spec.rb' + - 'spec/controllers/ultima_sample_sheet/sample_sheet_generator_spec.rb' + - 'spec/features/creating_a_quad_stamp_spec.rb' + - 'spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb' + - 'spec/features/location_reports/location_reports_spec.rb' + - 'spec/features/migrated/pre_cap_pool_test_spec.rb' + - 'spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb' + - 'spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb' + - 'spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb' + - 'spec/features/pooling_spec.rb' + - 'spec/features/retrospective_failure_spec.rb' + - 'spec/features/tag_layout_template_spec.rb' + - 'spec/helpers/batches_helper_spec.rb' + - 'spec/lib/ebi_check/process_spec.rb' + - 'spec/lib/http_clients/accessioning_v1_client_spec.rb' + - 'spec/lib/label_printer/asset_labels_spec.rb' + - 'spec/lib/label_printer/asset_redirect_spec.rb' + - 'spec/lib/label_printer/batch_plate_spec.rb' + - 'spec/lib/record_loader/tag_set_loader_spec.rb' + - 'spec/models/aliquot_spec.rb' + - 'spec/models/api/messages/pac_bio_run_io_spec.rb' + - 'spec/models/api/messages/pac_bio_run_with_tag2_io_spec.rb' + - 'spec/models/api/sample_io_spec.rb' + - 'spec/models/barcode_printer_spec.rb' + - 'spec/models/broadcast_event/helpers/external_subjects_spec.rb' + - 'spec/models/broadcast_event/plate_cherrypicked_spec.rb' + - 'spec/models/broadcast_event/pool_released_spec.rb' + - 'spec/models/broadcast_event/qc_assay_spec.rb' + - 'spec/models/comment_spec.rb' + - 'spec/models/heron/factories/tube_rack_spec.rb' + - 'spec/models/labware_spec.rb' + - 'spec/models/labwhere_reception_spec.rb' + - 'spec/models/linear_submission_spec.rb' + - 'spec/models/location_report_form_spec.rb' + - 'spec/models/location_report_spec.rb' + - 'spec/models/pick_list_spec.rb' + - 'spec/models/pooling_spec.rb' + - 'spec/models/qc_result/qc_result_factory_spec.rb' + - 'spec/models/receptacle_spec.rb' + - 'spec/models/report_fail_spec.rb' + - 'spec/models/request/sample_compound_aliquot_transfer_spec.rb' + - 'spec/models/request_spec.rb' + - 'spec/models/robot/pick_data_spec.rb' + - 'spec/models/robot/verification/source_dest_beds_spec.rb' + - 'spec/models/robot/verification/source_dest_control_beds_spec.rb' + - 'spec/models/sample_spec.rb' + - 'spec/models/sequencing_request_spec.rb' + - 'spec/models/study_spec.rb' + - 'spec/models/submission_spec.rb' + - 'spec/models/tag_group_spec.rb' + - 'spec/models/tag_set_spec.rb' + - 'spec/models/tasks/cherrypick_task_spec.rb' + - 'spec/models/transfer_request_spec.rb' + - 'spec/requests/api/v2/pick_lists_spec.rb' + - 'spec/requests/api/v2/plate_controller_spec.rb' + - 'spec/requests/api/v2/qc_assays_spec.rb' + - 'spec/requests/api/v2/qc_results_spec.rb' + - 'spec/sequencescape_excel/list_spec.rb' + - 'spec/sequencescape_excel/specialised_field_spec.rb' + - 'spec/tasks/assing_compound_sample_supplier_name_spec.rb' + - 'spec/uat_actions/generate_plates_spec.rb' + - 'spec/uat_actions/generate_tagged_plates_spec.rb' + - 'spec/uat_actions/update_state_of_requests_in_labware_spec.rb' + - 'spec/validators/ultima_validator_spec.rb' + # Offense count: 268 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: @@ -1214,6 +1346,22 @@ RSpec/NamedSubject: - 'spec/models/well_spec.rb' - 'spec/models/work_order_spec.rb' +# Offense count: 18 +# Configuration parameters: AllowedPatterns. +# AllowedPatterns: ^expect_, ^assert_ +RSpec/NoExpectationExample: + Exclude: + - 'spec/api/work_completion_spec.rb' + - 'spec/features/admin/add_a_printer_spec.rb' + - 'spec/features/submissions/bulk_submissions_spec.rb' + - 'spec/models/lane_spec.rb' + - 'spec/models/orders/order_spec.rb' + - 'spec/models/receptacle_spec.rb' + - 'spec/models/request_spec.rb' + - 'spec/models/request_type_spec.rb' + - 'spec/models/tasks/plate_template_task_spec.rb' + - 'spec/sequencescape_excel/range_spec.rb' + # Offense count: 2 RSpec/RepeatedDescription: Exclude: @@ -1245,6 +1393,37 @@ RSpec/ScatteredLet: - 'spec/models/work_completion_spec.rb' - 'spec/requests/api/v2/work_orders_spec.rb' +# Offense count: 25 +# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector. +# SupportedInflectors: default, active_support +RSpec/SpecFilePathFormat: + Exclude: + - 'spec/bulk_submission_excel/data_worksheet_spec.rb' + - 'spec/controllers/concerns/api/v2/disable_destroy_action_spec.rb' + - 'spec/controllers/sample_manifest_controller_spec.rb' + - 'spec/lib/accession/configuration_spec.rb' + - 'spec/lib/deployed_spec.rb' + - 'spec/lib/label_printer/batch_plate_amp_spec.rb' + - 'spec/lib/label_printer/batch_tube_spec.rb' + - 'spec/lib/label_printer/sample_manifest_plate_double_spec.rb' + - 'spec/models/library_assets_stocks_spec.rb' + - 'spec/models/location_report_form_spec.rb' + - 'spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb' + - 'spec/models/scrna_core_cdna_prep_feasibility_validator_spec.rb' + - 'spec/models/std_library_request_spec.rb' + - 'spec/models/submission/scrna_core_cdna_prep_feasibility_calcuator_spec.rb' + - 'spec/models/tag_group_form_object_spec.rb' + - 'spec/models/tube_purpose_spec.rb' + - 'spec/requests/api/v2/plate_controller_spec.rb' + - 'spec/requests/api/v2/qc_assays_spec.rb' + - 'spec/requests/api/v2/qc_results_spec.rb' + - 'spec/resources/api/v2/faculty_sponsor_spec.rb' + - 'spec/resources/api/v2/project_resource_spec.rb' + - 'spec/sample_manifest_excel/retention_instruction_verification_spec.rb' + - 'spec/sample_manifest_excel/upload/upload_spec.rb' + - 'spec/sequencescape_excel/configuration_spec.rb' + - 'spec/validators/novaseqx_read_length_validator_spec.rb' + # Offense count: 9 RSpec/StubbedMock: Exclude: @@ -1264,6 +1443,55 @@ RSpec/VoidExpect: - 'spec/sample_manifest_excel/test_download_spec.rb' - 'spec/sequencescape_excel/column_spec.rb' +# Offense count: 43 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Inferences. +RSpecRails/InferredSpecType: + Exclude: + - 'spec/controllers/batches_controller_spec.rb' + - 'spec/controllers/bioscan_control_locations_controller_spec.rb' + - 'spec/controllers/bulk_submission_excel/downloads_controller_spec.rb' + - 'spec/controllers/concerns/api/v2/disable_destroy_action_spec.rb' + - 'spec/controllers/errors_controller_spec.rb' + - 'spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb' + - 'spec/controllers/sessions_controller_spec.rb' + - 'spec/controllers/submissions_controller_spec.rb' + - 'spec/controllers/taxa_controller_spec.rb' + - 'spec/features/migrated/move_samples_from_plates_to_tubes_spec.rb' + - 'spec/features/samples/sample_accession_errors_spec.rb' + - 'spec/features/samples/sample_edit_spec.rb' + - 'spec/features/samples/sample_spec.rb' + - 'spec/features/studies/accession_study_dac_policy_spec.rb' + - 'spec/features/studies/accession_study_spec.rb' + - 'spec/helpers/delayed_jobs_helper_spec.rb' + - 'spec/helpers/samples_helper_spec.rb' + - 'spec/jobs/export_pool_xp_to_traction_job_spec.rb' + - 'spec/jobs/sample_accessioning_job_spec.rb' + - 'spec/models/accession/sample_status_spec.rb' + - 'spec/models/accessionable/study_spec.rb' + - 'spec/models/asset_links_create_edge_spec.rb' + - 'spec/models/element_aviti_sequencing_pipeline_spec.rb' + - 'spec/models/element_aviti_sequencing_request_spec.rb' + - 'spec/models/heron/factories/concerns/contents_spec.rb' + - 'spec/models/heron/factories/event_spec.rb' + - 'spec/models/heron/factories/plate_from_rack_spec.rb' + - 'spec/models/heron/factories/plate_spec.rb' + - 'spec/models/heron/factories/sample_spec.rb' + - 'spec/models/heron/factories/tube_rack_spec.rb' + - 'spec/models/heron/factories/tube_rack_status_spec.rb' + - 'spec/models/heron/factories/tube_spec.rb' + - 'spec/models/library_assets_stocks_spec.rb' + - 'spec/models/map_spec.rb' + - 'spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb' + - 'spec/models/poly_metadatum_spec.rb' + - 'spec/models/presenters/batch_submenu_presenter_spec.rb' + - 'spec/models/tube_from_plate_creation_spec.rb' + - 'spec/models/ultima_sequencing_pipeline_spec.rb' + - 'spec/models/ultima_sequencing_request_spec.rb' + - 'spec/requests/api/v2/plate_controller_spec.rb' + - 'spec/views/batches/print_amp_plate_labels_spec.rb' + - 'spec/views/batches/print_labels_spec.rb' + # Offense count: 10 # This cop supports safe autocorrection (--autocorrect). RSpecRails/MinitestAssertions: @@ -1282,6 +1510,48 @@ Rails/ActionControllerFlashBeforeRender: - 'app/controllers/projects_controller.rb' - 'app/controllers/requests_controller.rb' +# Offense count: 37 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/ActionControllerTestCase: + Exclude: + - 'test/controllers/admin_controller_test.rb' + - 'test/controllers/admin_programs_controller_test.rb' + - 'test/controllers/admin_projects_controller_test.rb' + - 'test/controllers/admin_roles_controller_test.rb' + - 'test/controllers/admin_studies_controller_test.rb' + - 'test/controllers/admin_users_controller_test.rb' + - 'test/controllers/api/submissions_controller.rb' + - 'test/controllers/authentication_controller_test.rb' + - 'test/controllers/batches_controller_test.rb' + - 'test/controllers/events_controller_test.rb' + - 'test/controllers/get_your_qc_completed_tubes_here_controller_test.rb' + - 'test/controllers/labware_controller_test.rb' + - 'test/controllers/pipelines_controller_test.rb' + - 'test/controllers/plate_summaries_controller_test.rb' + - 'test/controllers/plate_template_controller_test.rb' + - 'test/controllers/plates_controller_test.rb' + - 'test/controllers/plates_from_tubes_controller_test.rb' + - 'test/controllers/projects_controller_test.rb' + - 'test/controllers/qc_files_controller_test.rb' + - 'test/controllers/qc_reports_controller_test.rb' + - 'test/controllers/receptacles_controller_test.rb' + - 'test/controllers/requests_comments_controller_test.rb' + - 'test/controllers/requests_controller_test.rb' + - 'test/controllers/robots_controller_test.rb' + - 'test/controllers/roles_users_controller_test.rb' + - 'test/controllers/sample_manifests_controller_test.rb' + - 'test/controllers/samples_comments_controller_test.rb' + - 'test/controllers/samples_controller_test.rb' + - 'test/controllers/sessions_controller_test.rb' + - 'test/controllers/studies_asset_groups_controller_test.rb' + - 'test/controllers/studies_comments_controller_test.rb' + - 'test/controllers/studies_controller_test.rb' + - 'test/controllers/studies_events_controller_test.rb' + - 'test/controllers/studies_sample_controller_test.rb' + - 'test/controllers/users_controller_test.rb' + - 'test/controllers/workflows_controller_test.rb' + - 'test/unit/plate_owner_test.rb' + # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/ApplicationMailer: @@ -1429,6 +1699,98 @@ Rails/HttpStatus: - 'app/controllers/projects_controller.rb' - 'app/controllers/studies/documents_controller.rb' +# Offense count: 209 +Rails/I18nLocaleTexts: + Exclude: + - 'app/controllers/admin/bait_libraries/bait_library_suppliers_controller.rb' + - 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb' + - 'app/controllers/admin/bait_libraries_controller.rb' + - 'app/controllers/admin/custom_texts_controller.rb' + - 'app/controllers/admin/faculty_sponsors_controller.rb' + - 'app/controllers/admin/plate_purposes_controller.rb' + - 'app/controllers/admin/primer_panels_controller.rb' + - 'app/controllers/admin/programs_controller.rb' + - 'app/controllers/admin/projects_controller.rb' + - 'app/controllers/admin/robot_properties_controller.rb' + - 'app/controllers/admin/robots_controller.rb' + - 'app/controllers/admin/roles_controller.rb' + - 'app/controllers/admin/studies_controller.rb' + - 'app/controllers/admin/users_controller.rb' + - 'app/controllers/barcode_printers_controller.rb' + - 'app/controllers/batches_controller.rb' + - 'app/controllers/bulk_submissions_controller.rb' + - 'app/controllers/gels_controller.rb' + - 'app/controllers/get_your_qc_completed_tubes_here_controller.rb' + - 'app/controllers/labwhere_receptions_controller.rb' + - 'app/controllers/pipelines_controller.rb' + - 'app/controllers/plate_templates_controller.rb' + - 'app/controllers/plates_controller.rb' + - 'app/controllers/plates_from_tubes_controller.rb' + - 'app/controllers/projects_controller.rb' + - 'app/controllers/qc_reports_controller.rb' + - 'app/controllers/receptacles_controller.rb' + - 'app/controllers/reference_genomes_controller.rb' + - 'app/controllers/report_fails_controller.rb' + - 'app/controllers/requests_controller.rb' + - 'app/controllers/samples_controller.rb' + - 'app/controllers/sdb/suppliers_controller.rb' + - 'app/controllers/sessions_controller.rb' + - 'app/controllers/studies/asset_groups_controller.rb' + - 'app/controllers/studies/documents_controller.rb' + - 'app/controllers/studies_controller.rb' + - 'app/controllers/study_reports_controller.rb' + - 'app/controllers/submissions_controller.rb' + - 'app/controllers/tag_groups_controller.rb' + - 'app/controllers/tag_sets_controller.rb' + - 'app/controllers/tag_substitutions_controller.rb' + - 'app/controllers/users_controller.rb' + - 'app/models/barcode_printer_type.rb' + - 'app/models/batch/request_fail_and_remover.rb' + - 'app/models/budget_division.rb' + - 'app/models/data_release_study_type.rb' + - 'app/models/faculty_sponsor.rb' + - 'app/models/item.rb' + - 'app/models/lib_pool_norm_tube_generator.rb' + - 'app/models/phi_x/spiked_buffer.rb' + - 'app/models/pipeline.rb' + - 'app/models/plate/quad_creator.rb' + - 'app/models/pooling.rb' + - 'app/models/program.rb' + - 'app/models/project_manager.rb' + - 'app/models/qc_report.rb' + - 'app/models/reference_genome.rb' + - 'app/models/sample.rb' + - 'app/models/sample_manifest/uploader.rb' + - 'app/models/state_change.rb' + - 'app/models/stock_stamper.rb' + - 'app/models/study.rb' + - 'app/models/study_sample.rb' + - 'app/models/study_type.rb' + - 'app/models/tag_layout.rb' + - 'app/models/tag_substitution/substitution.rb' + - 'app/models/tasks/cherrypick_handler.rb' + - 'app/models/transfer/transfers_to_known_destination.rb' + - 'app/models/work_order_type.rb' + - 'app/models/workflow.rb' + - 'app/sample_manifest_excel/sample_manifest_excel/upload/data.rb' + - 'app/sequencescape_excel/sequencescape_excel/specialised_field/chromium_tag_well.rb' + - 'app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb' + - 'app/uat_actions/uat_actions/generate_fluidx_barcodes.rb' + - 'app/uat_actions/uat_actions/generate_plate_concentrations.rb' + - 'app/uat_actions/uat_actions/generate_plate_volumes.rb' + - 'app/uat_actions/uat_actions/generate_plates.rb' + - 'app/uat_actions/uat_actions/generate_primer_panel.rb' + - 'app/uat_actions/uat_actions/generate_qc_results.rb' + - 'app/uat_actions/uat_actions/generate_tag_group.rb' + - 'app/uat_actions/uat_actions/generate_tag_layout_template.rb' + - 'app/uat_actions/uat_actions/generate_tag_plates.rb' + - 'app/uat_actions/uat_actions/generate_tagged_plates.rb' + - 'app/uat_actions/uat_actions/plate_information.rb' + - 'app/uat_actions/uat_actions/test_submission.rb' + - 'app/uat_actions/uat_actions/tube_submission.rb' + - 'lib/authenticated_system.rb' + - 'lib/limber/helper.rb' + # Offense count: 41 # Configuration parameters: IgnoreScopes. Rails/InverseOf: @@ -1495,6 +1857,12 @@ Rails/RootPathnameMethods: Exclude: - 'spec/rails_helper.rb' +# Offense count: 2 +Rails/ThreeStateBooleanColumn: + Exclude: + - 'db/migrate/20250326144346_add_element_aviti_pipeline_to_request_metadata.rb' + - 'db/migrate/20250818125034_add_active_to_lot_types.rb' + # Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/WhereEquals: From 804314db62fedd0551a476d6236dfbb0bbfd0b4e Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 12:57:57 +0000 Subject: [PATCH 06/30] style: sort rubocop file using ruboclean $ bundle exec ruboclean --preserve-comments Add back inline comments --- .rubocop.yml | 356 +++++++++++++++++++++++++-------------------------- 1 file changed, 175 insertions(+), 181 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1894a352d..8c25494d4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,49 +1,56 @@ +--- + inherit_from: - - .rubocop_todo.yml -plugins: - - rubocop-capybara - - rubocop-factory_bot - - rubocop-minitest - - rubocop-performance - - rubocop-rails - - rubocop-rspec - - rubocop-rspec_rails - - test-prof +- ".rubocop_todo.yml" + +inherit_gem: + test-prof: config/rubocop-rspec.yml inherit_mode: merge: - - Exclude + - Exclude -inherit_gem: - test-prof: config/rubocop-rspec.yml +plugins: +- rubocop-capybara +- rubocop-factory_bot +- rubocop-minitest +- rubocop-performance +- rubocop-rails +- rubocop-rspec +- rubocop-rspec_rails +- test-prof AllCops: NewCops: enable Exclude: - - db/schema.rb - - db/views_schema.rb - - db/archived_migrations/* - # generated by cucumber-rails - - features/support/env.rb - # generated by cucumber-rails - - lib/tasks/cucumber.rake - # CI installs gems in the vendor directory, which causes rubocop to try - # and cop our gems. We don't want it to. - - vendor/**/* - - bin/* - - sbin/* - - node_modules/**/* - - tmp/**/* + - db/schema.rb + - db/views_schema.rb + - features/support/env.rb # generated by cucumber-rails + - lib/tasks/cucumber.rake # generated by cucumber-rails + - bin/* + - node_modules/**/* + - tmp/**/* -Layout/EmptyLineAfterMagicComment: +Rails: + Enabled: true + +# Capybara +Capybara/ClickLinkOrButtonStyle: Enabled: false -Layout/EndAlignment: - EnforcedStyleAlignWith: start_of_line +# Factory Bot +FactoryBot/FactoryAssociationWithStrategy: + Enabled: false Layout/DefEndAlignment: EnforcedStyleAlignWith: def +Layout/EmptyLineAfterMagicComment: + Enabled: false + +Layout/EndAlignment: + EnforcedStyleAlignWith: start_of_line + Layout/LeadingCommentSpace: AllowRBSInlineAnnotation: true @@ -53,57 +60,16 @@ Layout/MultilineMethodCallIndentation: Layout/MultilineOperationIndentation: EnforcedStyle: indented -# There is so much existing inconsistent code that it is not worth enforcing this cop -Naming/PredicateMethod: - Enabled: false - # Step definitions are defined with Given /regex/ do ... # There is little ambiguity here, and brackets just break convention Lint/AmbiguousRegexpLiteral: Exclude: - - features/support/step_definitions/**/* + - features/support/step_definitions/**/* -Rails: - Enabled: true - -Rails/SkipsModelValidations: - Exclude: - - "db/migrate/*.rb" - - "db/migrate_asset_refactor/*.rb" - - "features/support/step_definitions/*.rb" - -# This cop doesn't always increase clarity -Style/CollectionQuerying: - Enabled: false - -Style/Documentation: - Enabled: false - -# The single-line syntax can be clearer than the multi-line version for multiple definitions -Style/EmptyClassDefinition: - Enabled: false - -Style/EmptyMethod: - EnforcedStyle: expanded - -# Only use shorthand hash syntax when all keys match the variables for better readability -Style/HashSyntax: - EnforcedShorthandSyntax: consistent - -# Enforces 1234565789 as 123_456_789: While nice when dealing with actual big -# numbers, we're more likely to see it shout at us about barcodes. -Style/NumericLiterals: - Enabled: false - -# these are generally generated files and don't need excessive linting -Style/QuotedSymbols: - Exclude: - - "bin/*" - - # these are generally generated files and don't need excessive linting -Style/StringLiterals: - Exclude: - - "bin/*" +# Unused keyword arguments are good for maintaining API compatibility, and +# applying an underscore before the keyword name breaks that API. +Lint/UnusedMethodArgument: + AllowUnusedKeywordArguments: true # Blocks are used to structure tests and are part of the shoulda dsl. # The standard BlockLength limits are too stringent for this purpose. @@ -113,84 +79,72 @@ Style/StringLiterals: # We exclude builders, as they are concerned with rendering xml Metrics/BlockLength: Exclude: - - Gemfile - - "db/seeds/**/*" - - "**/*.builder" + - Gemfile + - db/seeds/**/* + - "**/*.builder" CountAsOne: - - array - - hash - - heredoc + - array + - hash + - heredoc AllowedMethods: - - describe - - context - - background - - scenario - - namespace - - task - - included - - shared_context - - shared_examples - - shared_examples_for - - state_machine - - configure - - draw - - feature - - subject - - let - - let! - - factory - - define - - guard - - transient - - with_nested_has_many_association - - with_association - - it - - class_eval - - has_metadata - - resources - - aasm - - redefine_aasm - - model - - step + - describe + - context + - background + - scenario + - namespace + - task + - included + - shared_context + - shared_examples + - shared_examples_for + - state_machine + - configure + - draw + - feature + - subject + - let + - let! + - factory + - define + - guard + - transient + - with_nested_has_many_association + - with_association + - it + - class_eval + - has_metadata + - resources + - aasm + - redefine_aasm + - model + - step -# We have a few custom find_by methods which we maintain. -# At least for now. find_by_id_or_name is a bit clunky. -Rails/DynamicFindBy: +# Disable for features and tests, we want lots of tests +Metrics/ClassLength: + inherit_mode: + merge: + - Exclude + CountAsOne: + - array + - hash + - heredoc Exclude: - - "app/sample_manifest_excel/**/*" - - "test/app/sample_manifest_excel/**/*" - AllowedMethods: - - find_by_sql - - find_by_id_or_name - - find_by_id_or_name! - - find_by_barcode - -# Explicit if statements are clearer than chaining with the safe navigation operator -# particularly where there is a behavioural impact -Rails/Presence: - Enabled: false + - spec/**/* + - test/**/* # Method length limits make little sense when you are describing a table schema or a view. Metrics/MethodLength: Exclude: - - "db/migrate/*" + - db/migrate/* CountAsOne: - - array - - hash - - heredoc + - array + - hash + - heredoc -Style/ClassAndModuleChildren: +# There is so much existing inconsistent code that it is not worth enforcing this cop +Naming/PredicateMethod: Enabled: false -Rails/UnknownEnv: - Environments: - - production - - development - - test - - cucumber - - profile - - staging - # Aggregate examples can be useful, but the cop gets into nasty battles with # other Spec cops, and is only really of value in expensive tests. RSpec/AggregateExamples: @@ -199,72 +153,112 @@ RSpec/AggregateExamples: # Added exclude because api and feature specs do not have a specific class. RSpec/DescribeClass: Exclude: - - "spec/requests/**/*.rb" - - "spec/api/**/*.rb" - - "spec/features/**/*.rb" - - "spec/views/**/*.rb" + - spec/requests/**/*.rb + - spec/api/**/*.rb + - spec/features/**/*.rb + - spec/views/**/*.rb # Disable for features, as we might want to step through long processes RSpec/ExampleLength: inherit_mode: merge: - - Exclude + - Exclude CountAsOne: - - array - - hash - - heredoc + - array + - hash + - heredoc Exclude: - - "spec/features/**/*" + - spec/features/**/* -# Disable for features and tests, we want lots of tests -Metrics/ClassLength: - inherit_mode: - merge: - - Exclude - CountAsOne: - - array - - hash - - heredoc +# We want to be able to use `it do ... end` as well as `it { is_expected.to ... }` +RSpec/ImplicitSubject: + EnforcedStyle: single_statement_only + +RSpec/MultipleExpectations: Exclude: - - "spec/**/*" - - "test/**/*" + - spec/features/**/* + +# We don't see a benefit to limiting the number of memoized helpers. +RSpec/MultipleMemoizedHelpers: + Enabled: false + +# Set a more reasonable max. We've been happy with our existing nesting. +RSpec/NestedGroups: + Max: 6 RSpecRails/AvoidSetupHook: Exclude: - - "test/**/*" + - test/**/* -RSpec/MultipleExpectations: +# We have a few custom find_by methods which we maintain. +# At least for now. find_by_id_or_name is a bit clunky. +Rails/DynamicFindBy: Exclude: - - "spec/features/**/*" + - app/sample_manifest_excel/**/* + AllowedMethods: + - find_by_sql + - find_by_id_or_name + - find_by_id_or_name! + - find_by_barcode -# Unused keyword arguments are good for maintaining API compatibility, and -# applying an underscore before the keyword name breaks that API. -Lint/UnusedMethodArgument: - AllowUnusedKeywordArguments: true +# Explicit if statements are clearer than chaining with the safe navigation operator +# particularly where there is a behavioural impact +Rails/Presence: + Enabled: false # This seems to be causing all sorts of issues with failing tests Rails/RedundantPresenceValidationOnBelongsTo: Enabled: false +Rails/SkipsModelValidations: + Exclude: + - db/migrate/*.rb + - features/support/step_definitions/*.rb + Rails/UniqueValidationWithoutIndex: Enabled: false -# Factory Bot -FactoryBot/FactoryAssociationWithStrategy: +Rails/UnknownEnv: + Environments: + - production + - development + - test + - cucumber + - profile + - staging + +Style/ClassAndModuleChildren: Enabled: false -# Capybara -Capybara/ClickLinkOrButtonStyle: +# This cop doesn't always increase clarity +Style/CollectionQuerying: Enabled: false -# We don't see a benefit to limiting the number of memoized helpers. -RSpec/MultipleMemoizedHelpers: +Style/Documentation: Enabled: false -# Set a more reasonable max. We've been happy with our existing nesting. -RSpec/NestedGroups: - Max: 6 +# The single-line syntax can be clearer than the multi-line version for multiple definitions +Style/EmptyClassDefinition: + Enabled: false -# We want to be able to use `it do ... end` as well as `it { is_expected.to ... }` -RSpec/ImplicitSubject: - EnforcedStyle: single_statement_only +Style/EmptyMethod: + EnforcedStyle: expanded + +# Only use shorthand hash syntax when all keys match the variables for better readability +Style/HashSyntax: + EnforcedShorthandSyntax: consistent + +# Enforces 1234565789 as 123_456_789: While nice when dealing with actual big +# numbers, we're more likely to see it shout at us about barcodes. +Style/NumericLiterals: + Enabled: false + +# these are generally generated files and don't need excessive linting +Style/QuotedSymbols: + Exclude: + - bin/* + +# these are generally generated files and don't need excessive linting +Style/StringLiterals: + Exclude: + - bin/* From a6f695f75a3fbb2d9f8b6c4155681fe55d501fad Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 13:04:13 +0000 Subject: [PATCH 07/30] style: lint Lint/NonAtomicFileOperation --- .rubocop_todo.yml | 21 ------------------- lib/tasks/views_schema.rake | 2 +- .../data_worksheet_spec.rb | 2 +- spec/bulk_submission_excel/download_spec.rb | 2 +- ...r_for_manifests_with_tag_sequences_spec.rb | 2 +- .../export_pool_xp_to_traction_job_spec.rb | 2 +- spec/models/sample_manifest/uploader_spec.rb | 2 +- spec/sample_manifest_excel/download_spec.rb | 2 +- ...retention_instruction_verification_spec.rb | 2 +- spec/sample_manifest_excel/tags_spec.rb | 2 +- .../test_download_spec.rb | 2 +- .../sample_manifest_excel/upload/data_spec.rb | 2 +- .../upload/processor_spec.rb | 16 +++++++------- .../sample_manifest_excel/upload/rows_spec.rb | 2 +- .../upload/upload_spec.rb | 2 +- spec/sample_manifest_excel/worksheet_spec.rb | 2 +- spec/sequencescape_excel/worksheet_spec.rb | 2 +- 17 files changed, 23 insertions(+), 44 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6314951f9..d84159ed4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -221,27 +221,6 @@ Lint/NestedMethodDefinition: Exclude: - 'lib/eventful_record.rb' -# Offense count: 46 -# This cop supports unsafe autocorrection (--autocorrect-all). -Lint/NonAtomicFileOperation: - Exclude: - - 'lib/tasks/views_schema.rake' - - 'spec/bulk_submission_excel/data_worksheet_spec.rb' - - 'spec/bulk_submission_excel/download_spec.rb' - - 'spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb' - - 'spec/jobs/export_pool_xp_to_traction_job_spec.rb' - - 'spec/models/sample_manifest/uploader_spec.rb' - - 'spec/sample_manifest_excel/download_spec.rb' - - 'spec/sample_manifest_excel/retention_instruction_verification_spec.rb' - - 'spec/sample_manifest_excel/tags_spec.rb' - - 'spec/sample_manifest_excel/test_download_spec.rb' - - 'spec/sample_manifest_excel/upload/data_spec.rb' - - 'spec/sample_manifest_excel/upload/processor_spec.rb' - - 'spec/sample_manifest_excel/upload/rows_spec.rb' - - 'spec/sample_manifest_excel/upload/upload_spec.rb' - - 'spec/sample_manifest_excel/worksheet_spec.rb' - - 'spec/sequencescape_excel/worksheet_spec.rb' - # Offense count: 4 Lint/NonLocalExitFromIterator: Exclude: diff --git a/lib/tasks/views_schema.rake b/lib/tasks/views_schema.rake index 3dadecf43..a87ec233a 100644 --- a/lib/tasks/views_schema.rake +++ b/lib/tasks/views_schema.rake @@ -14,7 +14,7 @@ namespace :db do schema.puts ')' end end - File.delete('./db/views_schema.old') if File.exist?('./db/views_schema.old') + FileUtils.rm_f('./db/views_schema.old') File.rename('./db/views_schema.rb', './db/views_schema.old') File.rename('./db/views_schema.tmp', './db/views_schema.rb') end diff --git a/spec/bulk_submission_excel/data_worksheet_spec.rb b/spec/bulk_submission_excel/data_worksheet_spec.rb index bd2209646..ef30fb7dc 100644 --- a/spec/bulk_submission_excel/data_worksheet_spec.rb +++ b/spec/bulk_submission_excel/data_worksheet_spec.rb @@ -22,7 +22,7 @@ let(:spreadsheet) { Roo::Spreadsheet.open(test_file) } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } context 'data worksheet' do let!(:worksheet) do diff --git a/spec/bulk_submission_excel/download_spec.rb b/spec/bulk_submission_excel/download_spec.rb index 7c6b84f12..fe55a38ae 100644 --- a/spec/bulk_submission_excel/download_spec.rb +++ b/spec/bulk_submission_excel/download_spec.rb @@ -32,7 +32,7 @@ let(:assets) { create(:plate_with_untagged_wells).wells } let(:submission_template) { create(:library_and_sequencing_template) } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } context 'without columns' do let(:columns) { nil } diff --git a/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb b/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb index 4000cb56b..ad33e62f2 100644 --- a/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb +++ b/spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb @@ -12,7 +12,7 @@ end after do - File.delete(test_file) if File.exist?(test_file) + FileUtils.rm_f(test_file) Delayed::Worker.delay_jobs = true end diff --git a/spec/jobs/export_pool_xp_to_traction_job_spec.rb b/spec/jobs/export_pool_xp_to_traction_job_spec.rb index 715effe24..8e9ef6e18 100644 --- a/spec/jobs/export_pool_xp_to_traction_job_spec.rb +++ b/spec/jobs/export_pool_xp_to_traction_job_spec.rb @@ -96,7 +96,7 @@ before do # Remove any cached schema file - File.delete(cache_file_path) if File.exist?(cache_file_path) + FileUtils.rm_f(cache_file_path) end context 'when the schema is cached' do diff --git a/spec/models/sample_manifest/uploader_spec.rb b/spec/models/sample_manifest/uploader_spec.rb index 3451efe88..85339a4ce 100644 --- a/spec/models/sample_manifest/uploader_spec.rb +++ b/spec/models/sample_manifest/uploader_spec.rb @@ -20,7 +20,7 @@ after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } describe '#initialize' do it 'will not be valid without a filename' do diff --git a/spec/sample_manifest_excel/download_spec.rb b/spec/sample_manifest_excel/download_spec.rb index bf634bd64..51aafc74c 100644 --- a/spec/sample_manifest_excel/download_spec.rb +++ b/spec/sample_manifest_excel/download_spec.rb @@ -23,7 +23,7 @@ def save_file after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } it 'is not valid without a sample manifest' do download = diff --git a/spec/sample_manifest_excel/retention_instruction_verification_spec.rb b/spec/sample_manifest_excel/retention_instruction_verification_spec.rb index 0c6a533ec..78eed4c49 100644 --- a/spec/sample_manifest_excel/retention_instruction_verification_spec.rb +++ b/spec/sample_manifest_excel/retention_instruction_verification_spec.rb @@ -14,7 +14,7 @@ after do SampleManifestExcel.reset! - File.delete(test_file) if File.exist?(test_file) + FileUtils.rm_f(test_file) end shared_examples 'manifest with retention instruction' do |template_name, config_column| diff --git a/spec/sample_manifest_excel/tags_spec.rb b/spec/sample_manifest_excel/tags_spec.rb index 4c85c3701..f2a4a0262 100644 --- a/spec/sample_manifest_excel/tags_spec.rb +++ b/spec/sample_manifest_excel/tags_spec.rb @@ -59,7 +59,7 @@ def initialize(upload) after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } context 'tag sequences' do let(:columns) { SampleManifestExcel.configuration.columns.tube_multiplexed_library_with_tag_sequences.dup } diff --git a/spec/sample_manifest_excel/test_download_spec.rb b/spec/sample_manifest_excel/test_download_spec.rb index 12ee3fb20..251f745ec 100644 --- a/spec/sample_manifest_excel/test_download_spec.rb +++ b/spec/sample_manifest_excel/test_download_spec.rb @@ -27,7 +27,7 @@ after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } it 'creates a file' do expect(File.file?(test_file)) diff --git a/spec/sample_manifest_excel/upload/data_spec.rb b/spec/sample_manifest_excel/upload/data_spec.rb index b1bbeb7c2..e739d0ad3 100644 --- a/spec/sample_manifest_excel/upload/data_spec.rb +++ b/spec/sample_manifest_excel/upload/data_spec.rb @@ -19,7 +19,7 @@ after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } it 'is not valid without a filename' do expect(described_class.new(nil)).not_to be_valid diff --git a/spec/sample_manifest_excel/upload/processor_spec.rb b/spec/sample_manifest_excel/upload/processor_spec.rb index 846293850..8f8a97b21 100644 --- a/spec/sample_manifest_excel/upload/processor_spec.rb +++ b/spec/sample_manifest_excel/upload/processor_spec.rb @@ -44,7 +44,7 @@ def cell(row, column) download.save(test_file_name) end - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } shared_examples 'it updates downstream aliquots' do |rows, columns| it 'will update the aliquots downstream if aliquots data has changed and override is set to true' do @@ -296,7 +296,7 @@ def cell(row, column) let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } let(:new_test_file) { Rack::Test::UploadedFile.new(Rails.root.join(new_test_file_name), '') } - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } shared_examples_for 'a mandatory field in the manifest' do it 'cannot have blank' do @@ -333,7 +333,7 @@ def cell(row, column) let(:download) { build(:test_download_tubes, columns: column_list, manifest_type: manifest_type) } let(:new_test_file) { Rack::Test::UploadedFile.new(Rails.root.join(new_test_file_name), '') } - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it 'cannot have blank retention instruction' do column = download.worksheet.columns.find_by(:name, :retention_instruction) @@ -437,7 +437,7 @@ def cell(row, column) upload.sample_manifest.state = 'completed' end - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it_behaves_like 'it updates downstream aliquots', [10, 11], insert_size_from: 6, insert_size_to: 7, i7: 2 end @@ -509,7 +509,7 @@ def cell(row, column) upload.sample_manifest.state = 'completed' end - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it 'will update the aliquots downstream if aliquots data has changed and override is set to true' do cell(10, 7).value = '100' @@ -685,7 +685,7 @@ def cell(row, column) upload.sample_manifest.state = 'completed' end - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it 'will update the samples if samples data has changed and override is set true' do reupload = @@ -731,7 +731,7 @@ def cell(row, column) upload.sample_manifest.state = 'completed' end - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it 'the same barcode cannot be used for multiple plates' do cell(9, 0).value = 'CGAP-00000' @@ -767,7 +767,7 @@ def cell(row, column) upload.sample_manifest.state = 'completed' end - after { File.delete(new_test_file_name) if File.exist?(new_test_file_name) } + after { FileUtils.rm_f(new_test_file_name) } it 'the retention instructions cannot be left blank' do col1 = download.worksheet.columns.find_by(:name, :retention_instruction).number - 1 diff --git a/spec/sample_manifest_excel/upload/rows_spec.rb b/spec/sample_manifest_excel/upload/rows_spec.rb index 8efd3e918..50abecd14 100644 --- a/spec/sample_manifest_excel/upload/rows_spec.rb +++ b/spec/sample_manifest_excel/upload/rows_spec.rb @@ -16,7 +16,7 @@ after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } before do create(:insdc_country, name: 'United Kingdom') diff --git a/spec/sample_manifest_excel/upload/upload_spec.rb b/spec/sample_manifest_excel/upload/upload_spec.rb index fb7456dae..1d180f88d 100644 --- a/spec/sample_manifest_excel/upload/upload_spec.rb +++ b/spec/sample_manifest_excel/upload/upload_spec.rb @@ -18,7 +18,7 @@ after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file_name) if File.exist?(test_file_name) } + after { FileUtils.rm_f(test_file_name) } before do create(:insdc_country, name: 'United Kingdom') diff --git a/spec/sample_manifest_excel/worksheet_spec.rb b/spec/sample_manifest_excel/worksheet_spec.rb index b77883e4d..b507967eb 100644 --- a/spec/sample_manifest_excel/worksheet_spec.rb +++ b/spec/sample_manifest_excel/worksheet_spec.rb @@ -30,7 +30,7 @@ def save_file after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } context 'type' do let(:options) { { workbook: workbook, ranges: SampleManifestExcel.configuration.ranges.dup, password: '1111' } } diff --git a/spec/sequencescape_excel/worksheet_spec.rb b/spec/sequencescape_excel/worksheet_spec.rb index 118cb6cf5..f5a71e57a 100644 --- a/spec/sequencescape_excel/worksheet_spec.rb +++ b/spec/sequencescape_excel/worksheet_spec.rb @@ -34,7 +34,7 @@ def save_file after(:all) { SampleManifestExcel.reset! } - after { File.delete(test_file) if File.exist?(test_file) } + after { FileUtils.rm_f(test_file) } describe 'validations ranges worksheet' do let!(:range_list) { SampleManifestExcel.configuration.ranges.dup } From be6807800caf87a8eba776fc06056dd3a80dbace Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 13:05:16 +0000 Subject: [PATCH 08/30] style: lint Lint/RedundantCopEnableDirective --- .rubocop_todo.yml | 6 ------ spec/models/plate_purpose_spec.rb | 2 -- 2 files changed, 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d84159ed4..d95b7168d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -234,12 +234,6 @@ Lint/RedundantCopDisableDirective: Exclude: - 'app/models/role/user_role_helper.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Lint/RedundantCopEnableDirective: - Exclude: - - 'spec/models/plate_purpose_spec.rb' - # Offense count: 4 Lint/ReturnInVoidContext: Exclude: diff --git a/spec/models/plate_purpose_spec.rb b/spec/models/plate_purpose_spec.rb index 67d8aa808..7b9c08ca2 100644 --- a/spec/models/plate_purpose_spec.rb +++ b/spec/models/plate_purpose_spec.rb @@ -9,8 +9,6 @@ shared_examples 'a plate factory' do before { expect(PlateBarcode).to receive(:create_barcode).and_return(build(:plate_barcode)) } - # rubocop:enable RSpec/ExpectInHook - describe '#create!' do subject { plate_purpose.create! } From 7266ed74a7fe77d35219489b57e47f280d71fe93 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 13:10:20 +0000 Subject: [PATCH 09/30] style: disable RSpec/IndexedLet --- .rubocop.yml | 4 +++ .rubocop_todo.yml | 70 ----------------------------------------------- 2 files changed, 4 insertions(+), 70 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8c25494d4..f3875fba6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -174,6 +174,10 @@ RSpec/ExampleLength: RSpec/ImplicitSubject: EnforcedStyle: single_statement_only +# Due to the nature of our application, this doesn't add value to our tests +RSpec/IndexedLet: + Enabled: false + RSpec/MultipleExpectations: Exclude: - spec/features/**/* diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d95b7168d..1b847f021 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -865,76 +865,6 @@ RSpec/ExpectInHook: - 'spec/models/transfer_request_collection_spec.rb' - 'spec/uat_actions/test_submission_spec.rb' -# Offense count: 361 -# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns. -RSpec/IndexedLet: - Exclude: - - 'spec/api/extraction_attributes_spec.rb' - - 'spec/controllers/studies/information_controller_spec.rb' - - 'spec/controllers/ultima_sample_sheet/sample_sheet_generator_spec.rb' - - 'spec/features/creating_a_quad_stamp_spec.rb' - - 'spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb' - - 'spec/features/location_reports/location_reports_spec.rb' - - 'spec/features/migrated/pre_cap_pool_test_spec.rb' - - 'spec/features/pipelines/cherrypick/cherrypick_for_fluidigm_pipeline_micro_litre_spec.rb' - - 'spec/features/pipelines/cherrypick/cherrypick_pipeline_spec.rb' - - 'spec/features/pipelines/sequencing/following_a_sequencing_pipeline_with_compound_sample_creation_spec.rb' - - 'spec/features/pooling_spec.rb' - - 'spec/features/retrospective_failure_spec.rb' - - 'spec/features/tag_layout_template_spec.rb' - - 'spec/helpers/batches_helper_spec.rb' - - 'spec/lib/ebi_check/process_spec.rb' - - 'spec/lib/http_clients/accessioning_v1_client_spec.rb' - - 'spec/lib/label_printer/asset_labels_spec.rb' - - 'spec/lib/label_printer/asset_redirect_spec.rb' - - 'spec/lib/label_printer/batch_plate_spec.rb' - - 'spec/lib/record_loader/tag_set_loader_spec.rb' - - 'spec/models/aliquot_spec.rb' - - 'spec/models/api/messages/pac_bio_run_io_spec.rb' - - 'spec/models/api/messages/pac_bio_run_with_tag2_io_spec.rb' - - 'spec/models/api/sample_io_spec.rb' - - 'spec/models/barcode_printer_spec.rb' - - 'spec/models/broadcast_event/helpers/external_subjects_spec.rb' - - 'spec/models/broadcast_event/plate_cherrypicked_spec.rb' - - 'spec/models/broadcast_event/pool_released_spec.rb' - - 'spec/models/broadcast_event/qc_assay_spec.rb' - - 'spec/models/comment_spec.rb' - - 'spec/models/heron/factories/tube_rack_spec.rb' - - 'spec/models/labware_spec.rb' - - 'spec/models/labwhere_reception_spec.rb' - - 'spec/models/linear_submission_spec.rb' - - 'spec/models/location_report_form_spec.rb' - - 'spec/models/location_report_spec.rb' - - 'spec/models/pick_list_spec.rb' - - 'spec/models/pooling_spec.rb' - - 'spec/models/qc_result/qc_result_factory_spec.rb' - - 'spec/models/receptacle_spec.rb' - - 'spec/models/report_fail_spec.rb' - - 'spec/models/request/sample_compound_aliquot_transfer_spec.rb' - - 'spec/models/request_spec.rb' - - 'spec/models/robot/pick_data_spec.rb' - - 'spec/models/robot/verification/source_dest_beds_spec.rb' - - 'spec/models/robot/verification/source_dest_control_beds_spec.rb' - - 'spec/models/sample_spec.rb' - - 'spec/models/sequencing_request_spec.rb' - - 'spec/models/study_spec.rb' - - 'spec/models/submission_spec.rb' - - 'spec/models/tag_group_spec.rb' - - 'spec/models/tag_set_spec.rb' - - 'spec/models/tasks/cherrypick_task_spec.rb' - - 'spec/models/transfer_request_spec.rb' - - 'spec/requests/api/v2/pick_lists_spec.rb' - - 'spec/requests/api/v2/plate_controller_spec.rb' - - 'spec/requests/api/v2/qc_assays_spec.rb' - - 'spec/requests/api/v2/qc_results_spec.rb' - - 'spec/sequencescape_excel/list_spec.rb' - - 'spec/sequencescape_excel/specialised_field_spec.rb' - - 'spec/tasks/assing_compound_sample_supplier_name_spec.rb' - - 'spec/uat_actions/generate_plates_spec.rb' - - 'spec/uat_actions/generate_tagged_plates_spec.rb' - - 'spec/uat_actions/update_state_of_requests_in_labware_spec.rb' - - 'spec/validators/ultima_validator_spec.rb' - # Offense count: 268 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: From 275177319139c0b8458db2702f474a74c8bb63d3 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 13:47:53 +0000 Subject: [PATCH 10/30] style: lint RSpec/SpecFilePathFormat --- .rubocop_todo.yml | 50 +++------ .../worksheet}/data_worksheet_spec.rb | 2 +- .../concerns}/disable_destroy_action_spec.rb | 0 .../api/v2/plates_controller_spec.rb} | 0 .../api/v2/qc_assays_controller_spec.rb} | 0 .../api/v2/qc_results_controller_spec.rb} | 0 .../sample_manifests_controller_spec.rb} | 0 spec/lib/accession/accessionable_spec.rb | 105 +++++++++++++----- spec/lib/accession/configuration_spec.rb | 46 -------- spec/lib/deployed_spec.rb | 48 ++++---- .../{ => label}/batch_plate_amp_spec.rb | 0 .../{ => label}/batch_tube_spec.rb | 0 .../sample_manifest_plate_double_spec.rb | 0 .../form_object_spec.rb} | 0 .../purpose_spec.rb} | 0 ...ec.rb => faculty_sponsor_resource_spec.rb} | 0 .../resources/api/v2/project_resource_spec.rb | 15 --- 17 files changed, 117 insertions(+), 149 deletions(-) rename spec/bulk_submission_excel/{ => bulk_submission_excel/worksheet}/data_worksheet_spec.rb (99%) rename spec/controllers/{concerns/api/v2 => api/v2/concerns}/disable_destroy_action_spec.rb (100%) rename spec/{requests/api/v2/plate_controller_spec.rb => controllers/api/v2/plates_controller_spec.rb} (100%) rename spec/{requests/api/v2/qc_assays_spec.rb => controllers/api/v2/qc_assays_controller_spec.rb} (100%) rename spec/{requests/api/v2/qc_results_spec.rb => controllers/api/v2/qc_results_controller_spec.rb} (100%) rename spec/controllers/{sample_manifest_controller_spec.rb => sdb/sample_manifests_controller_spec.rb} (100%) delete mode 100644 spec/lib/accession/configuration_spec.rb rename spec/lib/label_printer/{ => label}/batch_plate_amp_spec.rb (100%) rename spec/lib/label_printer/{ => label}/batch_tube_spec.rb (100%) rename spec/lib/label_printer/{ => label}/sample_manifest_plate_double_spec.rb (100%) rename spec/models/{tag_group_form_object_spec.rb => tag_group/form_object_spec.rb} (100%) rename spec/models/{tube_purpose_spec.rb => tube/purpose_spec.rb} (100%) rename spec/resources/api/v2/{faculty_sponsor_spec.rb => faculty_sponsor_resource_spec.rb} (100%) delete mode 100644 spec/resources/api/v2/project_resource_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1b847f021..9a68ad530 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2026-03-06 12:51:58 UTC using RuboCop version 1.85.1. +# on 2026-03-06 13:51:37 UTC using RuboCop version 1.85.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -511,6 +511,8 @@ Naming/VariableNumber: - 'db/seeds/0015_transfer_templates.rb' - 'spec/api/asset_audit_spec.rb' - 'spec/controllers/api/v2/heron/tube_racks_controller_spec.rb' + - 'spec/controllers/api/v2/qc_assays_controller_spec.rb' + - 'spec/controllers/api/v2/qc_results_controller_spec.rb' - 'spec/controllers/labwhere_receptions_controller_spec.rb' - 'spec/controllers/report_fails_controller_spec.rb' - 'spec/factories/accession/tags.rb' @@ -546,8 +548,6 @@ Naming/VariableNumber: - 'spec/models/transfer_request_spec.rb' - 'spec/models/well_spec.rb' - 'spec/requests/api/v2/pick_lists_spec.rb' - - 'spec/requests/api/v2/qc_assays_spec.rb' - - 'spec/requests/api/v2/qc_results_spec.rb' - 'spec/sequencescape_excel/conditional_formatting_list_spec.rb' - 'spec/uat_actions/generate_plates_spec.rb' - 'spec/uat_actions/generate_tagged_plates_spec.rb' @@ -628,7 +628,7 @@ RSpec/ContextWording: - 'spec/api/extraction_attributes_spec.rb' - 'spec/api/plate_purpose_spec.rb' - 'spec/api/submission_pool_spec.rb' - - 'spec/bulk_submission_excel/data_worksheet_spec.rb' + - 'spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb' - 'spec/bulk_submission_excel/download_spec.rb' - 'spec/controllers/admin/primer_panels_controller_spec.rb' - 'spec/controllers/lab_searches_controller_spec.rb' @@ -643,7 +643,7 @@ RSpec/ContextWording: - 'spec/lib/label_printer/asset_labels_spec.rb' - 'spec/lib/label_printer/asset_redirect_spec.rb' - 'spec/lib/label_printer/batch_plate_spec.rb' - - 'spec/lib/label_printer/sample_manifest_plate_double_spec.rb' + - 'spec/lib/label_printer/label/sample_manifest_plate_double_spec.rb' - 'spec/lib/record_loader/plate_purpose_loader_spec.rb' - 'spec/models/aliquot_spec.rb' - 'spec/models/api/messages/qc_result_io_spec.rb' @@ -705,8 +705,10 @@ RSpec/EmptyExampleGroup: RSpec/ExampleLength: Exclude: - 'spec/api/extraction_attributes_spec.rb' + - 'spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb' - 'spec/bulk_submission_excel/configuration_spec.rb' - - 'spec/bulk_submission_excel/data_worksheet_spec.rb' + - 'spec/controllers/api/v2/qc_assays_controller_spec.rb' + - 'spec/controllers/api/v2/qc_results_controller_spec.rb' - 'spec/controllers/npg_actions/assets_controller_spec.rb' - 'spec/controllers/submissions_controller_spec.rb' - 'spec/lib/accession/accessionable_spec.rb' @@ -770,8 +772,6 @@ RSpec/ExampleLength: - 'spec/requests/api/v2/heron/tube_racks_spec.rb' - 'spec/requests/api/v2/labware_spec.rb' - 'spec/requests/api/v2/plate_purposes_spec.rb' - - 'spec/requests/api/v2/qc_assays_spec.rb' - - 'spec/requests/api/v2/qc_results_spec.rb' - 'spec/requests/api/v2/sample_metadata_spec.rb' - 'spec/requests/api/v2/shared_examples/api_key_authenticatable.rb' - 'spec/requests/api/v2/tag_layout_templates_spec.rb' @@ -814,14 +814,13 @@ RSpec/ExampleLength: - 'spec/views/samples/index_html_erb_spec.rb' - 'spec/views/samples/show_html_erb_spec.rb' -# Offense count: 276 +# Offense count: 275 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. # DisallowedExamples: works RSpec/ExampleWording: Exclude: - 'spec/bulk_submission_excel/configuration_spec.rb' - - 'spec/bulk_submission_excel/data_worksheet_spec.rb' - 'spec/features/gpl207_bug_incorrect_submission_id_on_transfer_spec.rb' - 'spec/models/heron/factories/sample_spec.rb' - 'spec/models/heron/factories/tube_rack_spec.rb' @@ -996,12 +995,14 @@ RSpec/MultipleExpectations: - 'spec/api/tube_purpose_spec.rb' - 'spec/api/well_spec.rb' - 'spec/api/work_completion_spec.rb' + - 'spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb' - 'spec/bulk_submission_excel/configuration_spec.rb' - - 'spec/bulk_submission_excel/data_worksheet_spec.rb' - 'spec/bulk_submission_excel/download_spec.rb' - 'spec/controllers/admin/abilities_controller_spec.rb' - 'spec/controllers/api/v2/heron/plates_controller_spec.rb' - 'spec/controllers/api/v2/heron/tube_racks_controller_spec.rb' + - 'spec/controllers/api/v2/qc_assays_controller_spec.rb' + - 'spec/controllers/api/v2/qc_results_controller_spec.rb' - 'spec/controllers/bulk_submission_excel/downloads_controller_spec.rb' - 'spec/controllers/driver_files_controller_spec.rb' - 'spec/controllers/labwhere_receptions_controller_spec.rb' @@ -1014,7 +1015,6 @@ RSpec/MultipleExpectations: - 'spec/helpers/compound_sample_helper_spec.rb' - 'spec/jobs/export_pool_xp_to_traction_job_spec.rb' - 'spec/lib/accession/accessionable_spec.rb' - - 'spec/lib/accession/configuration_spec.rb' - 'spec/lib/accession/sample_spec.rb' - 'spec/lib/accession/service_spec.rb' - 'spec/lib/accession/submission_spec.rb' @@ -1130,8 +1130,6 @@ RSpec/MultipleExpectations: - 'spec/requests/api/v2/pre_capture_pools_spec.rb' - 'spec/requests/api/v2/primer_panels_spec.rb' - 'spec/requests/api/v2/purposes_spec.rb' - - 'spec/requests/api/v2/qc_assays_spec.rb' - - 'spec/requests/api/v2/qc_results_spec.rb' - 'spec/requests/api/v2/receptacles_spec.rb' - 'spec/requests/api/v2/request_types_spec.rb' - 'spec/requests/api/v2/requests_spec.rb' @@ -1220,7 +1218,7 @@ RSpec/NamedSubject: - 'spec/api/work_completion_spec.rb' - 'spec/controllers/studies/information_controller_spec.rb' - 'spec/controllers/studies_controller_spec.rb' - - 'spec/lib/label_printer/sample_manifest_plate_double_spec.rb' + - 'spec/lib/label_printer/label/sample_manifest_plate_double_spec.rb' - 'spec/models/aliquot_spec.rb' - 'spec/models/api/library_tube_io_spec.rb' - 'spec/models/api/messages/flowcell_io_spec.rb' @@ -1296,32 +1294,17 @@ RSpec/ScatteredLet: - 'spec/models/work_completion_spec.rb' - 'spec/requests/api/v2/work_orders_spec.rb' -# Offense count: 25 +# Offense count: 10 # Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector. # SupportedInflectors: default, active_support RSpec/SpecFilePathFormat: Exclude: - - 'spec/bulk_submission_excel/data_worksheet_spec.rb' - - 'spec/controllers/concerns/api/v2/disable_destroy_action_spec.rb' - - 'spec/controllers/sample_manifest_controller_spec.rb' - - 'spec/lib/accession/configuration_spec.rb' - - 'spec/lib/deployed_spec.rb' - - 'spec/lib/label_printer/batch_plate_amp_spec.rb' - - 'spec/lib/label_printer/batch_tube_spec.rb' - - 'spec/lib/label_printer/sample_manifest_plate_double_spec.rb' - 'spec/models/library_assets_stocks_spec.rb' - 'spec/models/location_report_form_spec.rb' - 'spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb' - 'spec/models/scrna_core_cdna_prep_feasibility_validator_spec.rb' - 'spec/models/std_library_request_spec.rb' - 'spec/models/submission/scrna_core_cdna_prep_feasibility_calcuator_spec.rb' - - 'spec/models/tag_group_form_object_spec.rb' - - 'spec/models/tube_purpose_spec.rb' - - 'spec/requests/api/v2/plate_controller_spec.rb' - - 'spec/requests/api/v2/qc_assays_spec.rb' - - 'spec/requests/api/v2/qc_results_spec.rb' - - 'spec/resources/api/v2/faculty_sponsor_spec.rb' - - 'spec/resources/api/v2/project_resource_spec.rb' - 'spec/sample_manifest_excel/retention_instruction_verification_spec.rb' - 'spec/sample_manifest_excel/upload/upload_spec.rb' - 'spec/sequencescape_excel/configuration_spec.rb' @@ -1346,15 +1329,15 @@ RSpec/VoidExpect: - 'spec/sample_manifest_excel/test_download_spec.rb' - 'spec/sequencescape_excel/column_spec.rb' -# Offense count: 43 +# Offense count: 42 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Inferences. RSpecRails/InferredSpecType: Exclude: + - 'spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb' - 'spec/controllers/batches_controller_spec.rb' - 'spec/controllers/bioscan_control_locations_controller_spec.rb' - 'spec/controllers/bulk_submission_excel/downloads_controller_spec.rb' - - 'spec/controllers/concerns/api/v2/disable_destroy_action_spec.rb' - 'spec/controllers/errors_controller_spec.rb' - 'spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb' - 'spec/controllers/sessions_controller_spec.rb' @@ -1391,7 +1374,6 @@ RSpecRails/InferredSpecType: - 'spec/models/tube_from_plate_creation_spec.rb' - 'spec/models/ultima_sequencing_pipeline_spec.rb' - 'spec/models/ultima_sequencing_request_spec.rb' - - 'spec/requests/api/v2/plate_controller_spec.rb' - 'spec/views/batches/print_amp_plate_labels_spec.rb' - 'spec/views/batches/print_labels_spec.rb' diff --git a/spec/bulk_submission_excel/data_worksheet_spec.rb b/spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb similarity index 99% rename from spec/bulk_submission_excel/data_worksheet_spec.rb rename to spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb index ef30fb7dc..ebde8e8b6 100644 --- a/spec/bulk_submission_excel/data_worksheet_spec.rb +++ b/spec/bulk_submission_excel/bulk_submission_excel/worksheet/data_worksheet_spec.rb @@ -43,7 +43,7 @@ @spreadsheet = Roo::Spreadsheet.open(test_file) end - it 'will have a axlsx worksheet' do + it 'has a axlsx worksheet' do expect(worksheet.axlsx_worksheet).to be_present end diff --git a/spec/controllers/concerns/api/v2/disable_destroy_action_spec.rb b/spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb similarity index 100% rename from spec/controllers/concerns/api/v2/disable_destroy_action_spec.rb rename to spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb diff --git a/spec/requests/api/v2/plate_controller_spec.rb b/spec/controllers/api/v2/plates_controller_spec.rb similarity index 100% rename from spec/requests/api/v2/plate_controller_spec.rb rename to spec/controllers/api/v2/plates_controller_spec.rb diff --git a/spec/requests/api/v2/qc_assays_spec.rb b/spec/controllers/api/v2/qc_assays_controller_spec.rb similarity index 100% rename from spec/requests/api/v2/qc_assays_spec.rb rename to spec/controllers/api/v2/qc_assays_controller_spec.rb diff --git a/spec/requests/api/v2/qc_results_spec.rb b/spec/controllers/api/v2/qc_results_controller_spec.rb similarity index 100% rename from spec/requests/api/v2/qc_results_spec.rb rename to spec/controllers/api/v2/qc_results_controller_spec.rb diff --git a/spec/controllers/sample_manifest_controller_spec.rb b/spec/controllers/sdb/sample_manifests_controller_spec.rb similarity index 100% rename from spec/controllers/sample_manifest_controller_spec.rb rename to spec/controllers/sdb/sample_manifests_controller_spec.rb diff --git a/spec/lib/accession/accessionable_spec.rb b/spec/lib/accession/accessionable_spec.rb index 18061acfb..9afb95a13 100644 --- a/spec/lib/accession/accessionable_spec.rb +++ b/spec/lib/accession/accessionable_spec.rb @@ -3,46 +3,91 @@ require 'rails_helper' RSpec.describe Accession::Accessionable, :accession, type: :model do - class Accessionobubble - include Accession::Accessionable + context 'with a class that includes Accessionable' do + class Accessionobubble + include Accession::Accessionable - def ebi_alias - 'ALIAS' + def ebi_alias + 'ALIAS' + end + + def build_xml(xml) + xml.ACCESSIONOBUBBLE 'Pop!' + end end - def build_xml(xml) - xml.ACCESSIONOBUBBLE 'Pop!' + before { allow(Time).to receive(:now).and_return(Time.zone.parse('2016-12-08T13:29:59Z')) } + + it 'has a date stamped alias' do + expect(Accessionobubble.new.ebi_alias_datestamped).to eq('ALIAS-2016-12-08T13:29:59Z') end - end - before { allow(Time).to receive(:now).and_return(Time.zone.parse('2016-12-08T13:29:59Z')) } + it 'has a file name' do + expect(Accessionobubble.new.filename).to eq('ALIAS-2016-12-08T132959Z.accessionobubble.xml') + end - it 'has a date stamped alias' do - expect(Accessionobubble.new.ebi_alias_datestamped).to eq('ALIAS-2016-12-08T13:29:59Z') - end + it 'has some xml' do + expect(Accessionobubble.new.to_xml).to be_present + end - it 'has a file name' do - expect(Accessionobubble.new.filename).to eq('ALIAS-2016-12-08T132959Z.accessionobubble.xml') - end + it 'has create a file with some text' do + accessionable = Accessionobubble.new + file = accessionable.to_file + file.open + text = file.read + expect(text).to include(accessionable.to_xml) + expect(text.last).to eq("\n") + file.close! + end - it 'has some xml' do - expect(Accessionobubble.new.to_xml).to be_present + it 'creates a file with the correct filename' do + accessionable = Accessionobubble.new + file = accessionable.to_file + expect(file.path).to end_with("_#{accessionable.filename}") + file.close! + end end - it 'has create a file with some text' do - accessionable = Accessionobubble.new - file = accessionable.to_file - file.open - text = file.read - expect(text).to include(accessionable.to_xml) - expect(text.last).to eq("\n") - file.close! - end + context 'when loading configuration' do + let(:configuration) { Accession::Configuration.new } - it 'creates a file with the correct filename' do - accessionable = Accessionobubble.new - file = accessionable.to_file - expect(file.path).to end_with("_#{accessionable.filename}") - file.close! + it 'is comparable' do + expect(Accession::Configuration.new).to eq(configuration) + end + + it 'is able to add a new file' do + configuration.add_file 'a_new_file' + expect(Accession::Configuration::FILES.length + 1).to eq(configuration.files.length) + expect(configuration.files).to include(:a_new_file) + expect(configuration).to respond_to('a_new_file=') + end + + context 'without a folder' do + it 'is not loaded' do + configuration.load! + expect(configuration).not_to be_loaded + end + end + + context 'with a valid folder' do + let(:folder) { File.join('spec', 'data', 'accession') } + + before do + configuration.folder = folder + configuration.load! + end + + it 'is loaded' do + expect(configuration).to be_loaded + end + + it 'loads the tag list' do + expect(configuration.tags).to eq(Accession::TagList.new(configuration.load_file(folder, 'tags'))) + end + + it 'freezes all of the configuration options' do + expect(configuration.tags).to be_frozen + end + end end end diff --git a/spec/lib/accession/configuration_spec.rb b/spec/lib/accession/configuration_spec.rb deleted file mode 100644 index aad3d618d..000000000 --- a/spec/lib/accession/configuration_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe Accession::Accessionable, :accession, type: :model do - let(:configuration) { Accession::Configuration.new } - - it 'is comparable' do - expect(Accession::Configuration.new).to eq(configuration) - end - - it 'is able to add a new file' do - configuration.add_file 'a_new_file' - expect(Accession::Configuration::FILES.length + 1).to eq(configuration.files.length) - expect(configuration.files).to include(:a_new_file) - expect(configuration).to respond_to('a_new_file=') - end - - context 'without a folder' do - it 'is not loaded' do - configuration.load! - expect(configuration).not_to be_loaded - end - end - - context 'with a valid folder' do - let(:folder) { File.join('spec', 'data', 'accession') } - - before do - configuration.folder = folder - configuration.load! - end - - it 'is loaded' do - expect(configuration).to be_loaded - end - - it 'loads the tag list' do - expect(configuration.tags).to eq(Accession::TagList.new(configuration.load_file(folder, 'tags'))) - end - - it 'freezes all of the configuration options' do - expect(configuration.tags).to be_frozen - end - end -end diff --git a/spec/lib/deployed_spec.rb b/spec/lib/deployed_spec.rb index aa7192c76..8adecb937 100644 --- a/spec/lib/deployed_spec.rb +++ b/spec/lib/deployed_spec.rb @@ -2,37 +2,39 @@ require 'rails_helper' -RSpec.describe Deployed::RepoData do - subject(:repo_data) { described_class.new } - - describe '#release_timestamp' do - before do - # freeze time to ensure consistent test results - allow(DateTime).to receive(:now).and_return(DateTime.parse('2025-07-18T12:00:00')) - allow(repo_data).to receive(:read_file).with('RELEASE').and_return(file_contents) # rubocop:disable RSpec/SubjectStub - end +RSpec.describe Deployed do + describe Deployed::RepoData do + subject(:repo_data) { described_class.new } + + describe '#release_timestamp' do + before do + # freeze time to ensure consistent test results + allow(DateTime).to receive(:now).and_return(DateTime.parse('2025-07-18T12:00:00')) + allow(repo_data).to receive(:read_file).with('RELEASE').and_return(file_contents) # rubocop:disable RSpec/SubjectStub + end - context 'when a RELEASE file exists with a timestamp' do - let(:file_contents) { '20231025123000' } + context 'when a RELEASE file exists with a timestamp' do + let(:file_contents) { '20231025123000' } - it 'returns the correct ISO 8601 formatted time' do - expect(repo_data.release_timestamp).to eq('2023-10-25T12:30:00') + it 'returns the correct ISO 8601 formatted time' do + expect(repo_data.release_timestamp).to eq('2023-10-25T12:30:00') + end end - end - context 'when a RELEASE file exists with a non-timestamp string' do - let(:file_contents) { 'release-v1.0.0' } + context 'when a RELEASE file exists with a non-timestamp string' do + let(:file_contents) { 'release-v1.0.0' } - it 'returns the current time in ISO 8601 format' do - expect(repo_data.release_timestamp).to eq('2025-07-18T12:00:00') + it 'returns the current time in ISO 8601 format' do + expect(repo_data.release_timestamp).to eq('2025-07-18T12:00:00') + end end - end - context 'when a RELEASE file does not exist' do - let(:file_contents) { '' } + context 'when a RELEASE file does not exist' do + let(:file_contents) { '' } - it 'returns the current time in ISO 8601 format' do - expect(repo_data.release_timestamp).to eq('2025-07-18T12:00:00') + it 'returns the current time in ISO 8601 format' do + expect(repo_data.release_timestamp).to eq('2025-07-18T12:00:00') + end end end end diff --git a/spec/lib/label_printer/batch_plate_amp_spec.rb b/spec/lib/label_printer/label/batch_plate_amp_spec.rb similarity index 100% rename from spec/lib/label_printer/batch_plate_amp_spec.rb rename to spec/lib/label_printer/label/batch_plate_amp_spec.rb diff --git a/spec/lib/label_printer/batch_tube_spec.rb b/spec/lib/label_printer/label/batch_tube_spec.rb similarity index 100% rename from spec/lib/label_printer/batch_tube_spec.rb rename to spec/lib/label_printer/label/batch_tube_spec.rb diff --git a/spec/lib/label_printer/sample_manifest_plate_double_spec.rb b/spec/lib/label_printer/label/sample_manifest_plate_double_spec.rb similarity index 100% rename from spec/lib/label_printer/sample_manifest_plate_double_spec.rb rename to spec/lib/label_printer/label/sample_manifest_plate_double_spec.rb diff --git a/spec/models/tag_group_form_object_spec.rb b/spec/models/tag_group/form_object_spec.rb similarity index 100% rename from spec/models/tag_group_form_object_spec.rb rename to spec/models/tag_group/form_object_spec.rb diff --git a/spec/models/tube_purpose_spec.rb b/spec/models/tube/purpose_spec.rb similarity index 100% rename from spec/models/tube_purpose_spec.rb rename to spec/models/tube/purpose_spec.rb diff --git a/spec/resources/api/v2/faculty_sponsor_spec.rb b/spec/resources/api/v2/faculty_sponsor_resource_spec.rb similarity index 100% rename from spec/resources/api/v2/faculty_sponsor_spec.rb rename to spec/resources/api/v2/faculty_sponsor_resource_spec.rb diff --git a/spec/resources/api/v2/project_resource_spec.rb b/spec/resources/api/v2/project_resource_spec.rb deleted file mode 100644 index 80f1f93da..000000000 --- a/spec/resources/api/v2/project_resource_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' -require './app/resources/api/v2/sample_resource' - -RSpec.describe Api::V2::SampleResource, type: :resource do - subject(:resource) { described_class.new(sample, {}) } - - let(:sample) { create(:sample) } - - it 'works', :aggregate_failures do # rubocop:todo RSpec/ExampleWording - expect(resource).to have_attribute :sanger_sample_id - expect(resource).to have_attribute :uuid - end -end From 3723ff5b1e218bd1f26cbaade9515c3f077c2a0e Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 13:58:36 +0000 Subject: [PATCH 11/30] style: lint RSpecRails/InferredSpecType --- .rubocop_todo.yml | 48 ------------------- .../concerns/disable_destroy_action_spec.rb | 2 +- spec/controllers/batches_controller_spec.rb | 2 +- ...oscan_control_locations_controller_spec.rb | 2 +- .../downloads_controller_spec.rb | 2 +- spec/controllers/errors_controller_spec.rb | 2 +- ...load_with_tag_sequences_controller_spec.rb | 2 +- spec/controllers/sessions_controller_spec.rb | 2 +- .../submissions_controller_spec.rb | 2 +- spec/controllers/taxa_controller_spec.rb | 2 +- .../move_samples_from_plates_to_tubes_spec.rb | 2 +- .../samples/sample_accession_errors_spec.rb | 2 +- spec/features/samples/sample_edit_spec.rb | 2 +- spec/features/samples/sample_spec.rb | 2 +- .../accession_study_dac_policy_spec.rb | 2 +- spec/features/studies/accession_study_spec.rb | 2 +- spec/helpers/delayed_jobs_helper_spec.rb | 2 +- spec/helpers/samples_helper_spec.rb | 2 +- .../export_pool_xp_to_traction_job_spec.rb | 2 +- spec/jobs/sample_accessioning_job_spec.rb | 2 +- spec/models/accession/sample_status_spec.rb | 2 +- spec/models/accessionable/study_spec.rb | 2 +- spec/models/asset_links_create_edge_spec.rb | 2 +- .../element_aviti_sequencing_pipeline_spec.rb | 2 +- .../element_aviti_sequencing_request_spec.rb | 2 +- .../heron/factories/concerns/contents_spec.rb | 2 +- spec/models/heron/factories/event_spec.rb | 2 +- .../heron/factories/plate_from_rack_spec.rb | 2 +- spec/models/heron/factories/plate_spec.rb | 2 +- spec/models/heron/factories/sample_spec.rb | 2 +- spec/models/heron/factories/tube_rack_spec.rb | 2 +- .../heron/factories/tube_rack_status_spec.rb | 2 +- spec/models/heron/factories/tube_spec.rb | 2 +- spec/models/library_assets_stocks_spec.rb | 2 +- spec/models/map_spec.rb | 2 +- ...va_seq_6000_p_e_sequencing_request_spec.rb | 2 +- spec/models/poly_metadatum_spec.rb | 2 +- .../batch_submenu_presenter_spec.rb | 2 +- spec/models/tube_from_plate_creation_spec.rb | 2 +- .../models/ultima_sequencing_pipeline_spec.rb | 2 +- spec/models/ultima_sequencing_request_spec.rb | 2 +- .../batches/print_amp_plate_labels_spec.rb | 2 +- spec/views/batches/print_labels_spec.rb | 2 +- 43 files changed, 42 insertions(+), 90 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9a68ad530..ffa4d9a4b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1329,54 +1329,6 @@ RSpec/VoidExpect: - 'spec/sample_manifest_excel/test_download_spec.rb' - 'spec/sequencescape_excel/column_spec.rb' -# Offense count: 42 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Inferences. -RSpecRails/InferredSpecType: - Exclude: - - 'spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb' - - 'spec/controllers/batches_controller_spec.rb' - - 'spec/controllers/bioscan_control_locations_controller_spec.rb' - - 'spec/controllers/bulk_submission_excel/downloads_controller_spec.rb' - - 'spec/controllers/errors_controller_spec.rb' - - 'spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb' - - 'spec/controllers/sessions_controller_spec.rb' - - 'spec/controllers/submissions_controller_spec.rb' - - 'spec/controllers/taxa_controller_spec.rb' - - 'spec/features/migrated/move_samples_from_plates_to_tubes_spec.rb' - - 'spec/features/samples/sample_accession_errors_spec.rb' - - 'spec/features/samples/sample_edit_spec.rb' - - 'spec/features/samples/sample_spec.rb' - - 'spec/features/studies/accession_study_dac_policy_spec.rb' - - 'spec/features/studies/accession_study_spec.rb' - - 'spec/helpers/delayed_jobs_helper_spec.rb' - - 'spec/helpers/samples_helper_spec.rb' - - 'spec/jobs/export_pool_xp_to_traction_job_spec.rb' - - 'spec/jobs/sample_accessioning_job_spec.rb' - - 'spec/models/accession/sample_status_spec.rb' - - 'spec/models/accessionable/study_spec.rb' - - 'spec/models/asset_links_create_edge_spec.rb' - - 'spec/models/element_aviti_sequencing_pipeline_spec.rb' - - 'spec/models/element_aviti_sequencing_request_spec.rb' - - 'spec/models/heron/factories/concerns/contents_spec.rb' - - 'spec/models/heron/factories/event_spec.rb' - - 'spec/models/heron/factories/plate_from_rack_spec.rb' - - 'spec/models/heron/factories/plate_spec.rb' - - 'spec/models/heron/factories/sample_spec.rb' - - 'spec/models/heron/factories/tube_rack_spec.rb' - - 'spec/models/heron/factories/tube_rack_status_spec.rb' - - 'spec/models/heron/factories/tube_spec.rb' - - 'spec/models/library_assets_stocks_spec.rb' - - 'spec/models/map_spec.rb' - - 'spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb' - - 'spec/models/poly_metadatum_spec.rb' - - 'spec/models/presenters/batch_submenu_presenter_spec.rb' - - 'spec/models/tube_from_plate_creation_spec.rb' - - 'spec/models/ultima_sequencing_pipeline_spec.rb' - - 'spec/models/ultima_sequencing_request_spec.rb' - - 'spec/views/batches/print_amp_plate_labels_spec.rb' - - 'spec/views/batches/print_labels_spec.rb' - # Offense count: 10 # This cop supports safe autocorrection (--autocorrect). RSpecRails/MinitestAssertions: diff --git a/spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb b/spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb index d4614b3c9..6c2a2f8ef 100644 --- a/spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb +++ b/spec/controllers/api/v2/concerns/disable_destroy_action_spec.rb @@ -7,7 +7,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe Api::V2::Concerns::DisableDestroyAction, type: :controller do +RSpec.describe Api::V2::Concerns::DisableDestroyAction do # We explicitly use the constant `Api::V2::DisableDestroyAction` here instead of `described_class` # because `described_class` is not accessible at the top level of the spec file where the # anonymous controller is being defined. Attempting to use `described_class` in this context diff --git a/spec/controllers/batches_controller_spec.rb b/spec/controllers/batches_controller_spec.rb index 7855875d8..9dae4f9a1 100644 --- a/spec/controllers/batches_controller_spec.rb +++ b/spec/controllers/batches_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe BatchesController, type: :controller do +RSpec.describe BatchesController do describe '#generate_ultima_sample_sheet' do let(:current_user) { create(:user) } let(:pipeline) { create(:ultima_sequencing_pipeline) } diff --git a/spec/controllers/bioscan_control_locations_controller_spec.rb b/spec/controllers/bioscan_control_locations_controller_spec.rb index 7726208fd..42fabd4b2 100644 --- a/spec/controllers/bioscan_control_locations_controller_spec.rb +++ b/spec/controllers/bioscan_control_locations_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe BioscanControlLocationsController, type: :controller do +RSpec.describe BioscanControlLocationsController do describe 'POST #create' do # Plate with samples and controls let!(:plate) do diff --git a/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb b/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb index 71eef6eda..82aab0a41 100644 --- a/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb +++ b/spec/controllers/bulk_submission_excel/downloads_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe BulkSubmissionExcel::DownloadsController, type: :controller do +RSpec.describe BulkSubmissionExcel::DownloadsController do subject(:downloads_controller) { described_class.new } let(:submission) { create(:submission) } diff --git a/spec/controllers/errors_controller_spec.rb b/spec/controllers/errors_controller_spec.rb index 8997a3fae..077ee2770 100644 --- a/spec/controllers/errors_controller_spec.rb +++ b/spec/controllers/errors_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe ErrorsController, type: :controller do +RSpec.describe ErrorsController do errors = %i[not_found internal_server_error service_unavailable] formats = [nil, :html, :json, :png, :unknown] diff --git a/spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb b/spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb index c4815f394..c23ebb82d 100644 --- a/spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb +++ b/spec/controllers/sample_manifest_upload_with_tag_sequences_controller_spec.rb @@ -3,7 +3,7 @@ # For more complete tests, see spec/features/sample_manifests/uploader_for_manifests_with_tag_sequences_spec.rb -RSpec.describe SampleManifestUploadWithTagSequencesController, type: :controller do +RSpec.describe SampleManifestUploadWithTagSequencesController do let(:user) { create(:user) } let(:upload_file) { 'pretend-this-is-an-actual-file' } let(:uploader) { instance_double(SampleManifest::Uploader, study: nil) } diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 8431b9462..0742ca632 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -4,7 +4,7 @@ # Related authentication tests are in test/controllers/authentication_controller_test.rb -RSpec.describe SessionsController, type: :controller do +RSpec.describe SessionsController do describe 'POST #login' do let(:user) { instance_double(User, id: 1) } diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index 304c9a9fa..6ae700ca4 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe SubmissionsController, type: :controller do +RSpec.describe SubmissionsController do render_views let(:request_type) { create(:well_request_type) } diff --git a/spec/controllers/taxa_controller_spec.rb b/spec/controllers/taxa_controller_spec.rb index 700035b10..3de95ffe9 100644 --- a/spec/controllers/taxa_controller_spec.rb +++ b/spec/controllers/taxa_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe TaxaController, type: :controller do +RSpec.describe TaxaController do let(:taxa_client) { instance_double(HTTPClients::ENATaxaClient) } before do diff --git a/spec/features/migrated/move_samples_from_plates_to_tubes_spec.rb b/spec/features/migrated/move_samples_from_plates_to_tubes_spec.rb index 5e4749cf7..846697466 100644 --- a/spec/features/migrated/move_samples_from_plates_to_tubes_spec.rb +++ b/spec/features/migrated/move_samples_from_plates_to_tubes_spec.rb @@ -4,7 +4,7 @@ # This test verifies moving samples from plates to tubes via /plates/to_sample_tubes . -RSpec.feature 'Creating sample tubes from a plate, add to asset group, and print barcodes', type: :feature do +RSpec.feature 'Creating sample tubes from a plate, add to asset group, and print barcodes' do let(:user) { create(:user, login: 'user') } let(:sanger_barcode) { Barcode.build_sanger_code39({ machine_barcode: '1220128459804', format: 'DN' }) } let!(:study) { create(:study, name: 'Study 4696931') } diff --git a/spec/features/samples/sample_accession_errors_spec.rb b/spec/features/samples/sample_accession_errors_spec.rb index b1b954b25..faec7b13e 100644 --- a/spec/features/samples/sample_accession_errors_spec.rb +++ b/spec/features/samples/sample_accession_errors_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Sample accession errors', :js, type: :feature do +RSpec.describe 'Sample accession errors', :js do let(:user) { create(:admin) } let(:study) { create(:managed_study, accession_number: 'ENA123') } diff --git a/spec/features/samples/sample_edit_spec.rb b/spec/features/samples/sample_edit_spec.rb index 0f099a66e..4601462db 100644 --- a/spec/features/samples/sample_edit_spec.rb +++ b/spec/features/samples/sample_edit_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Sample accession errors', :js, type: :feature do +RSpec.describe 'Sample accession errors', :js do let(:user) { create(:admin) } let(:sample) { create(:sample) } diff --git a/spec/features/samples/sample_spec.rb b/spec/features/samples/sample_spec.rb index eefca2e2c..56d551489 100644 --- a/spec/features/samples/sample_spec.rb +++ b/spec/features/samples/sample_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Sample', :js, type: :feature do +RSpec.describe 'Sample', :js do describe 'Sample study association' do let(:user) { create(:admin) } let!(:study) { create(:study, name: 'Study_PT_7125863') } diff --git a/spec/features/studies/accession_study_dac_policy_spec.rb b/spec/features/studies/accession_study_dac_policy_spec.rb index 9bdff4477..db2f23894 100644 --- a/spec/features/studies/accession_study_dac_policy_spec.rb +++ b/spec/features/studies/accession_study_dac_policy_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'EGA DAC and Policy accessioning', :accessioning_enabled, :js, type: :feature do +RSpec.describe 'EGA DAC and Policy accessioning', :accessioning_enabled, :js do include MockAccession let(:user) { create(:admin) } diff --git a/spec/features/studies/accession_study_spec.rb b/spec/features/studies/accession_study_spec.rb index eb36b8b76..dd1d457e7 100644 --- a/spec/features/studies/accession_study_spec.rb +++ b/spec/features/studies/accession_study_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Study accession number', :accessioning_enabled, :js, type: :feature do +RSpec.describe 'Study accession number', :accessioning_enabled, :js do include MockAccession let(:user) { create(:admin, first_name: 'John', last_name: 'Smith') } diff --git a/spec/helpers/delayed_jobs_helper_spec.rb b/spec/helpers/delayed_jobs_helper_spec.rb index 93f8b5cac..e7e09a882 100644 --- a/spec/helpers/delayed_jobs_helper_spec.rb +++ b/spec/helpers/delayed_jobs_helper_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe DelayedJobsHelper, type: :helper do +RSpec.describe DelayedJobsHelper do let(:last_error) { nil } let(:job_name) { 'DefaultJob' } let(:locked_by) { nil } diff --git a/spec/helpers/samples_helper_spec.rb b/spec/helpers/samples_helper_spec.rb index fd74b1565..90e79e1ec 100644 --- a/spec/helpers/samples_helper_spec.rb +++ b/spec/helpers/samples_helper_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe SamplesHelper, type: :helper do +RSpec.describe SamplesHelper do describe '#save_text' do subject { helper.save_text(sample) } diff --git a/spec/jobs/export_pool_xp_to_traction_job_spec.rb b/spec/jobs/export_pool_xp_to_traction_job_spec.rb index 8e9ef6e18..77d4f42dc 100644 --- a/spec/jobs/export_pool_xp_to_traction_job_spec.rb +++ b/spec/jobs/export_pool_xp_to_traction_job_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe ExportPoolXpToTractionJob, type: :job do +RSpec.describe ExportPoolXpToTractionJob do let(:export_job) { described_class.new(tube.human_barcode) } let(:tube) { create(:multiplexed_library_tube, sample_count: 3) } diff --git a/spec/jobs/sample_accessioning_job_spec.rb b/spec/jobs/sample_accessioning_job_spec.rb index 1935b08c5..f00edb5f8 100644 --- a/spec/jobs/sample_accessioning_job_spec.rb +++ b/spec/jobs/sample_accessioning_job_spec.rb @@ -3,7 +3,7 @@ # See additional related tests in spec/models/sample_spec.rb -RSpec.describe SampleAccessioningJob, type: :job do +RSpec.describe SampleAccessioningJob do include AccessionV1ClientHelper let(:sample_metadata) { create(:sample_metadata_for_accessioning) } diff --git a/spec/models/accession/sample_status_spec.rb b/spec/models/accession/sample_status_spec.rb index c55a9b8aa..fa206d798 100644 --- a/spec/models/accession/sample_status_spec.rb +++ b/spec/models/accession/sample_status_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe Accession::SampleStatus, type: :model do +RSpec.describe Accession::SampleStatus do let(:sample) { create(:sample) } describe 'associations' do diff --git a/spec/models/accessionable/study_spec.rb b/spec/models/accessionable/study_spec.rb index 9029e9c43..c70b77d0b 100644 --- a/spec/models/accessionable/study_spec.rb +++ b/spec/models/accessionable/study_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe Accessionable::Study, type: :model do +RSpec.describe Accessionable::Study do let(:user) { create(:user) } let(:study_metadata) { create(:study_metadata, study_ebi_accession_number: nil) } let(:study) { create(:study, study_metadata:) } diff --git a/spec/models/asset_links_create_edge_spec.rb b/spec/models/asset_links_create_edge_spec.rb index 975407db6..f04ebb057 100644 --- a/spec/models/asset_links_create_edge_spec.rb +++ b/spec/models/asset_links_create_edge_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe AssetLink, type: :model do +RSpec.describe AssetLink do # rubocop:disable RSpec/InstanceVariable,Metrics/MethodLength,RSpec/ExampleLength,RSpec/MultipleExpectations # Test the overridden create_edge class method. describe '.create_edge' do diff --git a/spec/models/element_aviti_sequencing_pipeline_spec.rb b/spec/models/element_aviti_sequencing_pipeline_spec.rb index 694b4a7c6..09a997ed5 100644 --- a/spec/models/element_aviti_sequencing_pipeline_spec.rb +++ b/spec/models/element_aviti_sequencing_pipeline_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe ElementAvitiSequencingPipeline, type: :model do +RSpec.describe ElementAvitiSequencingPipeline do describe '#post_release_batch' do let(:pipeline) { create(:element_aviti_sequencing_pipeline) } let(:batch) { create(:batch) } diff --git a/spec/models/element_aviti_sequencing_request_spec.rb b/spec/models/element_aviti_sequencing_request_spec.rb index 1a196a009..38f4343c8 100644 --- a/spec/models/element_aviti_sequencing_request_spec.rb +++ b/spec/models/element_aviti_sequencing_request_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe ElementAvitiSequencingRequest, type: :model do +RSpec.describe ElementAvitiSequencingRequest do let(:request) { create(:element_aviti_sequencing_request) } let(:validator) { ElementAvitiSequencingRequest::ElementAvitiRequestOptionsValidator.new(request) } diff --git a/spec/models/heron/factories/concerns/contents_spec.rb b/spec/models/heron/factories/concerns/contents_spec.rb index 6e512e501..2f02f811a 100644 --- a/spec/models/heron/factories/concerns/contents_spec.rb +++ b/spec/models/heron/factories/concerns/contents_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::Concerns::Contents, :heron, :lighthouse, type: :model do +RSpec.describe Heron::Factories::Concerns::Contents, :heron, :lighthouse do require 'rspec/mocks/standalone' let(:factory_klass) do Class.new do diff --git a/spec/models/heron/factories/event_spec.rb b/spec/models/heron/factories/event_spec.rb index 36b973771..0dd5a773a 100644 --- a/spec/models/heron/factories/event_spec.rb +++ b/spec/models/heron/factories/event_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::Event, :heron, :heron_events, type: :model do +RSpec.describe Heron::Factories::Event, :heron, :heron_events do let(:plate) { create(:plate) } let(:subjects) do [ diff --git a/spec/models/heron/factories/plate_from_rack_spec.rb b/spec/models/heron/factories/plate_from_rack_spec.rb index fc6a0f00b..86ef41990 100644 --- a/spec/models/heron/factories/plate_from_rack_spec.rb +++ b/spec/models/heron/factories/plate_from_rack_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::PlateFromRack, :heron, type: :model do +RSpec.describe Heron::Factories::PlateFromRack, :heron do let(:purpose) { create(:plate_purpose, target_type: 'Plate', name: 'Stock Plate', size: '96') } let(:rack) { create(:tube_rack) } let(:plate_factory) { described_class.new(tube_rack: rack, plate_purpose: purpose) } diff --git a/spec/models/heron/factories/plate_spec.rb b/spec/models/heron/factories/plate_spec.rb index b119a792c..f952d9ea6 100644 --- a/spec/models/heron/factories/plate_spec.rb +++ b/spec/models/heron/factories/plate_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::Plate, :heron, :heron_events, :lighthouse, type: :model do +RSpec.describe Heron::Factories::Plate, :heron, :heron_events, :lighthouse do let(:purpose) { create(:plate_purpose, target_type: 'Plate', name: 'Stock Plate', size: '96') } let(:study) { create(:study) } let(:barcode) { '0000000001' } diff --git a/spec/models/heron/factories/sample_spec.rb b/spec/models/heron/factories/sample_spec.rb index 54f7ff80c..a57357342 100644 --- a/spec/models/heron/factories/sample_spec.rb +++ b/spec/models/heron/factories/sample_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::Sample, :heron, :lighthouse, type: :model do +RSpec.describe Heron::Factories::Sample, :heron, :lighthouse do let(:study) { create(:study) } describe '#valid?' do diff --git a/spec/models/heron/factories/tube_rack_spec.rb b/spec/models/heron/factories/tube_rack_spec.rb index 8ba2fcadd..65188844d 100644 --- a/spec/models/heron/factories/tube_rack_spec.rb +++ b/spec/models/heron/factories/tube_rack_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::TubeRack, :heron, type: :model do +RSpec.describe Heron::Factories::TubeRack, :heron do let(:study) { create(:study) } let(:params) do diff --git a/spec/models/heron/factories/tube_rack_status_spec.rb b/spec/models/heron/factories/tube_rack_status_spec.rb index 8ca3b9b5c..05e54ae46 100644 --- a/spec/models/heron/factories/tube_rack_status_spec.rb +++ b/spec/models/heron/factories/tube_rack_status_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::TubeRackStatus, :heron, type: :model do +RSpec.describe Heron::Factories::TubeRackStatus, :heron do before { create(:study) } let(:params) { { barcode: '0000000001', status: 'validation_failed', messages: ['message 1', 'message 2'] } } diff --git a/spec/models/heron/factories/tube_spec.rb b/spec/models/heron/factories/tube_spec.rb index b8f55f84d..ef23e493b 100644 --- a/spec/models/heron/factories/tube_spec.rb +++ b/spec/models/heron/factories/tube_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe Heron::Factories::Tube, :heron, type: :model do +RSpec.describe Heron::Factories::Tube, :heron do let(:params) { { barcode: 'FD00000001' } } it 'is valid with all relevant attributes' do diff --git a/spec/models/library_assets_stocks_spec.rb b/spec/models/library_assets_stocks_spec.rb index febc26dd8..cbe10ccd2 100644 --- a/spec/models/library_assets_stocks_spec.rb +++ b/spec/models/library_assets_stocks_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe SampleManifest, type: :model do +RSpec.describe SampleManifest do describe 'Library behaviours' do let(:study) { create(:study) } diff --git a/spec/models/map_spec.rb b/spec/models/map_spec.rb index e48c87e78..002eed854 100644 --- a/spec/models/map_spec.rb +++ b/spec/models/map_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe Map, type: :model do +describe Map do context 'with Chromium Chip 16-well' do # The Map class contains a nested module called Coordinate. For clarity, we # use map_class to refer to the Map class and coordinate_module to refer to diff --git a/spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb b/spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb index 10385735a..22561d75c 100644 --- a/spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb +++ b/spec/models/nova_seq_6000_p_e_sequencing_request_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe NovaSeq6000PESequencingRequest, type: :model do +RSpec.describe NovaSeq6000PESequencingRequest do let(:request) { create(:nova_seq_6000_p_e_sequencing_request) } let(:validator) { NovaSeq6000PESequencingRequest::NovaSeq6000PERequestOptionsValidator.new(request) } diff --git a/spec/models/poly_metadatum_spec.rb b/spec/models/poly_metadatum_spec.rb index 0bbaea517..9651ec8e0 100644 --- a/spec/models/poly_metadatum_spec.rb +++ b/spec/models/poly_metadatum_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe PolyMetadatum, type: :model do +RSpec.describe PolyMetadatum do subject(:test_metadatum) { build(:poly_metadatum) } # Tests for validations diff --git a/spec/models/presenters/batch_submenu_presenter_spec.rb b/spec/models/presenters/batch_submenu_presenter_spec.rb index 8a4f04ed0..7388891a0 100644 --- a/spec/models/presenters/batch_submenu_presenter_spec.rb +++ b/spec/models/presenters/batch_submenu_presenter_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe Presenters::BatchSubmenuPresenter, type: :model do +RSpec.describe Presenters::BatchSubmenuPresenter do subject(:batch_submenu_presenter) { described_class.new(current_user, batch) } context 'when we are in the Ultima sequencing pipeline' do diff --git a/spec/models/tube_from_plate_creation_spec.rb b/spec/models/tube_from_plate_creation_spec.rb index c55c825a1..a9e341958 100644 --- a/spec/models/tube_from_plate_creation_spec.rb +++ b/spec/models/tube_from_plate_creation_spec.rb @@ -3,7 +3,7 @@ # spec/models/tube_from_plate_creation_spec.rb require 'rails_helper' -RSpec.describe TubeFromPlateCreation, type: :model do +RSpec.describe TubeFromPlateCreation do let(:child_purpose) { create(:tube_purpose) } let(:child) { create(:tube) } let(:parent) { create(:plate) } diff --git a/spec/models/ultima_sequencing_pipeline_spec.rb b/spec/models/ultima_sequencing_pipeline_spec.rb index cb83f647d..9e55c1018 100644 --- a/spec/models/ultima_sequencing_pipeline_spec.rb +++ b/spec/models/ultima_sequencing_pipeline_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rails_helper' -RSpec.describe UltimaSequencingPipeline, type: :model do +RSpec.describe UltimaSequencingPipeline do let(:pipeline) do described_class.new( workflow: Workflow.new, diff --git a/spec/models/ultima_sequencing_request_spec.rb b/spec/models/ultima_sequencing_request_spec.rb index eee50a02f..d152679b4 100644 --- a/spec/models/ultima_sequencing_request_spec.rb +++ b/spec/models/ultima_sequencing_request_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe UltimaSequencingRequest, type: :model do +RSpec.describe UltimaSequencingRequest do let(:request) { create(:ultima_sequencing_request) } describe 'Validations' do diff --git a/spec/views/batches/print_amp_plate_labels_spec.rb b/spec/views/batches/print_amp_plate_labels_spec.rb index 8cce2e1a7..d1ecc5616 100644 --- a/spec/views/batches/print_amp_plate_labels_spec.rb +++ b/spec/views/batches/print_amp_plate_labels_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'batches/print_amp_plate_labels.html.erb', type: :view do +RSpec.describe 'batches/print_amp_plate_labels.html.erb' do include AuthenticatedSystem let(:current_user) { create(:user) } diff --git a/spec/views/batches/print_labels_spec.rb b/spec/views/batches/print_labels_spec.rb index 696ca3397..b83806507 100644 --- a/spec/views/batches/print_labels_spec.rb +++ b/spec/views/batches/print_labels_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'batches/print_labels.html.erb', type: :view do +RSpec.describe 'batches/print_labels.html.erb' do include AuthenticatedSystem let(:current_user) { create(:user) } From 3370f75e9baa32131ae29b75dd703e5830ef8a94 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 14:03:48 +0000 Subject: [PATCH 12/30] style: disable Rails/I18nLocaleTexts --- .rubocop.yml | 4 +++ .rubocop_todo.yml | 92 ----------------------------------------------- 2 files changed, 4 insertions(+), 92 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f3875fba6..826ee0e12 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -205,6 +205,10 @@ Rails/DynamicFindBy: - find_by_id_or_name! - find_by_barcode +# Not planning to internationalise the app, so this is not relevant +Rails/I18nLocaleTexts: + Enabled: false + # Explicit if statements are clearer than chaining with the safe navigation operator # particularly where there is a behavioural impact Rails/Presence: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ffa4d9a4b..6ca12153c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1536,98 +1536,6 @@ Rails/HttpStatus: - 'app/controllers/projects_controller.rb' - 'app/controllers/studies/documents_controller.rb' -# Offense count: 209 -Rails/I18nLocaleTexts: - Exclude: - - 'app/controllers/admin/bait_libraries/bait_library_suppliers_controller.rb' - - 'app/controllers/admin/bait_libraries/bait_library_types_controller.rb' - - 'app/controllers/admin/bait_libraries_controller.rb' - - 'app/controllers/admin/custom_texts_controller.rb' - - 'app/controllers/admin/faculty_sponsors_controller.rb' - - 'app/controllers/admin/plate_purposes_controller.rb' - - 'app/controllers/admin/primer_panels_controller.rb' - - 'app/controllers/admin/programs_controller.rb' - - 'app/controllers/admin/projects_controller.rb' - - 'app/controllers/admin/robot_properties_controller.rb' - - 'app/controllers/admin/robots_controller.rb' - - 'app/controllers/admin/roles_controller.rb' - - 'app/controllers/admin/studies_controller.rb' - - 'app/controllers/admin/users_controller.rb' - - 'app/controllers/barcode_printers_controller.rb' - - 'app/controllers/batches_controller.rb' - - 'app/controllers/bulk_submissions_controller.rb' - - 'app/controllers/gels_controller.rb' - - 'app/controllers/get_your_qc_completed_tubes_here_controller.rb' - - 'app/controllers/labwhere_receptions_controller.rb' - - 'app/controllers/pipelines_controller.rb' - - 'app/controllers/plate_templates_controller.rb' - - 'app/controllers/plates_controller.rb' - - 'app/controllers/plates_from_tubes_controller.rb' - - 'app/controllers/projects_controller.rb' - - 'app/controllers/qc_reports_controller.rb' - - 'app/controllers/receptacles_controller.rb' - - 'app/controllers/reference_genomes_controller.rb' - - 'app/controllers/report_fails_controller.rb' - - 'app/controllers/requests_controller.rb' - - 'app/controllers/samples_controller.rb' - - 'app/controllers/sdb/suppliers_controller.rb' - - 'app/controllers/sessions_controller.rb' - - 'app/controllers/studies/asset_groups_controller.rb' - - 'app/controllers/studies/documents_controller.rb' - - 'app/controllers/studies_controller.rb' - - 'app/controllers/study_reports_controller.rb' - - 'app/controllers/submissions_controller.rb' - - 'app/controllers/tag_groups_controller.rb' - - 'app/controllers/tag_sets_controller.rb' - - 'app/controllers/tag_substitutions_controller.rb' - - 'app/controllers/users_controller.rb' - - 'app/models/barcode_printer_type.rb' - - 'app/models/batch/request_fail_and_remover.rb' - - 'app/models/budget_division.rb' - - 'app/models/data_release_study_type.rb' - - 'app/models/faculty_sponsor.rb' - - 'app/models/item.rb' - - 'app/models/lib_pool_norm_tube_generator.rb' - - 'app/models/phi_x/spiked_buffer.rb' - - 'app/models/pipeline.rb' - - 'app/models/plate/quad_creator.rb' - - 'app/models/pooling.rb' - - 'app/models/program.rb' - - 'app/models/project_manager.rb' - - 'app/models/qc_report.rb' - - 'app/models/reference_genome.rb' - - 'app/models/sample.rb' - - 'app/models/sample_manifest/uploader.rb' - - 'app/models/state_change.rb' - - 'app/models/stock_stamper.rb' - - 'app/models/study.rb' - - 'app/models/study_sample.rb' - - 'app/models/study_type.rb' - - 'app/models/tag_layout.rb' - - 'app/models/tag_substitution/substitution.rb' - - 'app/models/tasks/cherrypick_handler.rb' - - 'app/models/transfer/transfers_to_known_destination.rb' - - 'app/models/work_order_type.rb' - - 'app/models/workflow.rb' - - 'app/sample_manifest_excel/sample_manifest_excel/upload/data.rb' - - 'app/sequencescape_excel/sequencescape_excel/specialised_field/chromium_tag_well.rb' - - 'app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb' - - 'app/uat_actions/uat_actions/generate_fluidx_barcodes.rb' - - 'app/uat_actions/uat_actions/generate_plate_concentrations.rb' - - 'app/uat_actions/uat_actions/generate_plate_volumes.rb' - - 'app/uat_actions/uat_actions/generate_plates.rb' - - 'app/uat_actions/uat_actions/generate_primer_panel.rb' - - 'app/uat_actions/uat_actions/generate_qc_results.rb' - - 'app/uat_actions/uat_actions/generate_tag_group.rb' - - 'app/uat_actions/uat_actions/generate_tag_layout_template.rb' - - 'app/uat_actions/uat_actions/generate_tag_plates.rb' - - 'app/uat_actions/uat_actions/generate_tagged_plates.rb' - - 'app/uat_actions/uat_actions/plate_information.rb' - - 'app/uat_actions/uat_actions/test_submission.rb' - - 'app/uat_actions/uat_actions/tube_submission.rb' - - 'lib/authenticated_system.rb' - - 'lib/limber/helper.rb' - # Offense count: 41 # Configuration parameters: IgnoreScopes. Rails/InverseOf: From 38baaf55a0521fbb323cb079a8906cecb3bf15c9 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 14:40:36 +0000 Subject: [PATCH 13/30] style: lint Style/FileOpen --- .rubocop_todo.yml | 7 ------- spec/lib/accession/sample_spec.rb | 14 ++++++-------- spec/models/stock_stamper_spec.rb | 9 +++++---- test/unit/import_fluidigm_data_test.rb | 24 ++++++++---------------- 4 files changed, 19 insertions(+), 35 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6ca12153c..9039ee1c5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1732,13 +1732,6 @@ Style/ExplicitBlockArgument: - 'app/models/submission/flexible_request_graph.rb' - 'features/support/step_definitions/web_steps.rb' -# Offense count: 3 -Style/FileOpen: - Exclude: - - 'spec/lib/accession/sample_spec.rb' - - 'spec/models/stock_stamper_spec.rb' - - 'test/unit/import_fluidigm_data_test.rb' - # Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/spec/lib/accession/sample_spec.rb b/spec/lib/accession/sample_spec.rb index 6c96fb590..07bcf9fa1 100644 --- a/spec/lib/accession/sample_spec.rb +++ b/spec/lib/accession/sample_spec.rb @@ -394,15 +394,13 @@ def find_value_at_tag(xml_received, tag_name) end it 'validates against the SAMPLE XSD schema' do - # Schema downloaded from https://ena-docs.readthedocs.io/en/latest/submit/general-guide/webin-v1.html xsd_path = Rails.root.join('test/data/xsd/SRA.sample.xsd') - xsd_file = File.open(xsd_path) - schema = Nokogiri::XML::Schema(xsd_file) - document = Nokogiri::XML(xml) - errors = schema.validate(document) - expect(errors).to be_empty, "XML did not validate against XSD schema: #{errors.map(&:message).join('; ')}" - ensure - xsd_file.close + File.open(xsd_path) do |xsd_file| + schema = Nokogiri::XML::Schema(xsd_file) + document = Nokogiri::XML(xml) + errors = schema.validate(document) + expect(errors).to be_empty, "XML did not validate against XSD schema: #{errors.map(&:message).join('; ')}" + end end end diff --git a/spec/models/stock_stamper_spec.rb b/spec/models/stock_stamper_spec.rb index d9335c3a3..50fa61aa8 100644 --- a/spec/models/stock_stamper_spec.rb +++ b/spec/models/stock_stamper_spec.rb @@ -100,10 +100,11 @@ end it 'generates the right tecan file' do - file = File.open('spec/data/tecan/stock_stamper.gwl', 'rb') - expected_output = file.read - @stock_stamper.generate_tecan_gwl_file_as_text - expect(@stock_stamper.file_content).to eq expected_output + File.open('spec/data/tecan/stock_stamper.gwl', 'rb') do |file| + expected_output = file.read + @stock_stamper.generate_tecan_gwl_file_as_text + expect(@stock_stamper.file_content).to eq expected_output + end end it 'creates asset_audit on plate' do diff --git a/test/unit/import_fluidigm_data_test.rb b/test/unit/import_fluidigm_data_test.rb index 072e6e38f..d10eb08e8 100644 --- a/test/unit/import_fluidigm_data_test.rb +++ b/test/unit/import_fluidigm_data_test.rb @@ -9,23 +9,15 @@ class ImportFluidigmDataTest < ActiveSupport::TestCase NC = 'Unknown' def create_fluidigm_file - @file = File.open("#{Rails.root}/test/data/fluidigm.csv") - @fluidigm = FluidigmFile.new(@file.read) - @well_maps = { - 'S06' => { - markers: [XY, XY, XY], - count: 94 - }, - 'S04' => { - markers: [NC, XX, XX], - count: 92 - }, - 'S43' => { - markers: [XX, XX, XX], - count: 94 + File.open("#{Rails.root}/test/data/fluidigm.csv") do |file| + @fluidigm = FluidigmFile.new(file.read) + @well_maps = { + 'S06' => { markers: [XY, XY, XY], count: 94 }, + 'S04' => { markers: [NC, XX, XX], count: 92 }, + 'S43' => { markers: [XX, XX, XX], count: 94 } } - } - @fluidigm + @fluidigm + end end def create_stock_plate(barcode) From 842101f67de616ce27c92452a95ebb2e1a1e28ca Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 14:40:50 +0000 Subject: [PATCH 14/30] style: lint Style/OneClassPerFile --- script/support/sample_move.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/support/sample_move.rb b/script/support/sample_move.rb index 83a3e856b..4663ac179 100644 --- a/script/support/sample_move.rb +++ b/script/support/sample_move.rb @@ -4,11 +4,11 @@ class StudySample < ApplicationRecord end # added sample class as comments are not commentable at present 21/3/2019 -class Sample +class Sample # rubocop:disable Style/OneClassPerFile include Commentable end -class Asset +class Asset # rubocop:disable Style/OneClassPerFile has_many :submitted_assets has_many :orders, through: :submitted_assets, as: :asset end From dc579beb1673a4dc2b1c4622895b067bc43b6a56 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 14:42:35 +0000 Subject: [PATCH 15/30] style: lint Style/PredicateWithKind --- .rubocop_todo.yml | 6 ------ app/models/presenters/batch_submenu_presenter.rb | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9039ee1c5..ebc27cfb5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2145,12 +2145,6 @@ Style/PerlBackrefs: - 'features/support/step_definitions/tag_layout_steps.rb' - 'lib/validateable.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/PredicateWithKind: - Exclude: - - 'app/models/presenters/batch_submenu_presenter.rb' - # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. diff --git a/app/models/presenters/batch_submenu_presenter.rb b/app/models/presenters/batch_submenu_presenter.rb index 7b0db72ae..ab61700e1 100644 --- a/app/models/presenters/batch_submenu_presenter.rb +++ b/app/models/presenters/batch_submenu_presenter.rb @@ -86,11 +86,11 @@ def aviti_run_manifest? end # rubocop is suggesting changes that returns false positive - # rubocop: disable Performance/RedundantEqualityComparisonBlock + # rubocop: disable Performance/RedundantEqualityComparisonBlock, Style/PredicateWithKind def aviti_requests? @batch.requests.any? { |request| request.is_a?(ElementAvitiSequencingRequest) } end - # rubocop: enable Performance/RedundantEqualityComparisonBlock + # rubocop: enable Performance/RedundantEqualityComparisonBlock, Style/PredicateWithKind def ultima_run_manifest? @batch.released? && ultima_requests? From d0926ae380e35c4a9505696c09deb65ace9e7df5 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 14:47:49 +0000 Subject: [PATCH 16/30] style: lint Style/SelectByKind --- .rubocop_todo.yml | 9 --------- app/controllers/studies/asset_groups_controller.rb | 2 +- app/models/broadcast_event/order_made.rb | 2 +- app/models/lib_pool_norm_tube_generator.rb | 2 +- features/support/step_definitions/transfer_steps.rb | 2 +- 5 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ebc27cfb5..cd6e6d6a1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2231,15 +2231,6 @@ Style/SafeNavigation: - 'lib/event_factory.rb' - 'test/unit/qc_report_file_test.rb' -# Offense count: 4 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/SelectByKind: - Exclude: - - 'app/controllers/studies/asset_groups_controller.rb' - - 'app/models/broadcast_event/order_made.rb' - - 'app/models/lib_pool_norm_tube_generator.rb' - - 'features/support/step_definitions/transfer_steps.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SingleArgumentDig: diff --git a/app/controllers/studies/asset_groups_controller.rb b/app/controllers/studies/asset_groups_controller.rb index 8765aee30..7d640c6c8 100644 --- a/app/controllers/studies/asset_groups_controller.rb +++ b/app/controllers/studies/asset_groups_controller.rb @@ -133,7 +133,7 @@ def print @asset_group = AssetGroup.find(params[:id]) @study = Study.find(params[:study_id]) - @labware = @asset_group.labware.select { |asset| asset.is_a?(Barcode::Barcodeable) } + @labware = @asset_group.labware.grep(Barcode::Barcodeable) end def print_labels # rubocop:todo Metrics/AbcSize, Metrics/MethodLength diff --git a/app/models/broadcast_event/order_made.rb b/app/models/broadcast_event/order_made.rb index cfe70e417..c0f313715 100644 --- a/app/models/broadcast_event/order_made.rb +++ b/app/models/broadcast_event/order_made.rb @@ -53,7 +53,7 @@ class BroadcastEvent::OrderMade < BroadcastEvent def plates return @plates if @plates - wells = seed.assets.select { |a| a.is_a?(Well) } + wells = seed.assets.grep(Well) return [] if wells.empty? @plates = Plate.with_wells(wells) diff --git a/app/models/lib_pool_norm_tube_generator.rb b/app/models/lib_pool_norm_tube_generator.rb index b33383681..948b56790 100644 --- a/app/models/lib_pool_norm_tube_generator.rb +++ b/app/models/lib_pool_norm_tube_generator.rb @@ -33,7 +33,7 @@ def lib_pool_tubes @lib_pool_tubes ||= plate .children - .select { |c| c.is_a?(StockMultiplexedLibraryTube) } + .grep(StockMultiplexedLibraryTube) .reject { |tube| ignore_states.include?(tube.state) } end diff --git a/features/support/step_definitions/transfer_steps.rb b/features/support/step_definitions/transfer_steps.rb index 8f70e4469..9e89e3fbc 100644 --- a/features/support/step_definitions/transfer_steps.rb +++ b/features/support/step_definitions/transfer_steps.rb @@ -98,7 +98,7 @@ def assert_request_state(state, targets, direction, request_class) def change_request_state(state, targets, direction, request_class) association = direction == 'to' ? :requests_as_target : :requests_as_source Request.where( - id: Array(targets).map(&association).flatten.select { |r| r.is_a?(request_class) }.map(&:id) + id: Array(targets).map(&association).flatten.grep(request_class).map(&:id) ).update_all(state:) end From 2d71daa749e996aa52f1a858eeba5e626d76afd2 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 14:49:52 +0000 Subject: [PATCH 17/30] style: update rubocop todo --- .rubocop_todo.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cd6e6d6a1..c90fe287b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2026-03-06 13:51:37 UTC using RuboCop version 1.85.1. +# on 2026-03-06 14:49:27 UTC using RuboCop version 1.85.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -2025,7 +2025,7 @@ Style/NumericPredicate: - 'lib/deployed.rb' - 'lib/submission_serializer.rb' -# Offense count: 34 +# Offense count: 32 # Configuration parameters: AllowedClasses. Style/OneClassPerFile: Exclude: @@ -2038,7 +2038,6 @@ Style/OneClassPerFile: - 'lib/api_tools.rb' - 'lib/authenticated_test_helper.rb' - 'lib/informatics/test/helpers/authentication_helper.rb' - - 'script/support/sample_move.rb' - 'spec/models/broadcast_event/broadcast_event_spec.rb' - 'spec/support/api_v2_resource_matchers.rb' - 'spec/uat_actions/uat_actions_spec.rb' From 2690dd40c1b2e30b56208840ba0fa8cbba0c9d25 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 15:00:50 +0000 Subject: [PATCH 18/30] style: move comments in rubocop config --- .rubocop.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 826ee0e12..844f564ea 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -20,13 +20,14 @@ plugins: - rubocop-rspec_rails - test-prof +# env.rb and cucumber.rake are generated by cucumber-rails AllCops: NewCops: enable Exclude: - db/schema.rb - db/views_schema.rb - - features/support/env.rb # generated by cucumber-rails - - lib/tasks/cucumber.rake # generated by cucumber-rails + - features/support/env.rb + - lib/tasks/cucumber.rake - bin/* - node_modules/**/* - tmp/**/* From 31223597e563d0e7d2bb3473d61004db8f3872bd Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 15:07:57 +0000 Subject: [PATCH 19/30] ci: add ruboclean to ruby lint workflow --- .github/workflows/lint.yml | 3 +++ .rubocop.yml | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2dddd94ac..441d79b42 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -44,6 +44,9 @@ jobs: - name: Run rubocop run: bundle exec rubocop --extra-details --display-style-guide --parallel --format github --format progress + - name: Clean rubocop config + run: bundle exec ruboclean --preserve-comments --verify + prettier: name: Prettier runs-on: ubuntu-latest diff --git a/.rubocop.yml b/.rubocop.yml index 844f564ea..2bef9202c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,5 @@ --- +# To order the config, run: bundle exec ruboclean --preserve-comments inherit_from: - ".rubocop_todo.yml" From 8ce1ecfadcdc9503f698f84f087e744e017c638b Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 15:10:22 +0000 Subject: [PATCH 20/30] style: lint rubocop.yml --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 2bef9202c..0b54779d0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,5 @@ --- + # To order the config, run: bundle exec ruboclean --preserve-comments inherit_from: From c0195be410f69201c4a01b69850832e25a97276c Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 15:19:06 +0000 Subject: [PATCH 21/30] test: repair implied test type --- spec/controllers/api/v2/qc_assays_controller_spec.rb | 2 +- spec/controllers/api/v2/qc_results_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/api/v2/qc_assays_controller_spec.rb b/spec/controllers/api/v2/qc_assays_controller_spec.rb index a52268b50..5c3c3d3b9 100644 --- a/spec/controllers/api/v2/qc_assays_controller_spec.rb +++ b/spec/controllers/api/v2/qc_assays_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require './spec/requests/api/v2/shared_examples/api_key_authenticatable' -RSpec.describe Api::V2::QcAssaysController, :qc_result, with: :api_v2 do +RSpec.describe Api::V2::QcAssaysController, :qc_result, type: :request, with: :api_v2 do let(:asset_1) { attributes_for(:qc_result).merge(uuid: create(:receptacle).uuid) } let(:asset_2) { attributes_for(:qc_result).merge(uuid: create(:receptacle).uuid) } let(:asset_3) { attributes_for(:qc_result).merge(uuid: create(:receptacle).uuid) } diff --git a/spec/controllers/api/v2/qc_results_controller_spec.rb b/spec/controllers/api/v2/qc_results_controller_spec.rb index 793689368..0a6344067 100644 --- a/spec/controllers/api/v2/qc_results_controller_spec.rb +++ b/spec/controllers/api/v2/qc_results_controller_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require './spec/requests/api/v2/shared_examples/api_key_authenticatable' -RSpec.describe Api::V2::QcResultsController, :qc_result, with: :api_v2 do +RSpec.describe Api::V2::QcResultsController, :qc_result, type: :request, with: :api_v2 do let(:asset_invalid) { attributes_for(:qc_result) } let(:base_endpoint) { '/api/v2/qc_results' } From 90a5fac2cfc383bf7f5af9c9a27193703ebac8ff Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 15:21:06 +0000 Subject: [PATCH 22/30] style: tell prettier to ignore .rubocop.yml --- .prettierignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.prettierignore b/.prettierignore index 4a84a2e34..430d204f7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,6 +4,7 @@ .history/* .Rakelist .rubocop_todo.yml +.rubocop.yml .ruby-lsp/vendor .yardoc .yardoc/* From 412f1f673c2331887fd9da305429ff1e35af18b2 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 15:27:35 +0000 Subject: [PATCH 23/30] ci: remove yarn setup from ruby lint --- .github/workflows/lint.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 441d79b42..3495021cd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,9 +27,6 @@ jobs: - name: Setup Ruby uses: sanger/.github/.github/actions/setup/ruby@master - - name: Set up yarn - run: yarn install - - name: Cache Rubocop uses: sanger/.github/.github/actions/setup/cache@master with: From cb1ad4836008718b3fd4a999da28120e351107ad Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 6 Mar 2026 15:42:28 +0000 Subject: [PATCH 24/30] style: try clear rubocop cache to get latest config file to be used --- .rubocop_todo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c90fe287b..d85ada56a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit` -# on 2026-03-06 14:49:27 UTC using RuboCop version 1.85.1. +# on 2026-03-06 15:42:00 UTC using RuboCop version 1.85.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new From aa1d8a239cc628f02cf581680ce31470eac59b6c Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 9 Mar 2026 11:41:58 +0000 Subject: [PATCH 25/30] wip: debug verify error --- .github/workflows/lint.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3495021cd..8ac0630f1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -41,8 +41,14 @@ jobs: - name: Run rubocop run: bundle exec rubocop --extra-details --display-style-guide --parallel --format github --format progress + - name: Print rubocop config file before + run: cat .rubocop.yml + - name: Clean rubocop config - run: bundle exec ruboclean --preserve-comments --verify + run: bundle exec ruboclean --preserve-comments + + - name: Print rubocop config file after + run: cat .rubocop.yml prettier: name: Prettier From a8b258952c7b37035f40e90fe1149662166c397e Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 9 Mar 2026 11:43:18 +0000 Subject: [PATCH 26/30] Revert "wip: debug verify error" This reverts commit aa1d8a239cc628f02cf581680ce31470eac59b6c. --- .github/workflows/lint.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8ac0630f1..3495021cd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -41,14 +41,8 @@ jobs: - name: Run rubocop run: bundle exec rubocop --extra-details --display-style-guide --parallel --format github --format progress - - name: Print rubocop config file before - run: cat .rubocop.yml - - name: Clean rubocop config - run: bundle exec ruboclean --preserve-comments - - - name: Print rubocop config file after - run: cat .rubocop.yml + run: bundle exec ruboclean --preserve-comments --verify prettier: name: Prettier From d93a62efeaae2de605d83851fe64a98973ed454b Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 9 Mar 2026 22:40:14 +0000 Subject: [PATCH 27/30] Update postcss to version 8.5.8 --- package.json | 2 +- yarn.lock | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index eead6a30f..dcc6c990d 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "jsbarcode": "^3.12.3", "jszip": "^3.10.1", "popper.js": "^1.16.1", - "postcss": "^8.5.6", + "postcss": "^8.5.8", "postcss-flexbugs-fixes": "^5.0.2", "postcss-import": "^14.1.0", "postcss-preset-env": "^7.8.3", diff --git a/yarn.lock b/yarn.lock index e10b4ef20..86edb394b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1922,7 +1922,7 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.1.0, postcss-value-parser@^ resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== -postcss@^8.4.33, postcss@^8.4.43, postcss@^8.5.6: +postcss@^8.4.33, postcss@^8.4.43: version "8.5.6" resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.6.tgz#2825006615a619b4f62a9e7426cc120b349a8f3c" integrity sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg== @@ -1931,6 +1931,15 @@ postcss@^8.4.33, postcss@^8.4.43, postcss@^8.5.6: picocolors "^1.1.1" source-map-js "^1.2.1" +postcss@^8.5.8: + version "8.5.8" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.8.tgz#6230ecc8fb02e7a0f6982e53990937857e13f399" + integrity sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg== + dependencies: + nanoid "^3.3.11" + picocolors "^1.1.1" + source-map-js "^1.2.1" + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" From 745016ea6363fc05870f155068dfeeb59d5d5074 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 9 Mar 2026 11:41:58 +0000 Subject: [PATCH 28/30] wip: debug verify error --- .github/workflows/lint.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3495021cd..8ac0630f1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -41,8 +41,14 @@ jobs: - name: Run rubocop run: bundle exec rubocop --extra-details --display-style-guide --parallel --format github --format progress + - name: Print rubocop config file before + run: cat .rubocop.yml + - name: Clean rubocop config - run: bundle exec ruboclean --preserve-comments --verify + run: bundle exec ruboclean --preserve-comments + + - name: Print rubocop config file after + run: cat .rubocop.yml prettier: name: Prettier From fe806e37819653272b71579ee06a9f31396c2ad1 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 13 Mar 2026 09:28:28 +0000 Subject: [PATCH 29/30] wip: don't remove missing directories (includes dev) --- .github/workflows/lint.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8ac0630f1..eb331b28e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -50,6 +50,9 @@ jobs: - name: Print rubocop config file after run: cat .rubocop.yml + - name: Verify rubocop config + run: bundle exec ruboclean --preserve-comments --preserve-paths --verify + prettier: name: Prettier runs-on: ubuntu-latest From 08adc7c3ef792fddc3792934d9929a1bb0cf839e Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Fri, 13 Mar 2026 09:44:54 +0000 Subject: [PATCH 30/30] ci: remove debug steps --- .github/workflows/lint.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index eb331b28e..3c07524d3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -41,15 +41,6 @@ jobs: - name: Run rubocop run: bundle exec rubocop --extra-details --display-style-guide --parallel --format github --format progress - - name: Print rubocop config file before - run: cat .rubocop.yml - - - name: Clean rubocop config - run: bundle exec ruboclean --preserve-comments - - - name: Print rubocop config file after - run: cat .rubocop.yml - - name: Verify rubocop config run: bundle exec ruboclean --preserve-comments --preserve-paths --verify