coady/multimethod

View on GitHub

Showing 13 of 13 total issues

File __init__.py has 405 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import abc
import collections
import contextlib
import functools
import inspect
Severity: Minor
Found in multimethod/__init__.py - About 5 hrs to fix

    Function __new__ has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def __new__(cls, tp, *args):
            if tp is Any:
                return object
            if hasattr(tp, '__supertype__'):  # isinstance(..., NewType) only supported >=3.10
                tp = tp.__supertype__
    Severity: Minor
    Found in multimethod/__init__.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 __instancecheck__ has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def __instancecheck__(self, instance):
            if self.__origin__ is Literal:
                return any(type(arg) == type(instance) and arg == instance for arg in self.__args__)
            if self.__origin__ is Union:
                return isinstance(instance, self.__args__)
    Severity: Minor
    Found in multimethod/__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 __subclasscheck__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def __subclasscheck__(self, subclass):
            origin = get_origin(subclass) or subclass
            args = get_args(subclass)
            if origin is Literal:
                return all(isinstance(arg, self) for arg in args)
    Severity: Minor
    Found in multimethod/__init__.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

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

        def __setitem__(self, types: tuple, func: Callable):
            self.clean()
            if not isinstance(types, signature):
                types = signature(types)
            parents = types.parents = self.parents(types)
    Severity: Minor
    Found in multimethod/__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

    Avoid too many return statements within this function.
    Open

                return (
    Severity: Major
    Found in multimethod/__init__.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return False
      Severity: Major
      Found in multimethod/__init__.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return issubclass(subtype(Callable, *get_type_hints(instance).values()), self)
        Severity: Major
        Found in multimethod/__init__.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return False
          Severity: Major
          Found in multimethod/__init__.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return (  # check args first to avoid recursion error: python/cpython#73407
            Severity: Major
            Found in multimethod/__init__.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return all(map(isinstance, instance, self.__args__))
              Severity: Major
              Found in multimethod/__init__.py - About 30 mins to fix

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

                    def __call__(self, *args, **kwargs):
                        """Dispatch to first matching function."""
                        while self.pending:
                            func = self.pending.pop()
                            self[self.signature(func)] = func
                Severity: Minor
                Found in multimethod/__init__.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

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

                    def select(self, types: tuple, keys: set[signature]) -> Callable:
                        keys = {key for key in keys if key.callable(*types)}
                        funcs = {self[key] for key in keys}
                        if len(funcs) > 1:
                            groups = collections.defaultdict(set)
                Severity: Minor
                Found in multimethod/__init__.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