kmein/menstruation-telegram

View on GitHub
menstruation/query.py

Summary

Maintainability
D
2 days
Test Coverage

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 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

                                Avoid too many return statements within this function.
                                Open

                                            return Tag.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.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.H2O_E
                                    Severity: Major
                                    Found in menstruation/query.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

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

                                        Avoid too many return statements within this function.
                                        Open

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

                                          Avoid too many return statements within this function.
                                          Open

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

                                            Avoid too many return statements within this function.
                                            Open

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

                                              Avoid too many return statements within this function.
                                              Open

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

                                                There are no issues that match your filters.

                                                Category
                                                Status