BookingSync/bookingsync-api

View on GitHub
lib/bookingsync/api/client.rb

Summary

Maintainability
C
1 day
Test Coverage

Method call has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def call(method, path, data = nil, options = nil)
      instrument("call.bookingsync_api", method: method, path: path) do
        if [:get, :head].include?(method)
          options = data
          data = {}
Severity: Minor
Found in lib/bookingsync/api/client.rb - About 3 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 Client has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Client
    extend Forwardable
    include BookingSync::API::Client::Accounts
    include BookingSync::API::Client::Amenities
    include BookingSync::API::Client::Applications
Severity: Minor
Found in lib/bookingsync/api/client.rb - About 3 hrs to fix

    File client.rb has 291 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "bookingsync/api/middleware/logger"
    require "bookingsync/api/client/accounts"
    require "bookingsync/api/client/amenities"
    require "bookingsync/api/client/applications"
    require "bookingsync/api/client/applications_periods_rentals"
    Severity: Minor
    Found in lib/bookingsync/api/client.rb - About 3 hrs to fix

      Method call has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def call(method, path, data = nil, options = nil)
            instrument("call.bookingsync_api", method: method, path: path) do
              if [:get, :head].include?(method)
                options = data
                data = {}
      Severity: Minor
      Found in lib/bookingsync/api/client.rb - About 1 hr to fix

        Method fetch_with_block has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def fetch_with_block(path, options, request_settings, response = nil, &block)
        Severity: Minor
        Found in lib/bookingsync/api/client.rb - About 35 mins to fix

          Method fetch_with_paginate has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def fetch_with_paginate(path, options, request_settings, data = [], response = nil)
          Severity: Minor
          Found in lib/bookingsync/api/client.rb - About 35 mins to fix

            Method fetch_with_paginate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def fetch_with_paginate(path, options, request_settings, data = [], response = nil)
                  response = initial_call(path, options, request_settings) unless response
                  data.concat(response.resources)
                  if response.relations[:next] && request_settings[:auto_paginate]
                    fetch_with_paginate(path, options, request_settings, data, next_page(response, request_settings))
            Severity: Minor
            Found in lib/bookingsync/api/client.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

            There are no issues that match your filters.

            Category
            Status