kontron/python-ipmi

View on GitHub
pyipmi/ipmitool.py

Summary

Maintainability
F
1 wk
Test Coverage

File ipmitool.py has 599 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3

# Copyright (c) 2014  Kontron Europe GmbH
#
# This library is free software; you can redistribute it and/or
Severity: Major
Found in pyipmi/ipmitool.py - About 1 day to fix

    Function usage has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    def usage(toplevel=False):
        commands = []
        maxlen = 0
    
        if toplevel:
    Severity: Minor
    Found in pyipmi/ipmitool.py - About 6 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 main has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    def main():
        try:
            opts, args = getopt.getopt(sys.argv[1:], 't:hvVI:H:U:P:L:o:b:p:r:J')
        except getopt.GetoptError as err:
            print(str(err))
    Severity: Minor
    Found in pyipmi/ipmitool.py - About 6 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 cmd_fru_print has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def cmd_fru_print(ipmi, args):
        fru_id = 0
        print_all = False
        if len(args) > 0:
            fru_id = int(args[0])
    Severity: Minor
    Found in pyipmi/ipmitool.py - About 4 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 parse_interface_options has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_interface_options(interface_name, options):
        if options:
            options = options.split(',')
    
        interface_options = {}
    Severity: Minor
    Found in pyipmi/ipmitool.py - About 3 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 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 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 print_sdr_list_entry has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def print_sdr_list_entry(record_id, number, id_string, value, states):
    Severity: Minor
    Found in pyipmi/ipmitool.py - About 35 mins to fix

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

      def cmd_chassis_status(ipmi, args):
          status = ipmi.get_chassis_status()
      
          if json_output:
              status = {
      Severity: Minor
      Found in pyipmi/ipmitool.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

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

          if area:
              print('''
      Product Info Area:
        Manufacturer:       %(manufacturer)s
        Name:               %(name)s
      Severity: Major
      Found in pyipmi/ipmitool.py and 2 other locations - About 3 hrs to fix
      pyipmi/ipmitool.py on lines 228..239
      pyipmi/ipmitool.py on lines 243..257

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

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

          if area:
              print('''
      Chassis Info Area:
        Type:               %(type)d
        Part Number:        %(part_number)s
      Severity: Major
      Found in pyipmi/ipmitool.py and 2 other locations - About 3 hrs to fix
      pyipmi/ipmitool.py on lines 243..257
      pyipmi/ipmitool.py on lines 261..276

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

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

          if area:
              print('''
      Board Info Area:
        Mfg. Date / Time:   %(mfg_date)s
        Manufacturer:       %(manufacturer)s
      Severity: Major
      Found in pyipmi/ipmitool.py and 2 other locations - About 3 hrs to fix
      pyipmi/ipmitool.py on lines 228..239
      pyipmi/ipmitool.py on lines 261..276

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

      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

              if (len(subcommands) == len(argv) + 1
                      and subcommands[:len(argv)] == argv):
                  commands.append(cmd)
                  if cmd.arguments:
                      maxlen = max(maxlen, len(cmd.name)+len(cmd.arguments)+1)
      Severity: Major
      Found in pyipmi/ipmitool.py and 2 other locations - About 3 hrs to fix
      pyipmi/ipmitool.py on lines 438..444
      pyipmi/ipmitool.py on lines 450..456

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

      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

                  if (len(subcommands) > len(argv) + 1
                          and subcommands[:len(argv)] == argv):
                      commands.append(cmd)
                      if cmd.arguments:
                          maxlen = max(maxlen, len(cmd.name)+len(cmd.arguments)+1)
      Severity: Major
      Found in pyipmi/ipmitool.py and 2 other locations - About 3 hrs to fix
      pyipmi/ipmitool.py on lines 426..432
      pyipmi/ipmitool.py on lines 450..456

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

      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

                  if (len(subcommands) == len(argv)
                          and subcommands[:len(argv)] == argv):
                      commands.append(cmd)
                      if cmd.arguments:
                          maxlen = max(maxlen, len(cmd.name)+len(cmd.arguments)+1)
      Severity: Major
      Found in pyipmi/ipmitool.py and 2 other locations - About 3 hrs to fix
      pyipmi/ipmitool.py on lines 426..432
      pyipmi/ipmitool.py on lines 438..444

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

      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

          functions = (
                  ('SENSOR', 'Sensor Device'),
                  ('SDR_REPOSITORY', 'SDR Repository Device'),
                  ('SEL', 'SEL Device'),
                  ('FRU_INVENTORY', 'FRU Inventory Device'),
      Severity: Major
      Found in pyipmi/ipmitool.py and 2 other locations - About 1 hr to fix
      examples/interface_aardvark.py on lines 27..35
      examples/interface_rmcp.py on lines 33..41

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

      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