nadoka/nadoka

View on GitHub

Showing 69 of 69 total issues

File server.rb has 644 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rice/irc'
require 'ndk/error'
require 'ndk/config'
require 'ndk/server_state'
require 'ndk/client'
Severity: Major
Found in ndk/server.rb - About 1 day to fix

    File irc.rb has 591 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'socket'
    require 'thread'
    require 'monitor'
    begin
      require "openssl"
    Severity: Major
    Found in rice/irc.rb - About 1 day to fix

      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 start_clients_thread has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

            def start_clients_thread
              return unless @config.client_server_port
              @clients_thread = Thread.new{
                begin
                  @cserver = TCPServer.new(@config.client_server_host,
        Severity: Minor
        Found in ndk/server.rb - About 6 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 server_main_proc has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

            def server_main_proc
              ## login
        
              # send passwd
              if @server_passwd
        Severity: Minor
        Found in ndk/server.rb - About 5 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 server_main_proc has 114 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def server_main_proc
              ## login
        
              # send passwd
              if @server_passwd
        Severity: Major
        Found in ndk/server.rb - About 4 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 start has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              def start
                start_server_thread
                start_clients_thread
                timer_thread = Thread.new{
                  begin
          Severity: Minor
          Found in ndk/server.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

          Class NDK_Server has 31 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class NDK_Server
              TimerIntervalSec = 60
              MAX_PONG_FAIL    = 5
              
              def initialize rc
          Severity: Minor
          Found in ndk/server.rb - About 3 hrs to fix

            Method start_server_thread has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                def start_server_thread
                  @server_thread = Thread.new{
                    begin
                      @server = make_server()
                      @logger.slog "Server connection to #{@server.server}:#{@server.port}."
            Severity: Minor
            Found in ndk/server.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 read_thread has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                def read_thread(read_q, eol)
                  begin
                    read_q.clear
                    Thread.stop
            
            
            Severity: Minor
            Found in rice/irc.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 close has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                def close(restart = false)
                  begin
                    unless restart
                      @main_th.exit if alive?
                      @read_th.exit if @read_th.alive?
            Severity: Minor
            Found in rice/irc.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

            Method recv_from_server has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                def recv_from_server
                  while q = @rq.pop
                    
                    # Event
                    if q.kind_of? Array
            Severity: Minor
            Found in ndk/server.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

            Method ssl_params= has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def ssl_params=(ssl_params)
                  raise RuntimeError, 
                    "Already connected to #{@server}:#{@port}" unless @conn.empty?
                  unless ssl_params
                    @ssl_params = false
            Severity: Minor
            Found in rice/irc.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

            Method send_to_bot has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def send_to_bot msg, *arg
            
                  selector = 'on_' +
                    if msg.respond_to? :command
                      if /^\d+$/ =~ msg.command
            Severity: Minor
            Found in ndk/server.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 NDK_State has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class NDK_State
                class ChannelState
                  def initialize name
                    @name  = name
                    @topic = nil
            Severity: Minor
            Found in ndk/server_state.rb - About 2 hrs to fix

              Method start_clients_thread has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def start_clients_thread
                    return unless @config.client_server_port
                    @clients_thread = Thread.new{
                      begin
                        @cserver = TCPServer.new(@config.client_server_host,
              Severity: Minor
              Found in ndk/server.rb - About 1 hr to fix

                Method start has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def start
                      start_server_thread
                      start_clients_thread
                      timer_thread = Thread.new{
                        begin
                Severity: Minor
                Found in ndk/server.rb - About 1 hr to fix

                  Method daemon has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def Process.daemon(nochdir = nil, noclose = nil)
                      exit!(0) if fork
                      Process.setsid
                      exit!(0) if fork
                      Dir.chdir('/') unless nochdir
                  Severity: Minor
                  Found in nadoka.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 push has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def push(message)
                        conn = @conn[0]
                        if conn
                          conn.synchronize do
                            cmd = message.command
                  Severity: Minor
                  Found in rice/irc.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

                  Severity
                  Category
                  Status
                  Source
                  Language