kontron/python-ipmi

View on GitHub

Showing 341 of 341 total issues

File emulation.py has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import argparse
import logging
import os
import random
import socket
Severity: Minor
Found in pyipmi/emulation.py - About 2 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            string += chr(0x20 + (((d[0] & 0xc0) >> 6) | ((d[1] & 0xf) << 2)))
    Severity: Major
    Found in pyipmi/fields.py and 1 other location - About 2 hrs to fix
    pyipmi/fields.py on lines 60..60

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 59.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            string += chr(0x20 + (((d[1] & 0xf0) >> 4) | ((d[2] & 0x3) << 4)))
    Severity: Major
    Found in pyipmi/fields.py and 1 other location - About 2 hrs to fix
    pyipmi/fields.py on lines 59..59

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 59.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function _from_data has 65 lines of code (exceeds 25 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: Major
    Found in pyipmi/sdr.py - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      @register_message_class
      class ClearSdrRepositoryRsp(Message):
          __cmdid__ = constants.CMDID_CLEAR_SDR_REPOSITORY
          __netfn__ = constants.NETFN_STORAGE | 1
          __fields__ = (
      Severity: Major
      Found in pyipmi/msgs/sdr.py and 1 other location - About 2 hrs to fix
      pyipmi/msgs/sdr.py on lines 213..221

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 57.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      @register_message_class
      class QueryRollbackStatusRsp(PicmgMessage):
          __cmdid__ = constants.CMDID_HPM_QUERY_ROLLBACK_STATUS
          __netfn__ = constants.NETFN_GROUP_EXTENSION | 1
          __fields__ = (
      Severity: Major
      Found in pyipmi/msgs/hpm.py and 1 other location - About 2 hrs to fix
      pyipmi/msgs/vita.py on lines 530..539

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 57.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      @register_message_class
      class RunInitializationAgentRsp(Message):
          __cmdid__ = constants.CMDID_RUN_INITIALIZATION_AGENT
          __netfn__ = constants.NETFN_STORAGE | 1
          __fields__ = (
      Severity: Major
      Found in pyipmi/msgs/sdr.py and 1 other location - About 2 hrs to fix
      pyipmi/msgs/sdr.py on lines 192..200

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 57.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      @register_message_class
      class VitaGetPayloadModeCapabilitiesRsp(VitaMessage):
          __cmdid__ = constants.CMDID_VITA_GET_PAYLOAD_MODE_CAPABILITIES
          __netfn__ = constants.NETFN_GROUP_EXTENSION | 1
          __fields__ = (
      Severity: Major
      Found in pyipmi/msgs/vita.py and 1 other location - About 2 hrs to fix
      pyipmi/msgs/hpm.py on lines 242..250

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 57.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def enable_user(self, userid):
              req = create_request_by_name('SetUserPassword')
              req.userid.userid = userid
              req.operation.operation = PasswordOperation.ENABLE
              rsp = self.send_message(req)
      Severity: Major
      Found in pyipmi/messaging.py and 1 other location - About 2 hrs to fix
      pyipmi/messaging.py on lines 127..132

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def disable_user(self, userid):
              req = create_request_by_name('SetUserPassword')
              req.userid.userid = userid
              req.operation.operation = PasswordOperation.DISABLE
              rsp = self.send_message(req)
      Severity: Major
      Found in pyipmi/messaging.py and 1 other location - About 2 hrs to fix
      pyipmi/messaging.py on lines 120..125

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            def send_and_receive_raw(self, target, lun, netfn, raw_bytes):
                """Interface function to send and receive raw message.
        
                target: IPMI target
                lun: logical unit number
        Severity: Major
        Found in pyipmi/interfaces/ipmbdev.py and 1 other location - About 2 hrs to fix
        pyipmi/interfaces/aardvark.py on lines 188..202

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 53.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        @register_message_class
        class VitaGetFruLedPropertiesRsp(VitaMessage):
            __cmdid__ = constants.CMDID_VITA_GET_FRU_LED_PROPERTIES
            __netfn__ = constants.NETFN_GROUP_EXTENSION | 1
            __fields__ = (
        Severity: Major
        Found in pyipmi/msgs/vita.py and 1 other location - About 2 hrs to fix
        pyipmi/msgs/hpm.py on lines 221..229

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 53.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        @register_message_class
        class QuerySelftestResultsRsp(PicmgMessage):
            __cmdid__ = constants.CMDID_HPM_QUERY_SELFTEST_RESULTS
            __netfn__ = constants.NETFN_GROUP_EXTENSION | 1
            __fields__ = (
        Severity: Major
        Found in pyipmi/msgs/hpm.py and 1 other location - About 2 hrs to fix
        pyipmi/msgs/vita.py on lines 197..205

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 53.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            def send_and_receive_raw(self, target, lun, netfn, raw_bytes):
                """Interface function to send and receive raw message.
        
                target: IPMI target
                lun: logical unit number
        Severity: Major
        Found in pyipmi/interfaces/aardvark.py and 1 other location - About 2 hrs to fix
        pyipmi/interfaces/ipmbdev.py on lines 136..150

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 53.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          @register_message_class
          class GetSdrReq(Message):
              __cmdid__ = constants.CMDID_GET_SDR
              __netfn__ = constants.NETFN_STORAGE
              __fields__ = (
          Severity: Major
          Found in pyipmi/msgs/sdr.py and 1 other location - About 2 hrs to fix
          pyipmi/msgs/sel.py on lines 92..100

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          @register_message_class
          class SetFanLevelReq(PicmgMessage):
              __cmdid__ = constants.CMDID_SET_FAN_LEVEL
              __netfn__ = constants.NETFN_GROUP_EXTENSION
              __fields__ = (
          Severity: Major
          Found in pyipmi/msgs/picmg.py and 1 other location - About 2 hrs to fix
          pyipmi/msgs/dcmi.py on lines 62..70

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language