Showing 84 of 281 total issues
Function merge
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def merge(a, b, path=None):
if path is None:
path = []
for key in b:
if key in a:
- Read upRead up
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)
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()
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]
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):
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)
- Read upRead up
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_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']:
- Read upRead up
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'
- Read upRead up
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):
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, author, guild, channel, content, interaction_id=None, interaction_token=None):
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]]
- Read upRead up
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_class_level
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def render_class_level(self, lower_level, upper_level, xp_required, speeds, lang):
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
- Read upRead up
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
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):
Function download_from_taran
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def download_from_taran(self, message, map_name, version, token=''):
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'):
Function set_scroll
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def set_scroll(self, guild, channel, floor, room, scroll):
Function render_current_event
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def render_current_event(self, current_event, shortened, lengthened, lang):
Function render_team
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def render_team(self, team, author, shortened, lengthened, title=None):