tctree333/Bird-ID

View on GitHub

Showing 30 of 124 total issues

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

      Severity
      Category
      Status
      Source
      Language