SpeciesFileGroup/taxonworks

View on GitHub

Showing 12,631 of 12,631 total issues

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

export default function (state) {
  return ({ rowObjectId, rowObjectType }) => state.observations.find(o => o.rowObjectId === rowObjectId && o.rowObjectType === rowObjectType).isChecked
}
app/javascript/vue/tasks/observation_matrices/matrix_column_coder/store/getters/getFreeTextValueFor.js on lines 1..3

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

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

export function applyRegex(text, regexPatterns) {
  try {
    for (let i = 0; i < regexPatterns.length; i++) {
      const pattern = regexPatterns[i]
      const regex = new RegExp(pattern.match, 'g')

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

FilterHub.prototype.handleEvents = function (that) {
  const elements = [...document.querySelectorAll('#task_carrousel')]

  that.arrayTasks = elements.map(
    (element) =>
Severity: Minor
Found in app/assets/javascripts/views/hub/filterHub.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 similar_homonym_string has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def similar_homonym_string
    a = subject_taxon_name
    b = object_taxon_name
    if a.is_species_rank? && a.cached_secondary_homonym_alternative_spelling.nil? && a.cached_valid_taxon_name_id == b.cached_valid_taxon_name_id
      return true if a.name == b.name || a.name == b.masculine_name || a.name == b.feminine_name || a.name == b.neuter_name
Severity: Minor
Found in app/models/taxon_name_relationship/iczn/invalidating.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 target_name has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def target_name(target, language_id)
    n = self.name
    a = nil
    case target
    when :key
Severity: Minor
Found in app/models/descriptor.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 increment_matrix has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def increment_matrix
    i = []
    j = identity_matrix
    k = 0
    case step_identifier_on
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 target_name has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def target_name(target, language_id)
    n = self.name
    a = nil
    case target
    when :key
Severity: Minor
Found in app/models/character_state.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_fix_objective_synonym_relationship has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def sv_fix_objective_synonym_relationship
    fixed = false
    s = self.subject_taxon_name
    o = self.object_taxon_name
    if s.get_primary_type.empty?

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

    def build_protonyms
      if name_collection.nil?
        @file_errors.push 'No names were readable in the file.'
        return
      end
Severity: Minor
Found in lib/batch_load/import/taxonifi_to_taxonworks.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_the_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def build_the_list
    results_hash
    return {} if project_id.nil?
    return {} if classification_scope.blank? && otu_filter.blank? && taxon_name_filter.blank?

Severity: Minor
Found in lib/catalog/nomenclature/paper_catalog.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 new_from_citation has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def self.new_from_citation(citation: nil)
      citation&.strip!
      return false if citation.length < 6

    # begin
Severity: Minor
Found in lib/vendor/serrano.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 api_index
    q = ::Queries::TaxonName::Filter.new(params.merge!(api: true)).all
      .where(project_id: sessions_current_project_id)
      .order('taxon_names.id')

Severity: Major
Found in app/controllers/taxon_names_controller.rb and 1 other location - About 1 hr to fix
app/controllers/otus_controller.rb on lines 268..284

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

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

  def api_index
    q = ::Queries::Otu::Filter.new(params.merge!(api: true)).all
      .where(project_id: sessions_current_project_id)
      .order('otus.id')

Severity: Major
Found in app/controllers/otus_controller.rb and 1 other location - About 1 hr to fix
app/controllers/taxon_names_controller.rb on lines 241..257

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

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

  function processImport () {
    if (state.settings.isProcessing) {
      ImportRows(state.dataset.id, {
        filter: state.paramsFilter.filter,
        start_id: state.startRow,
Severity: Minor
Found in app/javascript/vue/tasks/dwca_import/store/actions/processImport.js - About 1 hr to fix

    Function init has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      init: function () {
        var whereIgo = location.pathname.replace('index', '');
    
        var start_next = 0;
        TW.views.tasks.collecting_events.parse.dates.bind_radio_buttons();

      Method create_objects has 39 lines of code (exceeds 25 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

        Method used_recently has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.used_recently(user_id, project_id, used_on = nil)
            return Sequence.none if used_on.nil?
            t = case used_on
                when 'GeneAttribute'
                  GeneAttribute.arel_table
        Severity: Minor
        Found in app/models/sequence.rb - About 1 hr to fix

          Method autocomplete has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def autocomplete
          
                  # [ query, order by use if true- don't if nil ]
                  queries = [
                    [ autocomplete_exact_id, false],
          Severity: Minor
          Found in lib/queries/source/autocomplete.rb - About 1 hr to fix

            Function loadCategoriesIcons has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              loadCategoriesIcons: function () {
                const categories = [
                  {
                    selector: '.data_card div[data-category-collecting_event="true"]',
                    icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 51"><path fill="currentColor" d="M33.2,23.2L21,49.1c-0.7,1.5-2.2,2.4-3.9,2.4s-3.1-0.9-3.8-2.4L1.1,23.2c-0.9-1.8-1.1-4-1.1-6C0,7.8,7.7,0.1,17.1,0.1s17.1,7.7,17.1,17.1C34.3,19.3,34,21.4,33.2,23.2z M17.1,8.7c-4.7,0-8.6,3.9-8.6,8.6s3.9,8.6,8.6,8.6s8.6-3.9,8.6-8.6S21.9,8.7,17.1,8.7z"/></svg>'
            Severity: Minor
            Found in app/assets/javascripts/views/hub/filter.js - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language