tctree333/Bird-ID

View on GitHub

Showing 124 of 124 total issues

Function display has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def display(self):
        """Return a list describing the filters."""
        output = []
        display = self.aliases(display_lookup=True)
        for title, values in self.__dict__.items():
Severity: Minor
Found in bot/filters.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 url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def url(
        self, taxon_code: str, media_type: MediaType, count: int, cursor: str = ""
    ) -> str:
        """Generate the search url based on the filters.

Severity: Minor
Found in bot/filters.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 getLocations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def getLocations(self, rank_by: str = None, rank_amount: int = None):
        data = None
        world = [
            item
            for item in self._request("/v2/locations", {"source": "jhu"})["locations"]
Severity: Minor
Found in bot/cogs/covid.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 error_handle has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def error_handle(
Severity: Minor
Found in bot/cogs/get_birds.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if (  # spellcheck
                                spellcheck(common, bird, 4) or spellcheck(sci_name, bird, 4)
                            ) and (  # ensure that it's a species by checking for binomial name
                                " " in sci_name
                            ):
    Severity: Major
    Found in bot/core.py - About 45 mins to fix

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

      def format_wiki_url(ctx, bird: str = None) -> str:
          logger.info("fetching wiki url")
          if bird is None:
              bird = ctx
              user_id = 0
      Severity: Minor
      Found in bot/data/__init__.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 to_int has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_int(self):
              """Convert filters into an integer representation.
      
              This is calculated with a 48 digit binary number representing the 48 filter options.
              """
      Severity: Minor
      Found in bot/filters.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

      Avoid deeply nested control flow statements.
      Open

                              if not block:
                                  break
                              out_file.write(block)
      Severity: Major
      Found in bot/core.py - About 45 mins to fix

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

            def from_int(cls, number: int):
                """Convert an int to a filter object."""
                if number >= 2**48 or number < 0:
                    raise ValueError("Input number out of bounds.")
                me = cls()
        Severity: Minor
        Found in bot/filters.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 content_type_lookup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def content_type_lookup(cls, content_type: str) -> Optional[str]:
                for media in cls:
                    for content, ext in media.types().items():
                        if content_type == content:
                            return ext
        Severity: Minor
        Found in bot/filters.py - About 25 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 _state_lists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def _state_lists():
            """Converts txt files of state data into lists."""
            filenames = ("birdList", "songBirds", "aliases")
            states_: Dict[str, Dict[str, List[str]]] = {}
            state_names = os.listdir("bot/data/state")
        Severity: Minor
        Found in bot/data/__init__.py - About 25 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 incorrect_increment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def incorrect_increment(ctx, bird: str, amount: int):
            """Increments the value of an incorrect bird by `amount`.
        
            `ctx` - Discord context object or user id\n
            `bird` - bird that was incorrect\n
        Severity: Minor
        Found in bot/data_functions.py - About 25 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 __call__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def __call__(self, ctx: commands.Context):
                if (
                    ctx.command.name
                    in (
                        "bird",
        Severity: Minor
        Found in bot/functions.py - About 25 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 streak_increment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def streak_increment(ctx, amount: int):
            """Increments the streak of a user by `amount`.
        
            `ctx` - Discord context object or user id\n
            `amount` (int) - amount to increment by, usually 1.
        Severity: Minor
        Found in bot/data_functions.py - About 25 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

        Standard pseudo-random generators are not suitable for security/cryptographic purposes.
        Open

                currentBird = random.choice(id_list)
        Severity: Info
        Found in web/practice.py by bandit

        Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.
        Open

            async def _send_stats(self, ctx: commands.Context, preamble):
        Severity: Critical
        Found in bot/cogs/race.py by sonar-python

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        Refactor this function to reduce its Cognitive Complexity from 35 to the 15 allowed.
        Open

            async def start(self, ctx: commands.Context, *, args_str: str = ""):
        Severity: Critical
        Found in bot/cogs/race.py by sonar-python

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        Consider possible security implications associated with pickle module.
        Open

        import pickle
        Severity: Info
        Found in bot/functions.py by bandit

        Standard pseudo-random generators are not suitable for security/cryptographic purposes.
        Open

                path = f"bot/media/images/drone/{images[random.randint(0,len(images)-1)]}"
        Severity: Info
        Found in bot/functions.py by bandit

        Standard pseudo-random generators are not suitable for security/cryptographic purposes.
        Open

                        currentBird = random.choice(birds)
        Severity: Info
        Found in bot/cogs/get_birds.py by bandit
        Severity
        Category
        Status
        Source
        Language