stefan-kolb/nucleus

View on GitHub
lib/nucleus/core/adapter_extensions/http_client.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method add_common_request_params has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def add_common_request_params(params)
        common_params = { connection_timeout: 610, write_timeout: 600, read_timeout: 600 }
        # allow to follow redirects in the APIs
        allowed_status_codes = params.key?(:expects) ? [*params[:expects]] : []
        allowed_status_codes.concat([301, 302, 303, 307, 308]) unless params[:follow_redirects] == false
Severity: Minor
Found in lib/nucleus/core/adapter_extensions/http_client.rb - About 55 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 execute_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def execute_request(method, default_expect, path, params, native_call = false)
Severity: Minor
Found in lib/nucleus/core/adapter_extensions/http_client.rb - About 35 mins to fix

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

          def execute_request(method, default_expect, path, params, native_call = false)
            params[:expects] = default_expect unless params.key? :expects
            params[:method] = method
    
            url = Regexp::PERFECT_URL_PATTERN =~ path ? path : to_url(path)
    Severity: Minor
    Found in lib/nucleus/core/adapter_extensions/http_client.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

    There are no issues that match your filters.

    Category
    Status