SpeciesFileGroup/taxonworks

View on GitHub
app/controllers/collecting_events_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

Class CollectingEventsController has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

class CollectingEventsController < ApplicationController
  include DataControllerConfiguration::ProjectDataControllerConfiguration

  before_action :set_collecting_event, only: [:show, :edit, :update, :destroy, :card, :clone]
  after_action -> { set_pagination_headers(:collecting_events) }, only: [:index], if: :json_request?
Severity: Minor
Found in app/controllers/collecting_events_controller.rb - About 3 hrs to fix

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

      def create_gpx_batch_load
        if params[:file] && digested_cookie_exists?(params[:file].tempfile, :gpx_batch_load_collecting_events_md5)
          @result = BatchLoad::Import::CollectingEvents::GpxInterpreter.new(**batch_params)
          if @result.create
            flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} collecting events w/georeferences were created."
    Severity: Minor
    Found in app/controllers/collecting_events_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_collecting_events_md5)
          @result = BatchLoad::Import::CollectingEvent.new(**batch_params)
          if @result.create
            flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} collecting events were created."
    Severity: Minor
    Found in app/controllers/collecting_events_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_collecting_events_md5)
          @result = BatchLoad::Import::CollectingEvents::CastorInterpreter.new(**batch_params)
          if @result.create
            flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} collecting events were created."
    Severity: Minor
    Found in app/controllers/collecting_events_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

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

        @collecting_event.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

    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: unify for use in CO

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

      def destroy
        @collecting_event.destroy
        respond_to do |format|
          if @collecting_event.destroyed?
            format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'CollectingEvent was successfully destroyed.')}
    Severity: Major
    Found in app/controllers/collecting_events_controller.rb and 3 other locations - About 1 hr to fix
    app/controllers/citations_controller.rb on lines 73..81
    app/controllers/otus_controller.rb on lines 94..102
    app/controllers/taxon_names_controller.rb on lines 82..90

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

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

      def create
        @collecting_event = CollectingEvent.new(collecting_event_params)
        respond_to do |format|
          if @collecting_event.save
            format.html { redirect_to @collecting_event, notice: 'Collecting event was successfully created.' }
    Severity: Major
    Found in app/controllers/collecting_events_controller.rb and 5 other locations - About 1 hr to fix
    app/controllers/documents_controller.rb on lines 29..38
    app/controllers/geographic_areas_geographic_items_controller.rb on lines 18..27
    app/controllers/projects_controller.rb on lines 31..40
    app/controllers/repositories_controller.rb on lines 30..39
    app/controllers/taxon_determinations_controller.rb on lines 40..49

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 50.

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

      def create_castor_batch_load
        if params[:file] && digested_cookie_exists?(params[:file].tempfile, :Castor_collecting_events_md5)
          @result = BatchLoad::Import::CollectingEvents::CastorInterpreter.new(**batch_params)
          if @result.create
            flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} collecting events were created."
    Severity: Major
    Found in app/controllers/collecting_events_controller.rb and 8 other locations - About 1 hr to fix
    app/controllers/collecting_events_controller.rb on lines 203..216
    app/controllers/collection_objects_controller.rb on lines 230..243
    app/controllers/collection_objects_controller.rb on lines 256..269
    app/controllers/namespaces_controller.rb on lines 107..120
    app/controllers/otus_controller.rb on lines 217..230
    app/controllers/sequences_controller.rb on lines 136..149
    app/controllers/sequences_controller.rb on lines 162..175
    app/controllers/taxon_names_controller.rb on lines 191..204

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

      def create_gpx_batch_load
        if params[:file] && digested_cookie_exists?(params[:file].tempfile, :gpx_batch_load_collecting_events_md5)
          @result = BatchLoad::Import::CollectingEvents::GpxInterpreter.new(**batch_params)
          if @result.create
            flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} collecting events w/georeferences were created."
    Severity: Major
    Found in app/controllers/collecting_events_controller.rb and 8 other locations - About 1 hr to fix
    app/controllers/collecting_events_controller.rb on lines 176..189
    app/controllers/collection_objects_controller.rb on lines 230..243
    app/controllers/collection_objects_controller.rb on lines 256..269
    app/controllers/namespaces_controller.rb on lines 107..120
    app/controllers/otus_controller.rb on lines 217..230
    app/controllers/sequences_controller.rb on lines 136..149
    app/controllers/sequences_controller.rb on lines 162..175
    app/controllers/taxon_names_controller.rb on lines 191..204

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

      def create_simple_batch_load
        if params[:file] && digested_cookie_exists?(params[:file].tempfile, :batch_collecting_events_md5)
          @result = BatchLoad::Import::CollectingEvent.new(**batch_params)
          if @result.create
            flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} collecting events were created."
    Severity: Major
    Found in app/controllers/collecting_events_controller.rb and 2 other locations - About 1 hr to fix
    app/controllers/asserted_distributions_controller.rb on lines 118..131
    app/controllers/taxon_names_controller.rb on lines 165..178

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

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

      def index
        respond_to do |format|
          format.html do
            @recent_objects = CollectingEvent.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
            render '/shared/data/all/index'
    Severity: Major
    Found in app/controllers/collecting_events_controller.rb and 5 other locations - About 55 mins to fix
    app/controllers/asserted_distributions_controller.rb on lines 8..17
    app/controllers/attributions_controller.rb on lines 8..16
    app/controllers/confidences_controller.rb on lines 9..17
    app/controllers/identifiers_controller.rb on lines 8..16
    app/controllers/otus_controller.rb on lines 9..16

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

    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 update
        respond_to do |format|
          if @collecting_event.update(collecting_event_params)
            format.html { redirect_to @collecting_event, notice: 'Collecting event was successfully updated.' }
            format.json { render :show, status: :ok, location: @collecting_event }
    Severity: Minor
    Found in app/controllers/collecting_events_controller.rb and 1 other location - About 55 mins to fix
    app/controllers/projects_controller.rb on lines 47..54

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

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

      def preview_castor_batch_load
        if params[:file]
          @result = BatchLoad::Import::CollectingEvents::CastorInterpreter.new(**batch_params)
          digest_cookie(params[:file].tempfile, :Castor_collecting_events_md5)
          render 'collecting_events/batch_load/castor/preview'
    Severity: Major
    Found in app/controllers/collecting_events_controller.rb and 11 other locations - About 30 mins to fix
    app/controllers/collecting_events_controller.rb on lines 191..200
    app/controllers/collection_objects_controller.rb on lines 219..227
    app/controllers/collection_objects_controller.rb on lines 245..253
    app/controllers/descriptors_controller.rb on lines 104..112
    app/controllers/namespaces_controller.rb on lines 96..104
    app/controllers/otus_controller.rb on lines 153..161
    app/controllers/otus_controller.rb on lines 205..213
    app/controllers/sequence_relationships_controller.rb on lines 87..95
    app/controllers/sequences_controller.rb on lines 125..133
    app/controllers/sequences_controller.rb on lines 151..159
    app/controllers/taxon_names_controller.rb on lines 180..188

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

      def preview_gpx_batch_load
        if params[:file]
          @result = BatchLoad::Import::CollectingEvents::GpxInterpreter.new(**batch_params)
          digest_cookie(params[:file].tempfile, :gpx_batch_load_collecting_events_md5)
          render 'collecting_events/batch_load/gpx/preview'
    Severity: Major
    Found in app/controllers/collecting_events_controller.rb and 11 other locations - About 30 mins to fix
    app/controllers/collecting_events_controller.rb on lines 165..173
    app/controllers/collection_objects_controller.rb on lines 219..227
    app/controllers/collection_objects_controller.rb on lines 245..253
    app/controllers/descriptors_controller.rb on lines 104..112
    app/controllers/namespaces_controller.rb on lines 96..104
    app/controllers/otus_controller.rb on lines 153..161
    app/controllers/otus_controller.rb on lines 205..213
    app/controllers/sequence_relationships_controller.rb on lines 87..95
    app/controllers/sequences_controller.rb on lines 125..133
    app/controllers/sequences_controller.rb on lines 151..159
    app/controllers/taxon_names_controller.rb on lines 180..188

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

      def preview_simple_batch_load
        if params[:file]
          @result = BatchLoad::Import::CollectingEvents.new(**batch_params)
          digest_cookie(params[:file].tempfile, :batch_collecting_events_md5)
          render 'collecting_events/batch_load/simple/preview'
    Severity: Minor
    Found in app/controllers/collecting_events_controller.rb and 2 other locations - About 30 mins to fix
    app/controllers/asserted_distributions_controller.rb on lines 107..115
    app/controllers/taxon_names_controller.rb on lines 154..162

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

    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

        }.collect{|b| {'name' => b.name, 'type' => b.type } }

    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

        }.collect{|b| {'name' => b.name, 'type' => b.type } }

    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 single-quoted strings when you don't need string interpolation or special symbols.
    Open

          flash[:notice] = "No file provided!"

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    There are no issues that match your filters.

    Category
    Status