lib/bookingsync/api/client.rb
Method call
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
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 = {}
- Read upRead up
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
Open
class Client
extend Forwardable
include BookingSync::API::Client::Accounts
include BookingSync::API::Client::Amenities
include BookingSync::API::Client::Applications
File client.rb
has 291 lines of code (exceeds 250 allowed). Consider refactoring. Open
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"
Method call
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 = {}
Method fetch_with_block
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def fetch_with_block(path, options, request_settings, response = nil, &block)
Method fetch_with_paginate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def fetch_with_paginate(path, options, request_settings, data = [], response = nil)
Method fetch_with_paginate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
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))
- Read upRead up
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"