alainivars/utils2devops

View on GitHub

Showing 34 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

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

                if obj.used_by:
                    print("Storage-pool not deleted, it's used by ", obj.used_by)
                else:
                    print('Deleting Storage-pool: ', obj.name)
                    try:
    Severity: Major
    Found in utils2devops/lxd_lxc/storage.py and 1 other location - About 2 hrs to fix
    utils2devops/lxd_lxc/profile.py on lines 16..26

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

    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

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

                elif obj.name == 'default':
                    print("Profile 'default' is not deleted")
                else:
                    print('Deleting profile: ', obj.name)
                    try:
    Severity: Major
    Found in utils2devops/lxd_lxc/profile.py and 1 other location - About 2 hrs to fix
    utils2devops/lxd_lxc/storage.py on lines 14..24

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

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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

            if args.deleteAllNetworks:
                if args.endpoint:
                    object = Network(args.endpoint, args.cert)
                else:
                    object = Network()
    Severity: Major
    Found in utils2devops/lxd_lxc/lxc_delete.py and 3 other locations - About 1 hr to fix
    utils2devops/lxd_lxc/lxc_delete.py on lines 22..27
    utils2devops/lxd_lxc/lxc_delete.py on lines 34..39
    utils2devops/lxd_lxc/lxc_delete.py on lines 40..45

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

    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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

            if args.deleteAllStorages:
                if args.endpoint:
                    object = Storage(args.endpoint, args.cert)
                else:
                    object = Storage()
    Severity: Major
    Found in utils2devops/lxd_lxc/lxc_delete.py and 3 other locations - About 1 hr to fix
    utils2devops/lxd_lxc/lxc_delete.py on lines 22..27
    utils2devops/lxd_lxc/lxc_delete.py on lines 28..33
    utils2devops/lxd_lxc/lxc_delete.py on lines 34..39

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

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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

            if args.deleteAllImages:
                if args.endpoint:
                    object = Image(args.endpoint, args.cert)
                else:
                    object = Image()
    Severity: Major
    Found in utils2devops/lxd_lxc/lxc_delete.py and 3 other locations - About 1 hr to fix
    utils2devops/lxd_lxc/lxc_delete.py on lines 28..33
    utils2devops/lxd_lxc/lxc_delete.py on lines 34..39
    utils2devops/lxd_lxc/lxc_delete.py on lines 40..45

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

    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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

            if args.deleteAllProfiles:
                if args.endpoint:
                    object = Profile(args.endpoint, args.cert)
                else:
                    object = Profile()
    Severity: Major
    Found in utils2devops/lxd_lxc/lxc_delete.py and 3 other locations - About 1 hr to fix
    utils2devops/lxd_lxc/lxc_delete.py on lines 22..27
    utils2devops/lxd_lxc/lxc_delete.py on lines 28..33
    utils2devops/lxd_lxc/lxc_delete.py on lines 40..45

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

    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 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 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 __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 _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 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

      Severity
      Category
      Status
      Source
      Language