bikeindex/bike_index

View on GitHub

Showing 160 of 166 total issues

Class Export has 43 methods (exceeds 40 allowed). Consider refactoring.
Open

class Export < ApplicationRecord
  PROGRESS_ENUM = %i[pending ongoing finished errored].freeze
  VALID_KINDS = %i[organization stolen manufacturer].freeze
  VALID_FILE_FORMATS = %i[csv xlsx].freeze
  DEFAULT_HEADERS = %w[link registered_at manufacturer model color serial is_stolen].freeze
Severity: Minor
Found in app/models/export.rb - About 2 hrs to fix

    Method search_organization_bikes has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
    Open

        def search_organization_bikes
          @permitted_org_bike_search_params = permitted_org_bike_search_params.except(:stolenness, :timezone, :period).values.reject(&:blank?)
          @search_query_present = permitted_org_bike_search_params.except(:stolenness, :timezone, :period).values.reject(&:blank?).any?
          @interpreted_params = Bike.searchable_interpreted_params(permitted_org_bike_search_params, ip: forwarded_ip_address)
          org = current_organization || passive_organization
    Severity: Minor
    Found in app/controllers/organized/bikes_controller.rb - About 2 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 resolve_token has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
    Open

      def resolve_token
        if params[:token_type] == "graduated_notification"
          matching_notification = GraduatedNotification.where(bike_id: @bike.id, marked_remaining_link_token: params[:token]).first
          if matching_notification.present? && matching_notification.processed?
            if matching_notification.marked_remaining_at.blank?
    Severity: Minor
    Found in app/controllers/bikes_controller.rb - About 2 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 set_calculated_attributes has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
    Open

      def set_calculated_attributes
        self.kind ||= calculated_kind
        if imported_tweet?
          self.body_html ||= self.class.auto_link_text(trh[:text]) if trh.dig(:text).present?
          self.alignment ||= VALID_ALIGNMENTS.first
    Severity: Minor
    Found in app/models/tweet.rb - About 2 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 perform has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
    Open

      def perform(bike_id)
        bike = Bike.unscoped.find_by_id(bike_id)
        return true if bike.blank?
    
        should_delete = bike.blank? || bike.deleted_at.present? || bike.example ||
    Severity: Minor
    Found in app/workers/duplicate_bike_finder_worker.rb - About 2 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 bikes_header_tags has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
    Open

      def bikes_header_tags
        meta_overrides = {}
        if (action_name == "new" || action_name == "create") && @bike.status_stolen?
          self.page_title = translation_title(location: "meta_titles.bikes_new_stolen")
          self.page_description = translation_description(location: "meta_descriptions.bikes_new_stolen")
    Severity: Minor
    Found in app/helpers/header_tag_helper.rb - About 2 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

    Class Invoice has 42 methods (exceeds 40 allowed). Consider refactoring.
    Open

    class Invoice < ApplicationRecord
      include Amountable # included for formatting stuff
      belongs_to :organization
      belongs_to :first_invoice, class_name: "Invoice" # Use subscription_first_invoice_id + subscription_first_invoice, NOT THIS
    
    
    Severity: Minor
    Found in app/models/invoice.rb - About 2 hrs to fix

      Method set_calculated_attributes has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring.
      Open

        def set_calculated_attributes
          return true unless name.present?
          self.name = strip_name_tags(name)
          self.name = "Stop messing about" unless name[/\d|\w/].present?
          self.website = Urlifyer.urlify(website) if website.present?
      Severity: Minor
      Found in app/models/organization.rb - About 2 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 searched_theft_alerts has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring.
      Open

        def searched_theft_alerts
          @search_recovered = InputNormalizer.boolean(params[:search_recovered])
          theft_alerts = if @search_recovered
            stolen_record_ids = StolenRecord.recovered.with_theft_alerts
              .where(theft_alerts: {created_at: @time_range}).pluck(:id)
      Severity: Minor
      Found in app/controllers/admin/theft_alerts_controller.rb - About 2 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 perform has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring.
      Open

        def perform(user_id, user = nil, skip_bike_update = false)
          user ||= User.find_by_id(user_id)
          return false unless user.present?
          # Bump updated_at to bust cache
          user.update(updated_at: Time.current, skip_update: true)
      Severity: Minor
      Found in app/workers/after_user_change_worker.rb - About 2 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 matching_payments has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring.
      Open

        def matching_payments
          return @matching_payments if defined?(@matching_payments)
          matching_payments = Payment
          if sort_column == "invoice_id"
            matching_payments = matching_payments.where.not(invoice_id: nil)
      Severity: Minor
      Found in app/controllers/admin/payments_controller.rb - About 2 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 perform has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring.
      Open

        def perform(impound_record_id)
          impound_record = ImpoundRecord.find(impound_record_id)
          bike = impound_record.bike
          if impound_record.organized?
            impound_configuration = impound_record.impound_configuration
      Severity: Minor
      Found in app/workers/process_impound_updates_worker.rb - About 2 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

      Function BinxAdminImageUploader has 77 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      function BinxAdminImageUploader() {
        return {
          init() {
            this.uppyFileUpload();
          },
      Severity: Major
      Found in app/javascript/scripts/pages/admin/image_uploader.js - About 2 hrs to fix

        Method clean_frame_size has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
        Open

          def clean_frame_size
            return true unless frame_size.present? || frame_size_number.present?
            if frame_size.present? && frame_size.match(/\d+\.?\d*/).present?
              # Don't overwrite frame_size_number if frame_size_number was passed
              if frame_size_number.blank? || !frame_size_number_changed?
        Severity: Minor
        Found in app/models/stolen_bike_listing.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 clean_frame_size has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
        Open

          def clean_frame_size
            return true unless frame_size.present? || frame_size_number.present?
            if frame_size.present? && frame_size.match(/\d+\.?\d*/).present?
              # Don't overwrite frame_size_number if frame_size_number was passed
              if frame_size_number.blank? || !frame_size_number_changed?
        Severity: Minor
        Found in app/models/bike.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 creation_badges has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
        Open

          def self.creation_badges(ownership = nil, bike = nil)
            return [] unless ownership.present?
            return [:example_bike] if bike&.example?
            return [:created_at_point_of_sale] if ownership.pos?
            c_badges = [creation_age_badge(bike || ownership.bike)].compact
        Severity: Minor
        Found in app/services/credibility_scorer.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 add_bike_book_data has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
        Open

          def add_bike_book_data(b_param = nil)
            return nil unless b_param&.bike.present? && b_param.manufacturer_id.present?
            return nil unless b_param.bike["frame_model"].present? && b_param.bike["year"].present?
            bb_data = BikeBookIntegration.new.get_model({
              manufacturer: Manufacturer.find(b_param.bike["manufacturer_id"]).name,
        Severity: Minor
        Found in app/services/bike_creator.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 index has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
        Open

            def index
              @page = params[:page] || 1
              set_period
              @bike_sticker = BikeSticker.lookup_with_fallback(params[:bike_sticker], organization_id: current_organization.id) if params[:bike_sticker].present?
              if current_organization.enabled?("bike_search")
        Severity: Minor
        Found in app/controllers/organized/bikes_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 matching_bulk_imports has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
        Open

          def matching_bulk_imports
            return @matching_bulk_imports if defined?(@matching_bulk_imports)
            bulk_imports = BulkImport
            if params[:search_ascend].present?
              bulk_imports = bulk_imports.ascend
        Severity: Minor
        Found in app/controllers/admin/bulk_imports_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 19 (exceeds 10 allowed). Consider refactoring.
        Open

          def update
            @user = current_user
            if @user.present? && params[:user].present? && @user.update(permitted_parameters)
              if params.dig(:user, :terms_of_service).present?
                if InputNormalizer.boolean(params.dig(:user, :terms_of_service))
        Severity: Minor
        Found in app/controllers/users_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

        Severity
        Category
        Status
        Source
        Language