cliffxuan/mew

View on GitHub

Showing 10 of 11 total issues

Function deserialize has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def deserialize(
        self, t: Any, value: Any, convert_key: Callable = lambda x: x
    ) -> Any:
        if t in self.serializers:
            return self.serializers[t].deserialize(value)
Severity: Minor
Found in mew/serializer.py - About 3 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 find_unsupported has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def find_unsupported(t: typing.Any) -> typing.List[typing.Any]:
    if t in SCALAR_TYPES:
        return []
    if isinstance(t, type):  # if it's a class
        if issubclass(t, enum.Enum):
Severity: Minor
Found in mew/decorator.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 serialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def serialize(self, obj: Any, convert_key: Callable = lambda x: x) -> Any:
        for t in self.serializers:
            if isinstance(obj, t):
                return self.serializers[t].serialize(obj)

Severity: Minor
Found in mew/serializer.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 too many return statements within this function.
Open

    return [t]
Severity: Major
Found in mew/decorator.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

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

      Avoid too many return statements within this function.
      Open

                  return find_unsupported(t.__args__[0])
      Severity: Major
      Found in mew/decorator.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return [self.serialize(i, convert_key) for i in obj]
        Severity: Major
        Found in mew/serializer.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return [arg for arg in t.__args__ if find_unsupported(arg)]
          Severity: Major
          Found in mew/decorator.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return [self.deserialize(args[0], item, convert_key) for item in value]
            Severity: Major
            Found in mew/serializer.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                      return self.deserialize(arg, value, convert_key)
              Severity: Major
              Found in mew/serializer.py - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language