kontron/python-ipmi

View on GitHub

Showing 88 of 341 total issues

Function get_sdr_data_helper has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def get_sdr_data_helper(reserve_fn, get_fn, record_id, reservation_id=None):
    """Helper function to retrieve the sdr data.

    A specified helper function is used to retrieve the chunks.

Severity: Minor
Found in pyipmi/helper.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

File sensor.py has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import absolute_import
# Copyright (c) 2014  Kontron Europe GmbH
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Severity: Minor
Found in pyipmi/msgs/sensor.py - About 2 hrs to fix

    Session has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Session(object):
        AUTH_TYPE_NONE = 0x00
        AUTH_TYPE_MD2 = 0x01
        AUTH_TYPE_MD5 = 0x02
        AUTH_TYPE_PASSWORD = 0x04
    Severity: Minor
    Found in pyipmi/session.py - About 2 hrs to fix

      Function unpack has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def unpack(self, pdu):
              auth_type = array('B', pdu)[0]
      
              if auth_type != 0:
                  header_len = struct.calcsize(self.HEADER_FORMAT_AUTH)
      Severity: Minor
      Found in pyipmi/interfaces/rmcp.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 read_fru_data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def read_fru_data(self, offset=None, count=None, fru_id=0):
              req_size = 32
              data = array.array('B')
      
              # first check for maximum area size
      Severity: Minor
      Found in pyipmi/fru.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 _decode_capabilities has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _decode_capabilities(self, capabilities):
              self.capabilities = []
      
              # ignore sensor
              if capabilities & 0x80:
      Severity: Minor
      Found in pyipmi/sdr.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 cmd_sdr_list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def cmd_sdr_list(ipmi, args):
          iter_fct = None
      
          device_id = ipmi.get_device_id()
          if device_id.supports_function('sdr_repository'):
      Severity: Minor
      Found in pyipmi/ipmitool.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 get_sel_entry has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_sel_entry(self, record_id, reservation=0):
              ENTIRE_RECORD = 0xff
              req = create_request_by_name('GetSelEntry')
              req.reservation_id = reservation
              req.record_id = record_id
      Severity: Minor
      Found in pyipmi/sel.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 get_and_clear_sel_entry has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_and_clear_sel_entry(self, record_id):
              """Atomically gets and clears the specified SEL record"""
              while True:
                  reservation = self.get_sel_reservation_id()
                  try:
      Severity: Minor
      Found in pyipmi/sel.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_response has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def _from_response(self, res):
              self.local_state_available = bool(res.led_states.local_avail)
              self.override_enabled = bool(res.led_states.override_en)
              self.lamp_test_enabled = bool(res.led_states.lamp_test_en)
      
      
      Severity: Minor
      Found in pyipmi/picmg.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 upload_binary has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def upload_binary(self, binary, timeout=2, interval=0.1, retry=3):
              """Upload all firmware blocks from a binary."""
              block_number = 0
              block_size = self._determine_max_block_size()
      
      
      Severity: Minor
      Found in pyipmi/hpm.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 _parse_output has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def _parse_output(self, output):
              cc, rsp = None, None
              hexstr = ''
      
              for line in py3dec_unic_bytes_fix(output).split('\n'):
      Severity: Minor
      Found in pyipmi/interfaces/ipmitool.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 wait_for_long_duration_command has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def wait_for_long_duration_command(self, expected_cmd, timeout, interval):
      
              start_time = time.time()
              while time.time() < start_time + timeout:
                  try:
      Severity: Minor
      Found in pyipmi/hpm.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 _clear_repository has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def _clear_repository(reserve_fn, clear_fn, ctrl, retry, reservation):
          while True:
              retry -= 1
              if retry <= 0:
                  raise RetryError()
      Severity: Minor
      Found in pyipmi/helper.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 pack has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def pack(self, sdu):
              if sdu is not None:
                  data_len = len(sdu)
              else:
                  data_len = 0
      Severity: Minor
      Found in pyipmi/interfaces/rmcp.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 send_and_receive_raw has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def send_and_receive_raw(self, target, lun, netfn, raw_bytes):
              if self._interface_type in ['lan', 'lanplus']:
                  cmd = self._build_ipmitool_cmd(target, lun, netfn, raw_bytes)
              elif self._interface_type in ['open']:
                  cmd = self._build_open_ipmitool_cmd(target, lun, netfn, raw_bytes)
      Severity: Minor
      Found in pyipmi/interfaces/ipmitool.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_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _from_data(self, data):
              buffer = ByteBuffer(data[5:])
              # record key bytes
              self._common_record_key(buffer.pop_slice(3))
              # record body bytes
      Severity: Minor
      Found in pyipmi/sdr.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 cmd_picmg_get_portstate_all has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def cmd_picmg_get_portstate_all(ipmi, args):
          for interface in range(3):
              for channel in range(16):
                  try:
                      (p, s) = ipmi.get_port_state(channel, interface)
      Severity: Minor
      Found in pyipmi/ipmitool.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_response has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _from_response(self, rsp):
              self.power_on = bool(rsp.current_power_state.power_on)
              self.overload = bool(rsp.current_power_state.power_overload)
              self.interlock = bool(rsp.current_power_state.interlock)
              self.fault = bool(rsp.current_power_state.power_fault)
      Severity: Minor
      Found in pyipmi/chassis.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 set_sensor_thresholds has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def set_sensor_thresholds(self, sensor_number, lun=0,
      Severity: Major
      Found in pyipmi/sensor.py - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language