ianheggie/health_check

View on GitHub
lib/health_check/utils.rb

Summary

Maintainability
D
1 day
Test Coverage

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 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_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 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

    There are no issues that match your filters.

    Category
    Status