ubpb/alma_api

View on GitHub

Showing 3 of 5 total issues

Method connection has 30 lines of code (exceeds 25 allowed). Consider refactoring.
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"
Severity: Minor
Found in lib/alma_api/client.rb - About 1 hr to fix

    Method base_url= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def base_url=(value)
          if value.is_a?(Symbol)
            raise ArgumentError, "Invalid gateway: #{value}" unless GATEWAYS.keys.include?(value)
    
            @base_url = GATEWAYS[value]
    Severity: Minor
    Found in lib/alma_api/configuration.rb - About 35 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

    Method handle_faraday_error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    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?
    Severity: Minor
    Found in lib/alma_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

    Severity
    Category
    Status
    Source
    Language