bikeindex/bike_index

View on GitHub

Showing 167 of 167 total issues

Method available_stolen_records has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

  def available_stolen_records
    return @available_stolen_records if defined?(@available_stolen_records)
    @unapproved_only = !InputNormalizer.boolean(params[:search_unapproved])
    @only_without_location = InputNormalizer.boolean(params[:search_without_location])
    if @unapproved_only
Severity: Minor
Found in app/controllers/admin/stolen_bikes_controller.rb - About 55 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 ensure_user_allowed_to_edit has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

  def ensure_user_allowed_to_edit
    @current_ownership = @bike.current_ownership
    type = @bike&.type || "bike"

    return true if @bike.authorize_and_claim_for_user(current_user)
Severity: Minor
Found in app/controllers/bikes/base_controller.rb - About 55 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 extracted_searchable_proximity_hash has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def extracted_searchable_proximity_hash(query_params, ip)
      return false unless query_params[:stolenness] == "proximity"
      location = query_params[:location]
      return false unless location && !(location =~ /anywhere/i)
      distance = query_params[:distance]&.to_i
Severity: Minor
Found in app/models/concerns/bike_searchable.rb - About 55 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_organizations has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

  def matching_organizations
    return @matching_organizations if defined?(@matching_organizations)
    @search_paid = InputNormalizer.boolean(params[:search_paid])
    matching_organizations = Organization.unscoped.where(deleted_at: nil) # We don't want deleted orgs
    matching_organizations = matching_organizations.paid if @search_paid
Severity: Minor
Found in app/controllers/admin/organizations_controller.rb - About 55 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 load_all has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def load_all(kinds = nil, print_counts: false)
      store_category_combos
      kinds ||= %w[Color CycleType Manufacturer PropulsionType]
      total_count = 0

Severity: Minor
Found in app/services/autocomplete/loader.rb - About 55 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 show has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

  def show
    @blog = Blog.friendly_find(params[:id])

    unless @blog
      raise ActionController::RoutingError.new("Not Found")
Severity: Minor
Found in app/controllers/news_controller.rb - About 55 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_or_new_from_token has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

  def self.find_or_new_from_token(toke = nil, user_id: nil, organization_id: nil, bike_sticker: nil)
    b = where(creator_id: user_id, id_token: toke).first if toke.present? && user_id.present?
    b ||= with_organization_or_no_creator(toke)
    b ||= BParam.new(creator_id: user_id, params: {revised_new: true}.as_json)
    b.creator_id ||= user_id
Severity: Minor
Found in app/models/b_param.rb - About 55 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 calculated_enabled_feature_slugs has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

  def calculated_enabled_feature_slugs
    fslugs = current_invoices.feature_slugs
    # If part of a region with bike_stickers, the organization receives the stickers organization feature
    if regional_parents.any?
      if regional_parents.any? { |o| o.enabled?("bike_stickers") }
Severity: Minor
Found in app/models/organization.rb - About 55 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 14 (exceeds 10 allowed). Consider refactoring.
Open

  def update
    @user_alert = current_user.user_alerts.find_by_id(params[:id])
    if @user_alert.present?
      if params[:alert_action] == "dismiss"
        if @user_alert.dismissable?
Severity: Minor
Found in app/controllers/user_alerts_controller.rb - About 55 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 user_info has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

          def user_info
            return {} unless current_scopes.include?("read_user")
            {
              user: {
                username: current_user.username,
Severity: Minor
Found in app/controllers/api/v3/me.rb - About 55 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 perform has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

  def perform(graduated_notification_id, marked_remaining_by_id = nil)
    graduated_notification = GraduatedNotification.find(graduated_notification_id)
    if graduated_notification.marked_remaining?
      return unless graduated_notification.user_registration_organization&.deleted_at.present?
    end
Severity: Minor
Found in app/workers/mark_graduated_notification_remaining_worker.rb - About 55 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 sortable has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
Open

  def sortable(column, title = nil, html_options = {})
    if title.is_a?(Hash) # If title is a hash, it wasn't passed
      html_options = title
      title = nil
    end
Severity: Minor
Found in app/helpers/application_helper.rb - About 45 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

Avoid deeply nested control flow statements.
Open

        if str_length < 15
          vowel_percent
        elsif str_length < 30
          vowel_percent + 15
        else
Severity: Major
Found in app/services/spam_estimator.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                elsif feedback_type.match?("bike_recovery")
                  recover_bike(bike, feedback)
    Severity: Major
    Found in app/controllers/api/v1/users_controller.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                    if bike.manufacturer_id.present?
                      bike.save
                      feedback.feedback_hash[:new_manufacturer] = bike.manufacturer.name
                    end
      Severity: Major
      Found in app/controllers/api/v1/users_controller.rb - About 45 mins to fix

        Method user_badges has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
        Open

          def self.user_badges(user)
            return [] unless user.present?
            return [:user_banned] if user.banned
            return [:user_ambassador] if user.ambassador?
            badges = []
        Severity: Minor
        Found in app/services/credibility_scorer.rb - About 45 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_notifications has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
        Open

          def matching_notifications
            notifications = Notification
            if permitted_scopes.include?(params[:search_kind])
              @kind = params[:search_kind]
              notifications = notifications.send(@kind)
        Severity: Minor
        Found in app/controllers/admin/notifications_controller.rb - About 45 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

        Avoid deeply nested control flow statements.
        Open

                  flash[:success] = if @user.memberships.any?
                    translation(:you_can_use_bike_index_as_org, org_name: @user.memberships.first.organization.name)
                  else
                    translation(:thanks_for_accepting_tos)
                  end
        Severity: Major
        Found in app/controllers/users_controller.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                        if bike.manufacturer_other.present?
                          feedback.feedback_hash[:old_manufacturer] += " (#{bike.manufacturer_other})"
                          bike.manufacturer_other = nil
                        end
          Severity: Major
          Found in app/controllers/api/v1/users_controller.rb - About 45 mins to fix

            Method searchable_query_items_colors has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
            Open

                def searchable_query_items_colors(query_params)
                  # params[:colors] should be an array (or a comma delineated string) - otherwise we parse out of the query string
                  if query_params[:colors].present?
                    colors = query_params[:colors].is_a?(String) ? query_params[:colors].split(",") : query_params[:colors]
                    return {colors: colors.map { |id| Color.friendly_find_id(id) }.compact}
            Severity: Minor
            Found in app/models/concerns/bike_searchable.rb - About 45 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