Cerberus1746/dataclass_dict

View on GitHub

Showing 4 of 4 total issues

Function __getitem__ has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def __getitem__(self, key: Union[int, str, slice]) -> Union[List[Any], Any]:
        if isinstance(key, int):
            key_name = self._mapping[key]
            return self.__getitem__(key_name)

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

    def __new__(cls, *_, **kwargs: Dict[str, Any]) -> "DataclassDict":
        if not hasattr(cls, "dataclass_args"):
            raise TypeError(
                "You can't instance the class directly, you must inherit it first or "
                "use the function 'create_dataclass_dict', 'dataclass_from_dict' or"
Severity: Minor
Found in src/dataclass_dict/__init__.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 __setattr__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def __setattr__(self, key: Union[str, int], value: Any):
        if key[0] != "_" and key not in self:
            field_type = type(value)

            if key not in getattr(self, _FIELDS):
Severity: Minor
Found in src/dataclass_dict/__init__.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_subclass__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def __init_subclass__(cls, **kwargs: Dict[str, Any]):
        cls.dataclass_args = {}

        for param_name, param in signature(dataclass).parameters.items():
            # both cls and _cls are to avoid bugs with nightly version of python.
Severity: Minor
Found in src/dataclass_dict/__init__.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

Severity
Category
Status
Source
Language