sealink/quicktravel_client

View on GitHub

Showing 7 of 7 total issues

Class Booking has 42 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Booking < Adapter
    def self.api_base
      '/api/bookings'
    end

Severity: Minor
Found in lib/quick_travel/booking.rb - About 5 hrs to fix

    Class ProductConfiguration has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class ProductConfiguration
        attr_reader :product, :extra_pick_configurations
        delegate :id, :name, to: :product
    
        def initialize(product)
    Severity: Minor
    Found in lib/quick_travel/product_configuration.rb - About 3 hrs to fix

      Method cache has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.cache(key, cache_options = nil)
            return yield unless key.present?
            cache_options ||= {}
            key = "#{@@namespace}_#{key}" unless cache_options[:disable_namespacing]
            cached_value = cache_store.read(key)
      Severity: Minor
      Found in lib/quick_travel/cache.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 call_and_validate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.call_and_validate(http_method, path, query = {}, opts = {})
            http_params = opts.clone
            # Set default token
            http_params[:query]   ||= FilterQuery.new(query).call
            http_params[:headers] ||= {}
      Severity: Minor
      Found in lib/quick_travel/adapter.rb - About 1 hr to fix

        Method define_readers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def define_readers(keys)
              keys.each do |key|
                next if respond_to?(key)
                define_singleton_method(key) { instance_variable_get("@#{key}") }
                if key.to_s.ends_with? '_cents'
        Severity: Minor
        Found in lib/quick_travel/init_from_hash.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 call_and_validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.call_and_validate(http_method, path, query = {}, opts = {})
              http_params = opts.clone
              # Set default token
              http_params[:query]   ||= FilterQuery.new(query).call
              http_params[:headers] ||= {}
        Severity: Minor
        Found in lib/quick_travel/adapter.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

        Avoid too many return statements within this method.
        Open

              return convert(value, :to_datetime) if attribute.to_s.ends_with?('_at')
        Severity: Major
        Found in lib/quick_travel/init_from_hash.rb - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language