bestmike007/log4rails

View on GitHub

Showing 22 of 22 total issues

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

    def self.toggle_methods(globlev, logger)
      for lev in globlev...LEVELS # satisfies >= globlev
        next if lev < logger.level # satisfies >= level
        next if LNAMES[lev] == 'OFF'
        next if LNAMES[lev] == 'ALL'
Severity: Minor
Found in lib/log4r/loggerfactory.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 build has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def build(logger_name, timestamp, level, message, exception, file, line, method)
Severity: Major
Found in lib/log4r/formatter/log4jxmlformatter.rb - About 1 hr to fix

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

            def reassign_any_children(parent)
              synchronize do
                for _, logger in instance.loggers
                  next if logger.is_root?
                  logger.parent = parent if logger.path =~ /^#{parent.fullname}$/
    Severity: Minor
    Found in lib/log4r/repository.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 set_from_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_from_hash(hash)
          ParameterParsers.each { |s, options|
            v = nil
            if hash.has_key?(s) || hash.has_key?(s.to_s) 
              v = (hash[s] or hash[s.to_i]).to_i
    Severity: Minor
    Found in lib/log4r/outputter/rollingfileoutputter.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 validate_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_file
          if @filename.class != String
            raise TypeError, "Argument 'filename' must be a String"
          end
          if FileTest.exist?( @filename )
    Severity: Minor
    Found in lib/log4r/outputter/fileoutputter.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(_fullname, _uri, _level=nil, 
                       _additive=true, _trace=false, &accept)
    Severity: Minor
    Found in lib/log4r/logserver.rb - About 45 mins to fix

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

          def write(data)
            return if !@expecting
            data = data[0..-2]
            m = @expecting.instance_of?(Array) ? @expecting.shift : @expecting
            if m.instance_of? String
      Severity: Minor
      Found in lib/log4r/outputter/rspecoutputter.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 parse_global_level has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_global_level
              return unless @config.has_key?('pre_config')
              global_level = nil
              ['global', 'root'].each do |node|
                if @config['pre_config'].has_key?(node)
      Severity: Minor
      Found in lib/log4r/yaml_configurator.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 validate_smtp_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_smtp_params(hash)
            ParameterParsers.each { |k, v|
              v ||= {}
              value = hash[k] || hash[k.to_s]
              value ||= v[:default]
      Severity: Minor
      Found in lib/log4r/outputter/emailoutputter.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 find_ancestor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def find_ancestor(path)
                arr = path.split Log4rConfig::LoggerPathDelimiter
                logger = nil
                synchronize do
                  while arr.size > 0 do
      Severity: Minor
      Found in lib/log4r/repository.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 key_to_sym has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def key_to_sym(hash)
              keys = []
              hash.each do |k, v|
                unless k.instance_of?(Symbol)
                  keys << k
      Severity: Minor
      Found in lib/log4r/yaml_configurator.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 requires_roll? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def requires_roll?
            return false if @rolling
            @rolling = size_exceeded? || time_exceeded?
            if @rolling
              Logger.log_internal {
      Severity: Minor
      Found in lib/log4r/outputter/rollingfileoutputter.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 config_outputter_only_at has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def config_outputter_only_at
              if @config.has_key? :only_at
                only_at = @config[:only_at]
                only_levels = (only_at.instance_of?(Array) ? only_at : [only_at]).map{ |l| LNAMES.index(l) }
                Outputter[outputter_name].only_at(*only_levels) if only_levels.size > 0
      Severity: Minor
      Found in lib/log4r/configurator.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def add(*_outputters)
            for thing in _outputters
              o = (thing.kind_of?(Outputter) ? thing : Outputter[thing])
              # some basic validation
              unless o.kind_of?(Outputter)
      Severity: Minor
      Found in lib/log4r/logger.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 formatter= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def formatter=(_formatter)
            if _formatter.kind_of?(Formatter)
              @formatter = _formatter
            elsif _formatter.kind_of?(Class) and _formatter <= Formatter
              if _formatter.respond_to? :instance
      Severity: Minor
      Found in lib/log4r/outputter/outputter.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 format_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def format_object(obj)
            if obj.kind_of? Exception
              return "Caught #{obj.class}: #{obj.message}\n\t" +
                     (obj.backtrace.nil? ? [] : obj.backtrace[0...@depth]).join("\n\t")
            elsif obj.kind_of? String
      Severity: Minor
      Found in lib/log4r/formatter/formatter.rb - About 25 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_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_config
            # auto reload config every 30 seconds.
            return unless check_again?
            detect_existing_config_path
            return if File.mtime(@config_path) == @config_time
      Severity: Minor
      Found in lib/log4rails/log4r_config_watcher.rb - About 25 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 all_children has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def all_children(parent)
                # children have the parent name + delimiter in their fullname
                daddy = parent.name + Log4r::Log4rConfig::LoggerPathDelimiter
                synchronize do
                  for fullname, logger in instance.loggers
      Severity: Minor
      Found in lib/log4r/repository.rb - About 25 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 create_methods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def create_methods(out, levels=nil)
              Logger.root # force levels to be loaded
      
              # first, undefine all the log levels
              for mname in LNAMES
      Severity: Minor
      Found in lib/log4r/outputter/outputterfactory.rb - About 25 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 deal_with_inheritance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def deal_with_inheritance(_level)
            mypath = @fullname.split Log4rConfig::LoggerPathDelimiter
            @name = mypath.pop
            if mypath.empty? # then root is my daddy
              @path = ""
      Severity: Minor
      Found in lib/log4r/logger.rb - About 25 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