jupi2142/drf_lighten

View on GitHub

Showing 6 of 6 total issues

Function parse has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(self, string: str) -> dict:
        stack = []
        for index, char in enumerate(string):
            if char.isspace():
                continue
Severity: Minor
Found in drf_lighten/parsers/new.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 merge has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def merge(fields: dict, exclude: dict) -> dict:
    unified = {
        "type": "keep",
        "fields": {
            "self": [],
Severity: Minor
Found in drf_lighten/lighteners.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 adapt has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def adapt(fields: Structure, type_="keep") -> dict:
    self_ = []
    nested = {}

    for field in fields:
Severity: Minor
Found in drf_lighten/lighteners.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

Function parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(self, string: str) -> Structure:
        first_split = sorted(string.strip(".,").split(","), key=len)
        second_split = [s.split(".", 1) for s in first_split]

        self_ = []
Severity: Minor
Found in drf_lighten/parsers/old.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

Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Minor
Found in drf_lighten/serializers.py - About 35 mins to fix

    Function lighten has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def lighten(
            self,
            serializer: Serializer,
            structure: Dict[str, Dict],
        ) -> None:
    Severity: Minor
    Found in drf_lighten/lighteners.py - About 25 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