danishi/dynamodb-csv

View on GitHub

Showing 26 of 26 total issues

Function csv_export has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

def csv_export(table: Any, file: str, parameters: Dict = {}) -> Tuple:
    """Export DynamoDB table to csv

    Args:
        table (Table): boto3 DynamoDB table object
Severity: Minor
Found in app/dynamodb/csv_export.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

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
Severity: Minor
Found in app/dynamodb/csv_import.py - About 5 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 execute has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def execute() -> Tuple:
    """Command execute

    Raises:
        ValueError: invalid config
Severity: Minor
Found in app/main.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 convert_item has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def convert_item(spec: str, item: Dict, key: str, delimiter: str) -> Any:
    """convert item

    Args:
        spec (str): type of item
Severity: Minor
Found in app/dynamodb/csv_export.py - About 1 hr 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 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
Severity: Minor
Found in app/dynamodb/csv_import.py - About 1 hr 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 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
Severity: Minor
Found in app/dynamodb/csv_import.py - About 1 hr 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 move has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def move(tables: List) -> Tuple:
    """DynamoDB table items move

    Args:
        tables (List): boto3 DynamoDB table objects
Severity: Minor
Found in app/dynamodb/move.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

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
Severity: Major
Found in app/dynamodb/csv_import.py - About 45 mins to fix

    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
    Severity: Major
    Found in app/dynamodb/csv_import.py - About 45 mins to fix

      Function truncate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def truncate(table: Any) -> Tuple:
          """DynamoDB table truncate
      
          Args:
              table (Any): boto3 DynamoDB table object
      Severity: Minor
      Found in app/dynamodb/truncate.py - About 35 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 config_read_and_get_table has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def config_read_and_get_table(args: Any) -> List:
          """Config read and Create DynamoDB table instance
      
          Args:
              args (Any): arguments
      Severity: Minor
      Found in app/main.py - About 35 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

      Avoid too many return statements within this function.
      Open

              return ("{name} csv exported {count} items".format(
      Severity: Major
      Found in app/dynamodb/csv_export.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return json.dumps(item[key], default=decimal_encode)
        Severity: Major
        Found in app/dynamodb/csv_export.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return json.loads(row[key], parse_float=Decimal)
          Severity: Major
          Found in app/dynamodb/csv_import.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return row[key]
            Severity: Major
            Found in app/dynamodb/csv_import.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return result
              Severity: Major
              Found in app/main.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return list(map(Decimal, row[key].split(delimiter)))
                Severity: Major
                Found in app/dynamodb/csv_import.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return ("Move mode requires a two tables.", 1)
                  Severity: Major
                  Found in app/main.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return row[key].split(delimiter)
                    Severity: Major
                    Found in app/dynamodb/csv_import.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return (str(e), 1)
                      Severity: Major
                      Found in app/dynamodb/csv_export.py - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language