itsVale/Vale.py

View on GitHub

Showing 43 of 43 total issues

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

    def create_sql(self):
        if not self.name:
            raise RuntimeError('Column should be defined inside a table subclass.')

        builder = [self.name, self.type.sql]
Severity: Minor
Found in utils/db/db.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_emoji_message has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_emoji_message(self, message, stars):
        emoji = self.star_emoji(stars)

        if stars > 1:
            content = f'{emoji} **{stars}** {message.channel.mention} ID: {message.id}'
Severity: Minor
Found in cogs/utility/starboard.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 _create_embed has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def _create_embed(self, number, action, mod, targets, reason, extra, time=None):
Severity: Major
Found in cogs/moderation/modlog.py - About 50 mins to fix

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

        def __init__(self, type, *, primary_key=False, nullable=False, unique=False, default=None):
    Severity: Major
    Found in utils/db/db.py - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if match:
                                  author_ids.append(int(match.group('id')))
                                  continue
      
      
      Severity: Major
      Found in cogs/utility/starboard.py - About 45 mins to fix

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

            def __init_subclass__(cls, *, game_cls, name=None, cmd=None, aliases=(), **kwargs):
        Severity: Minor
        Found in cogs/games/base.py - About 45 mins to fix

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

          def _build_command_requirements(command):
              requirements = []
          
              # All commands in this cog are owner-only anyways
              if command.cog_name == 'Owner':
          Severity: Minor
          Found in utils/help.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, ctx, entries, *, per_page=15, title=discord.Embed.Empty, color=None):
          Severity: Minor
          Found in utils/paginator.py - About 45 mins to fix

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

                def __new__(cls, time, event, args=None, kwargs=None, created=None, id=None):
            Severity: Minor
            Found in utils/scheduler.py - About 45 mins to fix

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

              def _split_params(command):
                  """Splits a command's parameters into required and optional parts."""
              
                  params = command.clean_params.values()
                  required = list(itertools.takewhile(_is_required_parameter, params))
              Severity: Minor
              Found in utils/examples.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 instructions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def instructions(self):
                      """Table of Contents."""
              
                      self._index = -1
                      ctx = self.ctx
              Severity: Minor
              Found in utils/help.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, destination, content=None, *, file=None, embed=None):
              Severity: Minor
              Found in utils/context_managers.py - About 35 mins to fix

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

                    def __init_subclass__(cls, *, board_factory, move_pattern=None, timeout=120):
                Severity: Minor
                Found in cogs/games/base.py - About 35 mins to fix

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

                      def _add_to_cache(self, name, guild_id, member_id, *, seconds=2):
                  Severity: Minor
                  Found in cogs/moderation/modlog.py - About 35 mins to fix

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

                        def __init__(self, column, *, type=None, on_delete='CASCADE', on_update='NO ACTION'):
                    Severity: Minor
                    Found in utils/db/db.py - About 35 mins to fix

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

                          def __init__(self, ctx, entries, *, inline=True, **kwargs):
                      Severity: Minor
                      Found in utils/paginator.py - About 35 mins to fix

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

                        def trigger(emoji, pattern=None, *, blocking=False, fallback=None):
                        Severity: Minor
                        Found in utils/paginator.py - About 35 mins to fix

                          Function _create_embed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def _create_embed(self, number, action, mod, targets, reason, extra, time=None):
                                  time = time or datetime.utcnow()
                                  action = _mod_actions[action]
                          
                                  bot_avatar = self.bot.user.avatar_url
                          Severity: Minor
                          Found in cogs/moderation/modlog.py - About 35 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 legal_moves has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def legal_moves(self):
                                  """Generates all legal moves in the current position.
                          
                                  If there are any jumps one could make, those get generated instead,
                                  as jumps must be made according to the rules of Checkers.
                          Severity: Minor
                          Found in cogs/games/checkers.py - About 35 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 move has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def move(self, move):
                                  """Takes a move and apply it to the game."""
                          
                                  if move not in self.legal_moves():
                                      raise ValueError(f'illegal move: {move!r}')
                          Severity: Minor
                          Found in cogs/games/checkers.py - About 35 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

                          Severity
                          Category
                          Status
                          Source
                          Language