Orange-OpenSource/python-onapsdk

View on GitHub

Showing 1,318 of 1,318 total issues

Function __init__ has 23 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self,  # pylint: disable=too-many-arguments, too-many-locals
Severity: Major
Found in src/onapsdk/aai/business/service.py - About 2 hrs to fix

    Cyclomatic complexity is too high in method send_message. (12)
    Open

        @classmethod
        def send_message(cls, method: str, action: str, url: str,  # pylint: disable=too-many-locals
                         **kwargs) -> Union[requests.Response, None]:
            """
            Send a message to an ONAP service.
    Severity: Minor
    Found in src/onapsdk/onap_service.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

    Cyclomatic complexity is too high in method create_node_template. (11)
    Open

        def create_node_template(self,
                                 node_template_type: Type[NodeTemplate],
                                 component: "Component") -> NodeTemplate:
            """Create a node template type object.
    
    
    Severity: Minor
    Found in src/onapsdk/sdc/service.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

    File loop_instance.py has 271 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    # SPDX-License-Identifier: Apache-2.0
    """Control Loop module."""
    import json
    Severity: Minor
    Found in src/onapsdk/clamp/loop_instance.py - About 2 hrs to fix

      Cyclomatic complexity is too high in method instantiate_macro. (10)
      Open

          @classmethod
          def instantiate_macro(cls,  # pylint: disable=too-many-arguments, too-many-locals
                                aai_service_instance: "ServiceInstance",
                                vnf_object: "Vnf",
                                line_of_business: str,
      Severity: Minor
      Found in src/onapsdk/so/instantiation.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 deep_load has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def deep_load(self) -> None:
              """Deep load Object informations from SDC."""
              url = (
                  f"{self.base_front_url}/sdc1/feProxy/rest/v1/"
                  "screen?excludeTypes=VFCMT&excludeTypes=Configuration"
      Severity: Minor
      Found in src/onapsdk/sdc/sdc_resource.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

      SdcOnboardable has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class SdcOnboardable(SDC, ABC):
          """Base class for onboardable SDC resources (Vendors, Services, ...)."""
      
          ACTION_TEMPLATE: str
          ACTION_METHOD: str
      Severity: Minor
      Found in src/onapsdk/sdc/__init__.py - About 2 hrs to fix

        Cyclomatic complexity is too high in method _parse_sdc_status. (9)
        Open

            @staticmethod
            def _parse_sdc_status(sdc_status: str, distribution_state: str,
                                  logger: logging.Logger) -> str:
                """
                Parse SDC status in order to normalize it.
        Severity: Minor
        Found in src/onapsdk/sdc/sdc_resource.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

        Cyclomatic complexity is too high in method onboard. (9)
        Open

            def onboard(self) -> None:
                """Onboard the VSP in SDC."""
                status: Optional[str] = self.status
                if not status:
                    if not self._vendor:
        Severity: Minor
        Found in src/onapsdk/sdc/vsp.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

        Cyclomatic complexity is too high in method deep_load. (9)
        Open

            def deep_load(self) -> None:
                """Deep load Object informations from SDC."""
                url = (
                    f"{self.base_front_url}/sdc1/feProxy/rest/v1/"
                    "screen?excludeTypes=VFCMT&excludeTypes=Configuration"
        Severity: Minor
        Found in src/onapsdk/sdc/sdc_resource.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

        Cyclomatic complexity is too high in method create_from_request_response. (9)
        Open

            @classmethod
            def create_from_request_response(cls, request_response: dict) -> "VnfInstantiation":
                """Create VNF instantiation object based on request details.
        
                Raises:
        Severity: Minor
        Found in src/onapsdk/so/instantiation.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 18 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self,  # pylint: disable=too-many-arguments, too-many-locals
        Severity: Major
        Found in src/onapsdk/aai/business/vf_module.py - About 2 hrs to fix

          Cyclomatic complexity is too high in method _create. (8)
          Open

              def _create(self, template_name: str, **kwargs) -> None:
                  """Create the object in SDC if not already existing."""
                  self._logger.info("attempting to create %s %s in SDC",
                                    type(self).__name__, self.name)
                  if not self.exists():
          Severity: Minor
          Found in src/onapsdk/sdc/__init__.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 create has 17 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def create(cls,  # pylint: disable=too-many-locals
          Severity: Major
          Found in src/onapsdk/aai/cloud_infrastructure/cloud_region.py - About 2 hrs to fix

            Function __init__ has 17 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self,  # pylint: disable=too-many-locals
            Severity: Major
            Found in src/onapsdk/aai/network/site_resource.py - About 2 hrs to fix

              Function create_from_request_response has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  def create_from_request_response(cls, request_response: dict) -> "VnfInstantiation":
                      """Create VNF instantiation object based on request details.
              
                      Raises:
                          ResourceNotFound: Service related with given object doesn't exist
              Severity: Minor
              Found in src/onapsdk/so/instantiation.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 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def __init__(self,  # pylint: disable=too-many-arguments, too-many-locals
                               service_instance: "ServiceInstance",
                               vnf_id: str,
                               vnf_type: str,
                               in_maint: bool,
              Severity: Major
              Found in src/onapsdk/aai/business/vnf.py - About 2 hrs to fix

                File onap_service.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                #!/usr/bin/env python3
                # -*- coding: utf-8 -*-
                # SPDX-License-Identifier: Apache-2.0
                """ONAP Service module."""
                from abc import ABC
                Severity: Minor
                Found in src/onapsdk/onap_service.py - About 2 hrs to fix

                  File complex.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """A&AI Complex module."""
                  from typing import Any, Dict, Iterator
                  from urllib.parse import urlencode
                  
                  from onapsdk.utils.jinja import jinja_env
                  Severity: Minor
                  Found in src/onapsdk/aai/cloud_infrastructure/complex.py - About 2 hrs to fix

                    Function __init__ has 16 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(self,
                    Severity: Major
                    Found in src/onapsdk/aai/cloud_infrastructure/cloud_region.py - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language