bikeindex/bike_index

View on GitHub

Showing 161 of 167 total issues

Avoid too many return statements within this method.
Open

      redirect_to(discourse_authentication_url) && (return true)
Severity: Major
Found in app/controllers/concerns/controller_helpers.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            redirect_to(new_session_url(partner: sign_in_partner)) && return
    Severity: Major
    Found in app/controllers/concerns/controller_helpers.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return u.member_bike_edit_of?(org) && editable_organization_ids.include?(org.id) if org.present?
      Severity: Major
      Found in app/models/bike.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return nil unless new_str.split("-").first.to_i.between?(EARLIEST_YEAR, LATEST_YEAR)
        Severity: Major
        Found in app/services/time_parser.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return true if BikeSticker.where(id: sticker_ids).any?(&:user_editable?)
          Severity: Major
          Found in app/services/bike_displayer.rb - About 30 mins to fix

            Method clean_state_and_street_data has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def clean_state_and_street_data
                # remove state if it's not for the same country - we currently only handle us states
                if country_id.present? && state_id.present?
                  self.state_id = nil unless state&.country_id == country_id
                end
            Severity: Minor
            Found in app/models/concerns/geocodeable.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 searchable_query_items_manufacturer has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def searchable_query_items_manufacturer(query_params)
                  # we expect a singular manufacturer but deal with arrays because the multi-select search
                  manufacturer_id = extracted_query_items_manufacturer_id(query_params)
                  if manufacturer_id && !manufacturer_id.is_a?(Integer)
                    manufacturer_id = [manufacturer_id].flatten.map { |m_id|
            Severity: Minor
            Found in app/models/concerns/bike_searchable.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 bike_templates has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def bike_templates
                {}.with_indifferent_access.tap do |h|
                  h[:bike_details] = translation(:bike_details, scope: t_scope)
                  h[:found_details] = translation(:found_details, scope: t_scope) if @bike.status_found?
                  h[:photos] = translation(:photos, scope: t_scope)
            Severity: Minor
            Found in app/controllers/concerns/bike_editable.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 matching_feedbacks has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def matching_feedbacks
                feedbacks = Feedback
                if params[:search_kind].present? && permitted_kinds.include?(params[:search_kind])
                  @search_kind = params[:search_kind]
                  feedbacks = feedbacks.send(@search_kind) unless @search_kind == "all"
            Severity: Minor
            Found in app/controllers/admin/feedbacks_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 set_paint_key has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def set_paint_key(paint_entry)
                return nil unless paint_entry.present?
            
                paint = Paint.friendly_find(paint_entry)
            
            
            Severity: Minor
            Found in app/models/b_param.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 matching_bike_sticker_updates has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def matching_bike_sticker_updates
                bike_sticker_updates = BikeStickerUpdate.all
                bike_stickers = BikeSticker.all
                if params[:organization_id] == "none"
                  bike_sticker_updates = bike_sticker_updates.where(organization_id: nil)
            Severity: Minor
            Found in app/controllers/admin/bike_sticker_updates_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 clean_city has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def clean_city(str)
                if str.match?(/(,|\.)\s*\w\w\s*\z/) && country_id == Country.united_states.id
                  str_state_abbr = str[/(,|\.)\s*\w\w\s*\z/].gsub(/,|\./, "").strip.downcase
                  str_no_state = str.gsub(/(,|\.)\s*\w\w\s*\z/, "")
                  if state_id.present?
            Severity: Minor
            Found in app/models/concerns/geocodeable.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 by_proximity has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def by_proximity
                return unless is_proximity
                stolen_ids = @bikes.pluck(:current_stolen_record_id)
                return unless stolen_ids.present?
                if @params[:proximity_radius].present? && @params[:proximity_radius].to_i > 1
            Severity: Minor
            Found in app/services/bike_searcher.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 visible_by? has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def visible_by?(passed_user = nil)
                return true unless user_hidden || deleted?
                if passed_user.present?
                  return true if passed_user.superuser?
                  return false if deleted?
            Severity: Minor
            Found in app/models/bike.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 matching_impound_records has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def matching_impound_records
                impound_records = ImpoundRecord
            
                if params[:search_status] == "all"
                  @search_status = "all"
            Severity: Minor
            Found in app/controllers/admin/impound_records_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 find_mail_snippets has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def find_mail_snippets
                  @organization = current_organization
                  @kind = if MailSnippet.organization_emails_with_snippets.include?(params[:id]) || params[:id] == "organization_stolen_message"
                    params[:id]
                  else
            Severity: Minor
            Found in app/controllers/organized/emails_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 creation_user_id has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                    def creation_user_id
                      if permanent_token? || doorkeeper_authorized_no_user?
                        # current_organization requires token user to be authorized - V2_ACCESSOR is not
                        organization = Organization.friendly_find(params[:organization_slug])
                        if organization.present? && current_token&.application&.owner&.admin_of?(organization)
            Severity: Minor
            Found in app/controllers/api/v2/bikes.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 update has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def update
                # Needs to update approved before saving so set_locations_shown is applied on save
            
                # Also, special handling because we need to be able to unset manual_pos_kind
                manual_pos_kind = params.dig(:organization, :manual_pos_kind)
            Severity: Minor
            Found in app/controllers/admin/organizations_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 has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def create
                  @b_param = find_or_new_b_param
                  iframe_redirect_params = {organization_id: current_organization.to_param}
                  if @b_param.created_bike.present?
                    flash[:success] = "#{@bike.created_bike.type} Created"
            Severity: Minor
            Found in app/controllers/organized/bikes_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 write_excel has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

              def write_excel(file)
                axlsx_package = Axlsx::Package.new
                axlsx_package.workbook.add_worksheet(name: "Basic Worksheet") do |sheet|
                  sheet.add_row(export_headers)
                  row_index = 0
            Severity: Minor
            Found in app/workers/organization_export_worker.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

            Severity
            Category
            Status
            Source
            Language