kontron/python-ipmi

View on GitHub
pyipmi/sdr.py

Summary

Maintainability
F
5 days
Test Coverage

File sdr.py has 489 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# 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
# License as published by the Free Software Foundation; either
Severity: Minor
Found in pyipmi/sdr.py - About 7 hrs to fix

    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

      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 _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 convert_sensor_value_to_raw has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def convert_sensor_value_to_raw(self, value):
              linearization = self.linearization & 0x7f
      
              if linearization is not L_LINEAR:
                  raise NotImplementedError()
      Severity: Minor
      Found in pyipmi/sdr.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 partial_add_sdr has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def partial_add_sdr(self, reservation_id, record_id,
      Severity: Minor
      Found in pyipmi/sdr.py - About 35 mins to fix

        Function convert_sensor_raw_to_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def convert_sensor_raw_to_value(self, raw):
                if raw is None:
                    return None
                fmt = self.analog_data_format
                if (fmt == self.DATA_FMT_1S_COMPLEMENT):
        Severity: Minor
        Found in pyipmi/sdr.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

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

                if capabilities & THRESHOLD_MASK == THRESHOLD_IS_NOT_SUPPORTED:
                    self.capabilities.append('threshold_not_supported')
                elif capabilities & THRESHOLD_MASK == THRESHOLD_IS_READABLE:
                    self.capabilities.append('threshold_readable')
                elif capabilities & THRESHOLD_MASK == THRESHOLD_IS_READ_AND_SETTABLE:
        Severity: Major
        Found in pyipmi/sdr.py and 1 other location - About 7 hrs to fix
        pyipmi/sdr.py on lines 359..366

        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 111.

        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

                if capabilities & HYSTERESIS_MASK == HYSTERESIS_IS_NOT_SUPPORTED:
                    self.capabilities.append('hysteresis_not_supported')
                elif capabilities & HYSTERESIS_MASK == HYSTERESIS_IS_READABLE:
                    self.capabilities.append('hysteresis_readable')
                elif capabilities & HYSTERESIS_MASK == HYSTERESIS_IS_READ_AND_SETTABLE:
        Severity: Major
        Found in pyipmi/sdr.py and 1 other location - About 7 hrs to fix
        pyipmi/sdr.py on lines 373..380

        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 111.

        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 _get_sdr_chunk(self, reservation_id, record_id, offset, length):
                req = create_request_by_name('GetSdr')
                req.reservation_id = reservation_id
                req.record_id = record_id
                req.offset = offset
        Severity: Major
        Found in pyipmi/sdr.py and 1 other location - About 3 hrs to fix
        pyipmi/sensor.py on lines 113..123

        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 72.

        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 sdr_repository_entries(self):
                """A generator that returns the SDR list.
        
                The Generator starts with ID=0x0000 and ends when ID=0xffff
                is returned.
        Severity: Major
        Found in pyipmi/sdr.py and 1 other location - About 3 hrs to fix
        pyipmi/sensor.py on lines 139..153

        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 64.

        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 3 locations. Consider refactoring.
        Open

            def __str__(self):
                s = '["%s"] [%s]' \
                    % (self.device_id_string,
                       ' '.join(['%02x' % b for b in self.data]))
                return s
        Severity: Major
        Found in pyipmi/sdr.py and 2 other locations - About 1 hr to fix
        pyipmi/sdr.py on lines 565..569
        pyipmi/sdr.py on lines 593..597

        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 47.

        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 3 locations. Consider refactoring.
        Open

            def __str__(self):
                s = '["%s"] [%s]' \
                    % (self.device_id_string,
                       ' '.join(['%02x' % b for b in self.data]))
                return s
        Severity: Major
        Found in pyipmi/sdr.py and 2 other locations - About 1 hr to fix
        pyipmi/sdr.py on lines 498..502
        pyipmi/sdr.py on lines 565..569

        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 47.

        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 3 locations. Consider refactoring.
        Open

            def __str__(self):
                s = '["%s"] [%s]' \
                    % (self.device_id_string,
                       ' '.join(['%02x' % b for b in self.data]))
                return s
        Severity: Major
        Found in pyipmi/sdr.py and 2 other locations - About 1 hr to fix
        pyipmi/sdr.py on lines 498..502
        pyipmi/sdr.py on lines 593..597

        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 47.

        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

                if hasattr(self, 'device_id_string'):
                    s = '["%s"] [%s]' % \
                         (self.device_id_string,
                          ' '.join(['%02x' % b for b in self.data]))
                else:
        Severity: Minor
        Found in pyipmi/sdr.py and 1 other location - About 35 mins to fix
        pyipmi/sel.py on lines 157..157

        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 33.

        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 _clear_sdr_repository(self, cmd, reservation_id):
                rsp = self.send_message_with_name('ClearSdrRepository',
                                                  reservation_id=reservation_id,
                                                  cmd=cmd)
                return rsp.status.erase_in_progress
        Severity: Minor
        Found in pyipmi/sdr.py and 1 other location - About 35 mins to fix
        pyipmi/sel.py on lines 39..43

        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 33.

        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

        There are no issues that match your filters.

        Category
        Status