sanger/sequencescape

View on GitHub

Showing 5,448 of 5,450 total issues

Complex method namespace(limber)::namespace(dev)::namespace(setup)::task#gbs_submission (31.8)
Open

      task gbs_submission: ['limber:dev:setup:gbs'] do
        plates = Purpose.find_by(name: 'GBS Stock').plates.order(id: :desc).limit(4)
        template = SubmissionTemplate.find_by!(name: 'Limber-Htp - GBS')
        plates.each do |plate|
          order =
Severity: Minor
Found in lib/tasks/limber_dev.rake by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method Studies::AssetGroupsController#add (31.8)
Open

  def add # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
    @asset_group = AssetGroup.find(params[:id])
    @study = Study.find(params[:study_id])
    if params[:asset]
      ids = params[:asset].select { |_asset_id, checked| checked == '1' }.keys

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method StudiesController#studies_from_scope (31.6)
Open

  def studies_from_scope(scope) # rubocop:todo Metrics/CyclomaticComplexity
    studies =
      case scope
      when 'interesting'
        Study.of_interest_to(current_user)
Severity: Minor
Found in app/controllers/studies_controller.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method Aliquot::Aliquotable::included (31.5)
Open

  def self.included(base) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
    base.class_eval do
      extend ClassMethods

      has_many :aliquots
Severity: Minor
Found in app/models/aliquot/aliquotable.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method LabwhereReception#save (31.4)
Open

  def save # rubocop:todo Metrics/AbcSize
    return false unless valid?

    begin
      scan =
Severity: Minor
Found in app/models/labwhere_reception.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method Transfer::BetweenPlateAndTubes#tube_name_for (31.4)
Open

  def tube_name_for(stock_wells) # rubocop:todo Metrics/AbcSize
    source_wells =
      source.plate_purpose.source_wells_for(stock_wells).sort { |w1, w2| w1.map.column_order <=> w2.map.column_order }
    stock_plates = source_wells.map(&:plate).uniq
    raise StandardError, 'There appears to be no stock plate!' if stock_plates.empty?

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  with_association(:target_asset, decorator: WarehouseAsset) do
    map_attribute_to_json_attribute(:uuid, 'target_asset_uuid')
    map_attribute_to_json_attribute(:id, 'target_asset_internal_id')
    map_attribute_to_json_attribute(:name, 'target_asset_name')
    map_attribute_to_json_attribute(:barcode_number, 'target_asset_barcode')
Severity: Major
Found in app/models/api/request_io.rb and 1 other location - About 1 hr to fix
app/models/api/request_io.rb on lines 94..114

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  with_association(:asset, decorator: WarehouseAsset) do
    map_attribute_to_json_attribute(:uuid, 'source_asset_uuid')
    map_attribute_to_json_attribute(:id, 'source_asset_internal_id')
    map_attribute_to_json_attribute(:name, 'source_asset_name')
    map_attribute_to_json_attribute(:barcode_number, 'source_asset_barcode')
Severity: Major
Found in app/models/api/request_io.rb and 1 other location - About 1 hr to fix
app/models/api/request_io.rb on lines 117..137

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method submission_structure has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def submission_structure # rubocop:todo Metrics/CyclomaticComplexity
    Hash
      .new { |h, i| h[i] = Array.new }
      .tap do |submission|
        csv_data_rows.each_with_index do |row, index|
Severity: Minor
Found in app/models/bulk_submission.rb - About 1 hr to fix

    Method progress_report_header has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def progress_report_header
        [
          'Status',
          'Study',
          'Supplier',
    Severity: Minor
    Found in app/models/study_report/study_details.rb - About 1 hr to fix

      Method stage has 32 lines of code (exceeds 25 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 1 hr to fix

        Complex method Core::Endpoint::BasicHandler::Json#core_path (31.3)
        Open

            def core_path(*args) # rubocop:todo Metrics/AbcSize
              options = args.extract_options!
              response = options[:response]
        
              root =
        Severity: Minor
        Found in app/api/core/endpoint/basic_handler.rb by flog

        Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

        You can read more about ABC metrics or the flog tool

        Complex method Request::Statemachine#destroy_aasm (31.3)
        Open

            def destroy_aasm # rubocop:todo Metrics/MethodLength
              # Destroy all evidence of the statemachine we've inherited!  Ugly, but it works!
              old_machine = AASM::StateMachineStore.fetch(self) && AASM::StateMachineStore.fetch(self).machine(:default)
              if old_machine
                old_machine.events.keys.each do |event|
        Severity: Minor
        Found in app/models/request/statemachine.rb by flog

        Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

        You can read more about ABC metrics or the flog tool

        Complex method Search::FindPlatesForUser#scope (31.2)
        Open

          def scope(user_criteria) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
            # We find all plates that do not have transfers where they are the source.  Once a plate has been transferred
            # (or marked for transfer) the destination plate becomes the end of the chain.
            criteria = default_parameters.stringify_keys.merge(user_criteria)
        
        

        Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

        You can read more about ABC metrics or the flog tool

        Complex method ModelExtensions::Request::included (31.1)
        Open

          def self.included(base) # rubocop:todo Metrics/AbcSize
            base.class_eval do
              scope :include_source_asset,
                    -> { includes(asset: [:uuid_object, :barcodes, :scanned_into_lab_event, { aliquots: %i[sample tag] }]) }
              scope :include_target_asset,
        Severity: Minor
        Found in app/api/model_extensions/request.rb by flog

        Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

        You can read more about ABC metrics or the flog tool

        Method well_to_destination has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def well_to_destination # rubocop:todo Metrics/AbcSize
            {}.tap do |sources_to_target|
              # Group the wells based on the submission
              groups = source.wells.in_column_major_order.with_pool_id.group_by(&:pool_id).delete_if { |k, _| k.nil? }.values
        
        
        Severity: Minor
        Found in app/models/transfer/between_plates_by_submission.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 swap has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def swap(current_user, batch_info = {}) # rubocop:todo Metrics/CyclomaticComplexity
            return false if batch_info.empty?
        
            # Find the two lanes that are to be swapped
            batch_request_left =
        Severity: Minor
        Found in app/models/batch.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 sorted_requests_for_destination_plate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def sorted_requests_for_destination_plate(requests_to_sort) # rubocop:todo Metrics/CyclomaticComplexity
            requests_to_sort.sort_by do |req|
              if req.target_asset&.map&.column_order
                [req.target_asset.plate.id, req.asset.plate&.pick_as_control? ? 0 : 1, req.target_asset.map.column_order]
              else
        Severity: Minor
        Found in app/models/robot/pick_data.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 perform_pick has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def perform_pick(requests, robot, control_source_plate, workflow_controller) # rubocop:todo Metrics/AbcSize
            max_plates = robot.max_beds
            raise StandardError, 'The chosen robot has no beds!' if max_plates.zero?
        
            destination_plates = []
        Severity: Minor
        Found in app/models/cherrypick_task.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 output_aliquot has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def output_aliquot(xml, aliquot) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
            xml.sample(
              sample_id: aliquot.sample_id,
              library_id: aliquot.library_id,
              library_name: aliquot.library_name,
        Severity: Minor
        Found in app/helpers/batches_helper.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

        Severity
        Category
        Status
        Source
        Language