bikeindex/bike_index

View on GitHub

Showing 161 of 167 total issues

Method calculated_pos_kind has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
Open

  def self.calculated_pos_kind(organization)
    return organization.manual_pos_kind if organization.manual_pos_kind.present?
    bikes = organization.created_bikes # NOTE: Only created, so regional orgs don't get them
    recent_bikes = bikes.where(created_at: (Time.current - 1.week)..Time.current)
    if organization.ascend_name.present? || recent_bikes.ascend_pos.count > 0
Severity: Minor
Found in app/workers/update_organization_pos_kind_worker.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

Function localizedDateText has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
Open

  localizedDateText (
    time,
    singleFormat,
    preciseTime,
    includeSeconds,
Severity: Minor
Found in app/javascript/scripts/utils/time_parser.js - 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 update has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
Open

    def update
      if !@impound_claim.submitting?
        flash[:error] = if @impound_claim.responded?
          "That claim has already been responded to"
        else
Severity: Minor
Found in app/controllers/organized/impound_claims_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 update has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
Open

  def update
    if !@impound_claim.submitting?
      flash[:error] = if @impound_claim.responded?
        "That claim has already been responded to"
      else
Severity: Minor
Found in app/controllers/review_impound_claims_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

Function init has 56 lines of code (exceeds 50 allowed). Consider refactoring.
Open

    init () {
      this.initAdminSearchSelect()
      this.initBikeTabs()

      // Enable utilities
Severity: Major
Found in app/javascript/scripts/pages/admin/binx_admin.js - About 1 hr to fix

    Method states has 54 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

      def states
        [
          {name: "Alabama", abbr: "AL"},
          {name: "Alaska", abbr: "AK"},
          {name: "Arizona", abbr: "AZ"},
    Severity: Major
    Found in app/models/states_and_countries.rb - About 1 hr to fix

      Method parse has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

        def self.parse(payload, sso_secret = nil)
          sso = new
          sso.sso_secret = sso_secret if sso_secret
      
          parsed = Rack::Utils.parse_query(payload)
      Severity: Minor
      Found in app/models/single_sign_on.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 set_period has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

        def set_period
          @timezone ||= Time.zone
          # Set time period
          @period ||= params[:period]
          if @period == "custom"
      Severity: Minor
      Found in app/controllers/concerns/controller_helpers.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 matching_user_alerts has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

        def matching_user_alerts
          user_alerts = UserAlert
          if UserAlert.kinds.include?(params[:search_kind])
            @kind = params[:search_kind]
            user_alerts = user_alerts.where(kind: @kind)
      Severity: Minor
      Found in app/controllers/admin/user_alerts_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 perform has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

        def perform(bike_id)
          bike = Bike.unscoped.where(id: bike_id).first
          if bike.present?
            bb_data = BikeBookIntegration.new.get_model(bike)
      
      
      Severity: Minor
      Found in app/workers/bike_book_update_worker.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

      Function exports has 51 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      module.exports = function (api) {
        var validEnv = ['development', 'test', 'production']
        var currentEnv = api.env()
        var isDevelopmentEnv = api.env('development')
        var isProductionEnv = api.env('production')
      Severity: Major
      Found in babel.config.js - About 1 hr to fix

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

          def set_location_info
            if current_stolen_record.present?
              # If there is a current stolen - even if it has a blank location - use it
              # It's used for searching and displaying stolen bikes, we don't want other information leaking
              self.attributes = if address_set_manually # Only set coordinates if the address is set manually
        Severity: Minor
        Found in app/models/bike.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 build_bike_status has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
        Open

          def build_bike_status
            self.max_char = compute_max_char
        
            location = ""
            if !close_twitter_accounts&.first&.default? && neighborhood.present?
        Severity: Minor
        Found in app/integrations/twitter_tweeter_integration.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 available_graduated_notifications has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
        Open

            def available_graduated_notifications
              return @available_graduated_notifications if defined?(@available_graduated_notifications)
              if params[:search_status] == "all"
                @search_status = "all"
                a_graduated_notifications = graduated_notifications
        Severity: Minor
        Found in app/controllers/organized/graduated_notifications_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 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

        Severity
        Category
        Status
        Source
        Language