maduck/GoWDiscordTeamBot

View on GitHub
views.py

Summary

Maintainability
D
1 day
Test Coverage

File views.py has 610 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime
import math

import discord
from jinja2 import Environment, FileSystemLoader
Severity: Major
Found in views.py - About 1 day 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 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 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 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 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

          invalid syntax (<unknown>, line 498)</unknown>
          Open

                  if details := author_details.get(author):
          Severity: Critical
          Found in views.py by pylint

          Used when a syntax error is raised for a module.

          There are no issues that match your filters.

          Category
          Status