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?
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
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?
- Read upRead up
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
- Read upRead up
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],
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
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]
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],
- Read upRead up
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"