maduck/GoWDiscordTeamBot

View on GitHub

Showing 281 of 281 total issues

Function translate_spell has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def translate_spell(self, spell_id, lang):
        spell = self.spells[spell_id]
        magic = _('[MAGIC]', lang)

        description = self.translate_spell_description(spell['description'], lang)
Severity: Minor
Found in search.py - 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

Function translate_weapon has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def translate_weapon(self, weapon, lang):
        weapon['name'] = _(weapon['name'], lang)
        weapon['description'] = _(weapon['description'], lang)
        weapon['color_code'] = "".join(sorted(weapon['colors']))
        weapon['spell_title'] = _('[TROOPHELP_SPELL0]', lang)
Severity: Minor
Found in search.py - About 1 hr to fix

    Function populate_world_data has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def populate_world_data(self):
            self.read_json_data()
    
            self.populate_spells()
            self.populate_traits()
    Severity: Minor
    Found in data_source/game_data.py - About 1 hr to fix

      Function get_current_event has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def get_current_event(self, lang, emojis):
              event = copy.deepcopy(self.weekly_event)
              kingdoms = self.search_kingdom(event['kingdom_id'], lang)
              if kingdoms:
                  event['kingdom'] = kingdoms[0]
      Severity: Minor
      Found in search.py - About 1 hr to fix

        Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, pet, time_left, message, mention, lang, answer_method, config, override_time_left=None):
        Severity: Major
        Found in models/pet_rescue.py - About 1 hr to fix

          Function populate_max_power_levels has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def populate_max_power_levels(self):
                  pattern = re.compile(r'KingdomTask(?P<level>\d+)-.+')
                  for kingdom in self.kingdoms.values():
                      max_kingdom_level = 0
                      for task in self.user_data['pTasksData']['Kingdom']:
          Severity: Minor
          Found in data_source/game_data.py - 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

          Function render_team has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def render_team(self, team, author, shortened, lengthened, title=None):
                  color = discord.Color.from_rgb(*RARITY_COLORS['Mythic'])
                  e = discord.Embed(color=color)
                  if team['banner']:
                      thumbnail_url = f'{CONFIG.get("graphics_url")}/Banners/Banners_{team["banner"]["filename"]}_full.png'
          Severity: Minor
          Found in views.py - 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

          Function translate_drop_chances has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def translate_drop_chances(self, data: dict, lang):
                  for key, item in data.copy().items():
                      if not self.is_untranslated(key):
                          continue
                      new_key = _(key, lang)
          Severity: Minor
          Found in search.py - 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

          Function format_output has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def format_output(self, guild, color, channel, prefix='!', _range=None, shortened=False):
          Severity: Major
          Found in tower_data.py - About 50 mins to fix

            Function render_class_level has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def render_class_level(self, lower_level, upper_level, xp_required, speeds, lang):
            Severity: Minor
            Found in views.py - About 45 mins to fix

              Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, author, guild, channel, content, interaction_id=None, interaction_token=None):
              Severity: Minor
              Found in discord_fake_classes.py - About 45 mins to fix

                Function get_weekly_summary has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_weekly_summary(self, lang, emojis):
                        world_event = self.get_current_event(lang, emojis)
                
                        def get_single_event(event_type, weekday):
                            if filtered_events := [e for e in self.events
                Severity: Minor
                Found in search.py - 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

                Function search has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def search(self, search_term, lang, **kwargs):
                        lang = LANGUAGE_CODE_MAPPING.get(lang, lang)
                        if search_term.isdigit() and int(search_term) in self.items:
                            if item := self.items.get(int(search_term)):
                                return [item.translations[lang]]
                Severity: Minor
                Found in data_source/__init__.py - 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

                Consider simplifying this complex logical expression.
                Open

                        if gacha_pool and gacha and gacha in gacha_pool:
                            item = gacha_pool[gacha]
                            return _(item['name'], lang, default=item.get('reference_name', item['name']))
                        elif event_type == '[PETRESCUE]' and gacha and gacha in self.pets:
                            return self.pets[gacha][lang].name
                Severity: Major
                Found in search.py - About 40 mins to fix

                  Function word_wrap has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def word_wrap(image, draw, text, roi_width, roi_height):
                  Severity: Minor
                  Found in graphic_base_preview.py - About 35 mins to fix

                    Function search_item has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def search_item(search_term, lang, items, lookup_keys, translator, sort_by='name'):
                    Severity: Minor
                    Found in search.py - About 35 mins to fix

                      Function format_whole_floor has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def format_whole_floor(self, floor: int, guild_data, floor_data, shortened: bool):
                      Severity: Minor
                      Found in tower_data.py - About 35 mins to fix

                        Function render_team has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def render_team(self, team, author, shortened, lengthened, title=None):
                        Severity: Minor
                        Found in views.py - About 35 mins to fix

                          Function download_from_taran has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def download_from_taran(self, message, map_name, version, token=''):
                          Severity: Minor
                          Found in tower_data.py - About 35 mins to fix

                            Function render_current_event has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def render_current_event(self, current_event, shortened, lengthened, lang):
                            Severity: Minor
                            Found in views.py - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language