fabiommendes/sidekick

View on GitHub
sidekick-seq/sidekick/seq/lib_grouping.py

Summary

Maintainability
C
7 hrs
Test Coverage

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

Function _chunks_sizes_ex has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def _chunks_sizes_ex(ns, seq, drop, pad):
    buf = []
    clear = buf.clear
    fill = buf.extend
    seq = iter(seq)
Severity: Minor
Found in sidekick-seq/sidekick/seq/lib_grouping.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 chunks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def chunks(
    n: Union[int, Iterable[int]], seq: Seq[T], *, pad=NOT_GIVEN, drop: bool = False
) -> Iter[Tuple[T, ...]]:
    """
    Partition sequence into non-overlapping tuples of length n.
Severity: Minor
Found in sidekick-seq/sidekick/seq/lib_grouping.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 chunks has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def chunks(
Severity: Minor
Found in sidekick-seq/sidekick/seq/lib_grouping.py - About 35 mins to fix

    Avoid too many return statements within this function.
    Open

            return Iter(_chunks_split(func, seq))
    Severity: Major
    Found in sidekick-seq/sidekick/seq/lib_grouping.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return Iter(_chunks_sizes_ex(n, seq, False, pad))
      Severity: Major
      Found in sidekick-seq/sidekick/seq/lib_grouping.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return Iter(_chunks_sizes(n, seq))
        Severity: Major
        Found in sidekick-seq/sidekick/seq/lib_grouping.py - About 30 mins to fix

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

          def chunks_by(func: Func, seq: Seq, how: ChunksHow = "values") -> Iter:
              """
              Partition sequence into chunks according to a function.
          
              It creates a new partition every time the value of func(item) changes.
          Severity: Minor
          Found in sidekick-seq/sidekick/seq/lib_grouping.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

          There are no issues that match your filters.

          Category
          Status