tulul/lycantulul_bot

View on GitHub

Showing 72 of 1,243 total issues

Avoid deeply nested control flow statements.
Open

            if in_group?(message)
              if group = Lycantulul::Group.get(message)
                if !group.pending_time_id
                  keyboard = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: group.time_setting_keyboard, resize_keyboard: true, one_time_keyboard: true, selective: true)
                  pending = send(message, 'Ubah waktu apa?', reply: true, keyboard: keyboard, async: false)
Severity: Major
Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                      if victim.role == SILVER_BULLET
                        ded = self.living_werewolves.sample
                        if ded
                          ded.kill
                          LycantululBot.log("#{ded.full_name} is killed because werewolves killed a silver bullet (from GAME)")
    Severity: Major
    Found in lib/lycantulul_bot/lycantulul/game.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  return unless message.from.username == 'araishikeiwai'
      Severity: Major
      Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

        Method list_players has a Cognitive Complexity of 8 (exceeds 5 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 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

        Avoid deeply nested control flow statements.
        Open

                    if in_group?(message)
                      if game = check_game(message)
                        if check_player(message)
                          if game.waiting?
                            user = message.from
        Severity: Major
        Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if in_group?(message)
                        if game = check_game(message)
                          if game.waiting?
                            if can_cancel_game?(message, game)
                              game.finish(stats: false)
          Severity: Major
          Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if in_group?(message)
                          if game = check_game(message)
                            summon(game, :all)
                          else
                            send(message, 'Ga ada yang lagi main, /bikin_baru dulu', reply: true)
            Severity: Major
            Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if new_member.username =~ /bot$/i && message.chat&.username =~ /lycantulul/i
                            unless new_member.username == 'tulul_stats_bot'
                              @bot.api.kick_chat_member(chat_id: '@lycantulul', user_id: new_member.id) rescue nil
                            end
                          elsif !Lycantulul::RegisteredPlayer.get(new_member.id) && !new_member.username == 'lycantulul_bot'
              Severity: Major
              Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if in_group?(message)
                              if group = Lycantulul::Group.get(message)
                                if group.pending_time_id
                                  group.cancel_pending_time
                                  send(message, 'Yosh. Udah boleh /ganti_settingan_waktu lagi', reply: true)
                Severity: Major
                Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                  self.temp_stats[victim.user_id] << 'mauled_first_day' if self.round == 1
                  Severity: Major
                  Found in lib/lycantulul_bot/lycantulul/game.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if in_group?(message)
                                  start_new_game(message)
                                else
                                  wrong_room(message)
                                end
                    Severity: Major
                    Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if in_group?(message)
                                    if game = check_game(message)
                                      if game.waiting?
                                        if !MAINTENANCE_PREVENT.call
                                          if game.players.count >= MINIMUM_PLAYER.call
                      Severity: Major
                      Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                    if in_group?(message)
                                      if game = check_game(message)
                                        summon(game, :alive)
                                      else
                                        send(message, 'Ga ada yang lagi main, /bikin_baru dulu', reply: true)
                        Severity: Major
                        Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                      if in_private?(message)
                                        if game = check_werewolf_in_game(message)
                                          log('werewolf confirmed')
                                          case game.add_victim(message.from.id, message.text)
                                          when Lycantulul::Game::RESPONSE_OK
                          Severity: Major
                          Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                        if in_group?(message)
                                          if game = check_game(message)
                                            if game.waiting?
                                              game.toggle_voting_scheme
                                              send(message, "Sistem voting berubah jadi #{game.voting_scheme}", reply: true)
                            Severity: Major
                            Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if in_group?(message)
                                            if game = check_game(message)
                                              if check_player(message)
                                                if game.waiting?
                                                  user = message.from
                              Severity: Major
                              Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            if in_group?(message)
                                              if game = check_game(message)
                                                unless game.waiting?
                                                  unless game.night?
                                                    if (Time.now - game.last_voting_list_query rescue 11).ceil > 10
                                Severity: Major
                                Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                              if in_private?(message)
                                                if check_player(message)
                                                  send_to_player(message.chat.id, Lycantulul::RegisteredPlayer.get(message.from.id).statistics, parse_mode: 'HTML')
                                                else
                                                  send(message, 'Maaf belum kedaftar, /start dulu yak')
                                  Severity: Major
                                  Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                              elsif left_member = message.left_chat_member
                                                if game = check_game(message)
                                                  game.players.with_id(left_member.id).destroy rescue nil
                                                end
                                    Severity: Major
                                    Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                  if in_group?(message)
                                                    if game = check_game(message)
                                                      if game.waiting?
                                                        if !game.pending_custom_id
                                                          keyboard = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: game.role_setting_keyboard, resize_keyboard: true, one_time_keyboard: true, selective: true)
                                      Severity: Major
                                      Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language