thesadru/apimodel

View on GitHub
apimodel/generator.py

Summary

Maintainability
C
1 day
Test Coverage
A
90%

Function add_schema has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

def add_schema(
    schema_name: str,
    raw_schema: typing.Mapping[str, RawSchema],
    schemas: typing.MutableMapping[str, Schema],
) -> Schema:
Severity: Minor
Found in apimodel/generator.py - About 4 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 format_field_type has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def format_field_type(
    field: typing.Union[str, Field],
    *,
    python: typing.Optional[VersionInfo] = None,
) -> str:
Severity: Minor
Found in apimodel/generator.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 join_mappings has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def join_mappings(mappings: typing.Sequence[typing.Mapping[str, T]]) -> typing.Mapping[str, tutils.MaybeTuple[T]]:
    """Join a sequence of mappings."""
    output: typing.Mapping[str, tutils.MaybeTuple[T]] = {}
    for index, mapping in enumerate(mappings):
        for k, value in mapping.items():
Severity: Minor
Found in apimodel/generator.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 recognize_json_type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def recognize_json_type(value: JSONType) -> RawSchema:
    """Recognize JSON type of value."""
    if value in tutils.NoneTypes:
        return "None"

Severity: Minor
Found in apimodel/generator.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 generate_models has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def generate_models(
    data: JSONType,
    *,
    python: typing.Optional[VersionInfo] = None,
) -> str:
Severity: Minor
Found in apimodel/generator.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

Avoid deeply nested control flow statements.
Open

                    if not isinstance(x, str):
                        raise ValueError("Found nesting in the raw schema.")

Severity: Major
Found in apimodel/generator.py - About 45 mins to fix

    There are no issues that match your filters.

    Category
    Status