SpeciesFileGroup/taxonworks

View on GitHub
app/controllers/collection_objects_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

Class CollectionObjectsController has 48 methods (exceeds 20 allowed). Consider refactoring.
Open

class CollectionObjectsController < ApplicationController
  include DataControllerConfiguration::ProjectDataControllerConfiguration

  before_action :set_collection_object, only: [
    :show, :edit, :update, :destroy, :navigation, :containerize,
Severity: Minor
Found in app/controllers/collection_objects_controller.rb - About 6 hrs to fix

    File collection_objects_controller.rb has 401 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class CollectionObjectsController < ApplicationController
      include DataControllerConfiguration::ProjectDataControllerConfiguration
    
      before_action :set_collection_object, only: [
        :show, :edit, :update, :destroy, :navigation, :containerize,
    Severity: Minor
    Found in app/controllers/collection_objects_controller.rb - About 5 hrs to fix

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

        def collection_object_params
          params.require(:collection_object).permit(
            :total, :preparation_type_id, :repository_id, :current_repository_id,
            :ranged_lot_category_id, :collecting_event_id,
            :buffered_collecting_event, :buffered_determinations,

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

        def collection_object_params
          params.require(:collection_object).permit(
            :total, :preparation_type_id, :repository_id, :current_repository_id,
            :ranged_lot_category_id, :collecting_event_id,
            :buffered_collecting_event, :buffered_determinations,
      Severity: Minor
      Found in app/controllers/collection_objects_controller.rb - About 1 hr to fix

        Method create_buffered_batch_load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def create_buffered_batch_load
            if params[:file] && digested_cookie_exists?(params[:file].tempfile, :Buffered_collection_objects_md5)
              @result = BatchLoad::Import::CollectionObjects::BufferedInterpreter.new(**batch_params)
              if @result.create
                flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} items were created."
        Severity: Minor
        Found in app/controllers/collection_objects_controller.rb - About 25 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 create_simple_batch_load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def create_simple_batch_load
            if params[:file] && digested_cookie_exists?(
                params[:file].tempfile,
                :batch_collection_objects_md5)
              @result = BatchLoad::Import::CollectionObjects.new(**batch_params.merge(user_map))
        Severity: Minor
        Found in app/controllers/collection_objects_controller.rb - About 25 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 create_castor_batch_load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def create_castor_batch_load
            if params[:file] && digested_cookie_exists?(params[:file].tempfile, :Castor_collection_objects_md5)
              @result = BatchLoad::Import::CollectionObjects::CastorInterpreter.new(**batch_params)
              if @result.create
                flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} items were created."
        Severity: Minor
        Found in app/controllers/collection_objects_controller.rb - About 25 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

        create returns a model which is always truthy.
        Open

              if @result.create

        This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

        This will allow: - update or save calls, assigned to a variable, or used as a condition in an if/unless/case statement. - create calls, assigned to a variable that then has a call to persisted?. - calls if the result is explicitly returned from methods and blocks, or provided as arguments. - calls whose signature doesn't look like an ActiveRecord persistence method.

        By default it will also allow implicit returns from methods and blocks. that behavior can be turned off with AllowImplicitReturn: false.

        You can permit receivers that are giving false positives with AllowedReceivers: []

        Example:

        # bad
        user.save
        user.update(name: 'Joe')
        user.find_or_create_by(name: 'Joe')
        user.destroy
        
        # good
        unless user.save
          # ...
        end
        user.save!
        user.update!(name: 'Joe')
        user.find_or_create_by!(name: 'Joe')
        user.destroy!
        
        user = User.find_or_create_by(name: 'Joe')
        unless user.persisted?
          # ...
        end
        
        def save_user
          return user.save
        end

        Example: AllowImplicitReturn: true (default)

        # good
        users.each { |u| u.save }
        
        def save_user
          user.save
        end

        Example: AllowImplicitReturn: false

        # bad
        users.each { |u| u.save }
        def save_user
          user.save
        end
        
        # good
        users.each { |u| u.save! }
        
        def save_user
          user.save!
        end
        
        def save_user
          return user.save
        end

        Example: AllowedReceivers: ['merchant.customers', 'Service::Mailer']

        # bad
        merchant.create
        customers.builder.save
        Mailer.create
        
        module Service::Mailer
          self.create
        end
        
        # good
        merchant.customers.create
        MerchantService.merchant.customers.destroy
        Service::Mailer.update(message: 'Message')
        ::Service::Mailer.update
        Services::Service::Mailer.update(message: 'Message')
        Service::Mailer::update

        Use destroy! instead of destroy if the return value is not checked.
        Open

            @collection_object.destroy

        This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

        This will allow: - update or save calls, assigned to a variable, or used as a condition in an if/unless/case statement. - create calls, assigned to a variable that then has a call to persisted?. - calls if the result is explicitly returned from methods and blocks, or provided as arguments. - calls whose signature doesn't look like an ActiveRecord persistence method.

        By default it will also allow implicit returns from methods and blocks. that behavior can be turned off with AllowImplicitReturn: false.

        You can permit receivers that are giving false positives with AllowedReceivers: []

        Example:

        # bad
        user.save
        user.update(name: 'Joe')
        user.find_or_create_by(name: 'Joe')
        user.destroy
        
        # good
        unless user.save
          # ...
        end
        user.save!
        user.update!(name: 'Joe')
        user.find_or_create_by!(name: 'Joe')
        user.destroy!
        
        user = User.find_or_create_by(name: 'Joe')
        unless user.persisted?
          # ...
        end
        
        def save_user
          return user.save
        end

        Example: AllowImplicitReturn: true (default)

        # good
        users.each { |u| u.save }
        
        def save_user
          user.save
        end

        Example: AllowImplicitReturn: false

        # bad
        users.each { |u| u.save }
        def save_user
          user.save
        end
        
        # good
        users.each { |u| u.save! }
        
        def save_user
          user.save!
        end
        
        def save_user
          return user.save
        end

        Example: AllowedReceivers: ['merchant.customers', 'Service::Mailer']

        # bad
        merchant.create
        customers.builder.save
        Mailer.create
        
        module Service::Mailer
          self.create
        end
        
        # good
        merchant.customers.create
        MerchantService.merchant.customers.destroy
        Service::Mailer.update(message: 'Message')
        ::Service::Mailer.update
        Services::Service::Mailer.update(message: 'Message')
        Service::Mailer::update

        create returns a model which is always truthy.
        Open

              if @result.create

        This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

        This will allow: - update or save calls, assigned to a variable, or used as a condition in an if/unless/case statement. - create calls, assigned to a variable that then has a call to persisted?. - calls if the result is explicitly returned from methods and blocks, or provided as arguments. - calls whose signature doesn't look like an ActiveRecord persistence method.

        By default it will also allow implicit returns from methods and blocks. that behavior can be turned off with AllowImplicitReturn: false.

        You can permit receivers that are giving false positives with AllowedReceivers: []

        Example:

        # bad
        user.save
        user.update(name: 'Joe')
        user.find_or_create_by(name: 'Joe')
        user.destroy
        
        # good
        unless user.save
          # ...
        end
        user.save!
        user.update!(name: 'Joe')
        user.find_or_create_by!(name: 'Joe')
        user.destroy!
        
        user = User.find_or_create_by(name: 'Joe')
        unless user.persisted?
          # ...
        end
        
        def save_user
          return user.save
        end

        Example: AllowImplicitReturn: true (default)

        # good
        users.each { |u| u.save }
        
        def save_user
          user.save
        end

        Example: AllowImplicitReturn: false

        # bad
        users.each { |u| u.save }
        def save_user
          user.save
        end
        
        # good
        users.each { |u| u.save! }
        
        def save_user
          user.save!
        end
        
        def save_user
          return user.save
        end

        Example: AllowedReceivers: ['merchant.customers', 'Service::Mailer']

        # bad
        merchant.create
        customers.builder.save
        Mailer.create
        
        module Service::Mailer
          self.create
        end
        
        # good
        merchant.customers.create
        MerchantService.merchant.customers.destroy
        Service::Mailer.update(message: 'Message')
        ::Service::Mailer.update
        Services::Service::Mailer.update(message: 'Message')
        Service::Mailer::update

        create returns a model which is always truthy.
        Open

              if @result.create

        This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

        This will allow: - update or save calls, assigned to a variable, or used as a condition in an if/unless/case statement. - create calls, assigned to a variable that then has a call to persisted?. - calls if the result is explicitly returned from methods and blocks, or provided as arguments. - calls whose signature doesn't look like an ActiveRecord persistence method.

        By default it will also allow implicit returns from methods and blocks. that behavior can be turned off with AllowImplicitReturn: false.

        You can permit receivers that are giving false positives with AllowedReceivers: []

        Example:

        # bad
        user.save
        user.update(name: 'Joe')
        user.find_or_create_by(name: 'Joe')
        user.destroy
        
        # good
        unless user.save
          # ...
        end
        user.save!
        user.update!(name: 'Joe')
        user.find_or_create_by!(name: 'Joe')
        user.destroy!
        
        user = User.find_or_create_by(name: 'Joe')
        unless user.persisted?
          # ...
        end
        
        def save_user
          return user.save
        end

        Example: AllowImplicitReturn: true (default)

        # good
        users.each { |u| u.save }
        
        def save_user
          user.save
        end

        Example: AllowImplicitReturn: false

        # bad
        users.each { |u| u.save }
        def save_user
          user.save
        end
        
        # good
        users.each { |u| u.save! }
        
        def save_user
          user.save!
        end
        
        def save_user
          return user.save
        end

        Example: AllowedReceivers: ['merchant.customers', 'Service::Mailer']

        # bad
        merchant.create
        customers.builder.save
        Mailer.create
        
        module Service::Mailer
          self.create
        end
        
        # good
        merchant.customers.create
        MerchantService.merchant.customers.destroy
        Service::Mailer.update(message: 'Message')
        ::Service::Mailer.update
        Services::Service::Mailer.update(message: 'Message')
        Service::Mailer::update

        TODO found
        Open

          # TODO: not used?

        TODO found
        Open

          # TODO: probably some deep clean

        TODO found
        Open

          # TODO: Move

        TODO found
        Open

          # TODO: remove for filter

        TODO found
        Open

          # TODO: render in view

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

              collecting_event_attributes: [],  # needs to be filled out!
              data_attributes_attributes: [ :id, :_destroy, :controlled_vocabulary_term_id, :type, :value ],
              tags_attributes: [:id, :_destroy, :keyword_id],
              depictions_attributes: [:id, :_destroy, :svg_clip, :svg_view_box, :position, :caption, :figure_label, :image_id],
              identifiers_attributes: [
        Severity: Major
        Found in app/controllers/collection_objects_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/field_occurrences_controller.rb on lines 110..134

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

        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 create
            @collection_object = CollectionObject.new(collection_object_params)
        
            respond_to do |format|
              if @collection_object.save
        Severity: Major
        Found in app/controllers/collection_objects_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/taxon_name_relationships_controller.rb on lines 40..50

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

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

          def create_castor_batch_load
            if params[:file] && digested_cookie_exists?(params[:file].tempfile, :Castor_collection_objects_md5)
              @result = BatchLoad::Import::CollectionObjects::CastorInterpreter.new(**batch_params)
              if @result.create
                flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} items were created."
        Severity: Major
        Found in app/controllers/collection_objects_controller.rb and 9 other locations - About 1 hr to fix
        app/controllers/collecting_events_controller.rb on lines 206..219
        app/controllers/collecting_events_controller.rb on lines 233..246
        app/controllers/collection_objects_controller.rb on lines 337..350
        app/controllers/descriptors_controller.rb on lines 162..177
        app/controllers/namespaces_controller.rb on lines 116..129
        app/controllers/otus_controller.rb on lines 220..233
        app/controllers/sequences_controller.rb on lines 141..154
        app/controllers/sequences_controller.rb on lines 167..180
        app/controllers/taxon_names_controller.rb on lines 199..212

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

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

          def create_buffered_batch_load
            if params[:file] && digested_cookie_exists?(params[:file].tempfile, :Buffered_collection_objects_md5)
              @result = BatchLoad::Import::CollectionObjects::BufferedInterpreter.new(**batch_params)
              if @result.create
                flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} items were created."
        Severity: Major
        Found in app/controllers/collection_objects_controller.rb and 9 other locations - About 1 hr to fix
        app/controllers/collecting_events_controller.rb on lines 206..219
        app/controllers/collecting_events_controller.rb on lines 233..246
        app/controllers/collection_objects_controller.rb on lines 311..324
        app/controllers/descriptors_controller.rb on lines 162..177
        app/controllers/namespaces_controller.rb on lines 116..129
        app/controllers/otus_controller.rb on lines 220..233
        app/controllers/sequences_controller.rb on lines 141..154
        app/controllers/sequences_controller.rb on lines 167..180
        app/controllers/taxon_names_controller.rb on lines 199..212

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

        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 preview_simple_batch_load
            if params[:file]
              @result = BatchLoad::Import::CollectionObjects.new(**batch_params.merge(user_map))
              digest_cookie(params[:file].tempfile, :batch_collection_objects_md5)
              render 'collection_objects/batch_load/simple/preview'
        Severity: Minor
        Found in app/controllers/collection_objects_controller.rb and 1 other location - About 35 mins to fix
        app/controllers/otus_controller.rb on lines 132..140

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

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

          def batch_update
            if c = CollectionObject.batch_update(
                preview: params[:preview],
                collection_object: collection_object_params.merge(by: sessions_current_user_id),
                collection_object_query: params[:collection_object_query])
        Severity: Major
        Found in app/controllers/collection_objects_controller.rb and 4 other locations - About 35 mins to fix
        app/controllers/asserted_distributions_controller.rb on lines 117..126
        app/controllers/biological_associations_controller.rb on lines 153..161
        app/controllers/collecting_events_controller.rb on lines 128..136
        app/controllers/otus_controller.rb on lines 254..263

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

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

          def preview_castor_batch_load
            if params[:file]
              @result = BatchLoad::Import::CollectionObjects::CastorInterpreter.new(**batch_params)
              digest_cookie(params[:file].tempfile, :Castor_collection_objects_md5)
              render 'collection_objects/batch_load/castor/preview'
        Severity: Major
        Found in app/controllers/collection_objects_controller.rb and 12 other locations - About 30 mins to fix
        app/controllers/collecting_events_controller.rb on lines 195..203
        app/controllers/collecting_events_controller.rb on lines 221..230
        app/controllers/collection_objects_controller.rb on lines 326..334
        app/controllers/descriptors_controller.rb on lines 121..129
        app/controllers/descriptors_controller.rb on lines 132..140
        app/controllers/namespaces_controller.rb on lines 105..113
        app/controllers/otus_controller.rb on lines 156..164
        app/controllers/otus_controller.rb on lines 208..216
        app/controllers/sequence_relationships_controller.rb on lines 92..100
        app/controllers/sequences_controller.rb on lines 130..138
        app/controllers/sequences_controller.rb on lines 156..164
        app/controllers/taxon_names_controller.rb on lines 188..196

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

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

          def preview_buffered_batch_load
            if params[:file]
              @result = BatchLoad::Import::CollectionObjects::BufferedInterpreter.new(**batch_params)
              digest_cookie(params[:file].tempfile, :Buffered_collection_objects_md5)
              render 'collection_objects/batch_load/buffered/preview'
        Severity: Major
        Found in app/controllers/collection_objects_controller.rb and 12 other locations - About 30 mins to fix
        app/controllers/collecting_events_controller.rb on lines 195..203
        app/controllers/collecting_events_controller.rb on lines 221..230
        app/controllers/collection_objects_controller.rb on lines 300..308
        app/controllers/descriptors_controller.rb on lines 121..129
        app/controllers/descriptors_controller.rb on lines 132..140
        app/controllers/namespaces_controller.rb on lines 105..113
        app/controllers/otus_controller.rb on lines 156..164
        app/controllers/otus_controller.rb on lines 208..216
        app/controllers/sequence_relationships_controller.rb on lines 92..100
        app/controllers/sequences_controller.rb on lines 130..138
        app/controllers/sequences_controller.rb on lines 156..164
        app/controllers/taxon_names_controller.rb on lines 188..196

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

        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

            @collection_objects = ::Queries::CollectionObject::Filter.new(params.merge!(api: true)).all
              .where(project_id: sessions_current_project_id)
              .order('collection_objects.id')
              .page(params[:page]).per(params[:per])
        Severity: Minor
        Found in app/controllers/collection_objects_controller.rb and 1 other location - About 15 mins to fix
        app/controllers/biological_associations_controller.rb on lines 135..140

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

        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 symbols instead of strings as hash keys.
        Open

                'start_month' => 'start_date_month',

        This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

        Example:

        # bad
        { 'one' => 1, 'two' => 2, 'three' => 3 }
        
        # good
        { one: 1, two: 2, three: 3 }

        Prefer symbols instead of strings as hash keys.
        Open

                'start_day'   => 'start_date_day',

        This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

        Example:

        # bad
        { 'one' => 1, 'two' => 2, 'three' => 3 }
        
        # good
        { one: 1, two: 2, three: 3 }

        Prefer symbols instead of strings as hash keys.
        Open

                'end_month'   => 'end_date_month',

        This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

        Example:

        # bad
        { 'one' => 1, 'two' => 2, 'three' => 3 }
        
        # good
        { one: 1, two: 2, three: 3 }

        Prefer symbols instead of strings as hash keys.
        Open

                'start_year'  => 'start_date_year',

        This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

        Example:

        # bad
        { 'one' => 1, 'two' => 2, 'three' => 3 }
        
        # good
        { one: 1, two: 2, three: 3 }

        Prefer symbols instead of strings as hash keys.
        Open

                'otu'         => 'otu_name',

        This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

        Example:

        # bad
        { 'one' => 1, 'two' => 2, 'three' => 3 }
        
        # good
        { one: 1, two: 2, three: 3 }

        Prefer symbols instead of strings as hash keys.
        Open

                'end_day'     => 'end_date_day',

        This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

        Example:

        # bad
        { 'one' => 1, 'two' => 2, 'three' => 3 }
        
        # good
        { one: 1, two: 2, three: 3 }

        Prefer symbols instead of strings as hash keys.
        Open

                'end_year'    => 'end_date_year'}

        This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

        Example:

        # bad
        { 'one' => 1, 'two' => 2, 'three' => 3 }
        
        # good
        { one: 1, two: 2, three: 3 }

        There are no issues that match your filters.

        Category
        Status