ManageIQ/manageiq-api-client

View on GitHub
lib/manageiq/api/client/connection.rb

Summary

Maintainability
B
4 hrs
Test Coverage
A
93%

Method send_request has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def send_request(method, path, params, &block)
          begin
            @error = nil
            @response = handle.run_request(method.to_sym, api_path(path), nil, nil) do |request|
              request.headers[:content_type]  = CONTENT_TYPE
Severity: Minor
Found in lib/manageiq/api/client/connection.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 handle has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def handle
          ssl_options = @connection_options[:ssl]
          Faraday.new(:url => url, :ssl => ssl_options) do |faraday|
            faraday.request(:url_encoded) # form-encode POST params
            faraday.options.open_timeout = @connection_options[:open_timeout] if @connection_options[:open_timeout]
Severity: Minor
Found in lib/manageiq/api/client/connection.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 check_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def check_response
          if response.status == 404
            message = json_response["error"].kind_of?(String) ? json_response["error"] : json_response.dig("error", "message")
            raise ManageIQ::API::Client::ResourceNotFound, message
          elsif response.status >= 400
Severity: Minor
Found in lib/manageiq/api/client/connection.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

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

        def api_path(path)
          if path.to_s.start_with?(url.to_s)
            path.to_s
          elsif path.to_s.blank?
            URI.join(url, API_PREFIX).to_s
Severity: Minor
Found in lib/manageiq/api/client/connection.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