SpeciesFileGroup/taxonworks

View on GitHub

Showing 739 of 12,579 total issues

Consider simplifying this complex logical expression.
Open

      if ($&.nil?) or
          (isbn_10.nil? and isbn_13.nil?) or
          ((isbn_10.nil? and type == '10') or (isbn_13.nil? and type == '13'))
        errors.add(:identifier, "'#{identifier}' has the wrong number of digits.")
        return
Severity: Major
Found in app/models/identifier/global/isbn.rb - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

        if !t.end_with?('us') &&
            !t.end_with?('a') &&
            !t.end_with?('um') &&
            !t.end_with?('is') &&
            !t.end_with?('e') &&

      Consider simplifying this complex logical expression.
      Open

          if !t.end_with?('us') &&
              !t.end_with?('a') &&
              !t.end_with?('um') &&
              !t.end_with?('is') &&
              !t.end_with?('e') &&

        Function get_first_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          get_first_name: function (string) {
        
            // if there is no space or , there is no first name
            if ((string.indexOf(",") > 1) || (string.indexOf(" ") > 1)) {
              var delimiter;
        Severity: Minor
        Found in app/assets/javascripts/views/people/_role_picker.js - 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

        Function URLParamsToJSON has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        const URLParamsToJSON = function (query) {
          if (query.indexOf('?') < 0) return {}
          query = query.substring(query.indexOf('?') + 1)
        
          return qs.parse(query, {
        Severity: Minor
        Found in app/javascript/vue/helpers/url/parse.js - 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

        Function buildFeatureCollectionFromShape has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            buildFeatureCollectionFromShape: function (shape, shape_type) {
        
              //  var featureCollection = [];
              var feature = [];
              var coordinates = [];
        Severity: Minor
        Found in app/assets/javascripts/vendor/lib/google/maps/draw.js - 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

        Function showchildren has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        CarrouselTask.prototype.showchildren = function (childIndex) {
          var count = 0
        
          if (typeof childIndex !== 'undefined') {
            if (childIndex > this.active.length - this.maxCards) {
        Severity: Minor
        Found in app/assets/javascripts/views/hub/task-filter.js - 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

        Function singleDrawnFeatureToMapListeners has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            singleDrawnFeatureToMapListeners: function (this_map, map_item, feature_control) {
              google.maps.event.addListener(this_map[1], 'overlaycomplete', function (event) {
                  // Remove the last created shape if it exists.
                  if (map_item != null) {
                    if (map_item[0] != null) {
        Severity: Minor
        Found in app/assets/javascripts/vendor/lib/google/maps/draw.js - 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 update_catalog_number_collection_code_namespace has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def update_catalog_number_collection_code_namespace(collection_code, namespace_id)
            return if collection_code.nil? # No support for mapping blank data at this time
        
            transaction do
              mapping = get_catalog_number_collection_code_namespace_mapping(collection_code)
        Severity: Minor
        Found in app/models/import_dataset/darwin_core/occurrences.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 update_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def update_fields
            upsert_fields = @data_field_changed
              &.filter_map&.with_index { |c, i| field_db_attributes(i, data_fields[i]) if c } || []
            delete_fields = @data_field_changed
              &.filter_map&.with_index { |c, i| i if c && data_fields[i].blank? } || []
        Severity: Minor
        Found in app/models/dataset_record.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 get_identifier_matrix has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_identifier_matrix
            i = increment_matrix
        
            m = []
        
        
        Severity: Minor
        Found in app/models/sled_image.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 container= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def container=(object)
            if object.metamorphosize.kind_of?(Container)
              if self.parent
                self.parent.contained_object = object
              else
        Severity: Minor
        Found in app/models/container_item.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 query_batch_update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def query_batch_update(request)
              return false if request.unprocessable?
        
              r = request.stub_response
              r.method = 'query_batch_update'
        Severity: Minor
        Found in app/models/concerns/shared/query_batch_update.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 geographic_area_autocomplete_tag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def geographic_area_autocomplete_tag(geographic_area, term)
            return nil if geographic_area.nil?
        
            if term
              s = geographic_area.name.gsub(/#{Regexp.escape(term)}/i, "<mark>#{term}</mark>") + ' '
        Severity: Minor
        Found in app/helpers/geographic_areas_helper.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 get_klass has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_klass
            render json: {status: 400} if (params[:type] && params[:global_id]) || (params[:type].blank? && params[:global_id].blank?)
        
            if params[:type]
              @klass = params[:type]
        Severity: Minor
        Found in app/controllers/metadata_controller.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 sv_determined_before_collected has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def sv_determined_before_collected
            ce = collecting_event
            return true if ce.nil? || ce.start_date_year.nil?
            #ce_date = ce.start_date_year.to_s + '/' + sprintf( '%02d', ce.start_date_month.to_i) + "/" + sprintf( '%02d', ce.start_date_day.to_i)
            #ce_date = ce.end_date_year.to_s + '/' + sprintf( '%02d', ce.end_date_month.to_i) + "/" + sprintf( '%02d', ce.end_date_day.to_i) unless ce.end_date_year.nil?
        Severity: Minor
        Found in app/models/collection_object/biological_collection_object.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 sandbox_details_tag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def sandbox_details_tag
            if Settings.sandbox_mode? 
              content_tag(:span, class: 'subtle') do
                [ 'SANDBOX - build',
                  (Settings.sandbox_short_commit_sha ?
        Severity: Minor
        Found in app/helpers/workbench/layout_helper.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 save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def save
              if collection_objects.size == 0
                errors = ActiveModel::Errors.new('base')
                errors.add(:total, 'No totals provided!')
                return false, errors
        Severity: Minor
        Found in lib/material.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 autocomplete has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def autocomplete
                queries = [
                  autocomplete_exact_name,
                  #autocomplete_exact_alternate_value,
                  autocomplete_exact_alternate_value('name', 'AlternateValue::Translation'),
        Severity: Minor
        Found in lib/queries/serial/autocomplete.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 data_attribute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def data_attribute(columns, type = 'import')
              r = BatchLoad::ColumnResolver::Result.new
        
              predicate = columns['predicate']
              value = columns['value']
        Severity: Minor
        Found in lib/batch_load/column_resolver.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

        Severity
        Category
        Status
        Source
        Language