tulul/lycantulul_bot

View on GitHub

Showing 72 of 1,243 total issues

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

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

    def finish(stats: true)
      self.with_lock(wait: true) do
        self.update_attribute(:finished, true)
        if stats
          self.players.each do |pl|
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 get_task has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def get_task(role)
      case role
      when VILLAGER
        "Diam menunggu kematian. Seriously. Tapi bisa bantu-bantu yang lain lah sumbang suara buat bunuh para serigala, sekalian berdoa biar dilindungi sama #{self.get_role(PROTECTOR)} kalo ada"
      when GREEDY_VILLAGER
Severity: Minor
Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 hr to fix

    Method get_role has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def get_role(role)
          case role
          when VILLAGER
            'Warga Kampung'
          when GREEDY_VILLAGER
    Severity: Minor
    Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 hr to fix

      Method role_valid? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def role_valid?
            ww_count_valid =
              if self.custom_roles && ((ww = self.custom_roles[WEREWOLF]) || (sww = self.custom_roles[SUPER_WEREWOLF]))
                val = true
                wwc = ww > 0 rescue 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 add_necromancee has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_necromancee(necromancer_id, necromancee)
            self.with_lock(wait: true) do
              return RESPONSE_DOUBLE if self.necromancee.any?{ |se| se[:necromancer_id] == necromancer_id }
              return RESPONSE_INVALID unless valid_action?(necromancer_id, necromancee, 'necromancer') || valid_action?(necromancer_id, necromancee, 'super_necromancer')
      
      
      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 get_stats has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.get_stats(stat)
            stats = ["Statistik #{stat}"]
            case stat
            when '/stats'
              stats << "Current stats:"
      Severity: Minor
      Found in lib/lycantulul_bot/lycantulul/statistics.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 summon has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def summon(game, who)
            if (Time.now - game.last_summon_query rescue 11).ceil > 10
              to_call =
                case who
                when :all
      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 check_voting_finished has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_voting_finished(game, round, force = false)
            log("checking voting 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 send has 31 lines of code (exceeds 25 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 1 hr to fix

        Method finish has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def finish(stats: true)
              self.with_lock(wait: true) do
                self.update_attribute(:finished, true)
                if stats
                  self.players.each do |pl|
        Severity: Minor
        Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 hr to fix

          Method summon has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def summon(game, who)
                if (Time.now - game.last_summon_query rescue 11).ceil > 10
                  to_call =
                    case who
                    when :all
          Severity: Minor
          Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 1 hr to fix

            Method list_players has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def list_players
                  liv_count = self.living_players.count
                  ded_count = self.dead_players.count
            
                  res = "Masi idup: <b>#{liv_count} makhluk</b>\n"
            Severity: Minor
            Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 hr to fix

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

                  def add_votee(voter_id, votee)
                    self.with_lock(wait: true) do
                      return RESPONSE_DOUBLE if self.votee.any?{ |vo| vo[:voter_id] == voter_id }
                      return RESPONSE_INVALID unless valid_action?(voter_id, votee, 'player')
              
              
              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 protect_players has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

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

                def self.start
                  Telegram::Bot::Client.run($token) do |bot|
                    bot.listen do |message|
                      Lycantulul::InputProcessorJob.perform_async(message, bot)
                    end
              Severity: Minor
              Found in lib/lycantulul_bot/lycantulul_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 check_custom_role has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def check_custom_role(role_string)
                    self.with_lock(wait: true) do
                      custom = nil
                      return nil unless role_string
                      role_string = role_string.gsub(/[^A-Za-z]/, '').downcase
              Severity: Minor
              Found in lib/lycantulul_bot/lycantulul/game.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 add_victim has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def add_victim(killer_id, victim)
                    self.with_lock(wait: true) do
                      return RESPONSE_DOUBLE if self.victim.any?{ |vi| vi[:killer_id] == killer_id }
                      return RESPONSE_INVALID unless valid_action?(killer_id, victim, 'werewolf') || valid_action?(killer_id, victim, 'super_werewolf')
              
              
              Severity: Minor
              Found in lib/lycantulul_bot/lycantulul/game.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

              Avoid deeply nested control flow statements.
              Open

                          if in_private?(message)
                            if check_player(message)
                              send(message, 'Udah kedaftar!')
                            else
                              Lycantulul::RegisteredPlayer.create_from_message(message.from)
              Severity: Major
              Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language