alainivars/utils2devops

View on GitHub

Showing 24 of 34 total issues

File __init__.py has 443 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class BaseFormat:
    begin_block = '{\n'
    end_block = '}\n\n'

    def format_item(self, name, item, indent: int = 1):
Severity: Minor
Found in utils2devops/aws/__init__.py - About 6 hrs to fix

    Function list_lambda_function has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_lambda_function(
            profile_name: str = 'terraform',
            region_name: str = 'us-east-1'
    ) -> [str]:
        """This function list all AWS lambda how can access the profile
    Severity: Minor
    Found in utils2devops/aws/aws_lambda.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 list_route_tables has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_route_tables(
            profile_name: str = 'terraform',
            region_name: str = 'us-east-1'
    ) -> [str]:
        """This function list all AWS Internet Gateways how can access the profile
    Severity: Minor
    Found in utils2devops/aws/route_table.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 list_network_acls has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_network_acls(
            profile_name: str = 'terraform',
            region_name: str = 'us-east-1'
    ) -> [str]:
        """This function list all AWS network ACL how can access the profile
    Severity: Minor
    Found in utils2devops/aws/network_acl.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 add_str_tags has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_str_tags(self):
            the_str = '\ttags {\n'
            tags = self.tags
            if type(tags) == list:
                for tag in self.tags:
    Severity: Minor
    Found in utils2devops/aws/__init__.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 delete_all has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def delete_all(self):
            for obj in self.client.profiles.all():
                if obj.used_by:
                    print("Profile not deleted, it's used by ", obj.used_by)
                elif obj.name == 'default':
    Severity: Minor
    Found in utils2devops/lxd_lxc/profile.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 delete_all has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def delete_all(self):
            for obj in self.client.storage_pools.all():
                if obj.used_by:
                    print("Storage-pool not deleted, it's used by ", obj.used_by)
                else:
    Severity: Minor
    Found in utils2devops/lxd_lxc/storage.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 __str__ has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __str__(self):
            the_str = super(Lambda, self).__str__()
            the_str += self.format_item_cond('filename', self.ofilename)
            the_str += self.format_item_cond('s3_bucket', self.os3_bucket)
            the_str += self.format_item_cond('s3_key', self.os3_key)
    Severity: Minor
    Found in utils2devops/aws/__init__.py - About 1 hr to fix

      Function __str__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def __str__(self):
              the_str = ''
              if not self.inserted:
                  the_str += super(Route, self).__str__()
              the_str += '\n\troute {\n'
      Severity: Minor
      Found in utils2devops/aws/__init__.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

      Function delete_all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def delete_all(self, controller_uuid: str, model_uuid: str):
              for container in self.client.containers.all():
                  if (container.config['user.juju-controller-uuid'] == controller_uuid
                          or container.config['user.juju-model-uuid'] == model_uuid) \
                          and not Container.is_controller(container):
      Severity: Minor
      Found in utils2devops/lxd_lxc/container.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

      Function start_all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def start_all(self, controller_uuid: str, model_uuid: str):
              for container in self.client.containers.all():
                  if (container.config['user.juju-controller-uuid'] == controller_uuid
                          or container.config['user.juju-model-uuid'] == model_uuid) \
                          and not Container.is_controller(container):
      Severity: Minor
      Found in utils2devops/lxd_lxc/container.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

      Function stop_all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def stop_all(self, controller_uuid: str, model_uuid: str):
              for container in self.client.containers.all():
                  if (container.config['user.juju-controller-uuid'] == controller_uuid
                          or container.config['user.juju-model-uuid'] == model_uuid) \
                          and not Container.is_controller(container):
      Severity: Minor
      Found in utils2devops/lxd_lxc/container.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

      Function delete_all has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def delete_all(self):
              """
              Delete all network
              :return:
              """
      Severity: Minor
      Found in utils2devops/lxd_lxc/network.py - About 45 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

      Function status_all has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def status_all(self):
              for container in self.client.containers.all():
                  try:
                      to_print = self.base_line(container)
                      if self.VERBOSE == 1:
      Severity: Minor
      Found in utils2devops/lxd_lxc/container.py - About 45 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

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

          def get(self, name, **kwargs):
              assert name, 'Name can not be empty'
              if self._keys is None:
                  self.refresh()
      
      
      Severity: Minor
      Found in utils2devops/aws/ssm.py - About 45 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

      Function _get_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_value(self, name, abs_key):
              entry = self._keys[name]
      
              # simple ttl
              if self._ttl is False or \
      Severity: Minor
      Found in utils2devops/aws/ssm.py - About 45 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

      Function __str__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __str__(self):
              if any('Name' in d['Key'] for d in self.tags):
                  for tag in self.tags:
                      if tag['Key'] == 'Name' and tag['Value'] not in self.name:
                          self.name = self.name + '-' + tag['Value']
      Severity: Minor
      Found in utils2devops/aws/__init__.py - About 35 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

      Function start_controller has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def start_controller(self, controller_uuid: str):
              for container in self.client.containers.all():
                  if container.config['user.juju-controller-uuid'] == controller_uuid\
                          and Container.is_controller(container):
                      if container.status != 'Running':
      Severity: Minor
      Found in utils2devops/lxd_lxc/container.py - About 35 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

      Function stop_controller has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def stop_controller(self, controller_uuid: str):
              for container in self.client.containers.all():
                  if container.config['user.juju-controller-uuid'] == controller_uuid\
                          and Container.is_controller(container):
                      if container.status == 'Running':
      Severity: Minor
      Found in utils2devops/lxd_lxc/container.py - About 35 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

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

      def get_aws_secret(region_name, secret_name):
          """
          Get Aws secret
          :param region_name:
          :param secret_name:
      Severity: Minor
      Found in utils2devops/aws/secretmanager.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

      Severity
      Category
      Status
      Source
      Language