padrino/padrino-framework

View on GitHub
padrino-core/lib/padrino-core/logger.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method setup! has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def self.setup!
      config_level = (PADRINO_LOG_LEVEL || Padrino.env || :test).to_sym # need this for PADRINO_LOG_LEVEL
      config = Config[config_level]

      unless config
Severity: Minor
Found in padrino-core/lib/padrino-core/logger.rb - About 2 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

Class Logger has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Logger
    ##
    # Ruby (standard) logger levels:
    #
    # :fatal:: An not handleable error that results in a program crash
Severity: Minor
Found in padrino-core/lib/padrino-core/logger.rb - About 2 hrs to fix

    Method initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(options={})
          @buffer           = []
          @auto_flush       = options.has_key?(:auto_flush) ? options[:auto_flush] : true
          @level            = options[:log_level] ? Padrino::Logger::Levels[options[:log_level]] : Padrino::Logger::Levels[:debug]
          @log              = options[:stream]  || $stdout
    Severity: Minor
    Found in padrino-core/lib/padrino-core/logger.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 setup! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.setup!
          config_level = (PADRINO_LOG_LEVEL || Padrino.env || :test).to_sym # need this for PADRINO_LOG_LEVEL
          config = Config[config_level]
    
          unless config
    Severity: Minor
    Found in padrino-core/lib/padrino-core/logger.rb - About 1 hr to fix

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

            def bench(action, began_at, message, level=:debug, color=:yellow)
      Severity: Minor
      Found in padrino-core/lib/padrino-core/logger.rb - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status