SpeciesFileGroup/taxonworks

View on GitHub

Showing 12,628 of 12,628 total issues

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

  return UpdateCatalogueNumber(payload).then(_ => {
    Object.assign(catalogNumber, { namespace_id: namespaceId })
    state.settings.namespaceUpdated = true
  })
app/javascript/vue/tasks/dwca_import/store/actions/updateDefaultCatalogNumber.js on lines 13..16

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

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

    this.createShortcut(
      `${platformKey}+h`,
      'Go to hub',
      'General shortcuts',
      function () {
Severity: Minor
Found in app/assets/javascripts/workbench/keyboard.js and 1 other location - About 55 mins to fix
app/assets/javascripts/workbench/keyboard.js on lines 55..64

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

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

    const recipient = rest.loan_recipient_roles?.map(({ id, ...item }) => ({
      ...item,
      person_id: item.person.id,
      type: ROLE_LOAN_RECIPIENT
    }))
Severity: Minor
Found in app/javascript/vue/tasks/loans/new/store/actions/cloneFrom.js and 1 other location - About 55 mins to fix
app/javascript/vue/tasks/loans/new/store/actions/cloneFrom.js on lines 9..13

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

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

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

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

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

    def query_batch_update(request)
      r = request.stub_response
      r.method = 'query_batch_update'

      return r if request.unprocessable?
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 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 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 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
        [ '<span data-icon="warning"></span> SANDBOX - TEMPORARY <span data-icon="warning"></span> 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 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 boolean_param has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def boolean_param(params, attribute)
    return nil if attribute.nil? || params[attribute].nil?
    case params[attribute].class.name
    when 'TrueClass', 'FalseClass'
      params[attribute]
Severity: Minor
Found in lib/queries/helpers.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

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

  def value_facet
    return nil if data_attribute_exact_value.blank?  && data_attribute_wildcard_value.blank?

    a,b = nil, nil

Severity: Minor
Found in lib/queries/concerns/data_attributes.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

Severity
Category
Status
Source
Language