sharetribe/sharetribe

View on GitHub
app/controllers/people_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

File people_controller.rb has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class PeopleController < Devise::RegistrationsController
  include ConfigRecaptcha

  skip_before_action :verify_authenticity_token, :only => [:create]
  skip_before_action :require_no_authentication, :only => [:new]
Severity: Minor
Found in app/controllers/people_controller.rb - About 3 hrs to fix

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

      def create
        domain = @current_community ? @current_community.full_url : "#{request.protocol}#{request.host_with_port}"
        error_redirect_path = domain + sign_up_path
    
        unless validate_recaptcha(params['g-recaptcha-response'])
    Severity: Minor
    Found in app/controllers/people_controller.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 update has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def update
        target_user = Person.find_by!(username: params[:id], community_id: @current_community.id)
        if @current_user != target_user
          logger.info "ADMIN ACTION: admin='#{@current_user.id}' update person='#{target_user.id}' params=#{params.inspect}"
        end
    Severity: Minor
    Found in app/controllers/people_controller.rb - About 2 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 update has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def update
        target_user = Person.find_by!(username: params[:id], community_id: @current_community.id)
        if @current_user != target_user
          logger.info "ADMIN ACTION: admin='#{@current_user.id}' update person='#{target_user.id}' params=#{params.inspect}"
        end
    Severity: Major
    Found in app/controllers/people_controller.rb - About 2 hrs to fix

      Method create has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          domain = @current_community ? @current_community.full_url : "#{request.protocol}#{request.host_with_port}"
          error_redirect_path = domain + sign_up_path
      
          unless validate_recaptcha(params['g-recaptcha-response'])
      Severity: Minor
      Found in app/controllers/people_controller.rb - About 2 hrs to fix

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

          def person_create_params(params)
            result = params.require(:person).slice(
                :given_name,
                :family_name,
                :display_name,
        Severity: Minor
        Found in app/controllers/people_controller.rb - About 1 hr to fix

          Avoid too many return statements within this method.
          Open

                redirect_to error_redirect_path and return
          Severity: Major
          Found in app/controllers/people_controller.rb - About 30 mins to fix

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

              def new
                @selected_tribe_navi_tab = "members"
                redirect_to search_path if logged_in?
                session[:invitation_code] = params[:code] if params[:code]
                service_init
            Severity: Minor
            Found in app/controllers/people_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

            There are no issues that match your filters.

            Category
            Status