zhmcclient/python-zhmcclient

View on GitHub

Showing 336 of 336 total issues

Function list_permitted_lpars has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def list_permitted_lpars(
            self, full_properties=False, filter_args=None,
            additional_properties=None):
        """
        List the permitted LPARs of CPCs in classic mode managed by this HMC.
Severity: Minor
Found in zhmcclient/_console.py - About 5 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 post has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def post(self, uri, resource=None, body=None, logon_required=True,
             wait_for_completion=False, operation_timeout=None,
             renew_session=True):
        """
        Perform the HTTP POST method against the resource identified by a URI,
Severity: Minor
Found in zhmcclient/_session.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 post has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def post(method, hmc, uri, uri_parms, body, logon_required,
             wait_for_completion):
        # pylint: disable=unused-argument
        """Operation: Submit Requests."""
        assert wait_for_completion is True  # async not supported yet
Severity: Minor
Found in zhmcclient_mock/_urihandler.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

File _hmc_definitions.py has 364 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2019,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/testutils/_hmc_definitions.py - About 4 hrs to fix

    File _notification.py has 362 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    # 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.
    Severity: Minor
    Found in zhmcclient/_notification.py - About 4 hrs to fix

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

              if hmc_version >= (2, 14, 1):
                  disk_partition_id = body.get('disk-partition-id', 0)
                  os_load_parameters = body.get(
                      'operating-system-specific-load-parameters', '')
                  boot_record_lba = body.get('boot-record-logical-block-address', '0')
      Severity: Major
      Found in zhmcclient_mock/_urihandler.py and 1 other location - About 4 hrs to fix
      zhmcclient_mock/_urihandler.py on lines 4921..4930

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

      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 hmc_version >= (2, 14, 1):
                  disk_partition_id = body.get('disk-partition-id', 0)
                  os_load_parameters = body.get(
                      'operating-system-specific-load-parameters', '')
                  boot_record_lba = body.get('boot-record-logical-block-address', '0')
      Severity: Major
      Found in zhmcclient_mock/_urihandler.py and 1 other location - About 4 hrs to fix
      zhmcclient_mock/_urihandler.py on lines 5009..5018

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

      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 35 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Session(object):
          """
          A session to the HMC, optionally in context of an HMC user.
      
          The session supports operations that require to be authenticated, as well
      Severity: Minor
      Found in zhmcclient/_session.py - About 4 hrs to fix

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

                if resource:
                    names = []
                    res_class = resource.manager.class_name
                    while resource:
                        # Using resource.name gets into an infinite recursion when
        Severity: Major
        Found in zhmcclient/_session.py and 1 other location - About 4 hrs to fix
        zhmcclient/_session.py on lines 981..994

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

        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 resource:
                    names = []
                    res_class = resource.manager.class_name
                    while resource:
                        # Using resource.name gets into an infinite recursion when
        Severity: Major
        Found in zhmcclient/_session.py and 1 other location - About 4 hrs to fix
        zhmcclient/_session.py on lines 1058..1071

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

        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 _auto_updater.py has 354 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/env python
        # Copyright 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.
        Severity: Minor
        Found in zhmcclient/_auto_updater.py - About 4 hrs to fix

          Function _list_with_operation has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

              def _list_with_operation(
                      self, list_uri, result_prop, full_properties, filter_args,
                      additional_properties):
                  """
                  List resource objects by using a List operation.
          Severity: Minor
          Found in zhmcclient/_manager.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 list_permitted_adapters has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

              def list_permitted_adapters(
                      self, full_properties=False, filter_args=None,
                      additional_properties=None):
                  """
                  List the permitted adapters of all CPCs managed by this HMC.
          Severity: Minor
          Found in zhmcclient/_console.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 _setup_metric_group_values has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              def _setup_metric_group_values(self):
                  """
                  Return the list of MetricGroupValues objects for this metrics response,
                  by processing its metrics response string.
          
          
          Severity: Minor
          Found in zhmcclient/_metrics.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

          Cyclomatic complexity is too high in method _convert_to_config. (34)
          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 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 resource has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              def resource(self):
                  """
                  :class:`~zhmcclient.BaseResource`: The Python resource object of the
                    resource these metric values apply to.
          
          
          Severity: Minor
          Found in zhmcclient/_metrics.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 _log_http_response has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              def _log_http_response(
                      method, url, resource, status, headers=None, content=None):
                  """
                  Log the HTTP response of an HMC REST API call, at the debug level.
          
          
          Severity: Minor
          Found in zhmcclient/_session.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 get_free_crypto_domains has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_free_crypto_domains(self, crypto_adapters=None):
                  """
                  Return a list of crypto domains that are free for usage on a list of
                  crypto adapters in this CPC.
          
          
          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

          Function post has 96 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def post(method, hmc, uri, uri_parms, body, logon_required,
                       wait_for_completion):
                  # pylint: disable=unused-argument
                  """Operation: Create Partition (requires DPM mode)."""
          
          
          Severity: Major
          Found in zhmcclient_mock/_urihandler.py - About 3 hrs to fix

            BaseManager has 31 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class BaseManager(object):
                """
                Abstract base class for manager classes (e.g.
                :class:`~zhmcclient.CpcManager`).
            
            
            Severity: Minor
            Found in zhmcclient/_manager.py - About 3 hrs to fix
              Severity
              Category
              Status
              Source
              Language