vinyguedess/alcherializer

View on GitHub

Showing 4 of 4 total issues

Function _get_fields has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_fields(self) -> Dict[str, Any]:
        required_fields = []
        if hasattr(self.meta, "fields"):
            required_fields = self.meta.fields

Severity: Minor
Found in alcherializer/serializer.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 _get_instance_field_value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_instance_field_value(self, instance, field: str) -> Any:
        if isinstance(self.fields[field].get("type"), fields.MethodField):
            return getattr(self, f"get_{field}", lambda o: None)(instance)

        value = getattr(instance, field)
Severity: Minor
Found in alcherializer/serializer.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 too many return statements within this function.
Open

        return value
Severity: Major
Found in alcherializer/serializer.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return fields.BaseField(key, field)
    Severity: Major
    Found in alcherializer/serializer.py - About 30 mins to fix
      Severity
      Category
      Status
      Source
      Language