sanger/sequencescape

View on GitHub

Showing 5,448 of 5,450 total issues

Complex method FluidigmTemplateTask#plate_purpose_options (33.1)
Open

  def plate_purpose_options(batch) # rubocop:todo Metrics/AbcSize
    next_requests = batch.requests.flat_map(&:next_requests)
    plate_purposes = next_requests.filter_map(&:request_type).uniq.map(&:acceptable_purposes).flatten.uniq

    # If downstream requests don't specify an acceptable_purpose, fallback to any target purposes
Severity: Minor
Found in app/models/fluidigm_template_task.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 Batch#reset! (33.0)
Open

  def reset!(current_user) # rubocop:todo Metrics/AbcSize
    ActiveRecord::Base.transaction do
      discard!

      requests.each do |request|
Severity: Minor
Found in app/models/batch.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

Function plateBarcodeScan has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  plateBarcodeScan: async ({ commit, dispatch, state }, plate_barcode) => {
    // Firstly we record that the plate has been scanned.
    commit("scanPlate", { barcode: plate_barcode });
    const scanned_plate_id = state.scanStore[`_${plate_barcode}`].id;

Severity: Minor
Found in app/frontend/plate-picks/store/actions.js - 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 validate_each has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_each(record, attribute, value)
    return unless check_hash(record, attribute, value)

    value.each do |program, params|
      record.errors.add attribute, "invalid label #{program}" unless program.in?(PROGRAMS_LABELS)
Severity: Minor
Found in app/models/concerns/programs_validator.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 construct! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def self.construct!(hash) # rubocop:todo Metrics/CyclomaticComplexity
    st = {}

    STRAIGHT_CLONE.each { |key| st[key.to_sym] = hash[key.to_sym] }

Severity: Minor
Found in lib/submission_serializer.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 update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def update(_attributes = {}) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/MethodLength
        return unless valid? && foreign_barcode_format.present?

        # if this tube's list of barcodes already contains a foreign barcode with the same format then update the
        # existing one

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 update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def update(_attributes = {}) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/MethodLength
        return unless valid? && foreign_barcode_format.present?

        # checking if the plate this well belongs to already has this foreign barcode set in its list of barcodes.
        # or if it contains a foreign barcode with the same format, then update that existing one

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 ApplicationHelper#render_parsed_json (33.0)
Open

  def render_parsed_json(json) # rubocop:todo Metrics/AbcSize
    case json
    when String
      json
    when Array
Severity: Minor
Found in app/helpers/application_helper.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 Submission::AccessionBehaviour#check_data_release_and_accession_for_submission (32.9)
Open

  def check_data_release_and_accession_for_submission # rubocop:todo Metrics/AbcSize
    return if configatron.disable_accession_check == true

    if not study.valid_data_release_properties?
      errors.add(:study, "#{study.name}: Please fill in the study data release information")

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 GetYourQcCompletedTubesHereController#create (32.6)
Open

  def create # rubocop:todo Metrics/AbcSize
    @generator =
      LibPoolNormTubeGenerator.new(params[:barcode], current_user, Study.find_by(name: 'Lib PCR-XP QC Completed Tubes'))
    if @generator.valid?
      if @generator.create!

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#setup_studies_from_scope (32.5)
Open

  def setup_studies_from_scope(exclude_nested_resource = false) # rubocop:todo Metrics/AbcSize
    if logged_in? && (not exclude_nested_resource)
      @alternatives = [
        'interesting',
        'followed',
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 ApplicationHelper#dynamic_link_to (32.5)
Open

  def dynamic_link_to(summary_item) # rubocop:todo Metrics/AbcSize
    object = summary_item.object
    if object.instance_of?(Submission)
      link_to("Submission #{object.id}", study_information_submission_path(object.study, object))
    elsif object.instance_of?(Receptacle)
Severity: Minor
Found in app/helpers/application_helper.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::BetweenPlates#each_transfer (32.4)
Open

  def each_transfer # rubocop:todo Metrics/AbcSize
    source_wells = valid_source_wells.index_by(&:map_description)
    destination_locations = transfers.values_at(*source_wells.keys).flatten
    destination_wells = destination.wells.located_at_position(destination_locations).index_by(&:map_description)

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 User::Authentication#update_profile_via_ldap (32.4)
Open

  def update_profile_via_ldap # rubocop:todo Metrics/AbcSize
    ldap = Net::LDAP.new(host: configatron.ldap_server, port: configatron.ldap_port)

    filter = Net::LDAP::Filter.eq('uid', login)
    treebase = 'ou=people,dc=sanger,dc=ac,dc=uk'
Severity: Minor
Found in app/models/user/authentication.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 PhiX::SpikedBuffer#generate_spiked_buffers (32.4)
Open

  def generate_spiked_buffers # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
    Array.new(number.to_i) do |index|
      spiked_buffer =
        PhiX
          .spiked_buffer_purpose
Severity: Minor
Found in app/models/phi_x/spiked_buffer.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 apply_fluidigm_data has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_fluidigm_data(fluidigm_file) # rubocop:todo Metrics/AbcSize
    qc_assay = QcAssay.new
    raise FluidigmError, 'File does not match plate' unless fluidigm_file.for_plate?(fluidigm_barcode)

    wells
Severity: Minor
Found in app/models/plate/fluidigm_behaviour.rb - About 1 hr to fix

    Complex method Transfer::Associations::included (32.1)
    Open

      def self.included(base) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
        base.class_eval do
          include Transfer::State
    
          has_many :transfers_as_source, # rubocop:todo Rails/HasManyOrHasOneDependent
    Severity: Minor
    Found in app/models/transfer/associations.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 SampleManifestExcel::Tags::ExampleData#take_as_groups_and_indexes (31.9)
    Open

          def take_as_groups_and_indexes(first, last, duplicate = false) # rubocop:todo Metrics/AbcSize
            tag_groups = FactoryBot.create_list(:tag_group, 2, tag_count: (last - first) + 1)
    
            {}.tap do |hsh|
              (first..last).each_with_index do |n, i|

    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 configure has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def configure(model) # rubocop:todo Metrics/CyclomaticComplexity
          conditions = @options.slice(:if, :on)
          save_blank_value = @options.delete(:save_blank)
          allow_blank = save_blank_value
          model.with_options(conditions) do |object|
    Severity: Minor
    Found in app/models/attributable/attribute.rb - About 1 hr to fix

      Method show_summary has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def show_summary # rubocop:todo Metrics/CyclomaticComplexity
          page_params = { page: params[:page] || 1, per_page: params[:per_page] || 50 }
      
          if request.xhr?
            @summary = params[:summary] || 'assets-progress'
      Severity: Minor
      Found in app/controllers/studies/information_controller.rb - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language