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 const ATTRIBUTES = {
  id: 'ID',
  name: 'Name',
  short_name: 'Short name',
  description: 'Description',
app/javascript/vue/tasks/images/new_image/const/layout.js on lines 12..23

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

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

export default (state, args) => {
  const {
    descriptorId,
    isUnsaved
  } = args
app/javascript/vue/tasks/observation_matrices/matrix_row_coder/store/mutations/setDescriptorSaving.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 61.

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

export const PANEL_NAME = {
  PanelAuthor: 'PanelAuthor',
  PanelEditor: 'PanelEditor',
  PanelOwner: 'PanelOwner',
  PanelLicenses: 'PanelLicenses',
Severity: Major
Found in app/javascript/vue/tasks/images/new_image/const/layout.js and 1 other location - About 1 hr to fix
app/javascript/vue/tasks/descriptors/filter/constants/attributes.js on lines 1..12

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

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

  def update
    respond_to do |format|
      if @tagged_section_keyword.update(tagged_section_keyword_params)
        format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Tagged section keyword was successfully updated.')}
        format.json {render json: @tagged_section_keyword, status: :ok, location: @tagged_section_keyword}
Severity: Major
Found in app/controllers/tagged_section_keywords_controller.rb and 2 other locations - About 1 hr to fix
app/controllers/citation_topics_controller.rb on lines 24..31
app/controllers/container_items_controller.rb on lines 39..46

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

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

  def update
    respond_to do |format|
      if @citation_topic.update(citation_topic_params)
        format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Citation topic was successfully updated.')}
        format.json { render json: @citation_topic, status: :ok, location: @citation_topic }
Severity: Major
Found in app/controllers/citation_topics_controller.rb and 2 other locations - About 1 hr to fix
app/controllers/container_items_controller.rb on lines 39..46
app/controllers/tagged_section_keywords_controller.rb on lines 24..31

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

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

  def update
    respond_to do |format|
      if @container_item.update(container_item_params)
        format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was successfully created.')}
        format.json { render json: @container_item, status: :ok, location: @container_item }
Severity: Major
Found in app/controllers/container_items_controller.rb and 2 other locations - About 1 hr to fix
app/controllers/citation_topics_controller.rb on lines 24..31
app/controllers/tagged_section_keywords_controller.rb on lines 24..31

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

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

  init: function() {
    var src = 'https://paleobiodb.org/data1.2/strata/auto.json';

    // https://paleobiodb.org/data1.2/strata/list_doc.html
    // documentation states 'member' is valid, response says it is not
Severity: Minor
Found in app/assets/javascripts/views/collecting_events/form.js - About 1 hr to fix

    Function addRows has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        addRows(matrixId) {
          const promises = []
          const data = this.otuIds.map((id) => ({
            observation_matrix_id: matrixId,
            observation_object_id: id,

      Function resizeTaskCarrousel has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        resizeTaskCarrousel() {
          const userWindowWidth = window.innerWidth
          const userWindowHeight = window.innerHeight
          const isFavouritePage = !!document.querySelector('#favorite-page')
          const taskSection = document.querySelector('.task-section')
      Severity: Minor
      Found in app/assets/javascripts/views/hub/filter.js - About 1 hr to fix

        Method cached_map_sync_metadata has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def cached_map_sync_metadata(cached_map)
            return {} unless cached_map.present?
        
        
            o = Otu.find(cached_map.otu_id)
        Severity: Minor
        Found in app/helpers/cached_maps_helper.rb - About 1 hr to fix

          Method initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def initialize(query_params)
                  super
          
                  @any_global_id = params[:any_global_id]
                  @biological_association_id = params[:biological_association_id]
          Severity: Minor
          Found in lib/queries/biological_association/filter.rb - About 1 hr to fix

            Method hunt_lat_long has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def self.hunt_lat_long(label, how = ' ')
                  if how.nil?
                    pieces = [label]
                  else
                    pieces = label.split(how)
            Severity: Minor
            Found in lib/utilities/geo.rb - About 1 hr to fix

              Function useTableLayoutConfiguration has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              export function useTableLayoutConfiguration({ model, layouts } = {}) {
                const state = reactive({
                  currentLayout: {},
                  layouts: {},
                  properties: {},

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

                  fillContainer(items, { direction }) {
                    const { size } = this.container
              
                    for (let i = 0; i < size[direction[2]]; i++) {
                      for (let j = 0; j < size[direction[1]]; j++) {

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

                def set_cached_names_for_taxon_names
                  # !! only fire if subject_taxon_name changed
                  return true unless subject_taxon_name_id_previously_changed? || destroyed?
              
                  TaxonName.transaction do
              Severity: Minor
              Found in app/models/taxon_name_relationship.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 using_issn_class has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                def using_issn_class
                  validate_preamble = false
                  unless identifier.nil?
                    issn = identifier.upcase
              
              
              Severity: Minor
              Found in app/models/identifier/global/issn.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 syncronize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                def syncronize
                  if metadata_was == []
                    process if !metadata&.empty?
                  else
                    # At this point we only allow coordinate updates
              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 validate_type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                def validate_type
                  # TODO: Remove, handled by STI
                  if type && !TAXON_NAME_RELATIONSHIP_NAMES.include?(type.to_s)
                    errors.add(:type, "'#{type}' is not a valid taxon name relationship")
                  elsif self.type_class && object_taxon_name.class.to_s == 'Protonym' && !self.type_class.valid_object_ranks.include?(object_taxon_name.rank_string)
              Severity: Minor
              Found in app/models/taxon_name_relationship.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 observation_export_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                def observation_export_value(observation)
                  case observation.type
                  when 'Observation::Qualitative'
                    LABEL_REPLACEMENT[observation.character_state.label].nil? ? observation.character_state.label : LABEL_REPLACEMENT[observation.character_state.label]
                  when 'Observation::PresenceAbsence'
              Severity: Minor
              Found in app/helpers/observation_matrices_helper.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 11 (exceeds 5 allowed). Consider refactoring.
              Open

                def update
                  @collection_object.update(collection_object_params)
                  @collection_object.valid?
                  flash[:notice] = 'Collection object was' + (@collection_object.valid? ? '' : ' NOT') + ' successfully updated.' + (@collection_object.valid? ? '' : @collection_object.errors.full_messages.join('; '))
              
              

              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