airbnb/caravel

View on GitHub
superset/utils/date_parser.py

Summary

Maintainability
D
2 days
Test Coverage

Function get_since_until has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
    time_range: str | None = None,
    since: str | None = None,
    until: str | None = None,
    time_shift: str | None = None,
Severity: Minor
Found in superset/utils/date_parser.py - About 1 day 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

File date_parser.py has 470 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
Severity: Minor
Found in superset/utils/date_parser.py - About 7 hrs to fix

    Function get_since_until has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def get_since_until(  # pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
    Severity: Major
    Found in superset/utils/date_parser.py - About 1 hr to fix

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

          def eval(self) -> datetime:
              dttm_expression, unit = self.value
              dttm = dttm_expression.eval()
              if unit == "year":
                  dttm = dttm.replace(
      Severity: Minor
      Found in superset/utils/date_parser.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 parse_human_datetime has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_human_datetime(human_readable: str) -> datetime:
          """Returns ``datetime.datetime`` from human readable strings"""
          x_periods = r"^\s*([0-9]+)\s+(second|minute|hour|day|week|month|quarter|year)s?\s*$"
          if re.search(x_periods, human_readable, re.IGNORECASE):
              raise TimeRangeAmbiguousError(human_readable)
      Severity: Minor
      Found in superset/utils/date_parser.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 eval has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def eval(self) -> int:
              if len(self.value) == 2:
                  _dttm_from, _dttm_to = self.value
                  return (_dttm_to.eval() - _dttm_from.eval()).days
      
      
      Severity: Minor
      Found in superset/utils/date_parser.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

      There are no issues that match your filters.

      Category
      Status