morizyun/http_status_checker

View on GitHub

Showing 4 of 4 total issues

Method get_response has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def get_response(url, wait_sec, redirect_url = nil, redirect_count = 0, retry_count = 0)
      result = HttpStatusChecker::Connection.get_header(redirect_url || url)
      parse_response(redirect_count, redirect_url, result, url, wait_sec)
    rescue => e
      if retry_count < RETRY_MAX
Severity: Minor
Found in lib/http_status_checker/base.rb - About 45 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 get_response has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def get_response(url, wait_sec, redirect_url = nil, redirect_count = 0, retry_count = 0)
Severity: Minor
Found in lib/http_status_checker/base.rb - About 35 mins to fix

    Method parse_response has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def parse_response(redirect_count, redirect_url, result, url, wait_sec)
    Severity: Minor
    Found in lib/http_status_checker/base.rb - About 35 mins to fix

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

          def parse_response(redirect_count, redirect_url, result, url, wait_sec)
            location_url = result['location']
            if !location_url.nil? && (redirect_url || url) != location_url
              raise InvalidRedirectError if redirect_count >= REDIRECT_MAX
              get_response(url, wait_sec, location_url, redirect_count + 1, 0)
      Severity: Minor
      Found in lib/http_status_checker/base.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

      Severity
      Category
      Status
      Source
      Language