saltstack/salt

View on GitHub
salt/modules/boto_ec2.py

Summary

Maintainability
F
2 wks
Test Coverage

File boto_ec2.py has 1757 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Connection module for Amazon EC2

.. versionadded:: 2015.8.0
Severity: Major
Found in salt/modules/boto_ec2.py - About 4 days to fix

    Function set_volumes_tags has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    def set_volumes_tags(tag_maps, authoritative=False, dry_run=False,
                        region=None, key=None, keyid=None, profile=None):
        '''
        .. versionadded:: 2016.11.0
    
    
    Severity: Minor
    Found in salt/modules/boto_ec2.py - About 6 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 run has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def run(image_id, name=None, tags=None, key_name=None, security_groups=None,
            user_data=None, instance_type='m1.small', placement=None,
            kernel_id=None, ramdisk_id=None, monitoring_enabled=None, vpc_id=None,
            vpc_name=None, subnet_id=None, subnet_name=None, private_ip_address=None,
            block_device_map=None, disable_api_termination=None,
    Severity: Minor
    Found in salt/modules/boto_ec2.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 find_images has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_images(ami_name=None, executable_by=None, owners=None, image_ids=None, tags=None,
                    region=None, key=None, keyid=None, profile=None, return_objs=False):
    
        '''
        Given image properties, find and return matching AMI ids
    Severity: Minor
    Found in salt/modules/boto_ec2.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

    Cyclomatic complexity is too high in function set_volumes_tags. (26)
    Open

    def set_volumes_tags(tag_maps, authoritative=False, dry_run=False,
                        region=None, key=None, keyid=None, profile=None):
        '''
        .. versionadded:: 2016.11.0
    
    
    Severity: Minor
    Found in salt/modules/boto_ec2.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 modify_network_interface_attribute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def modify_network_interface_attribute(
            name=None, network_interface_id=None, attr=None,
            value=None, region=None, key=None, keyid=None, profile=None):
        '''
        Modify an attribute of an Elastic Network Interface.
    Severity: Minor
    Found in salt/modules/boto_ec2.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 find_instances has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_instances(instance_id=None, name=None, tags=None, region=None,
                       key=None, keyid=None, profile=None, return_objs=False,
                       in_states=None, filters=None):
    
        '''
    Severity: Minor
    Found in salt/modules/boto_ec2.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 associate_eip_address has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def associate_eip_address(instance_id=None, instance_name=None, public_ip=None,
                              allocation_id=None, network_interface_id=None,
                              network_interface_name=None, private_ip_address=None,
                              allow_reassociation=False, region=None, key=None,
                              keyid=None, profile=None):
    Severity: Minor
    Found in salt/modules/boto_ec2.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 get_attribute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_attribute(attribute, instance_name=None, instance_id=None, region=None, key=None,
                      keyid=None, profile=None, filters=None):
        '''
        Get an EC2 instance attribute.
    
    
    Severity: Minor
    Found in salt/modules/boto_ec2.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_unassociated_eip_address has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_unassociated_eip_address(domain='standard', region=None, key=None,
                                     keyid=None, profile=None):
        '''
        Return the first unassociated EIP
    
    
    Severity: Minor
    Found in salt/modules/boto_ec2.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_network_interface has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_network_interface(conn, name=None, network_interface_id=None):
        r = {}
        if not (name or network_interface_id):
            raise SaltInvocationError(
                'Either name or network_interface_id must be provided.'
    Severity: Minor
    Found in salt/modules/boto_ec2.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 _describe_network_interface has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _describe_network_interface(eni):
        r = {}
        for attr in ['status', 'description', 'availability_zone', 'requesterId',
                     'requester_managed', 'mac_address', 'private_ip_address',
                     'vpc_id', 'id', 'source_dest_check', 'owner_id', 'tags',
    Severity: Minor
    Found in salt/modules/boto_ec2.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 set_attribute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def set_attribute(attribute, attribute_value, instance_name=None, instance_id=None, region=None, key=None, keyid=None,
                      profile=None, filters=None):
        '''
        Set an EC2 instance attribute.
        Returns whether the operation succeeded or not.
    Severity: Minor
    Found in salt/modules/boto_ec2.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

    Avoid deeply nested control flow statements.
    Open

                        if not delete_tags(vol.id, remove, region=region, key=key, keyid=keyid, profile=profile):
                            ret['success'] = False
                            ret['comment'] = "Failed to remove tags on vol.id {0}: {1}".format(vol.id, remove)
                            return ret
        ret['changes'].update(changes) if changes['old'] or changes['new'] else None  # pylint: disable=W0106
    Severity: Major
    Found in salt/modules/boto_ec2.py - About 45 mins to fix

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

      def detach_network_interface(
              name=None, network_interface_id=None, attachment_id=None,
              force=False, region=None, key=None, keyid=None, profile=None):
          '''
          Detach an Elastic Network Interface.
      Severity: Minor
      Found in salt/modules/boto_ec2.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 attach_network_interface has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def attach_network_interface(device_index, name=None, network_interface_id=None,
                                   instance_name=None, instance_id=None,
                                   region=None, key=None, keyid=None, profile=None):
          '''
          Attach an Elastic Network Interface.
      Severity: Minor
      Found in salt/modules/boto_ec2.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 assign_private_ip_addresses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def assign_private_ip_addresses(network_interface_name=None, network_interface_id=None,
                                      private_ip_addresses=None, secondary_private_ip_address_count=None,
                                      allow_reassignment=False, region=None, key=None,
                                      keyid=None, profile=None):
          '''
      Severity: Minor
      Found in salt/modules/boto_ec2.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 unassign_private_ip_addresses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def unassign_private_ip_addresses(network_interface_name=None, network_interface_id=None,
                                        private_ip_addresses=None, region=None,
                                        key=None, keyid=None, profile=None):
          '''
          Unassigns one or more secondary private IP addresses from a network interface
      Severity: Minor
      Found in salt/modules/boto_ec2.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 _wait_for_volume_available has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def _wait_for_volume_available(conn, volume_id, retries=5, interval=5):
          i = 0
          while True:
              i = i + 1
              time.sleep(interval)
      Severity: Minor
      Found in salt/modules/boto_ec2.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 create_network_interface has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_network_interface(name, subnet_id=None, subnet_name=None,
                                   private_ip_address=None, description=None,
                                   groups=None, region=None, key=None, keyid=None,
                                   profile=None):
          '''
      Severity: Minor
      Found in salt/modules/boto_ec2.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

      Avoid too many return statements within this function.
      Open

              return False
      Severity: Major
      Found in salt/modules/boto_ec2.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return r
        Severity: Major
        Found in salt/modules/boto_ec2.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return False
          Severity: Major
          Found in salt/modules/boto_ec2.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return conn.associate_address(instance_id=instance_id,
            Severity: Major
            Found in salt/modules/boto_ec2.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return False
              Severity: Major
              Found in salt/modules/boto_ec2.py - About 30 mins to fix

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

                def create_tags(resource_ids, tags, region=None, key=None, keyid=None, profile=None):
                    '''
                    Create new metadata tags for the specified resource ids.
                
                    .. versionadded:: 2016.11.0
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 5 hrs to fix
                salt/modules/boto_ec2.py on lines 1945..1979

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

                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

                def delete_tags(resource_ids, tags, region=None, key=None, keyid=None, profile=None):
                    '''
                    Delete metadata tags for the specified resource ids.
                
                    .. versionadded:: 2016.11.0
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 5 hrs to fix
                salt/modules/boto_ec2.py on lines 1912..1942

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

                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 3 locations. Consider refactoring.
                Open

                    if network_interface_name:
                        try:
                            network_interface_id = get_network_interface_id(
                                network_interface_name, region=region, key=key, keyid=keyid,
                                profile=profile)
                Severity: Major
                Found in salt/modules/boto_ec2.py and 2 other locations - About 3 hrs to fix
                salt/modules/boto_ec2.py on lines 465..476
                salt/modules/boto_ec2.py on lines 519..530

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

                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 3 locations. Consider refactoring.
                Open

                    if network_interface_name:
                        try:
                            network_interface_id = get_network_interface_id(
                                network_interface_name, region=region, key=key, keyid=keyid,
                                profile=profile)
                Severity: Major
                Found in salt/modules/boto_ec2.py and 2 other locations - About 3 hrs to fix
                salt/modules/boto_ec2.py on lines 371..382
                salt/modules/boto_ec2.py on lines 519..530

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

                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 3 locations. Consider refactoring.
                Open

                    if network_interface_name:
                        try:
                            network_interface_id = get_network_interface_id(
                                network_interface_name, region=region, key=key, keyid=keyid,
                                profile=profile)
                Severity: Major
                Found in salt/modules/boto_ec2.py and 2 other locations - About 3 hrs to fix
                salt/modules/boto_ec2.py on lines 371..382
                salt/modules/boto_ec2.py on lines 465..476

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

                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

                    if subnet_name:
                        r = __salt__['boto_vpc.get_resource_id']('subnet', subnet_name,
                                                                 region=region, key=key,
                                                                 keyid=keyid, profile=profile)
                        if 'id' not in r:
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 2 hrs to fix
                salt/modules/boto_ec2.py on lines 1451..1459

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

                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

                    if subnet_name:
                        resource = __salt__['boto_vpc.get_resource_id']('subnet', subnet_name,
                                                                        region=region, key=key,
                                                                        keyid=keyid,
                                                                        profile=profile)
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 2 hrs to fix
                salt/modules/boto_ec2.py on lines 987..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 67.

                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

                            if not create_tags(vol.id, tags, region=region, key=key, keyid=keyid, profile=profile):
                                ret['success'] = False
                                ret['comment'] = "Failed to set tags on vol.id {0}: {1}".format(vol.id, tags)
                                return ret
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 2 hrs to fix
                salt/modules/boto_ec2.py on lines 1871..1874

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

                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

                                    if not delete_tags(vol.id, remove, region=region, key=key, keyid=keyid, profile=profile):
                                        ret['success'] = False
                                        ret['comment'] = "Failed to remove tags on vol.id {0}: {1}".format(vol.id, remove)
                                        return ret
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 2 hrs to fix
                salt/modules/boto_ec2.py on lines 1864..1867

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

                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

                def __virtual__():
                    '''
                    Only load if boto libraries exist and if boto libraries are greater than
                    a given version.
                    '''
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 2 hrs to fix
                salt/modules/boto_secgroup.py on lines 72..88

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

                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

                        try:
                            instance_id = get_id(name=instance_name, region=region, key=key,
                                                 keyid=keyid, profile=profile)
                        except boto.exception.BotoServerError as e:
                            log.error(e)
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 1 hr to fix
                salt/modules/boto_ec2.py on lines 1570..1576

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

                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 instance_name:
                        try:
                            instance_id = get_id(name=instance_name, region=region, key=key,
                                                 keyid=keyid, profile=profile)
                        except boto.exception.BotoServerError as e:
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 1 hr to fix
                salt/modules/boto_ec2.py on lines 358..363

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

                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

                    try:
                        info = _describe_network_interface(eni)
                        network_interface_id = info['id']
                    except KeyError:
                        r['error'] = {'message': 'ID not found for this network interface.'}
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 1 hr to fix
                salt/modules/boto_ec2.py on lines 1518..1523

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

                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

                    try:
                        info = _describe_network_interface(eni)
                        network_interface_id = info['id']
                    except KeyError:
                        r['error'] = {'message': 'ID not found for this network interface.'}
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 1 hr to fix
                salt/modules/boto_ec2.py on lines 1563..1568

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

                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

                    if attr == 'groups':
                        _attr = 'groupSet'
                    elif attr == 'source_dest_check':
                        _attr = 'sourceDestCheck'
                    elif attr == 'delete_on_termination':
                Severity: Major
                Found in salt/modules/boto_ec2.py and 1 other location - About 1 hr to fix
                salt/states/module.py on lines 563..572

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

                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 10 locations. Consider refactoring.
                Open

                            if tags:
                                for tag_name, tag_value in six.iteritems(tags):
                                    filter_parameters['filters']['tag:{0}'.format(tag_name)] = tag_value
                Severity: Major
                Found in salt/modules/boto_ec2.py and 9 other locations - About 1 hr to fix
                salt/modules/boto_ec2.py on lines 583..585
                salt/modules/boto_secgroup.py on lines 576..578
                salt/modules/boto_vpc.py on lines 399..401
                salt/modules/boto_vpc.py on lines 507..509
                salt/modules/boto_vpc.py on lines 788..790
                salt/modules/boto_vpc.py on lines 828..830
                salt/modules/boto_vpc.py on lines 947..949
                salt/modules/boto_vpc.py on lines 2149..2151
                salt/modules/boto_vpc.py on lines 2505..2507

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

                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 10 locations. Consider refactoring.
                Open

                        if tags:
                            for tag_name, tag_value in six.iteritems(tags):
                                filter_parameters['filters']['tag:{0}'.format(tag_name)] = tag_value
                Severity: Major
                Found in salt/modules/boto_ec2.py and 9 other locations - About 1 hr to fix
                salt/modules/boto_ec2.py on lines 673..675
                salt/modules/boto_secgroup.py on lines 576..578
                salt/modules/boto_vpc.py on lines 399..401
                salt/modules/boto_vpc.py on lines 507..509
                salt/modules/boto_vpc.py on lines 788..790
                salt/modules/boto_vpc.py on lines 828..830
                salt/modules/boto_vpc.py on lines 947..949
                salt/modules/boto_vpc.py on lines 2149..2151
                salt/modules/boto_vpc.py on lines 2505..2507

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

                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

                        if update:
                            d = dict((k, tags[k]) for k in update)
                            log.debug('Updated tags for vol.id %s: %s', vol.id, d)
                Severity: Minor
                Found in salt/modules/boto_ec2.py and 1 other location - About 45 mins to fix
                salt/modules/boto_ec2.py on lines 1857..1859

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

                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

                        if add:
                            d = dict((k, tags[k]) for k in add)
                            log.debug('New tags for vol.id %s: %s', vol.id, d)
                Severity: Minor
                Found in salt/modules/boto_ec2.py and 1 other location - About 45 mins to fix
                salt/modules/boto_ec2.py on lines 1860..1862

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

                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

                    if _attr == 'deleteOnTermination':
                        try:
                            _attachment_id = info['attachment']['id']
                        except KeyError:
                            r['error'] = {
                Severity: Minor
                Found in salt/modules/boto_ec2.py and 1 other location - About 40 mins to fix
                salt/modules/boto_ec2.py on lines 1614..1618

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

                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

                        try:
                            attachment_id = info['attachment']['id']
                        except KeyError:
                            r['error'] = {'message': 'Attachment id not found for this ENI.'}
                            return r
                Severity: Minor
                Found in salt/modules/boto_ec2.py and 1 other location - About 40 mins to fix
                salt/modules/boto_ec2.py on lines 1678..1687

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

                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

                There are no issues that match your filters.

                Category
                Status