nadoka/nadoka

View on GitHub
ndk/config.rb

Summary

Maintainability
D
2 days
Test Coverage

File config.rb has 459 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'uri'
require 'socket'
require 'kconv'

require 'ndk/logger'
Severity: Minor
Found in ndk/config.rb - About 7 hrs to fix

    Method log_format_message has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def log_format_message msgfmts, msgobj
          type   = msgobj[:type]
          format = msgfmts.fetch(type, @config[:default_log][:message_format][type])
    
          if format.kind_of? Proc
    Severity: Minor
    Found in ndk/config.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 log_format_message has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def log_format_message msgfmts, msgobj
          type   = msgobj[:type]
          format = msgfmts.fetch(type, @config[:default_log][:message_format][type])
    
          if format.kind_of? Proc
    Severity: Minor
    Found in ndk/config.rb - About 1 hr to fix

      Method load_bots has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def load_bots
            # for compatibility
            return load_bots_old if @config[:botconfig].kind_of? Hash
            @bots = @config[:botconfig].map{|bot|
              if bot.kind_of? Hash
      Severity: Minor
      Found in ndk/config.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 load_bots_old has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def load_bots_old
            (@config[:botfiles] + (@config[:defaultbotfiles]||[])).each{|file|
              load_botfile file
            }
            
      Severity: Minor
      Found in ndk/config.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 channel_setting has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def channel_setting
            # treat with channel information
            if chs = @config[:channel_info]
              dchs = []
              lchs = []
      Severity: Minor
      Found in ndk/config.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 remove_previous_setting has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def remove_previous_setting
            # remove setting class
            base_klass = ConfigClass.shift
            while klass = ConfigClass.shift
              Object.module_eval{
      Severity: Minor
      Found in ndk/config.rb - About 1 hr to fix

        Method make_logwriter has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def make_logwriter log
              return unless log
              
              case log
              when Hash
        Severity: Minor
        Found in ndk/config.rb - About 1 hr to fix

          Method load_bots_old has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def load_bots_old
                (@config[:botfiles] + (@config[:defaultbotfiles]||[])).each{|file|
                  load_botfile file
                }
                
          Severity: Minor
          Found in ndk/config.rb - About 1 hr to fix

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

                def make_logwriter log
                  return unless log
                  
                  case log
                  when Hash
            Severity: Minor
            Found in ndk/config.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 load_botfile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def load_botfile file
                  loaded = false
                  
                  if @config[:plugins_dir].respond_to? :each
                    @config[:plugins_dir].each{|dir|
            Severity: Minor
            Found in ndk/config.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 server_setting has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def server_setting
                  if svrs = @config[:servers]
                    svl = []
                    svrs.each{|si|
                      ports = si[:port] || 6667
            Severity: Minor
            Found in ndk/config.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 make_default_logwriter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def make_default_logwriter
                  if @config[:default_log].kind_of? Hash
                    dl = @config[:default_log]
                  else
                    # defult_log must be Hash
            Severity: Minor
            Found in ndk/config.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

            There are no issues that match your filters.

            Category
            Status