Showing 3 of 5 total issues
Method connection
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def connection(format: nil, params: {})
# The format parameter is used to specify the format of the request.
# Alma supports both JSON and XML, but the default is JSON.
format = case AlmaApi.validate_format!(format)
when "xml" then "application/xml"
Method base_url=
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def base_url=(value)
if value.is_a?(Symbol)
raise ArgumentError, "Invalid gateway: #{value}" unless GATEWAYS.keys.include?(value)
@base_url = GATEWAYS[value]
- 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
Method handle_faraday_error
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def handle_faraday_error(error)
# The error response body is either XML, JSON or empty, so we need to parse it
error_message, error_code = parse_error_response_body(error.response_body)
if error_message.present? && error_code.present?
- 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"