saltstack/salt

View on GitHub
salt/cloud/clouds/xen.py

Summary

Maintainability
F
1 wk
Test Coverage

File xen.py has 1062 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

'''
XenServer Cloud Driver
======================
Severity: Major
Found in salt/cloud/clouds/xen.py - About 2 days to fix

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

    def destroy_vm_vdis(name=None, session=None, call=None):
        '''
        Get virtual block devices on VM
    
        .. code-block:: bash
    Severity: Minor
    Found in salt/cloud/clouds/xen.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 vdi_list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def vdi_list(call=None, kwargs=None):
        '''
        Return available Xen VDI images
    
        If this function is called with the ``-f`` or ``--function`` then
    Severity: Minor
    Found in salt/cloud/clouds/xen.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 list_nodes_full has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_nodes_full(session=None):
        '''
        List full virtual machines
    
          .. code-block:: bash
    Severity: Minor
    Found in salt/cloud/clouds/xen.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 create has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def create(vm_):
        '''
        Create a VM in Xen
    
        The configuration for this function is read from the profile settings.
    Severity: Minor
    Found in salt/cloud/clouds/xen.py - About 1 hr to fix

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

      def get_vm_ip(name=None, session=None, call=None):
          '''
          Get the IP address of the VM
      
          .. code-block:: bash
      Severity: Minor
      Found in salt/cloud/clouds/xen.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 destroy_template has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def destroy_template(name=None, call=None, kwargs=None):
          '''
          Destroy Xen VM or template instance
      
              .. code-block:: bash
      Severity: Minor
      Found in salt/cloud/clouds/xen.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 _wait_for_ip has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def _wait_for_ip(name, session):
          '''
          Wait for IP  to be available during create()
          '''
          start_time = datetime.now()
      Severity: Minor
      Found in salt/cloud/clouds/xen.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_vm_ip has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def set_vm_ip(name=None,
                    ipv4_cidr=None,
                    ipv4_gw=None,
                    session=None,
                    call=None):
      Severity: Minor
      Found in salt/cloud/clouds/xen.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 'iso' not in vdi_record['name_label']:
                              session.xenapi.VDI.destroy(vbd_record['VDI'])
                              ret['vdi-{}'.format(x)] = vdi_record['name_label']
                      x += 1
      Severity: Major
      Found in salt/cloud/clouds/xen.py - About 45 mins to fix

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

        def vbd_list(name=None, call=None):
            '''
            Get a list of VBDs on a VM
        
            **requires**: the name of the vm with the vbd definition
        Severity: Minor
        Found in salt/cloud/clouds/xen.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 list_nodes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def list_nodes():
            '''
            List virtual machines
        
              .. code-block:: bash
        Severity: Minor
        Found in salt/cloud/clouds/xen.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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def create(vm_):
            '''
            Create a VM in Xen
        
            The configuration for this function is read from the profile settings.
        Severity: Minor
        Found in salt/cloud/clouds/xen.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 show_instance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def show_instance(name, session=None, call=None):
            '''
            Show information about a specific VM or template
        
                .. code-block:: bash
        Severity: Minor
        Found in salt/cloud/clouds/xen.py - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        def destroy(name=None, call=None):
            '''
            Destroy Xen VM or template instance
        
            .. code-block:: bash
        Severity: Minor
        Found in salt/cloud/clouds/xen.py - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        def resume(name, call=None, session=None):
            '''
            Resume a vm from disk
        
            .. code-block:: bash
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 5 hrs to fix
        salt/cloud/clouds/xen.py on lines 785..804

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

        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 start(name, call=None, session=None):
            '''
            Start  a vm
        
            .. code-block:: bash
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 5 hrs to fix
        salt/cloud/clouds/xen.py on lines 873..892

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

        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

        def pause(name, call=None, session=None):
            '''
            Pause a vm
        
            .. code-block:: bash
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 3 other locations - About 5 hrs to fix
        salt/cloud/clouds/xen.py on lines 829..848
        salt/cloud/clouds/xen.py on lines 851..870
        salt/cloud/clouds/xen.py on lines 912..931

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

        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

        def suspend(name, call=None, session=None):
            '''
            Suspend a vm to disk
        
            .. code-block:: bash
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 3 other locations - About 5 hrs to fix
        salt/cloud/clouds/xen.py on lines 807..826
        salt/cloud/clouds/xen.py on lines 829..848
        salt/cloud/clouds/xen.py on lines 912..931

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

        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

        def unpause(name, call=None, session=None):
            '''
            UnPause a vm
        
            .. code-block:: bash
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 3 other locations - About 5 hrs to fix
        salt/cloud/clouds/xen.py on lines 807..826
        salt/cloud/clouds/xen.py on lines 851..870
        salt/cloud/clouds/xen.py on lines 912..931

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

        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

        def shutdown(name, call=None, session=None):
            '''
            Shutdown  a vm
        
            .. code-block:: bash
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 3 other locations - About 5 hrs to fix
        salt/cloud/clouds/xen.py on lines 807..826
        salt/cloud/clouds/xen.py on lines 829..848
        salt/cloud/clouds/xen.py on lines 851..870

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

        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 sr_list(call=None):
            '''
            Geta list of storage repositories
        
            .. code-block:: bash
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 5 hrs to fix
        salt/cloud/clouds/xen.py on lines 1121..1139

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

        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 pif_list(call=None):
            '''
            Get a list of Resource Pools
        
            .. code-block:: bash
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 5 hrs to fix
        salt/cloud/clouds/xen.py on lines 1056..1075

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

        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 pool_list(call=None):
            '''
            Get a list of Resource Pools
        
            .. code-block:: bash
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 5 hrs to fix
        salt/cloud/clouds/xen.py on lines 1078..1096

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

        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 host_list(call=None):
            '''
            Get a list of Xen Servers
        
            .. code-block:: bash
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 5 hrs to fix
        salt/cloud/clouds/xen.py on lines 1099..1118

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

        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 _get_vm(name=None, session=None):
            '''
            Get XEN vm instance object reference
            '''
            if session is None:
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 3 hrs to fix
        salt/cloud/clouds/xen.py on lines 972..981

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

        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 _get_sr(name=None, session=None):
            '''
            Get XEN sr (storage repo) object reference
            '''
            if session is None:
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 3 hrs to fix
        salt/cloud/clouds/xen.py on lines 960..969

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

        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

            __utils__['cloud.fire_event'](
                'event',
                'created instance',
                'salt/cloud/{0}/created'.format(name),
                args={
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 2 hrs to fix
        salt/cloud/clouds/xen.py on lines 569..579

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

        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

            __utils__['cloud.fire_event'](
                'event',
                'starting create',
                'salt/cloud/{0}/creating'.format(name),
                args={
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 2 hrs to fix
        salt/cloud/clouds/xen.py on lines 649..659

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

        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 vbds is not None:
                    x = 0
                    for vbd in vbds:
                        vbd_record = session.xenapi.VBD.get_record(vbd)
                        data['vbd-{}'.format(x)] = vbd_record
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 2 hrs to fix
        salt/cloud/clouds/xen.py on lines 1164..1169

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

        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 vifs is not None:
                x = 0
                for vif in vifs:
                    vif_record = session.xenapi.VIF.get_record(vif)
                    data['vif-{}'.format(x)] = vif_record
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 1 other location - About 2 hrs to fix
        salt/cloud/clouds/xen.py on lines 1198..1203

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

        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

                    try:
                        base_template_name = record['other_config']['base_template_name']
                    except Exception:
                        base_template_name = None
                        log.debug(
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 2 other locations - About 1 hr to fix
        salt/cloud/clouds/xen.py on lines 199..205
        salt/cloud/clouds/xen.py on lines 490..496

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

                try:
                    base_template_name = record['other_config']['base_template_name']
                except Exception:
                    base_template_name = None
                    log.debug(
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 2 other locations - About 1 hr to fix
        salt/cloud/clouds/xen.py on lines 199..205
        salt/cloud/clouds/xen.py on lines 323..329

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

                    try:
                        base_template_name = record['other_config']['base_template_name']
                    except Exception:
                        base_template_name = None
                        log.debug(
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 2 other locations - About 1 hr to fix
        salt/cloud/clouds/xen.py on lines 323..329
        salt/cloud/clouds/xen.py on lines 490..496

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

                if __opts__.get('update_cachedir', False) is True:
                    __utils__['cloud.delete_minion_cachedir'](
                        name,
                        __active_provider_name__.split(':')[0],
                        __opts__
        Severity: Major
        Found in salt/cloud/clouds/xen.py and 22 other locations - About 50 mins to fix
        salt/cloud/clouds/azurearm.py on lines 1528..1532
        salt/cloud/clouds/digitalocean.py on lines 868..869
        salt/cloud/clouds/ec2.py on lines 3417..3418
        salt/cloud/clouds/gce.py on lines 2377..2378
        salt/cloud/clouds/gogrid.py on lines 421..422
        salt/cloud/clouds/joyent.py on lines 429..430
        salt/cloud/clouds/linode.py on lines 758..759
        salt/cloud/clouds/lxc.py on lines 415..416
        salt/cloud/clouds/msazure.py on lines 947..948
        salt/cloud/clouds/nova.py on lines 569..570
        salt/cloud/clouds/oneandone.py on lines 918..922
        salt/cloud/clouds/opennebula.py on lines 1226..1230
        salt/cloud/clouds/openstack.py on lines 816..817
        salt/cloud/clouds/parallels.py on lines 561..562
        salt/cloud/clouds/profitbricks.py on lines 1023..1027
        salt/cloud/clouds/proxmox.py on lines 1194..1196
        salt/cloud/clouds/scaleway.py on lines 456..458
        salt/cloud/clouds/softlayer.py on lines 637..638
        salt/cloud/clouds/softlayer_hw.py on lines 547..548
        salt/cloud/clouds/vagrant.py on lines 308..310
        salt/cloud/clouds/vmware.py on lines 2513..2514
        salt/cloud/libcloudfuncs.py on lines 403..404

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

        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