sanger/sequencescape

View on GitHub
app/models/robot/verification/base.rb

Summary

Maintainability
B
6 hrs
Test Coverage
A
98%

Method filter_barcode_to_plate_index has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def filter_barcode_to_plate_index(destinations)
    destinations.each_with_object({}) do |(destination_barcode, destination_info), all_barcodes|
      mapping_sorted = sort_mapping_by_destination_well(destination_barcode, destination_info['mapping'])
      mapping_sorted.each do |map_well|
        barcode, _well = map_well['src_well']
Severity: Minor
Found in app/models/robot/verification/base.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 valid_submission? has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def valid_submission?(params) # rubocop:todo Metrics/CyclomaticComplexity
    destination_plate_barcode = params[:barcodes][:destination_plate_barcode]
    batch = Batch.find_by(id: params[:batch_id])
    robot = Robot.find_by(id: params[:robot_id])
    user = User.find_by(id: params[:user_id])
Severity: Minor
Found in app/models/robot/verification/base.rb - About 1 hr to fix

    Method valid_submission? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def valid_submission?(params) # rubocop:todo Metrics/CyclomaticComplexity
        destination_plate_barcode = params[:barcodes][:destination_plate_barcode]
        batch = Batch.find_by(id: params[:batch_id])
        robot = Robot.find_by(id: params[:robot_id])
        user = User.find_by(id: params[:user_id])
    Severity: Minor
    Found in app/models/robot/verification/base.rb - About 55 mins 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 valid_plates_on_robot? has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def valid_plates_on_robot?(beds, plates, bed_prefix, robot, _batch, expected_plate_layout)
    Severity: Minor
    Found in app/models/robot/verification/base.rb - About 45 mins to fix

      Method valid_destination_plates_on_robot? has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def valid_destination_plates_on_robot?(beds, plates, robot, batch, all_expected_plate_layout)
      Severity: Minor
      Found in app/models/robot/verification/base.rb - About 35 mins to fix

        Method valid_source_plates_on_robot? has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def valid_source_plates_on_robot?(beds, plates, robot, batch, all_expected_plate_layout)
        Severity: Minor
        Found in app/models/robot/verification/base.rb - About 35 mins to fix

          Method validate_barcode_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def validate_barcode_params(barcode_hash) # rubocop:todo Metrics/CyclomaticComplexity
              return yield('No barcodes specified') if barcode_hash.nil?
          
              if barcode_hash[:batch_barcode].blank? || !Batch.valid_barcode?(barcode_hash[:batch_barcode])
                yield('Worksheet barcode invalid')
          Severity: Minor
          Found in app/models/robot/verification/base.rb - About 35 mins 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 valid_plates_on_robot? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def valid_plates_on_robot?(beds, plates, bed_prefix, robot, _batch, expected_plate_layout)
              # rubocop:enable Metrics/ParameterLists
              return false if expected_plate_layout.blank?
          
              expected_plate_layout.each do |plate_barcode, sort_number|
          Severity: Minor
          Found in app/models/robot/verification/base.rb - About 35 mins 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

          There are no issues that match your filters.

          Category
          Status