fabiommendes/sidekick

View on GitHub

Showing 157 of 157 total issues

Function lazy_singledispatch has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

def lazy_singledispatch(func):  # noqa: C901
    """
    Single-dispatch generic function decorator.

    Transforms a function into a generic function, which can have different
Severity: Minor
Found in sidekick-experimental/sidekick/experimental/function_dispatch.py - About 6 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

fn has 31 functions (exceeds 20 allowed). Consider refactoring.
Open

class fn(mixins.FnMixin, metaclass=FunctionMeta):
    """
    Base class for function-like objects in Sidekick.
    """

Severity: Minor
Found in sidekick-functions/sidekick/functions/fn.py - About 3 hrs to fix

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

        def __getitem__(self, item, _chain=itertools.chain):
            if isinstance(item, int):
                if item >= 0:
                    head = []
                    for i, x in enumerate(self._iterator):
    Severity: Minor
    Found in sidekick-seq/sidekick/seq/iter.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 funcs has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def funcs(ret, arity=None, *, pure=True, accept_kwargs=True, diversity=50):
        """
        Return random functions.
    
        Args:
    Severity: Minor
    Found in sidekick-hypothesis/sidekick/hypothesis/base.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 decompose has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def decompose(self):
        """
        Return a namedtuple with the parts of function signature.
        """
    
    
    Severity: Minor
    Found in sidekick-beta/sidekick/beta/app/function_wrapper.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 partition has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def partition(
        key: Union[int, Pred], seq: Seq, sep: bool = False
    ) -> Union[Tuple[Seq, Seq], Tuple[list, list, Seq]]:
        """
        Partition sequence in two.
    Severity: Minor
    Found in sidekick-seq/sidekick/seq/lib_grouping.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

    L has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class L(DataMagic, type=list):
        """
        Class for the L magic object.
        """
    
    
    Severity: Minor
    Found in sidekick-experimental/sidekick/experimental/magics/list_magic.py - About 2 hrs to fix

      Function _casedispatch has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      def _casedispatch(base, default_method=None):
          registry = {}
          cache = {}
      
          def error(cls):
      Severity: Minor
      Found in sidekick-experimental/sidekick/experimental/case_syntax.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 simplify_ast has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      def simplify_ast(ast):
          """Deep AST simplification"""
      
          if isinstance(ast, GetAttr):
              attr, value = ast
      Severity: Minor
      Found in sidekick-functions/sidekick/functions/fn_placeholders.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 shape_tree has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      def shape_tree(max_depth, attrs, leaves):
          mk_attrs = mk_random_attrs(attrs)
          strategy = random.choice(["shallow", "deep", "random"])
          root = Node(**mk_attrs())
      
      
      Severity: Minor
      Found in sidekick-hypothesis/sidekick/hypothesis/tree.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 unique has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      def unique(seq: Seq, *, key: Func = None, exclude: Seq = (), slow=False) -> Iter:
          """
          Returns the given sequence with duplicates removed.
      
          Preserves order. If key is supplied map distinguishes values by comparing
      Severity: Minor
      Found in sidekick-seq/sidekick/seq/lib_selecting.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

      Iter has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Iter(Iterator[T]):
          """
          Base sidekick iterator class.
      
          This class extends classical Python iterators with a few extra operators.
      Severity: Minor
      Found in sidekick-seq/sidekick/seq/iter.py - About 2 hrs to fix

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

        def op_wrapper_class(
            binary,
            rbinary=None,
            unary=None,
            arithmetic=True,
        Severity: Minor
        Found in sidekick-api/sidekick/api/_operators.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 from_namespace has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def from_namespace(base, namespace=None):
            if namespace is None:
                return lambda ns: from_namespace(base, ns)
            if not base._UnionMeta__is_closed:
                return SimpleNamespace(base=base, namespace=namespace, dispatch=...)
        Severity: Minor
        Found in sidekick-experimental/sidekick/experimental/case_syntax.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 impure has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def impure(name, tt, ns, *, arity=None, flip=False):
            method = getattr(tt, name)
            if name in ns:
                raise TypeError(f"function already registered: {name}")
        
        
        Severity: Minor
        Found in sidekick-experimental/sidekick/experimental/magics/base_magics.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 peek has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def peek(self, steps=0, *, default=NOT_GIVEN):
                """
                Peek next element without consuming iterator.
        
                Pass the number of steps to check how many steps forward it will peek.
        Severity: Minor
        Found in sidekick-experimental/sidekick/experimental/iterators.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 _from_sequence has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def _from_sequence(self, seq):
                if len(seq) < 2:
                    raise ValueError("sequence must have at least 2 elements")
        
                idx = seq.index(...)
        Severity: Minor
        Found in sidekick-seq/sidekick/seq/lib_creation.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 _sibling has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def _sibling(self, delta):
                if self._parent is not None:
                    siblings = self._parent.children
                    for idx, sibling in enumerate(siblings):
                        if self is sibling:
        Severity: Minor
        Found in sidekick-tree/sidekick/tree/node_base.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 map_if has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def map_if(pred: Pred, func: Func, *seqs: Seq, index: Index = None) -> Iter:
            """
            Applies func in the elements in which pred(elem) is True.
        
            If more than one sequence is given, non-transformed elements are obtained
        Severity: Minor
        Found in sidekick-seq/sidekick/seq/lib_transforming.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 dedupe has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def dedupe(seq: Seq, *, key: Func = None) -> Iter:
            """
            Remove duplicates of successive elements.
        
            Args:
        Severity: Minor
        Found in sidekick-seq/sidekick/seq/lib_selecting.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

        Severity
        Category
        Status
        Source
        Language