collerek/sqlalchemy-to-ormar

View on GitHub

Showing 3 of 3 total issues

Function _extract_relations has a Cognitive Complexity of 18 (exceeds 8 allowed). Consider refactoring.
Open

def _extract_relations(
    mapper: Mapper,
    fields: Dict,
    reverse: bool,
    metadata: MetaData,
Severity: Minor
Found in sqlalchemy_to_ormar/main.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 _extract_db_columns has a Cognitive Complexity of 15 (exceeds 8 allowed). Consider refactoring.
Open

def _extract_db_columns(table: Table, exclude: Container[str], fields: Dict) -> Dict:
    for column in table.columns:
        if column.key in exclude or column.foreign_keys:
            continue
        field_definition = dict()
Severity: Minor
Found in sqlalchemy_to_ormar/main.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 _update_refs_in_related has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
Open

def _update_refs_in_related(model: Type[Model]):
    fields_dict = list(model.Meta.model_fields.items())
    for name, field in fields_dict:
        if field.is_relation:
            target = model.Meta.model_fields[name].to
Severity: Minor
Found in sqlalchemy_to_ormar/main.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

Severity
Category
Status
Source
Language