Function csv_import
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def csv_import(table: Any, file: str, ignore: bool = False) -> Tuple:
"""csv import into DynamoDB table
Args:
table (Any): boto3 DynamoDB table object
- 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 write_to_dynamo
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def write_to_dynamo(table: Any, rows: Dict, ignore: bool = False) -> None:
"""csv rows into DynamoDB
Args:
table (Any): boto3 DynamoDB table object
- 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 convert_column
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def convert_column(spec: str, row: Dict, key: str, delimiter: str) -> Any:
"""convert column
Args:
spec (str): type of column
- 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 deeply nested control flow statements. Open
if "ConvertBlankToDropAttrs" in csv_spec["IMPORT_OPTION"] and not row[key]:
to_drop_attrs = csv_spec.get("IMPORT_OPTION", "ConvertBlankToDropAttrs").split(",")
if key in to_drop_attrs:
del row[key]
continue
Avoid deeply nested control flow statements. Open
if "ConvertBlankToNullAttrs" in csv_spec["IMPORT_OPTION"] and not row[key]:
to_null_attrs = csv_spec.get("IMPORT_OPTION", "ConvertBlankToNullAttrs").split(",")
if key in to_null_attrs:
row[key] = None
continue
Avoid too many return
statements within this function. Open
return json.loads(row[key], parse_float=Decimal)
Avoid too many return
statements within this function. Open
return row[key]
Avoid too many return
statements within this function. Open
return list(map(Decimal, row[key].split(delimiter)))
Avoid too many return
statements within this function. Open
return row[key].split(delimiter)
Avoid too many return
statements within this function. Open
return set(row[key].split(delimiter))
Avoid too many return
statements within this function. Open
return set(list(map(Decimal, row[key].split(delimiter))))