superset/utils/mock_data.py
Function add_sample_rows
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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
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])
- Read upRead up
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
Open
return lambda: random.uniform(-sys.maxsize, sys.maxsize)
Avoid too many return
statements within this function. Open
Open
return lambda: str(uuid4())
Avoid too many return
statements within this function. Open
Open
return lambda: datetime.fromordinal(MINIMUM_DATE.toordinal()) + timedelta(
Avoid too many return
statements within this function. Open
Open
return lambda: {
Avoid too many return
statements within this function. Open
Open
return lambda: b"UNKNOWN TYPE"
Avoid too many return
statements within this function. Open
Open
return lambda: time(
Avoid too many return
statements within this function. Open
Open
return lambda: decimal.Decimal(datetime.now().timestamp() * 1000)
Avoid too many return
statements within this function. Open
Open
return lambda: random.choice([True, False])
Avoid too many return
statements within this function. Open
Open
return lambda: MINIMUM_DATE + timedelta(days=random.randrange(days_range))
Avoid too many return
statements within this function. Open
Open
return uuid4
Avoid too many return
statements within this function. Open
Open
return lambda: "".join(random.choices(string.ascii_letters, k=length))
Avoid too many return
statements within this function. Open
Open
return lambda: os.urandom(length)
Avoid too many return
statements within this function. Open
Open
return lambda: os.urandom(length)