kmein/menstruation-telegram

View on GitHub

Showing 28 of 28 total issues

File handlers.py has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
import functools
import logging
import random
import re
Severity: Minor
Found in menstruation/handlers.py - About 5 hrs to fix

    Function from_text has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_text(text: str) -> "Tag":
            if text == "vegetarian":
                return Tag.VEGETARIAN
            elif text == "vegan":
                return Tag.VEGAN
    Severity: Minor
    Found in menstruation/query.py - About 2 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

    Function __str__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def __str__(self: "Tag") -> str:
            if self == Tag.VEGETARIAN:
                return "vegetarian"
            elif self == Tag.VEGAN:
                return "vegan"
    Severity: Minor
    Found in menstruation/query.py - About 2 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

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

    def notify_subscriber(context: CallbackContext):
        user_id = context.job.name
        if not user_db.is_subscriber(user_id):
            logging.error(f"{user_id} is no subscriber, but had a subscription job")
            remove_subscriber(user_id)
    Severity: Minor
    Found in menstruation/jobs.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 from_text has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_text(text: str) -> "Query":
            def extract_date(text: str) -> Optional[date]:
                matches = re.search(r"(\d{4}-\d{2}-\d{2}|today|tomorrow)", text)
                if matches:
                    if matches.group(1) == "today":
    Severity: Minor
    Found in menstruation/query.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in menstruation/query.py - About 35 mins to fix

      Avoid too many return statements within this function.
      Open

                  return Tag.CO2_B
      Severity: Major
      Found in menstruation/query.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return "H2O E"
        Severity: Major
        Found in menstruation/query.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return Tag.CO2_E
          Severity: Major
          Found in menstruation/query.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return "H2O A"
            Severity: Major
            Found in menstruation/query.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return Tag.CO2_C
              Severity: Major
              Found in menstruation/query.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return "CO2 A"
                Severity: Major
                Found in menstruation/query.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return "CO2 C"
                  Severity: Major
                  Found in menstruation/query.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return "H2O B"
                    Severity: Major
                    Found in menstruation/query.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return Tag.CO2_A
                      Severity: Major
                      Found in menstruation/query.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return "climate friendly"
                        Severity: Major
                        Found in menstruation/query.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return "H2O C"
                          Severity: Major
                          Found in menstruation/query.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return Tag.H2O_C
                            Severity: Major
                            Found in menstruation/query.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return Tag.CLIMATE_FRIENDLY
                              Severity: Major
                              Found in menstruation/query.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return "CO2 E"
                                Severity: Major
                                Found in menstruation/query.py - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language