SpeciesFileGroup/taxonworks

View on GitHub

Showing 12,631 of 12,631 total issues

Function useDraggable has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export function useDraggable({ target, handler }) {
  const position = reactive({
    init: false,
    x: 0,
    y: 0,
Severity: Minor
Found in app/javascript/vue/composables/useDraggable.js - About 2 hrs 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_type_source has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def sv_type_source
    soft_validations.add(:base, 'Source is not selected neither for type nor for taxon') unless type_source
    if %w(paralectotype neotype lectotype paralectotypes).include?(type_type)
      if source.nil?
        soft_validations.add(:base, "Source for #{type_type} designation is not selected ") if source.nil?
Severity: Minor
Found in app/models/type_material.rb - About 2 hrs 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 insert_couplet has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def insert_couplet
    c,d = nil, nil

    p = node_position

Severity: Minor
Found in app/models/lead.rb - About 2 hrs 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_selected has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def save_selected
    next_id = next_collecting_event_id
    selected = params[:selected]
    if selected.blank?
      message = 'Nothing to save.'

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

  def save_selected
    selected = params[:selected]
    next_id  = next_collecting_event_id
    if selected.blank?
      message = 'Nothing to save.'

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

  def self.parse_iso_date_str(date_str)

    full_pattern = %r{^
          (?<year>[0-9]{4})(-(?<month>[0-9]{1,2}))?(-(?<day>[0-9]{1,2}))?  # Date in these formats: YYYY | YYYY-M(M)? | YYYY-M(M)?-D(D)?
          (
Severity: Minor
Found in lib/utilities/dates.rb - About 2 hrs 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

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

  def target_name(target, language_id)
    n = self.name
    a = nil
    case target
    when :key
Severity: Major
Found in app/models/character_state.rb and 1 other location - About 2 hrs to fix
app/models/descriptor.rb on lines 59..83

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

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

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

  def target_name(target, language_id)
    n = self.name
    a = nil
    case target
    when :key
Severity: Major
Found in app/models/descriptor.rb and 1 other location - About 2 hrs to fix
app/models/character_state.rb on lines 49..73

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

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

  def get_diffs version_new, version_old
    added_strings = []
    added_strings_indices = []
    deleted_strings = []
    deleted_strings_indices = []
Severity: Major
Found in app/helpers/plugins/papertrail_helper.rb - About 2 hrs to fix

    File container.js has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { defineStore } from 'pinia'
    import { Container, ContainerItem } from '@/routes/endpoints'
    import {
      makeContainer,
      makeContainerPayload,
    Severity: Minor
    Found in app/javascript/vue/tasks/containers/new_container/store/container.js - About 2 hrs to fix

      File biodiversity.rb has 253 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Vendor
      
        # Wraps the biodiversity gem (https://github.com/GlobalNamesArchitecture/biodiversity)
        # Links parsed string results to Protonyms/Combinations in TaxonWorks.
        #   a = Vendor::Biodiversity::Result.new 
      Severity: Minor
      Found in lib/vendor/biodiversity.rb - About 2 hrs to fix

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

        function putJSON(url, payload) {
          return new Promise((resolve, reject) => {
            ajaxCall('patch', url, payload).then(
              (response) => {
                resolve(response.body)
        app/javascript/vue/tasks/observation_matrices/matrix_row_coder/request/MatrixRowCoderRequest.js on lines 17..28

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

        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

        function postJSON(url, payload) {
          return new Promise((resolve, reject) => {
            ajaxCall('post', url, payload).then(
              (response) => {
                resolve(response.body)
        app/javascript/vue/tasks/observation_matrices/matrix_row_coder/request/MatrixRowCoderRequest.js on lines 30..41

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

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

            def build
              v = object.valid_taxon_name
              base_names = v.historical_taxon_names
        
              base_names.each do |t|
        Severity: Major
        Found in lib/catalog/nomenclature/entry.rb - About 2 hrs to fix

          Method has too many lines. [28/25]
          Open

            def self.roots_with_data(project_id, load_root_otus = false)
              # The updated_at subquery computes key_updated_at (and others), the second
              # query uses that to compute key_updated_by (by finding which node has the
              # corresponding key_updated_at).
              # TODO: couplet_count will be wrong if any couplets don't have exactly two
          Severity: Minor
          Found in app/models/lead.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [28/25]
          Open

            def destroy_couplet
              k = children.order(:position).reload.to_a
              return true if k.empty?
          
              # TODO: handle multiple facets
          Severity: Minor
          Found in app/models/lead.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [28/25]
          Open

              def sv_missing_part_of_speech
                if is_species_rank? && self.part_of_speech_class.nil? && !has_misspelling_relationship? && is_available?
          
                  z = TaxonNameClassification.
                      joins(:taxon_name).

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [28/25]
          Open

            def nexml_depictions(options = {})
              opt = {target: '', descriptors: []}.merge!(options)
              xml = Builder::XmlMarkup.new(target: opt[:target])
              m = opt[:observation_matrix]
              xml.depictions do

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [28/25]
          Open

            def paper_distribution_row(entry_item)
              o = case entry_item.object.class.name
              when 'TypeMaterial'
                entry_item.object.collection_object
              else

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [28/25]
          Open

              def soft_validators(only_sets: [], except_sets: [], only_methods: [], except_methods: [], include_flagged: false, fixable: nil, include_superclass: true)
                only_methods = Utilities::Params.arrayify(only_methods)
                return only_methods if !only_methods.empty?
          
                except_methods = Utilities::Params.arrayify(except_methods)
          Severity: Minor
          Found in lib/soft_validation.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Severity
          Category
          Status
          Source
          Language