SpeciesFileGroup/taxonworks

View on GitHub

Showing 12,631 of 12,631 total issues

Method create_objects has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def create_objects
    return true unless !collection_object_params.nil?
    begin
      metadata.each do |i|
        next unless i['metadata'].blank?
Severity: Minor
Found in app/models/sled_image.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 identifier_is_uri has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def identifier_is_uri
    unless identifier.nil?
      uris = URI.extract(identifier)
      if uris.count == 0
        errors.add(:identifier, 'No URI detected.')
Severity: Minor
Found in app/models/identifier/global/uri.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 sv_parent_priority has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def sv_parent_priority
      if self.rank_class
        rank_group = self.rank_class.parent
        parent = self.parent

Severity: Minor
Found in app/models/protonym/soft_validation_extensions.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 14 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    klass = whitelist_constantize(params.require(:object_type))
    @object = klass.find(params[:object_id])

    if invalid_object(@object)
Severity: Minor
Found in app/controllers/papertrail_controller.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 create has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @controlled_vocabulary_term = ControlledVocabularyTerm.new(controlled_vocabulary_term_params)
    respond_to do |format|
      if @controlled_vocabulary_term.save
        msg = "#{@controlled_vocabulary_term.type} '#{@controlled_vocabulary_term.name}' was successfully created."
Severity: Minor
Found in app/controllers/topics_controller.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 validate_each has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_each(record, attribute, value)
    min_value = @min_value.respond_to?(:call) ? @min_value.call : @min_value
    max_value = @max_value.respond_to?(:call) ? @max_value.call : @max_value

    message ||= @message || options.fetch(:message, "must be an integer between #{min_value} and #{max_value}")
Severity: Minor
Found in app/validators/date_time_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 build_otus has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def build_otus
      # test_build
      build_objects = {}
      i = 1 # accounting for headers
      csv.each do |row|
Severity: Minor
Found in lib/batch_load/import/otus.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 nilify_blanks has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def nilify_blanks
    attributes.each do |column, value|
      next unless value.is_a?(String)
      next unless value.respond_to?(:blank?)

Severity: Minor
Found in config/initializers/application_record/nilify_blanks.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

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

  def self.used_recently(user_id, project_id)
    t = CollectionObject.arel_table
    p = Repository.arel_table

    # i is a select manager
Severity: Major
Found in app/models/repository.rb and 1 other location - About 1 hr to fix
app/models/biological_relationship.rb on lines 48..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 70.

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

  def self.elevation_regex_from_verbatim_label(text)
    text = ' ' + text.downcase.squish + ' '
    elevation = {}

    if (matchdata1 = text.match(/\D(\d*,?\d+)\s?[-–]\s?(\d*,?\d+) ?(m|ft|feet|meters)\.?\W/))
Severity: Minor
Found in lib/utilities/elevation.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

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

  def self.used_recently(user_id, project_id)
    t = BiologicalAssociation.arel_table
    k = BiologicalRelationship.arel_table 

    # i is a select manager
Severity: Major
Found in app/models/biological_relationship.rb and 1 other location - About 1 hr to fix
app/models/repository.rb on lines 55..71

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

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 3 locations. Consider refactoring.
Open

export default (state, id) => {
  const index = state.combinations.findIndex(combination => combination.id === id)

  if (index > -1) {
    state.combinations.splice(index, 1)
app/javascript/vue/tasks/digitize/store/mutations/Container/removeContainerItem.js on lines 1..7
app/javascript/vue/tasks/digitize/store/mutations/removeBiocuration.js on lines 1..7

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

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 3 locations. Consider refactoring.
Open

export default (state, value) => {
  const index = state.biocurations.findIndex(item => item.id === value)

  if (index > -1) {
    state.biocurations.splice(index, 1)
app/javascript/vue/tasks/digitize/store/mutations/Container/removeContainerItem.js on lines 1..7
app/javascript/vue/tasks/nomenclature/new_taxon_name/store/mutations/removeCombination.js on lines 1..7

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

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 3 locations. Consider refactoring.
Open

export default (state, id) => {
  const index = state.containerItems.findIndex(item => item.id === id)

  if (index > -1) {
    state.containerItems.splice(index, 1)
app/javascript/vue/tasks/digitize/store/mutations/removeBiocuration.js on lines 1..7
app/javascript/vue/tasks/nomenclature/new_taxon_name/store/mutations/removeCombination.js on lines 1..7

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

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

  createPinboardItem(pinObject) {
    const template = document.createElement('template')
    template.innerHTML = `
      <li 
        class="slide-panel-category-item"
Severity: Minor
Found in app/assets/javascripts/workbench/pinboard.js - About 1 hr to fix

    Function tableList has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const tableList = computed(() => {
        function getItemsFromObj(obj, property) {
          return property?.id
            ? obj.dataAttributes[property.id].map((item) => item.value)
            : [obj.attributes[property]]

      Method to_json has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def to_json
          result = {
            'otu_ids' => map_source_objects.keys
          }
      
      
      Severity: Minor
      Found in lib/distribution.rb - About 1 hr to fix

        Method citations_with_names has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def citations_with_names
              return @citations_with_names if !@citations_with_names.nil?
        
              d = Hash.new do |hash, key|
                hash[key] = []
        Severity: Minor
        Found in lib/catalog/nomenclature/entry.rb - About 1 hr to fix

          Method date_sql_from_params has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.date_sql_from_params(params)
              st_date, end_date = params['st_datepicker'], params['en_datepicker']
              # processing start date data
              st_year, st_month, st_day = params['start_date_year'], params['start_date_month'], params['start_date_day']
              unless st_date.blank?
          Severity: Minor
          Found in lib/utilities/dates.rb - About 1 hr to fix

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

                removeFromList (id) {
                  const position = this.list.findIndex(element => element.id === id)
            
                  if (position > -1) {
                    this.list.splice(position, 1)
            app/javascript/vue/components/radials/annotator/components/annotatorExtend.js on lines 49..55
            app/javascript/vue/components/radials/navigation/components/radialObjectExtend.js on lines 43..49

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

            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