zhmcclient/python-zhmcclient

View on GitHub

Showing 336 of 336 total issues

Function __init__ has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, manager, properties):
        self._manager = manager  # May be None
        if properties is not None:
            self._properties = copy.deepcopy(properties)
        else:
Severity: Minor
Found in zhmcclient_mock/_hmc.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

Partition has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

class Partition(BaseResource):
    """
    Representation of a :term:`Partition`.

    Derived from :class:`~zhmcclient.BaseResource`; see there for common
Severity: Minor
Found in zhmcclient/_partition.py - About 3 hrs to fix

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

            if ftp_host is not None:
                body['ftp-retrieve'] = True
                body['ftp-server-host'] = ftp_host
                body['ftp-server-user'] = ftp_user
                body['ftp-server-password'] = ftp_password
    Severity: Major
    Found in zhmcclient/_cpc.py and 1 other location - About 3 hrs to fix
    zhmcclient/_console.py on lines 1256..1262

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

    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

            if ftp_host is not None:
                body['ftp-retrieve'] = True
                body['ftp-server-host'] = ftp_host
                body['ftp-server-user'] = ftp_user
                body['ftp-server-password'] = ftp_password
    Severity: Major
    Found in zhmcclient/_console.py and 1 other location - About 3 hrs to fix
    zhmcclient/_cpc.py on lines 2188..2194

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

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

        def _convert_to_config(self, inventory_list, include_unused_adapters):
            """
            Convert the inventory list to a DPM configuration dict.
    
            Important: In order to support export of DPM configs with zhmcclient
    Severity: Minor
    Found in zhmcclient/_cpc.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

    File _user_role.py has 306 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # Copyright 2017,2021 IBM Corp. All Rights Reserved.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    Severity: Minor
    Found in zhmcclient/_user_role.py - About 3 hrs to fix

      Cyclomatic complexity is too high in method on_message. (30)
      Open

          def on_message(self, headers, message):
              """
              Event method that gets called when this listener has received a JMS
              message (representing an HMC notification).
      
      
      Severity: Minor
      Found in zhmcclient/_auto_updater.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function __init__ has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, manager, properties):
              super(FakedAdapter, self).__init__(
                  manager=manager,
                  properties=properties)
              # Initial values to be prepared for raising InputError
      Severity: Minor
      Found in zhmcclient_mock/_hmc.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 pull_properties has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def pull_properties(self, properties):
              """
              Retrieve the specified set of resource properties from the HMC and
              cache them in this Python object.
      
      
      Severity: Minor
      Found in zhmcclient/_resource.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

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

              if processor_info:
                  pi = []
                  for ptype, pvalue in processor_info.items():
                      pi_item = {
                          'processor-type': ptype,
      Severity: Major
      Found in zhmcclient/_cpc.py and 1 other location - About 3 hrs to fix
      zhmcclient/_cpc.py on lines 1707..1716

      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

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

                  if isinstance(prop_value, six.string_types):
                      # HMC resource property is Enum String or (non-enum) String,
                      # and is both matched by regexp matching. Ideally, regexp
                      # matching should only be done for non-enum strings, but
                      # distinguishing them is not possible given that the client
      Severity: Major
      Found in zhmcclient_mock/_hmc.py and 1 other location - About 3 hrs to fix
      zhmcclient/_utils.py on lines 537..557

      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

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

              if isinstance(prop_value, six.string_types):
                  # HMC resource property is Enum String or (non-enum) String,
                  # and is both matched by regexp matching. Ideally, regexp
                  # matching should only be done for non-enum strings, but
                  # distinguishing them is not possible given that the client
      Severity: Major
      Found in zhmcclient/_utils.py and 1 other location - About 3 hrs to fix
      zhmcclient_mock/_hmc.py on lines 703..723

      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

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

              if processor_info:
                  pi = []
                  for ptype, pvalue in processor_info.items():
                      pi_item = {
                          'processor-type': ptype,
      Severity: Major
      Found in zhmcclient/_cpc.py and 1 other location - About 3 hrs to fix
      zhmcclient/_cpc.py on lines 1795..1804

      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

      File _activation_profile.py has 298 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # Copyright 2016,2021 IBM Corp. All Rights Reserved.
      #
      # Licensed under the Apache License, Version 2.0 (the "License");
      # you may not use this file except in compliance with the License.
      # You may obtain a copy of the License at
      Severity: Minor
      Found in zhmcclient/_activation_profile.py - About 3 hrs to fix

        Function get has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            def get(cls, method, hmc, uri, uri_parms, logon_required):
                # pylint: disable=unused-argument
                """Operation: List Permitted LPARs."""
                uri, query_parms = parse_query_parms(method, uri)
                check_invalid_query_parms(
        Severity: Minor
        Found in zhmcclient_mock/_urihandler.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 matches_prop has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        def matches_prop(obj, prop_name, prop_match, case_insensitive):
            """
            Return a boolean indicating whether a resource object matches with
            a single property against a property match value.
        
        
        Severity: Minor
        Found in zhmcclient/_utils.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

        File _nic.py has 293 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # Copyright 2016,2021 IBM Corp. All Rights Reserved.
        #
        # Licensed under the Apache License, Version 2.0 (the "License");
        # you may not use this file except in compliance with the License.
        # You may obtain a copy of the License at
        Severity: Minor
        Found in zhmcclient/_nic.py - About 3 hrs to fix

          File _client.py has 291 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # Copyright 2016,2021 IBM Corp. All Rights Reserved.
          #
          # Licensed under the Apache License, Version 2.0 (the "License");
          # you may not use this file except in compliance with the License.
          # You may obtain a copy of the License at
          Severity: Minor
          Found in zhmcclient/_client.py - About 3 hrs to fix

            Function get has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                def get(cls, method, hmc, uri, uri_parms, logon_required):
                    # pylint: disable=unused-argument
                    """Operation: List Permitted Partitions."""
                    uri, query_parms = parse_query_parms(method, uri)
                    check_invalid_query_parms(
            Severity: Minor
            Found in zhmcclient_mock/_urihandler.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 _matches_prop has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                def _matches_prop(self, obj, prop_name, prop_match, case_insensitive):
                    """
                    Return a boolean indicating whether a faked resource object matches
                    with a single property against a property match value.
                    This is used for implementing filtering in the faked resource managers.
            Severity: Minor
            Found in zhmcclient_mock/_hmc.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

            Severity
            Category
            Status
            Source
            Language