zhmcclient/python-zhmcclient

View on GitHub
zhmcclient/_manager.py

Summary

Maintainability
F
5 days
Test Coverage

File _manager.py has 1108 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: Major
Found in zhmcclient/_manager.py - About 2 days 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

    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

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

          def _list_with_parent_array(
                  self, parent_obj, uris_prop, full_properties, filter_args):
              """
              List resource objects by using an array of URIs in the parent object.
      
      
      Severity: Minor
      Found in zhmcclient/_manager.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 _try_optimized_lookup has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def _try_optimized_lookup(self, filter_args):
              """
              Try to find a resource in an optimized way when the filter arguments
              allow for that.
      
      
      Severity: Minor
      Found in zhmcclient/_manager.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 __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, resource_class, class_name, session, parent, base_uri,
      Severity: Major
      Found in zhmcclient/_manager.py - About 1 hr to fix

        Function _get_properties_bulk has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_properties_bulk(self, props_list, client_filters):
                """
                Get resource properties using a bulk operation.
        
                Parameters:
        Severity: Minor
        Found in zhmcclient/_manager.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 resource_object has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def resource_object(self, uri_or_oid, props=None):
                """
                Return a minimalistic Python resource object for this resource class,
                that is scoped to this manager.
        
        
        Severity: Minor
        Found in zhmcclient/_manager.py - About 55 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

        Avoid deeply nested control flow statements.
        Open

                                if matches_filters(resource_obj, client_filters):
                                    resource_obj_list.append(resource_obj)
        
        
        Severity: Major
        Found in zhmcclient/_manager.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if full_properties:
                                      resource_obj.pull_full_properties()
          
          
          Severity: Major
          Found in zhmcclient/_manager.py - About 45 mins to fix

            Function _list_with_operation has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def _list_with_operation(
            Severity: Minor
            Found in zhmcclient/_manager.py - About 35 mins to fix

              Avoid too many return statements within this function.
              Open

                          return resource_obj
              Severity: Major
              Found in zhmcclient/_manager.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return None
                Severity: Major
                Found in zhmcclient/_manager.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                      return None
                  Severity: Major
                  Found in zhmcclient/_manager.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return None
                    Severity: Major
                    Found in zhmcclient/_manager.py - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status