SpeciesFileGroup/taxonworks

View on GitHub
app/models/collection_object.rb

Summary

Maintainability
F
4 days
Test Coverage

File collection_object.rb has 458 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class CollectionObject < ApplicationRecord
  include GlobalID::Identification
  include Housekeeping

  include Shared::Citations
Severity: Minor
Found in app/models/collection_object.rb - About 7 hrs to fix

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

      def self.generate_report_download(scope, col_defs, table_data = nil)
        CSV.generate do |csv|
          row = CO_OTU_HEADERS
          unless col_defs.nil?
            %w(ce co bc).each { |column_type|
    Severity: Minor
    Found in app/models/collection_object.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 co_attributes has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.co_attributes(collection_object, col_defs)
        retval = []; collection = col_defs
        unless collection.nil?
          # for this collection object, gather all the possible data_attributes
          all_internal_das = collection_object.internal_attributes
    Severity: Minor
    Found in app/models/collection_object.rb - About 3 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 ce_attributes has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.ce_attributes(collection_object, col_defs)
        retval = []; collection = col_defs
        unless collection.nil?
          # for this collection object, gather all the possible data_attributes
          all_internal_das = collection_object.collecting_event.internal_attributes
    Severity: Minor
    Found in app/models/collection_object.rb - About 3 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

    Class CollectionObject has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class CollectionObject < ApplicationRecord
      include GlobalID::Identification
      include Housekeeping
    
      include Shared::Citations
    Severity: Minor
    Found in app/models/collection_object.rb - About 3 hrs to fix

      Method generate_report_download has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.generate_report_download(scope, col_defs, table_data = nil)
          CSV.generate do |csv|
            row = CO_OTU_HEADERS
            unless col_defs.nil?
              %w(ce co bc).each { |column_type|
      Severity: Minor
      Found in app/models/collection_object.rb - About 3 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 has too many lines. [35/25]
      Open

        def self.co_attributes(collection_object, col_defs)
          retval = []; collection = col_defs
          unless collection.nil?
            # for this collection object, gather all the possible data_attributes
            all_internal_das = collection_object.internal_attributes
      Severity: Minor
      Found in app/models/collection_object.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. [33/25]
      Open

        def self.ce_attributes(collection_object, col_defs)
          retval = []; collection = col_defs
          unless collection.nil?
            # for this collection object, gather all the possible data_attributes
            all_internal_das = collection_object.collecting_event.internal_attributes
      Severity: Minor
      Found in app/models/collection_object.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. [31/25]
      Open

        def self.used_recently(used_on = '')
          t = case used_on
              when 'TaxonDetermination'
                TaxonDetermination.arel_table
              when 'BiologicalAssociation'
      Severity: Minor
      Found in app/models/collection_object.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 generate_report_download has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.generate_report_download(scope, col_defs, table_data = nil)
          CSV.generate do |csv|
            row = CO_OTU_HEADERS
            unless col_defs.nil?
              %w(ce co bc).each { |column_type|
      Severity: Minor
      Found in app/models/collection_object.rb - About 1 hr to fix

        Method bc_attributes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.bc_attributes(collection_object, col_defs)
            retval = []
            collection = col_defs
            unless collection.nil?
              group = collection[:bc]
        Severity: Minor
        Found in app/models/collection_object.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 co_attributes has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.co_attributes(collection_object, col_defs)
            retval = []; collection = col_defs
            unless collection.nil?
              # for this collection object, gather all the possible data_attributes
              all_internal_das = collection_object.internal_attributes
        Severity: Minor
        Found in app/models/collection_object.rb - About 1 hr to fix

          Method ce_attributes has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.ce_attributes(collection_object, col_defs)
              retval = []; collection = col_defs
              unless collection.nil?
                # for this collection object, gather all the possible data_attributes
                all_internal_das = collection_object.collecting_event.internal_attributes
          Severity: Minor
          Found in app/models/collection_object.rb - About 1 hr to fix

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

              def self.used_recently(used_on = '')
                t = case used_on
                    when 'TaxonDetermination'
                      TaxonDetermination.arel_table
                    when 'BiologicalAssociation'
            Severity: Minor
            Found in app/models/collection_object.rb - About 1 hr to fix

              Method earliest_date has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.earliest_date(project_id)
                  a = CollectingEvent.joins(:collection_objects).where(project_id: project_id).minimum(:start_date_year)
                  b = CollectingEvent.joins(:collection_objects).where(project_id: project_id).minimum(:end_date_year)
              
                  return EARLIEST_DATE if a.nil? && b.nil?  # 1700-01-01
              Severity: Minor
              Found in app/models/collection_object.rb - About 45 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 latest_date has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.latest_date(project_id)
                  a = CollectingEvent.joins(:collection_objects).where(project_id: project_id).maximum(:start_date_year)
                  b = CollectingEvent.joins(:collection_objects).where(project_id: project_id).maximum(:end_date_year)
              
                  c = Time.now.strftime('%Y-%m-%d')
              Severity: Minor
              Found in app/models/collection_object.rb - About 45 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

              Avoid more than 3 levels of block nesting.
              Open

                        unless group[:in].empty?
                          group[:in].each_key { |header|
                            this_val = collection_object.biocuration_classes.map(&:name).include?(header) ? '1' : '0'
                            retval.push(this_val) # push one value (nil or not) for each selected header
                          }
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for excessive nesting of conditional and looping constructs.

              You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

              The maximum level of nesting allowed is configurable.

              Avoid more than 3 levels of block nesting.
              Open

                                if da.import_predicate == header
                                  this_val = da.value
                                  break
                                end
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for excessive nesting of conditional and looping constructs.

              You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

              The maximum level of nesting allowed is configurable.

              Avoid more than 3 levels of block nesting.
              Open

                                if da.predicate.name == header
                                  this_val = da.value
                                  break
                                end
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for excessive nesting of conditional and looping constructs.

              You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

              The maximum level of nesting allowed is configurable.

              Avoid more than 3 levels of block nesting.
              Open

                        unless group[:im].empty?
                          group[:im].each_key { |header|
                            this_val = nil
                            all_import_das.each { |da|
                              if da.import_predicate == header
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for excessive nesting of conditional and looping constructs.

              You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

              The maximum level of nesting allowed is configurable.

              Avoid more than 3 levels of block nesting.
              Open

                        unless group[:in].empty?
                          group[:in].each_key { |header|
                            this_val = nil
                            all_internal_das.each { |da|
                              if da.predicate.name == header
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for excessive nesting of conditional and looping constructs.

              You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

              The maximum level of nesting allowed is configurable.

              Prefer 1.week.
              Open

                          .where(t['updated_at'].gt( 1.weeks.ago ))
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for correct grammar when using ActiveSupport's core extensions to the numeric classes.

              Example:

              # bad
              3.day.ago
              1.months.ago
              
              # good
              3.days.ago
              1.month.ago

              Use ranged_lot_category_id.present? instead of !ranged_lot_category_id.blank?.
              Open

                  errors.add(:ranged_lot_category_id, 'Both ranged_lot_category and total can not be set') if !ranged_lot_category_id.blank? && !total.blank?
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

              Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

              Example: NotNilAndNotEmpty: true (default)

              # Converts usages of `!nil? && !empty?` to `present?`
              
              # bad
              !foo.nil? && !foo.empty?
              
              # bad
              foo != nil && !foo.empty?
              
              # good
              foo.present?

              Example: NotBlank: true (default)

              # Converts usages of `!blank?` to `present?`
              
              # bad
              !foo.blank?
              
              # bad
              not foo.blank?
              
              # good
              foo.present?

              Example: UnlessBlank: true (default)

              # Converts usages of `unless blank?` to `if present?`
              
              # bad
              something unless foo.blank?
              
              # good
              something if foo.present?

              Use total.present? instead of !total.blank?.
              Open

                  errors.add(:ranged_lot_category_id, 'Both ranged_lot_category and total can not be set') if !ranged_lot_category_id.blank? && !total.blank?
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

              Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

              Example: NotNilAndNotEmpty: true (default)

              # Converts usages of `!nil? && !empty?` to `present?`
              
              # bad
              !foo.nil? && !foo.empty?
              
              # bad
              foo != nil && !foo.empty?
              
              # good
              foo.present?

              Example: NotBlank: true (default)

              # Converts usages of `!blank?` to `present?`
              
              # bad
              !foo.blank?
              
              # bad
              not foo.blank?
              
              # good
              foo.present?

              Example: UnlessBlank: true (default)

              # Converts usages of `unless blank?` to `if present?`
              
              # bad
              something unless foo.blank?
              
              # good
              something if foo.present?

              Use find_by instead of where.first.
              Open

                  Identifier::Local::CatalogNumber.where(identifier_object: self).first
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop is used to identify usages of where.first and change them to use find_by instead.

              Example:

              # bad
              User.where(name: 'Bruce').first
              User.where(name: 'Bruce').take
              
              # good
              User.find_by(name: 'Bruce')

              Use self.deaccession_reason.present? instead of !self.deaccession_reason.blank?.
              Open

                  soft_validations.add(:deaccessioned_at, 'Date is not selected') if self.deaccessioned_at.nil? && !self.deaccession_reason.blank?
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

              Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

              Example: NotNilAndNotEmpty: true (default)

              # Converts usages of `!nil? && !empty?` to `present?`
              
              # bad
              !foo.nil? && !foo.empty?
              
              # bad
              foo != nil && !foo.empty?
              
              # good
              foo.present?

              Example: NotBlank: true (default)

              # Converts usages of `!blank?` to `present?`
              
              # bad
              !foo.blank?
              
              # bad
              not foo.blank?
              
              # good
              foo.present?

              Example: UnlessBlank: true (default)

              # Converts usages of `unless blank?` to `if present?`
              
              # bad
              something unless foo.blank?
              
              # good
              something if foo.present?

              Use ranged_lot_category_id.present? instead of !ranged_lot_category_id.blank?.
              Open

                  elsif total.nil? && !ranged_lot_category_id.blank?
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

              Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

              Example: NotNilAndNotEmpty: true (default)

              # Converts usages of `!nil? && !empty?` to `present?`
              
              # bad
              !foo.nil? && !foo.empty?
              
              # bad
              foo != nil && !foo.empty?
              
              # good
              foo.present?

              Example: NotBlank: true (default)

              # Converts usages of `!blank?` to `present?`
              
              # bad
              !foo.blank?
              
              # bad
              not foo.blank?
              
              # good
              foo.present?

              Example: UnlessBlank: true (default)

              # Converts usages of `unless blank?` to `if present?`
              
              # bad
              something unless foo.blank?
              
              # good
              something if foo.present?

              Use attributed[a].present? instead of !attributed[a].blank?.
              Open

                    if !attributed[a].blank?
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

              Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

              Example: NotNilAndNotEmpty: true (default)

              # Converts usages of `!nil? && !empty?` to `present?`
              
              # bad
              !foo.nil? && !foo.empty?
              
              # bad
              foo != nil && !foo.empty?
              
              # good
              foo.present?

              Example: NotBlank: true (default)

              # Converts usages of `!blank?` to `present?`
              
              # bad
              !foo.blank?
              
              # bad
              not foo.blank?
              
              # good
              foo.present?

              Example: UnlessBlank: true (default)

              # Converts usages of `unless blank?` to `if present?`
              
              # bad
              something unless foo.blank?
              
              # good
              something if foo.present?

              Prefer 1.week.
              Open

                            t['updated_at'].gt(1.weeks.ago).and(
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for correct grammar when using ActiveSupport's core extensions to the numeric classes.

              Example:

              # bad
              3.day.ago
              1.months.ago
              
              # good
              3.days.ago
              1.month.ago

              TODO found
              Open

                # TODO: Deprecate.  Used?!
              Severity: Minor
              Found in app/models/collection_object.rb by fixme

              TODO found
              Open

                # TODO: Clarify this.
              Severity: Minor
              Found in app/models/collection_object.rb by fixme

              TODO found
              Open

                # TODO: move to a helper
              Severity: Minor
              Found in app/models/collection_object.rb by fixme

              TODO found
              Open

                # TODO: this should be refactored to be collection object centric AFTER
              Severity: Minor
              Found in app/models/collection_object.rb by fixme

              TODO found
              Open

              #   The date when the object was removed from tracking.  If provide then Repository must be null?! TODO: resolve
              Severity: Minor
              Found in app/models/collection_object.rb by fixme

              TODO found
              Open

                # TODO: deprecate
              Severity: Minor
              Found in app/models/collection_object.rb by fixme

              TODO found
              Open

                  allow_partial = (partial_overlap.downcase == 'off' ? false : true) # TODO: Just get the correct values from the form!
              Severity: Minor
              Found in app/models/collection_object.rb by fixme

              TODO found
              Open

                # TODO: this should be refactored to be collection object centric AFTER
              Severity: Minor
              Found in app/models/collection_object.rb by fixme

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

                def self.ce_headers(project_id)
                  CollectionObject.selected_column_names
                  cvt_list = InternalAttribute.where(project_id: project_id, attribute_subject_type: 'CollectingEvent')
                               .distinct
                               .pluck(:controlled_vocabulary_term_id)
              Severity: Major
              Found in app/models/collection_object.rb and 1 other location - About 1 hr to fix
              app/models/collection_object.rb on lines 404..417

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

              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 self.co_headers(project_id)
                  CollectionObject.selected_column_names
                  cvt_list = InternalAttribute.where(project_id: project_id, attribute_subject_type: 'CollectionObject')
                               .distinct
                               .pluck(:controlled_vocabulary_term_id)
              Severity: Major
              Found in app/models/collection_object.rb and 1 other location - About 1 hr to fix
              app/models/collection_object.rb on lines 344..357

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

              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

                  i = case used_on
                      when 'BiologicalAssociation'
                        t.project(t['biological_association_subject_id'], t['updated_at']).from(t)
                          .where(
                            t['updated_at'].gt(1.weeks.ago).and(
              Severity: Major
              Found in app/models/collection_object.rb and 1 other location - About 1 hr to fix
              app/models/otu.rb on lines 281..293

              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

                  j = case used_on
                      when 'BiologicalAssociation'
                        Arel::Nodes::InnerJoin.new(z, Arel::Nodes::On.new(
                          z['biological_association_subject_id'].eq(p['id'])
                        ))
              Severity: Major
              Found in app/models/collection_object.rb and 2 other locations - About 40 mins to fix
              app/models/otu.rb on lines 298..304
              app/models/sequence.rb on lines 107..113

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

              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

              Prefer the new style validations validates :column, presence: value over validates_presence_of.
              Open

                validates_presence_of :type
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for the use of old-style attribute validation macros.

              Example:

              # bad
              validates_acceptance_of :foo
              validates_confirmation_of :foo
              validates_exclusion_of :foo
              validates_format_of :foo
              validates_inclusion_of :foo
              validates_length_of :foo
              validates_numericality_of :foo
              validates_presence_of :foo
              validates_absence_of :foo
              validates_size_of :foo
              validates_uniqueness_of :foo
              
              # good
              validates :foo, acceptance: true
              validates :foo, confirmation: true
              validates :foo, exclusion: true
              validates :foo, format: true
              validates :foo, inclusion: true
              validates :foo, length: true
              validates :foo, numericality: true
              validates :foo, presence: true
              validates :foo, absence: true
              validates :foo, size: true
              validates :foo, uniqueness: true

              Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.xmlschema, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.httpdate, Time.now.to_i, Time.now.to_f instead.
              Open

                  c = Time.now.strftime('%Y-%m-%d')
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks for the use of Time methods without zone.

              Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

              Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

              When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

              Example: EnforcedStyle: strict

              # `strict` means that `Time` should be used with `zone`.
              
              # bad
              Time.now
              Time.parse('2015-03-02 19:05:37')
              
              # bad
              Time.current
              Time.at(timestamp).in_time_zone
              
              # good
              Time.zone.now
              Time.zone.parse('2015-03-02 19:05:37')

              Example: EnforcedStyle: flexible (default)

              # `flexible` allows usage of `in_time_zone` instead of `zone`.
              
              # bad
              Time.now
              Time.parse('2015-03-02 19:05:37')
              
              # good
              Time.zone.now
              Time.zone.parse('2015-03-02 19:05:37')
              
              # good
              Time.current
              Time.at(timestamp).in_time_zone

              Freeze mutable objects assigned to constants.
              Open

                GRAPH_ENTRY_POINTS = [:biological_associations, :data_attributes, :taxon_determinations, :biocuration_classifications]
              Severity: Minor
              Found in app/models/collection_object.rb by rubocop

              This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

              Strict mode can be used to freeze all constants, rather than just literals. Strict mode is considered an experimental feature. It has not been updated with an exhaustive list of all methods that will produce frozen objects so there is a decent chance of getting some false positives. Luckily, there is no harm in freezing an already frozen object.

              Example: EnforcedStyle: literals (default)

              # bad
              CONST = [1, 2, 3]
              
              # good
              CONST = [1, 2, 3].freeze
              
              # good
              CONST = <

              Example: EnforcedStyle: strict

              # bad
              CONST = Something.new
              
              # bad
              CONST = Struct.new do
                def foo
                  puts 1
                end
              end
              
              # good
              CONST = Something.new.freeze
              
              # good
              CONST = Struct.new do
                def foo
                  puts 1
                end
              end.freeze

              There are no issues that match your filters.

              Category
              Status