tulul/lycantulul_bot

View on GitHub

Showing 72 of 1,243 total issues

Method perform has a Cognitive Complexity of 611 (exceeds 5 allowed). Consider refactoring.
Open

    def perform(message, bot)
      @bot = bot
      log("incoming message from #{message.from.first_name}: #{message.text}")

      if MAINTENANCE.call
Severity: Minor
Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 1 wk 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 input_processor_job.rb has 1033 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Lycantulul
  class InputProcessorJob
    include SuckerPunch::Job

    attr_accessor :bot
Severity: Major
Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 2 days to fix

    Method perform has 473 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def perform(message, bot)
          @bot = bot
          log("incoming message from #{message.from.first_name}: #{message.text}")
    
          if MAINTENANCE.call
    Severity: Major
    Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 2 days to fix

      File game.rb has 791 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Lycantulul
        class Game
          include Mongoid::Document
          include Mongoid::Locker
          include Mongoid::Timestamps
      Severity: Major
      Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 day to fix

        Method kill_victim has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
        Open

            def kill_victim
              self.with_lock(wait: true) do
                vc = self.sort(victim)
                hhost = self.homeless_host
                LycantululBot.log(vc.to_s)
        Severity: Minor
        Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 day 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 Game has 63 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Game
            include Mongoid::Document
            include Mongoid::Locker
            include Mongoid::Timestamps
        
        
        Severity: Major
        Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 day to fix

          Method message_action has 156 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def message_action(game, action, aux = nil)
                case action
                when BROADCAST_ROLE
                  log('game starts')
                  opening = 'MULAI! MWA HA HA HA'
          Severity: Major
          Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 6 hrs to fix

            Class InputProcessorJob has 39 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class InputProcessorJob
                include SuckerPunch::Job
            
                attr_accessor :bot
            
            
            Severity: Minor
            Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 5 hrs to fix

              Method role_count has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                  def role_count(role, count = nil)
                    count ||= self.players.count
                    count -= Lycantulul::InputProcessorJob::MINIMUM_PLAYER.call
              
                    custom = self.custom_roles[role] rescue nil
              Severity: Minor
              Found in lib/lycantulul_bot/lycantulul/game.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 message_action has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
              Open

                  def message_action(game, action, aux = nil)
                    case action
                    when BROADCAST_ROLE
                      log('game starts')
                      opening = 'MULAI! MWA HA HA HA'
              Severity: Minor
              Found in lib/lycantulul_bot/lycantulul/input_processor_job.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 send has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  def send(message, text, reply: nil, html: nil, keyboard: nil, async: true)
                    options = {
                      chat_id: message.chat.id,
                      text: text[0...4000],
                    }
              Severity: Minor
              Found in lib/lycantulul_bot/lycantulul/input_processor_job.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 get_stats has 69 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.get_stats(stat)
                    stats = ["Statistik #{stat}"]
                    case stat
                    when '/stats'
                      stats << "Current stats:"
              Severity: Major
              Found in lib/lycantulul_bot/lycantulul/statistics.rb - About 2 hrs to fix

                Method kill_victim has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def kill_victim
                      self.with_lock(wait: true) do
                        vc = self.sort(victim)
                        hhost = self.homeless_host
                        LycantululBot.log(vc.to_s)
                Severity: Major
                Found in lib/lycantulul_bot/lycantulul/game.rb - About 2 hrs to fix

                  Method raise_the_dead has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def raise_the_dead
                        self.with_lock(wait: true) do
                          ss = self.necromancee
                          LycantululBot.log(ss.to_s)
                          self.update_attribute(:necromancee, [])
                  Severity: Minor
                  Found in lib/lycantulul_bot/lycantulul/game.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 check_round_finished has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def check_round_finished(game, round, force = false)
                        log("checking round finished #{round}")
                        game.reload
                        return unless round == game.round && game.night? && !game.waiting? && !game.discussion? && !game.finished?
                        log('continuing')
                  Severity: Minor
                  Found in lib/lycantulul_bot/lycantulul/input_processor_job.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 enlighten_seer has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def enlighten_seer
                        self.with_lock(wait: true) do
                          ss = self.seen
                          LycantululBot.log(ss.to_s)
                          self.update_attribute(:seen, [])
                  Severity: Minor
                  Found in lib/lycantulul_bot/lycantulul/game.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 check_win has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def check_win(game)
                        log('checking win condition')
                        game.reload
                        win = false
                        ending = ''
                  Severity: Minor
                  Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 1 hr to fix

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

                        def kill_votee
                          self.with_lock(wait: true) do
                            vc = self.sort(votee)
                            LycantululBot.log(vc.to_s)
                            self.update_attribute(:night, true)
                    Severity: Minor
                    Found in lib/lycantulul_bot/lycantulul/game.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 role_count has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def role_count(role, count = nil)
                          count ||= self.players.count
                          count -= Lycantulul::InputProcessorJob::MINIMUM_PLAYER.call
                    
                          custom = self.custom_roles[role] rescue nil
                    Severity: Minor
                    Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 hr to fix

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

                          def perform(bot, options)
                            retry_count = 0
                            begin
                              bot.api.send_message(options)
                            rescue Faraday::TimeoutError => e
                      Severity: Minor
                      Found in lib/lycantulul_bot/lycantulul/message_queue_job.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