strizhechenko/netutils-linux

View on GitHub

Showing 15 of 21 total issues

Function make_table has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def make_table(header, align_map=None, rows=None):
    """ Wrapper for pretty table """
    table = PrettyTable()
    table.horizontal_char = table.vertical_char = table.junction_char = ' '
    try:
Severity: Minor
Found in netutils_linux_monitoring/layout.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 eval has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def eval(self):
        self.diff = deepcopy(self.current)
        for i, line in enumerate(self.diff):
            for j, column in enumerate(line):
                if isinstance(column, int):
Severity: Minor
Found in netutils_linux_monitoring/irqtop.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 eval has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def eval(self):
        """ Evaluates difference between snmp metrics """
        self.diff = deepcopy(self.current)
        for proto, data in iteritems(self.diff):
            for i, metric in enumerate(data):
Severity: Minor
Found in netutils_linux_monitoring/snmptop.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 run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self):
        """ Default main()-like function for specific top-like utils except meta-utils. """
        infinite = -1
        if self.options.iterations != infinite:
            self.options.iterations += 1
Severity: Minor
Found in netutils_linux_monitoring/base_top.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 netdev_queue_relationship has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def netdev_queue_relationship(queue, dev):
        if dev not in queue:
            return
        if queue == dev:
            return 'own'
Severity: Minor
Found in netutils_linux_hardware/interrupts.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 unit_change has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def unit_change(self):
        if not any([self.options.bits, self.options.kbits, self.options.mbits]):
            return
        for i, stat in enumerate(self.stats):
            if 'bytes' not in stat.shortname:
Severity: Minor
Found in netutils_linux_monitoring/link_rate.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 apply has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def apply(self, decision):
        """
        '* 4' is in case of NIC has more queues than socket has CPUs
        :param decision: list of tuples(irq, queue_name, socket)
        """
Severity: Minor
Found in netutils_linux_tuning/rss_ladder.py - About 35 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 eval has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def eval(self):
        self.diff = deepcopy(self.current)
        for dev, data in iteritems(self.current):
            for stat in self.stats:
                if self.options.random:
Severity: Minor
Found in netutils_linux_monitoring/link_rate.py - About 35 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 'shared'
Severity: Major
Found in netutils_linux_hardware/interrupts.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return 'unknown'
    Severity: Major
    Found in netutils_linux_hardware/interrupts.py - About 30 mins to fix

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

          def mask_detect(self):
              """
              Finds a way to calculate CPU mask to apply:
              1. --cpu-mask
              2. --cpus
      Severity: Minor
      Found in netutils_linux_tuning/auto_softirq_tune.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 detect_layout_lscpu has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def detect_layout_lscpu(self, lscpu_output=None):
              """
              :param lscpu_output: <str> with output of `lscpu -p` or None
              :return: <str> output of `lscpu -p` or None
              """
      Severity: Minor
      Found in netutils_linux_monitoring/topology.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 make_rows has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def make_rows(self):
              cpu_count = 0
              output_lines = list()
              if not self.diff_total:
                  return ''
      Severity: Minor
      Found in netutils_linux_monitoring/irqtop.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 make_rows has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def make_rows(self):
              """ :returns: rows for prettytable output (filled with empty values) """
              rows = []
              repr_source = self.repr_source()
              max_len = max(len(subdict) for subdict in repr_source.values())
      Severity: Minor
      Found in netutils_linux_monitoring/snmptop.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 all_netdev_queues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def all_netdev_queues(text, netdevs):
              for line in text.strip().split('\n'):
                  for netdev in netdevs:
                      if netdev in line:
                          yield line.strip()
      Severity: Minor
      Found in netutils_linux_hardware/interrupts.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