tctree333/Bird-ID

View on GitHub

Showing 124 of 124 total issues

File functions.py has 745 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# functions.py | function definitions
# Copyright (C) 2019-2021  EraserBird, person_v1.32, hmmm

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Severity: Major
Found in bot/functions.py - About 1 day to fix

    File core.py has 573 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # core.py | core media fetching functions
    # Copyright (C) 2019-2021  EraserBird, person_v1.32, hmmm
    
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    Severity: Major
    Found in bot/core.py - About 1 day to fix

      File filters.py has 467 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # filters.py | Macaulay Library filter representation functions
      # Copyright (C) 2019-2021  EraserBird, person_v1.32, hmmm
      
      # This program is free software: you can redistribute it and/or modify
      # it under the terms of the GNU General Public License as published by
      Severity: Minor
      Found in bot/filters.py - About 7 hrs to fix

        File stats.py has 450 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # stats.py | commands for bot statistics
        # Copyright (C) 2019-2021  EraserBird, person_v1.32, hmmm
        
        # This program is free software: you can redistribute it and/or modify
        # it under the terms of the GNU General Public License as published by
        Severity: Minor
        Found in bot/cogs/stats.py - About 6 hrs to fix

          File score.py has 446 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # score.py | commands to show score related things
          # Copyright (C) 2019-2021  EraserBird, person_v1.32, hmmm
          
          # This program is free software: you can redistribute it and/or modify
          # it under the terms of the GNU General Public License as published by
          Severity: Minor
          Found in bot/cogs/score.py - About 6 hrs to fix

            Cyclomatic complexity is too high in function handle_error. (35)
            Open

            async def handle_error(ctx, error):
                """Function for comprehensive error handling."""
                if isinstance(error, commands.CommandOnCooldown):  # send cooldown
                    await ctx.send(
                        (
            Severity: Minor
            Found in bot/functions.py by radon

            Cyclomatic Complexity

            Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

            Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

            Construct Effect on CC Reasoning
            if +1 An if statement is a single decision.
            elif +1 The elif statement adds another decision.
            else +0 The else statement does not cause a new decision. The decision is at the if.
            for +1 There is a decision at the start of the loop.
            while +1 There is a decision at the while statement.
            except +1 Each except branch adds a new conditional path of execution.
            finally +0 The finally block is unconditionally executed.
            with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
            assert +1 The assert statement internally roughly equals a conditional statement.
            Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
            Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

            Source: http://radon.readthedocs.org/en/latest/intro.html

            Cyclomatic complexity is too high in method custom. (31)
            Open

                @commands.hybrid_command(
                    brief="- Sets your custom bird list",
                    help="- Sets your custom bird list. "
                    + "This command only works in DMs. Lists have a max size of 200 birds. "
                    + "When verifying, the bot may incorrectly say it didn't find any images. "
            Severity: Minor
            Found in bot/cogs/state.py by radon

            Cyclomatic Complexity

            Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

            Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

            Construct Effect on CC Reasoning
            if +1 An if statement is a single decision.
            elif +1 The elif statement adds another decision.
            else +0 The else statement does not cause a new decision. The decision is at the if.
            for +1 There is a decision at the start of the loop.
            while +1 There is a decision at the while statement.
            except +1 Each except branch adds a new conditional path of execution.
            finally +0 The finally block is unconditionally executed.
            with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
            assert +1 The assert statement internally roughly equals a conditional statement.
            Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
            Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

            Source: http://radon.readthedocs.org/en/latest/intro.html

            Cyclomatic complexity is too high in method send_bird_. (29)
            Open

                async def send_bird_(
                    self,
                    ctx,
                    media: Optional[str],
                    filters: Filter,
            Severity: Minor
            Found in bot/cogs/get_birds.py by radon

            Cyclomatic Complexity

            Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

            Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

            Construct Effect on CC Reasoning
            if +1 An if statement is a single decision.
            elif +1 The elif statement adds another decision.
            else +0 The else statement does not cause a new decision. The decision is at the if.
            for +1 There is a decision at the start of the loop.
            while +1 There is a decision at the while statement.
            except +1 Each except branch adds a new conditional path of execution.
            finally +0 The finally block is unconditionally executed.
            with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
            assert +1 The assert statement internally roughly equals a conditional statement.
            Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
            Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

            Source: http://radon.readthedocs.org/en/latest/intro.html

            File get_birds.py has 401 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # get_birds.py | commands for getting bird images or songs
            # Copyright (C) 2019-2021  EraserBird, person_v1.32, hmmm
            
            # This program is free software: you can redistribute it and/or modify
            # it under the terms of the GNU General Public License as published by
            Severity: Minor
            Found in bot/cogs/get_birds.py - About 5 hrs to fix

              File state.py has 371 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # state.py | commands for state specific birds
              # Copyright (C) 2019-2021  EraserBird, person_v1.32
              
              # This program is free software: you can redistribute it and/or modify
              # it under the terms of the GNU General Public License as published by
              Severity: Minor
              Found in bot/cogs/state.py - About 4 hrs to fix

                Cyclomatic complexity is too high in function send_bird. (23)
                Open

                async def send_bird(
                    ctx, bird: str, media_type: MediaType, filters: Filter, on_error=None, message=None
                ):
                    """Gets bird media and sends it to the user.
                
                
                Severity: Minor
                Found in bot/core.py by radon

                Cyclomatic Complexity

                Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                Construct Effect on CC Reasoning
                if +1 An if statement is a single decision.
                elif +1 The elif statement adds another decision.
                else +0 The else statement does not cause a new decision. The decision is at the if.
                for +1 There is a decision at the start of the loop.
                while +1 There is a decision at the while statement.
                except +1 Each except branch adds a new conditional path of execution.
                finally +0 The finally block is unconditionally executed.
                with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                assert +1 The assert statement internally roughly equals a conditional statement.
                Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                Source: http://radon.readthedocs.org/en/latest/intro.html

                Cyclomatic complexity is too high in method parse. (23)
                Open

                    @staticmethod
                    async def parse(ctx, args_str: str):
                        """Parse arguments for options."""
                
                        args = args_str.split(" ")
                Severity: Minor
                Found in bot/cogs/get_birds.py by radon

                Cyclomatic Complexity

                Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                Construct Effect on CC Reasoning
                if +1 An if statement is a single decision.
                elif +1 The elif statement adds another decision.
                else +0 The else statement does not cause a new decision. The decision is at the if.
                for +1 There is a decision at the start of the loop.
                while +1 There is a decision at the while statement.
                except +1 Each except branch adds a new conditional path of execution.
                finally +0 The finally block is unconditionally executed.
                with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                assert +1 The assert statement internally roughly equals a conditional statement.
                Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                Source: http://radon.readthedocs.org/en/latest/intro.html

                File other.py has 344 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # other.py | misc. commands
                # Copyright (C) 2019-2021  EraserBird, person_v1.32, hmmm
                
                # This program is free software: you can redistribute it and/or modify
                # it under the terms of the GNU General Public License as published by
                Severity: Minor
                Found in bot/cogs/other.py - About 4 hrs to fix

                  Cyclomatic complexity is too high in method user_lb. (19)
                  Open

                      @staticmethod
                      async def user_lb(ctx, title, page, database_key=None, data=None):
                          if database_key is None and data is None:
                              raise GenericError("database_key and data are both NoneType", 990)
                          if database_key is not None and data is not None:
                  Severity: Minor
                  Found in bot/cogs/score.py by radon

                  Cyclomatic Complexity

                  Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                  Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                  Construct Effect on CC Reasoning
                  if +1 An if statement is a single decision.
                  elif +1 The elif statement adds another decision.
                  else +0 The else statement does not cause a new decision. The decision is at the if.
                  for +1 There is a decision at the start of the loop.
                  while +1 There is a decision at the while statement.
                  except +1 Each except branch adds a new conditional path of execution.
                  finally +0 The finally block is unconditionally executed.
                  with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                  assert +1 The assert statement internally roughly equals a conditional statement.
                  Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                  Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Cyclomatic complexity is too high in method state. (18)
                  Open

                      @commands.hybrid_command(
                          help="- Sets a specific bird list as a role", name="set", aliases=["state"]
                      )
                      @commands.check(CustomCooldown(5.0, bucket=commands.BucketType.user))
                      @commands.guild_only()
                  Severity: Minor
                  Found in bot/cogs/state.py by radon

                  Cyclomatic Complexity

                  Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                  Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                  Construct Effect on CC Reasoning
                  if +1 An if statement is a single decision.
                  elif +1 The elif statement adds another decision.
                  else +0 The else statement does not cause a new decision. The decision is at the if.
                  for +1 There is a decision at the start of the loop.
                  while +1 There is a decision at the while statement.
                  except +1 Each except branch adds a new conditional path of execution.
                  finally +0 The finally block is unconditionally executed.
                  with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                  assert +1 The assert statement internally roughly equals a conditional statement.
                  Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                  Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Cyclomatic complexity is too high in method check. (18)
                  Open

                      @commands.hybrid_command(
                          help="- Checks your answer.", usage="guess", aliases=["guess", "c"]
                      )
                      @commands.check(CustomCooldown(3.0, bucket=commands.BucketType.user))
                      @app_commands.rename(arg="guess")
                  Severity: Minor
                  Found in bot/cogs/check.py by radon

                  Cyclomatic Complexity

                  Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                  Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                  Construct Effect on CC Reasoning
                  if +1 An if statement is a single decision.
                  elif +1 The elif statement adds another decision.
                  else +0 The else statement does not cause a new decision. The decision is at the if.
                  for +1 There is a decision at the start of the loop.
                  while +1 There is a decision at the while statement.
                  except +1 Each except branch adds a new conditional path of execution.
                  finally +0 The finally block is unconditionally executed.
                  with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                  assert +1 The assert statement internally roughly equals a conditional statement.
                  Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                  Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Function cache has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def cache(pre=None, local=True):
                      """Cache decorator based on functools.lru_cache.
                  
                      This is not a very good cache, but it "works" for our
                      purposes.
                  Severity: Minor
                  Found in bot/functions.py - About 3 hrs 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

                  Cyclomatic complexity is too high in function build_id_list. (17)
                  Open

                  def build_id_list(
                      user_id: str = None,
                      taxon: Union[list, str] = None,
                      state: Union[list, str] = None,
                      media_type: MediaType = MediaType.IMAGE,
                  Severity: Minor
                  Found in bot/functions.py by radon

                  Cyclomatic Complexity

                  Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                  Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                  Construct Effect on CC Reasoning
                  if +1 An if statement is a single decision.
                  elif +1 The elif statement adds another decision.
                  else +0 The else statement does not cause a new decision. The decision is at the if.
                  for +1 There is a decision at the start of the loop.
                  while +1 There is a decision at the while statement.
                  except +1 Each except branch adds a new conditional path of execution.
                  finally +0 The finally block is unconditionally executed.
                  with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                  assert +1 The assert statement internally roughly equals a conditional statement.
                  Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                  Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Cyclomatic complexity is too high in method race_autocheck. (15)
                  Open

                      async def race_autocheck(self, message: discord.Message):
                          if not database.exists(f"race.data:{message.channel.id}"):
                              return
                  
                          currentBird = database.hget(f"channel:{message.channel.id}", "bird").decode(
                  Severity: Minor
                  Found in bot/cogs/check.py by radon

                  Cyclomatic Complexity

                  Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                  Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                  Construct Effect on CC Reasoning
                  if +1 An if statement is a single decision.
                  elif +1 The elif statement adds another decision.
                  else +0 The else statement does not cause a new decision. The decision is at the if.
                  for +1 There is a decision at the start of the loop.
                  while +1 There is a decision at the while statement.
                  except +1 Each except branch adds a new conditional path of execution.
                  finally +0 The finally block is unconditionally executed.
                  with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                  assert +1 The assert statement internally roughly equals a conditional statement.
                  Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                  Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Cyclomatic complexity is too high in function get_voice_client. (15)
                  Open

                  async def get_voice_client(
                      ctx, connect: bool = False, silent: bool = False
                  ) -> Optional[discord.VoiceClient]:
                      logger.info("fetching voice client")
                  
                  
                  Severity: Minor
                  Found in bot/voice.py by radon

                  Cyclomatic Complexity

                  Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                  Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                  Construct Effect on CC Reasoning
                  if +1 An if statement is a single decision.
                  elif +1 The elif statement adds another decision.
                  else +0 The else statement does not cause a new decision. The decision is at the if.
                  for +1 There is a decision at the start of the loop.
                  while +1 There is a decision at the while statement.
                  except +1 Each except branch adds a new conditional path of execution.
                  finally +0 The finally block is unconditionally executed.
                  with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                  assert +1 The assert statement internally roughly equals a conditional statement.
                  Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                  Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Severity
                  Category
                  Status
                  Source
                  Language