sharetribe/sharetribe

View on GitHub
app/controllers/homepage_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

Method index has 107 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def index
    params = unsafe_params_hash.select{|k, v| v.present? }

    redirect_to landing_page_path and return if no_current_user_in_private_clp_enabled_marketplace?

Severity: Major
Found in app/controllers/homepage_controller.rb - About 4 hrs to fix

    File homepage_controller.rb has 319 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class HomepageController < ApplicationController
    
      before_action :save_current_path, :except => :sign_in
    
      APP_DEFAULT_VIEW_TYPE = "grid".freeze
    Severity: Minor
    Found in app/controllers/homepage_controller.rb - About 3 hrs to fix

      Method index has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          params = unsafe_params_hash.select{|k, v| v.present? }
      
          redirect_to landing_page_path and return if no_current_user_in_private_clp_enabled_marketplace?
      
      
      Severity: Minor
      Found in app/controllers/homepage_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 location_search_params has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def location_search_params(params, keyword_search_in_use)
          marketplace_configuration = @current_community.configuration
      
          distance = params[:distance_max].to_f
          distance_system = marketplace_configuration ? marketplace_configuration[:distance_unit].to_sym : nil
      Severity: Minor
      Found in app/controllers/homepage_controller.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 find_listings has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def find_listings(params:, current_page:, listings_per_page:, filter_params:, includes:, location_search_in_use:, keyword_search_in_use:, relevant_search_fields:)
      
          search = {
            # Add listing_id
            categories: filter_params[:categories],
      Severity: Minor
      Found in app/controllers/homepage_controller.rb - About 1 hr to fix

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

          def location_search_params(params, keyword_search_in_use)
            marketplace_configuration = @current_community.configuration
        
            distance = params[:distance_max].to_f
            distance_system = marketplace_configuration ? marketplace_configuration[:distance_unit].to_sym : nil
        Severity: Minor
        Found in app/controllers/homepage_controller.rb - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

              if FeatureFlagHelper.feature_enabled?(:searchpage_v1)
                @view_type = "grid"
              else
                @view_type = SearchPageHelper.selected_view_type(params[:view], @current_community.default_browse_view, APP_DEFAULT_VIEW_TYPE, allowed_view_types)
                @big_cover_photo = !(@current_user || CustomLandingPage::LandingPageStore.enabled?(@current_community.id)) || params[:big_cover_photo]
          Severity: Major
          Found in app/controllers/homepage_controller.rb - About 40 mins to fix

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

              def find_listings(params:, current_page:, listings_per_page:, filter_params:, includes:, location_search_in_use:, keyword_search_in_use:, relevant_search_fields:)
            
                search = {
                  # Add listing_id
                  categories: filter_params[:categories],
            Severity: Minor
            Found in app/controllers/homepage_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