codekitchen/tkellem

View on GitHub

Showing 36 of 36 total issues

Method execute has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

    def execute
      # TODO: this got gross
      if args.empty? && !opts['remove']
        list
        return
Severity: Minor
Found in lib/tkellem/tkellem_bot.rb - About 7 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 receive_line has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

  def receive_line(line)
    failsafe("message: {#{line}}") do
      line.force_encoding Encoding::UTF_8
      trace "from client: #{line}"
      return if line.blank?
Severity: Minor
Found in lib/tkellem/bouncer_connection.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

File tkellem_bot.rb has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'shellwords'
require 'yaml'

module Tkellem

Severity: Minor
Found in lib/tkellem/tkellem_bot.rb - About 5 hrs to fix

    Method maybe_connect has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      def maybe_connect
        return unless @connecting_nick && @username && !@user
        if @password
          @name = @username
          @user = User.authenticate(@username, @password)
    Severity: Minor
    Found in lib/tkellem/bouncer_connection.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 server_msg has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      def server_msg(msg)
        return if plugins.any? do |plugin|
          !plugin.server_msg(self, msg)
        end
    
    
    Severity: Minor
    Found in lib/tkellem/bouncer.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 receive_line has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def receive_line(line)
        failsafe("message: {#{line}}") do
          line.force_encoding Encoding::UTF_8
          trace "from client: #{line}"
          return if line.blank?
    Severity: Major
    Found in lib/tkellem/bouncer_connection.rb - About 2 hrs to fix

      File backlog.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'backwards_file_reader'
      require 'fileutils'
      require 'geoip'
      require 'pathname'
      require 'time'
      Severity: Minor
      Found in lib/tkellem/plugins/backlog.rb - About 2 hrs to fix

        Method server_msg has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def server_msg(msg)
            return if plugins.any? do |plugin|
              !plugin.server_msg(self, msg)
            end
        
        
        Severity: Major
        Found in lib/tkellem/bouncer.rb - About 2 hrs to fix

          Class Backlog has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Backlog
            include Tkellem::EasyLogger
          
            Bouncer.add_plugin(self)
            SERVER_TIME_CAPS = %w{server-time znc.in/server-time-iso}.freeze
          Severity: Minor
          Found in lib/tkellem/plugins/backlog.rb - About 2 hrs to fix

            File bouncer_connection.rb has 260 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'active_support/core_ext/object/blank'
            
            require 'eventmachine'
            require 'tkellem/irc_message'
            
            
            Severity: Minor
            Found in lib/tkellem/bouncer_connection.rb - About 2 hrs to fix

              Method execute has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def execute
                    # TODO: this got gross
                    if args.empty? && !opts['remove']
                      list
                      return
              Severity: Minor
              Found in lib/tkellem/tkellem_bot.rb - About 1 hr to fix

                Method send_backlog has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                  def send_backlog(conn, ctx_name, stream, time_zone)
                    while line = stream.gets
                      timestamp, msg = self.class.parse_line(line, ctx_name)
                      next unless msg
                      msg.readdress_to(@bouncer.nick)
                Severity: Minor
                Found in lib/tkellem/plugins/backlog.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 client_msg has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  def client_msg(client, msg)
                    return if plugins.any? do |plugin|
                      !plugin.client_msg(self, client, msg)
                    end
                
                
                Severity: Minor
                Found in lib/tkellem/bouncer.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 replay has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  def replay
                    line = []
                
                    if !tags.empty?
                      line << "@#{tags.map { |k, v| v.nil? ? k : "#{k}=#{v}"}.join(';') }"
                Severity: Minor
                Found in lib/tkellem/irc_message.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 run has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def run
                    op = OptionParser.new do |opts|
                      opts.banner = "Usage #{$0} <command> <options>"
                      opts.separator %{\nWhere <command> is one of:
                  start      start the jobs daemon
                Severity: Minor
                Found in lib/tkellem/daemon.rb - About 1 hr to fix

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

                      def execute
                        if opts['network'].present? # only settable by admins
                          target = Network.where(["LOWER(name) = LOWER(?) AND user_id IS NULL", opts['network']]).first
                        else
                          target = bouncer.try(:network_user)
                  Severity: Minor
                  Found in lib/tkellem/tkellem_bot.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 maybe_connect has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def maybe_connect
                      return unless @connecting_nick && @username && !@user
                      if @password
                        @name = @username
                        @user = User.authenticate(@username, @password)
                  Severity: Minor
                  Found in lib/tkellem/bouncer_connection.rb - About 1 hr to fix

                    Method client_msg has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def client_msg(client, msg)
                        return if plugins.any? do |plugin|
                          !plugin.client_msg(self, client, msg)
                        end
                    
                    
                    Severity: Minor
                    Found in lib/tkellem/bouncer.rb - About 1 hr to fix

                      Method execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def execute
                            case args.size
                            when 0
                              r "Settings:"
                              Setting.all.each { |s| r "    #{s}" }
                      Severity: Minor
                      Found in lib/tkellem/tkellem_bot.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 modify has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def modify
                            instance = model.where(find_attributes).first
                            new_record = false
                            if instance
                              instance.attributes = attributes
                      Severity: Minor
                      Found in lib/tkellem/tkellem_bot.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