maduck/GoWDiscordTeamBot

View on GitHub

Showing 84 of 281 total issues

Function get_current_event has a Cognitive Complexity of 14 (exceeds 5 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

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

    def add_troops_to_kingdoms_by_filename(self):
        pattern = re.compile(r'.+_(?P<filebase>K\d+).*')
        for troop_id, troop in self.troops.items():
            if troop_id == '`?`':
                continue
Severity: Minor
Found in data_source/game_data.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 __init__ has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __init__(self):
        self.data = None
        self.user_data = {
            'pEconomyModel': {
                'TroopReleaseDates': [],
Severity: Minor
Found in data_source/game_data.py - About 1 hr to fix

    Function get_team_from_code has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_team_from_code(self, code, lang):
            result = {
                'troops': [],
                'banner': {},
                'class': None,
    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 transform_campaign_task has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def transform_campaign_task(self, task, week):
            extra_data = {}
            task_order = 0
            kingdom_id = 0
            if 'Reroll' not in task['Id']:
    Severity: Minor
    Found in data_source/game_data.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 populate_kingdoms has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def populate_kingdoms(self):
            for kingdom in self.data['Kingdoms']:
                self.pets.fill_untranslated_kingdom_name(kingdom['Id'], kingdom['ReferenceName'])
                colors = [f'[GEM_{c.upper()}]' for c in COLORS]
                colors = zip(colors, kingdom['BannerColors'])
    Severity: Minor
    Found in data_source/game_data.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 populate_soulforge has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def populate_soulforge(self):
            tabs = [
                '[SOULFORGE_TAB_LEVEL]',
                '[SOULFORGE_TAB_JEWELS]',
                '[SOULFORGE_TAB_TRAITSTONES]',
    Severity: Minor
    Found in data_source/game_data.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 __init__ has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __init__(self):
            world = GameData()
            world.populate_world_data()
            self.troops = world.troops
            self.troop_types = world.troop_types
    Severity: Minor
    Found in search.py - About 1 hr to fix

      Function render_events has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def render_events(self, events, _filter, lang):
              e = discord.Embed(title=_('[EVENTS]', lang), color=self.WHITE)
              message_lines = []
              last_event_date = events[0]['start']
              for event in events:
      Severity: Minor
      Found in views.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 populate_effect_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def populate_effect_data(self):
              effect = self.data['effect']
      
              if not self.EFFECT_BONUS:
                  self.get_effect_bonuses()
      Severity: Minor
      Found in data_source/pet.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 get_current_campaign_week has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_current_campaign_week(self):
              if self.campaign_week:
                  return self.campaign_week
              release_dates = self.user_data['pEconomyModel']['ArtifactReleaseDates']
              now = datetime.datetime.utcnow() + datetime.timedelta(hours=CONFIG.get('data_shift_hours'))
      Severity: Minor
      Found in data_source/game_data.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_kingdom has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def translate_kingdom(self, kingdom, lang):
              kingdom['name'] = _(kingdom['name'], lang)
              if self.is_untranslated(kingdom['name']):
                  kingdom['name'] = kingdom['reference_name']
              kingdom['description'] = _(kingdom['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 kingdom_percentage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def kingdom_percentage(self, filter_name, filter_values, lang):
              result = {}
              now = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
              hidden_kingdoms = [3032, 3033, 3034, 3038]
      
      
      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 guess_weekly_kingdom_from_troop_spoilers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def guess_weekly_kingdom_from_troop_spoilers(self, lang):
              result = {}
              latest_date = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
              for spoiler in self.spoilers:
                  if spoiler['type'] == 'troop' \
      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_kingdom has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def translate_kingdom(self, kingdom, lang):
              kingdom['name'] = _(kingdom['name'], lang)
              if self.is_untranslated(kingdom['name']):
                  kingdom['name'] = kingdom['reference_name']
              kingdom['description'] = _(kingdom['description'], lang)
      Severity: Minor
      Found in search.py - About 1 hr to fix

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

            def kingdom_satisfies_task(self, kingdom, task):
                valid_ids = [kingdom['id']]
                if kingdom['location'] == 'krystara' and kingdom['linked_kingdom_id']:
                    valid_ids.append(kingdom['linked_kingdom_id'])
        
        
        Severity: Minor
        Found in data_source/game_data.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 has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def translate(self):
                super().translate()
                for translation in self.translations.values():
                    if 'effect_replacement' in translation:
                        for before, after in translation.data['effect_replacement'].items():
        Severity: Minor
        Found in data_source/pet.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 get_map_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_map_data(self, lang, location):
                if not location:
                    location = 'krystara'
                base_folder = 'Worldmap'
                map_data = {
        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_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 search_trait has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def search_trait(self, search_term, lang):
                possible_matches = []
                for code, trait in self.traits.items():
                    translated_name = extract_search_tag(_(trait['name'], lang))
                    translated_description = extract_search_tag(_(trait['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

        Severity
        Category
        Status
        Source
        Language