sanger/sequencescape

View on GitHub

Showing 281 of 5,426 total issues

Method generate_json_to_object_mapping has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def generate_json_to_object_mapping(json_to_attribute) # rubocop:todo Metrics/CyclomaticComplexity
    code = []

    # Split the mappings into two to make things easier.  Read only attributes are easily
    # handled right now, provided there is not a read_write one that shares their name.
Severity: Major
Found in app/api/core/io/base/json_formatting_behaviour/input.rb - About 2 hrs to fix

    File well.rb has 269 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Well < Receptacle # rubocop:todo Metrics/ClassLength
      include Api::WellIO::Extensions
      include ModelExtensions::Well
      include Cherrypick::VolumeByNanoGrams
      include Cherrypick::VolumeByNanoGramsPerMicroLitre
    Severity: Minor
    Found in app/models/well.rb - About 2 hrs to fix

      Method stage has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def stage # rubocop:todo Metrics/CyclomaticComplexity
          @workflow = Workflow.includes(:tasks).find(params[:workflow_id])
          @stage = params[:id].to_i
          @task = @workflow.tasks[@stage]
      
      
      Severity: Minor
      Found in app/controllers/workflows_controller.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Class SampleManifest has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class SampleManifest < ApplicationRecord # rubocop:todo Metrics/ClassLength
        include Uuid::Uuidable
        include ModelExtensions::SampleManifest
        include SampleManifest::BarcodePrinterBehaviour
        include SampleManifest::CoreBehaviour
      Severity: Minor
      Found in app/models/sample_manifest.rb - About 2 hrs to fix

        Class Base has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

              class Base
                MANDATORY_FIELDS = %w[country_of_origin date_of_sample_collection].freeze
        
                include ActiveModel::Model
                include SequencescapeExcel::SubclassChecker

          Method render_cherrypick_task has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def render_cherrypick_task(_task, params) # rubocop:todo Metrics/CyclomaticComplexity
              if flash[:error].present?
                redirect_to action: 'stage', batch_id: @batch.id, workflow_id: @workflow.id, id: (@stage - 1).to_s
                return
              end
          Severity: Minor
          Found in app/models/tasks/cherrypick_handler.rb - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          File submissions.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // Submission workflow jQuery Plugin...
          (function (window, $) {
            "use strict";
          
            var methods = {
          Severity: Minor
          Found in app/frontend/entrypoints/submissions.js - About 2 hrs to fix

            Class Aliquot has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Aliquot < ApplicationRecord # rubocop:todo Metrics/ClassLength
              include Uuid::Uuidable
              include Api::Messages::FlowcellIO::AliquotExtensions
              include Api::Messages::QcResultIO::AliquotExtensions
              include AliquotIndexer::AliquotScopes
            Severity: Minor
            Found in app/models/aliquot.rb - About 2 hrs to fix

              Class Pooling has 21 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Pooling # rubocop:todo Metrics/ClassLength
                include ActiveModel::Model
              
                attr_writer :barcodes, :source_assets
                attr_accessor :stock_mx_tube_required, :stock_mx_tube, :standard_mx_tube, :barcode_printer, :count
              Severity: Minor
              Found in app/models/pooling.rb - About 2 hrs to fix

                Class Pipeline has 21 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Pipeline < ApplicationRecord # rubocop:todo Metrics/ClassLength
                  include Uuid::Uuidable
                  include Pipeline::BatchValidation
                  include SharedBehaviour::Named
                
                
                Severity: Minor
                Found in app/models/pipeline.rb - About 2 hrs to fix

                  Method default_permitted_metadata_fields has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def default_permitted_metadata_fields
                      {
                        sample_metadata_attributes: %i[
                          consent_withdrawn
                          organism
                  Severity: Major
                  Found in app/controllers/samples_controller.rb - About 2 hrs to fix

                    Method included has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.included(base) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
                        base.class_eval do
                          # We probably want to move this validation
                          validates_each(:project, if: :checking_project?) do |record, _attr, project|
                            record.errors.add(:base, "Project #{project.name} is not approved") unless project.approved?
                    Severity: Minor
                    Found in app/models/submission/project_validation.rb - About 2 hrs to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method submit has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def submit(user, *accessionables) # rubocop:todo Metrics/CyclomaticComplexity
                        ActiveRecord::Base.transaction do
                          submission = Accessionable::Submission.new(self, user, *accessionables)
                    
                          errors = submission.all_accessionables.map(&:errors).flatten
                    Severity: Major
                    Found in app/models/accession_service.rb - About 2 hrs to fix

                      File receptacle.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      class Receptacle < Asset # rubocop:todo Metrics/ClassLength
                        include Uuid::Uuidable
                        include Commentable
                        include Transfer::State
                        include Aliquot::Remover
                      Severity: Minor
                      Found in app/models/receptacle.rb - About 2 hrs to fix

                        Method sample_named has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def sample_named(name, study)
                              {
                                'sample_tube_attributes' => {
                                  'two_dimensional_barcode' => ''
                                },
                        Severity: Minor
                        Found in lib/working_setup/standard_seeder.rb - About 2 hrs to fix

                          Method render_cherrypick_task has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def render_cherrypick_task(_task, params) # rubocop:todo Metrics/CyclomaticComplexity
                              if flash[:error].present?
                                redirect_to action: 'stage', batch_id: @batch.id, workflow_id: @workflow.id, id: (@stage - 1).to_s
                                return
                              end
                          Severity: Minor
                          Found in app/models/tasks/cherrypick_handler.rb - About 1 hr to fix

                            Function addOrderHandler has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              var addOrderHandler = function (_event) {
                                // Loads this order's parameters into thewindow.SCAPE.submission object...
                                $("#order-parameters")
                                  .find("select, input")
                                  .each(function () {
                            Severity: Minor
                            Found in app/frontend/entrypoints/submissions.js - About 1 hr to fix

                              Method included has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def self.included(base) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
                                    base.class_eval do
                                      def mx_library
                                        asset.external_identifier
                                      end
                              Severity: Minor
                              Found in app/models/api/messages/flowcell_io.rb - About 1 hr to fix

                                Method handle_has_many has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def handle_has_many(attributes, attribute, json, object) # rubocop:todo Metrics/CyclomaticComplexity
                                      if json.first.is_a?(Hash)
                                        uuids = Uuid.include_resource.lookup_many_uuids(json.filter_map { |j| j['uuid'] })
                                        uuid_to_resource = uuids.each_with_object({}) { |uuid, hash| hash[uuid.external_id] = uuid.resource }
                                        mapped_attributes =
                                Severity: Minor
                                Found in app/api/core/io/base/json_formatting_behaviour/input.rb - About 1 hr to fix

                                Cognitive Complexity

                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                A method's cognitive complexity is based on a few simple rules:

                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                • Code is considered more complex for each "break in the linear flow of the code"
                                • Code is considered more complex when "flow breaking structures are nested"

                                Further reading

                                Method progress_report_on_all_assets has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def progress_report_on_all_assets # rubocop:todo Metrics/AbcSize
                                    yield(progress_report_header)
                                
                                    each_stock_well_id_in_study_in_batches do |asset_ids|
                                      # eager loading of well_attribute , can only be done on  wells ...
                                Severity: Minor
                                Found in app/models/study_report/study_details.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language