sanger/sequencescape

View on GitHub

Showing 5,431 of 5,433 total issues

Complex method Submission::PresenterSkeleton#lanes_from_request_options (39.5)
Open

  def lanes_from_request_options # rubocop:todo Metrics/AbcSize
    return order.request_options.fetch(:multiplier, {}).values.last || 1 if order.request_types[-2].nil?

    sequencing_request = RequestType.find(order.request_types.last)
    multiplier_hash = order.request_options.fetch(:multiplier, {})

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 IlluminaHtp::InitialStockTubePurpose#sibling_tubes (39.4)
Open

  def sibling_tubes(tube) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
    return [] if tube.submission.nil?

    # Find all requests that are being pooled together
    sibling_requests = tube.submission.requests.multiplexed.opened.ids

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 MbraveTagsCreator#create_24_tag_groups_reverse (39.2)
Open

  def create_24_tag_groups_reverse
    tags = []
    mbrave_tags = []
    group = 1
    log_line { "Creating reverse tags from: #{reverse_filename}" }
Severity: Minor
Found in lib/mbrave_tags_creator.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 SequencescapeExcel::List::ClassMethods#list_for (39.1)
Open

      def list_for(*args) # rubocop:todo Metrics/AbcSize
        options = args.extract_options!

        model = args.first.to_s.classify

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

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 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

        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

        Complex method StockStamper#generate_tecan_data (39.0)
        Open

          def generate_tecan_data # rubocop:todo Metrics/AbcSize
            source_barcode = "#{plate.machine_barcode}_s"
            destination_barcode = "#{plate.machine_barcode}_d"
            data_object = {
              'user' => user.login,
        Severity: Minor
        Found in app/models/stock_stamper.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 BulkTransfer#each_transfer (38.9)
        Open

          def each_transfer # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
            well_transfers
              .group_by { |tf| [tf['source_uuid'], tf['destination_uuid']] }
              .each do |source_dest, all_transfers|
                transfers = Hash.new { |h, i| h[i] = [] }
        Severity: Minor
        Found in app/models/bulk_transfer.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 SamplesController#accession (38.8)
        Open

          def accession # rubocop:todo Metrics/AbcSize
            @sample = Sample.find(params[:id])
            @sample.validate_ena_required_fields!
            @sample.accession_service.submit_sample_for_user(@sample, current_user)
        
        
        Severity: Minor
        Found in app/controllers/samples_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 Core::Io::Base::JsonFormattingBehaviour::Output#generate_object_to_json_mapping (38.7)
        Open

          def generate_object_to_json_mapping(attribute_to_json) # rubocop:todo Metrics/AbcSize
            # Sort the attribute_to_json map such that the JSON elements are in order, thus ensuring that
            # we will only open and close blocks as we go.  Then build a tree that can be executed against
            # an object to generate the JSON appropriately.
            tree =

        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 Core::Service::ErrorHandling::registered (38.6)
        Open

          def self.registered(app) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
            app.instance_eval do
              helpers Helpers
        
              error(
        Severity: Minor
        Found in app/api/core/service/error_handling.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 StudyReportsController#create (38.6)
        Open

          def create # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
            study = Study.find_by(id: params[:study_report][:study])
            study_report = StudyReport.create!(study: study, user: @current_user)
        
            study_report.schedule_report

        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::Order#request_options_structured (38.2)
        Open

          def request_options_structured # rubocop:todo Metrics/AbcSize
            NonNilHash
              .new(:stringify_keys)
              .tap do |json|
                NonNilHash
        Severity: Minor
        Found in app/api/model_extensions/order.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 Robot::Generator::Behaviours::HamiltonDefault#source_mappings (38.1)
        Open

          def source_mappings(data_object) # rubocop:todo Metrics/AbcSize
            source_mappings = ''
            each_mapping(data_object) do |mapping, destination_plate_barcode, plate_details|
              source_plate_barcode = (mapping['src_well'][0]).to_s
              source_well_position = mapping['src_well'][1]

        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::BetweenPlates#calculate_location_submissions (38.0)
        Open

          def calculate_location_submissions # rubocop:todo Metrics/AbcSize
            # We're probably just stamping
            return {} if simple_stamp? || pre_cap_groups.empty?
        
            destination_sources.each_with_object({}) do |dest_source, store|
        Severity: Minor
        Found in app/models/transfer/between_plates.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 LabwareController#update (37.9)
        Open

          def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
            respond_to do |format|
              params_hash = params.to_unsafe_h
              if @asset.update(labware_params.merge(params_hash.fetch(:lane, {})))
                flash[:notice] = find_flash(params_hash)
        Severity: Minor
        Found in app/controllers/labware_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 RobotVerificationsController#download (37.8)
        Open

          def download # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
            @robot = Robot.find(params[:robot_id])
            @robot_verification = @robot.verification_behaviour
        
            if @robot_verification.valid_submission?(params)

        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

              if params[:role]
                authorizable_object =
                  if params[:role][:authorizable_type] == 'Project'
                    Project.find(params[:role][:authorizable_id])
                  else
        Severity: Major
        Found in app/controllers/admin/users_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/admin/users_controller.rb on lines 74..90

        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 72.

        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

        Severity
        Category
        Status
        Source
        Language