linkedin/kafka-tools

View on GitHub
kafka/tools/assigner/actions/balancemodules/rackaware.py

Summary

Maintainability
A
50 mins
Test Coverage

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

    def _try_pick_swap_partition(self, partition, pos, small_partitions, large_partitions):
        """
        Given a partition and a replica position, try and find a partition that has a replica in the same position
        that can be swapped to improve rack separation. The partition selected should be the closest in size possible.

Severity: Minor
Found in kafka/tools/assigner/actions/balancemodules/rackaware.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 _process_partitions_at_pos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _process_partitions_at_pos(self, pos):
        # Create a sorted list of partitions to use at this position (descending size)
        partitions = self._get_sorted_partition_list_at_pos(pos)

        for i, partition in enumerate(partitions):
Severity: Minor
Found in kafka/tools/assigner/actions/balancemodules/rackaware.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