codekitchen/tkellem

View on GitHub
lib/tkellem/tkellem_bot.rb

Summary

Maintainability
D
2 days
Test Coverage

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

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 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 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 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

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

          def self.build_options(user, cmd = nil)
            OptionParser.new.tap do |options|
              @options.try(:each) { |opt_name,args|
                next if !admin_user?(user) && @admin_onlies.include?(opt_name)
                options.on(*args) { |v| cmd.opts[opt_name] = v }
      Severity: Minor
      Found in lib/tkellem/tkellem_bot.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute
            name = args.shift.try(:upcase)
            r "**** tkellem help ****"
            if name.nil?
              r "For more information on a command, type:"
      Severity: Minor
      Found in lib/tkellem/tkellem_bot.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute
            user = self.user
      
            if opts['username']
              if Command.admin_user?(user)
      Severity: Minor
      Found in lib/tkellem/tkellem_bot.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 list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def list
            public_networks = Network.where('user_id IS NULL').to_a
            user_networks = user.try(:reload).try(:networks) || []
            if user_networks.present? && public_networks.present?
              r "Public networks are prefixed with [P], user-specific networks with [U]."
      Severity: Minor
      Found in lib/tkellem/tkellem_bot.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