airbnb/caravel

View on GitHub
superset/utils/mock_data.py

Summary

Maintainability
C
1 day
Test Coverage

Function add_sample_rows has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def add_sample_rows(model: type[Model], count: int) -> Iterator[Model]:
    """
    Add entities of a given model.

    :param Model model: a Superset/FAB model
Severity: Minor
Found in superset/utils/mock_data.py - About 3 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 get_type_generator has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def get_type_generator(  # pylint: disable=too-many-return-statements,too-many-branches
    sqltype: sqlalchemy.sql.sqltypes,
) -> Callable[[], Any]:
    if isinstance(sqltype, sqlalchemy.dialects.mysql.types.TINYINT):
        return lambda: random.choice([0, 1])
Severity: Minor
Found in superset/utils/mock_data.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

Avoid too many return statements within this function.
Open

        return lambda: random.uniform(-sys.maxsize, sys.maxsize)
Severity: Major
Found in superset/utils/mock_data.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return lambda: str(uuid4())
    Severity: Major
    Found in superset/utils/mock_data.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return lambda: datetime.fromordinal(MINIMUM_DATE.toordinal()) + timedelta(
      Severity: Major
      Found in superset/utils/mock_data.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return lambda: {
        Severity: Major
        Found in superset/utils/mock_data.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return lambda: b"UNKNOWN TYPE"
          Severity: Major
          Found in superset/utils/mock_data.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return lambda: time(
            Severity: Major
            Found in superset/utils/mock_data.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return lambda: decimal.Decimal(datetime.now().timestamp() * 1000)
              Severity: Major
              Found in superset/utils/mock_data.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return lambda: random.choice([True, False])
                Severity: Major
                Found in superset/utils/mock_data.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return lambda: MINIMUM_DATE + timedelta(days=random.randrange(days_range))
                  Severity: Major
                  Found in superset/utils/mock_data.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return uuid4
                    Severity: Major
                    Found in superset/utils/mock_data.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return lambda: "".join(random.choices(string.ascii_letters, k=length))
                      Severity: Major
                      Found in superset/utils/mock_data.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return lambda: os.urandom(length)
                        Severity: Major
                        Found in superset/utils/mock_data.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return lambda: os.urandom(length)
                          Severity: Major
                          Found in superset/utils/mock_data.py - About 30 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status