ianheggie/health_check

View on GitHub

Showing 13 of 13 total issues

Method process_checks has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    def self.process_checks(checks, called_from_middleware = false)
      errors = ''
      checks.each do |check|
        case check
          when 'and', 'site'
Severity: Minor
Found in lib/health_check/utils.rb - About 1 day 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 index has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def index
      last_modified = Time.now.utc
      max_age = HealthCheck.max_age
      if max_age > 1
        last_modified = Time.at((last_modified.to_f / max_age).floor * max_age).utc
Severity: Minor
Found in lib/health_check/health_check_controller.rb - About 4 hrs 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 call has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def call(env)
      (response_type, middleware_checks, full_stack_checks) = parse_env(env)
      if response_type
        if error_response = (ip_blocked(env) || not_authenticated(env))
          return error_response
Severity: Minor
Found in lib/health_check/middleware_health_check.rb - About 3 hrs 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 process_checks has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.process_checks(checks, called_from_middleware = false)
      errors = ''
      checks.each do |check|
        case check
          when 'and', 'site'
Severity: Major
Found in lib/health_check/utils.rb - About 2 hrs to fix

    Method check has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def check
            unless defined?(::Aws)
              raise "Wrong configuration. Missing 'aws-sdk' or 'aws-sdk-s3' gem"
            end
            return create_error 's3', 'Could not connect to aws' if aws_s3_client.nil?
    Severity: Minor
    Found in lib/health_check/s3_health_check.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_cache has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.check_cache
          t = Time.now.to_i
          value = "ok #{t}"
          ret = ::Rails.cache.read('__health_check_cache_test__')
          if ret.to_s =~ /^ok (\d+)$/ 
    Severity: Minor
    Found in lib/health_check/utils.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 index has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def index
          last_modified = Time.now.utc
          max_age = HealthCheck.max_age
          if max_age > 1
            last_modified = Time.at((last_modified.to_f / max_age).floor * max_age).utc
    Severity: Minor
    Found in lib/health_check/health_check_controller.rb - About 1 hr to fix

      Method call has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def call(env)
            (response_type, middleware_checks, full_stack_checks) = parse_env(env)
            if response_type
              if error_response = (ip_blocked(env) || not_authenticated(env))
                return error_response
      Severity: Minor
      Found in lib/health_check/middleware_health_check.rb - About 1 hr to fix

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

              def check
                raise "Wrong configuration. Missing 'redis' gem" unless defined?(::Redis)
        
                client.ping == 'PONG' ? '' : "Redis.ping returned #{res.inspect} instead of PONG"
              rescue Exception => err
        Severity: Minor
        Found in lib/health_check/redis_health_check.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 check_smtp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.check_smtp(settings, timeout)
              status = ''
              begin
                if @skip_external_checks
                  status = '250'
        Severity: Minor
        Found in lib/health_check/utils.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 check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.check
              unless defined?(::Sidekiq)
                raise "Wrong configuration. Missing 'sidekiq' gem"
              end
              ::Sidekiq.redis do |r|
        Severity: Minor
        Found in lib/health_check/sidekiq_health_check.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 check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.check
              unless defined?(::Elasticsearch)
                raise "Wrong configuration. Missing 'elasticsearch' gem"
              end
              res = ::Elasticsearch::Client.new.ping
        Severity: Minor
        Found in lib/health_check/elasticsearch_health_check.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 check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

             def self.check
               unless defined?(::Resque)
                 raise "Wrong configuration. Missing 'resque' gem"
               end
              res = ::Resque.redis.ping
        Severity: Minor
        Found in lib/health_check/resque_health_check.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