saltstack/salt

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

Summary

Maintainability
F
1 wk
Test Coverage

File joyent.py has 863 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Joyent Cloud Module
===================

Severity: Major
Found in salt/cloud/clouds/joyent.py - About 2 days to fix

    Function list_nodes has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_nodes(full=False, call=None):
        '''
        list of nodes, keeping only a brief listing
    
        CLI Example:
    Severity: Minor
    Found in salt/cloud/clouds/joyent.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 query has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def query(action=None,
              command=None,
              args=None,
              method='GET',
              location=None,
    Severity: Minor
    Found in salt/cloud/clouds/joyent.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 reformat_node has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def reformat_node(item=None, full=False):
        '''
        Reformat the returned data from joyent, determine public/private IPs and
        strip out fields if necessary to provide either full or brief content.
    
    
    Severity: Minor
    Found in salt/cloud/clouds/joyent.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 query_instance has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def query_instance(vm_=None, call=None):
        '''
        Query an instance upon creation from the Joyent API
        '''
        if isinstance(vm_, six.string_types) and call == 'action':
    Severity: Minor
    Found in salt/cloud/clouds/joyent.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 key_list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def key_list(items=None):
        '''
        convert list to dictionary using the key as the identifier
        :param items: array to iterate over
        :return: dictionary
    Severity: Minor
    Found in salt/cloud/clouds/joyent.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_node has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_node(**kwargs):
        '''
        convenience function to make the rest api call for node creation.
        '''
        name = kwargs['name']
    Severity: Minor
    Found in salt/cloud/clouds/joyent.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 query has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def query(action=None,
              command=None,
              args=None,
              method='GET',
              location=None,
    Severity: Minor
    Found in salt/cloud/clouds/joyent.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                          if 'name' in node:
                              node['location'] = location
                              ret[node['name']] = reformat_node(item=node, full=full)
                  else:
      Severity: Major
      Found in salt/cloud/clouds/joyent.py - About 45 mins to fix

        Avoid too many return statements within this function.
        Open

            return {'keys': {data['name']: data['key']}}
        Severity: Major
        Found in salt/cloud/clouds/joyent.py - About 30 mins to fix

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

          def take_action(name=None, call=None, command=None, data=None, method='GET',
                          location=DEFAULT_LOCATION):
          
              '''
              take action call used by start,stop, reboot
          Severity: Minor
          Found in salt/cloud/clouds/joyent.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 3 locations. Consider refactoring.
          Open

          def start(name, call=None):
              '''
              start a machine by name
              :param name: name given to the machine
              :param call: call value in this case is 'action'
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 2 other locations - About 4 hrs to fix
          salt/cloud/clouds/joyent.py on lines 435..452
          salt/cloud/clouds/joyent.py on lines 455..472

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

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

          def stop(name, call=None):
              '''
              stop a machine by name
              :param name: name given to the machine
              :param call: call value in this case is 'action'
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 2 other locations - About 4 hrs to fix
          salt/cloud/clouds/joyent.py on lines 435..452
          salt/cloud/clouds/joyent.py on lines 475..493

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

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

          def reboot(name, call=None):
              '''
              reboot a machine by name
              :param name: name given to the machine
              :param call: call value in this case is 'action'
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 2 other locations - About 4 hrs to fix
          salt/cloud/clouds/joyent.py on lines 455..472
          salt/cloud/clouds/joyent.py on lines 475..493

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

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

              __utils__['cloud.fire_event'](
                  'event',
                  'requesting instance',
                  'salt/cloud/{0}/requesting'.format(vm_['name']),
                  args={
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 6 other locations - About 2 hrs to fix
          salt/cloud/clouds/gogrid.py on lines 125..133
          salt/cloud/clouds/nova.py on lines 685..693
          salt/cloud/clouds/parallels.py on lines 258..266
          salt/cloud/clouds/qingcloud.py on lines 691..699
          salt/cloud/clouds/scaleway.py on lines 241..249
          salt/cloud/clouds/vultrpy.py on lines 329..337

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

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

              __utils__['cloud.fire_event'](
                  'event',
                  'starting create',
                  'salt/cloud/{0}/creating'.format(vm_['name']),
                  args=__utils__['cloud.filter_event']('creating', vm_, ['name', 'profile', 'provider', 'driver']),
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 37 other locations - About 2 hrs to fix
          salt/cloud/clouds/aliyun.py on lines 625..631
          salt/cloud/clouds/aliyun.py on lines 732..738
          salt/cloud/clouds/azurearm.py on lines 1349..1359
          salt/cloud/clouds/azurearm.py on lines 1398..1406
          salt/cloud/clouds/azurearm.py on lines 1480..1489
          salt/cloud/clouds/digitalocean.py on lines 287..293
          salt/cloud/clouds/digitalocean.py on lines 537..543
          salt/cloud/clouds/dimensiondata.py on lines 207..213
          salt/cloud/clouds/dimensiondata.py on lines 337..343
          salt/cloud/clouds/ec2.py on lines 2579..2585
          salt/cloud/clouds/gce.py on lines 2461..2467
          salt/cloud/clouds/gce.py on lines 2551..2557
          salt/cloud/clouds/gce.py on lines 2635..2641
          salt/cloud/clouds/gogrid.py on lines 96..102
          salt/cloud/clouds/gogrid.py on lines 180..186
          salt/cloud/clouds/joyent.py on lines 325..331
          salt/cloud/clouds/lxc.py on lines 440..446
          salt/cloud/clouds/lxc.py on lines 460..466
          salt/cloud/clouds/lxc.py on lines 488..494
          salt/cloud/clouds/msazure.py on lines 429..435
          salt/cloud/clouds/msazure.py on lines 683..689
          salt/cloud/clouds/nova.py on lines 961..967
          salt/cloud/clouds/opennebula.py on lines 1006..1012
          salt/cloud/clouds/openstack.py on lines 684..690
          salt/cloud/clouds/packet.py on lines 347..353
          salt/cloud/clouds/parallels.py on lines 287..293
          salt/cloud/clouds/parallels.py on lines 356..362
          salt/cloud/clouds/proxmox.py on lines 578..585
          salt/cloud/clouds/qingcloud.py on lines 668..674
          salt/cloud/clouds/qingcloud.py on lines 738..744
          salt/cloud/clouds/scaleway.py on lines 200..206
          salt/cloud/clouds/scaleway.py on lines 304..310
          salt/cloud/clouds/virtualbox.py on lines 176..182
          salt/cloud/clouds/vmware.py on lines 2543..2549
          salt/cloud/clouds/vmware.py on lines 3072..3078
          salt/cloud/clouds/vultrpy.py on lines 292..298
          salt/cloud/clouds/vultrpy.py on lines 465..471

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

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

              __utils__['cloud.fire_event'](
                  'event',
                  'created instance',
                  'salt/cloud/{0}/created'.format(vm_['name']),
                  args=__utils__['cloud.filter_event']('created', vm_, ['name', 'profile', 'provider', 'driver']),
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 37 other locations - About 2 hrs to fix
          salt/cloud/clouds/aliyun.py on lines 625..631
          salt/cloud/clouds/aliyun.py on lines 732..738
          salt/cloud/clouds/azurearm.py on lines 1349..1359
          salt/cloud/clouds/azurearm.py on lines 1398..1406
          salt/cloud/clouds/azurearm.py on lines 1480..1489
          salt/cloud/clouds/digitalocean.py on lines 287..293
          salt/cloud/clouds/digitalocean.py on lines 537..543
          salt/cloud/clouds/dimensiondata.py on lines 207..213
          salt/cloud/clouds/dimensiondata.py on lines 337..343
          salt/cloud/clouds/ec2.py on lines 2579..2585
          salt/cloud/clouds/gce.py on lines 2461..2467
          salt/cloud/clouds/gce.py on lines 2551..2557
          salt/cloud/clouds/gce.py on lines 2635..2641
          salt/cloud/clouds/gogrid.py on lines 96..102
          salt/cloud/clouds/gogrid.py on lines 180..186
          salt/cloud/clouds/joyent.py on lines 274..280
          salt/cloud/clouds/lxc.py on lines 440..446
          salt/cloud/clouds/lxc.py on lines 460..466
          salt/cloud/clouds/lxc.py on lines 488..494
          salt/cloud/clouds/msazure.py on lines 429..435
          salt/cloud/clouds/msazure.py on lines 683..689
          salt/cloud/clouds/nova.py on lines 961..967
          salt/cloud/clouds/opennebula.py on lines 1006..1012
          salt/cloud/clouds/openstack.py on lines 684..690
          salt/cloud/clouds/packet.py on lines 347..353
          salt/cloud/clouds/parallels.py on lines 287..293
          salt/cloud/clouds/parallels.py on lines 356..362
          salt/cloud/clouds/proxmox.py on lines 578..585
          salt/cloud/clouds/qingcloud.py on lines 668..674
          salt/cloud/clouds/qingcloud.py on lines 738..744
          salt/cloud/clouds/scaleway.py on lines 200..206
          salt/cloud/clouds/scaleway.py on lines 304..310
          salt/cloud/clouds/virtualbox.py on lines 176..182
          salt/cloud/clouds/vmware.py on lines 2543..2549
          salt/cloud/clouds/vmware.py on lines 3072..3078
          salt/cloud/clouds/vultrpy.py on lines 292..298
          salt/cloud/clouds/vultrpy.py on lines 465..471

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

          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

                  for node in nodes:
                      if 'name' in node:
                          node['location'] = location
                          ret[node['name']] = reformat_node(item=node, full=full)
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 2 hrs to fix
          salt/cloud/clouds/joyent.py on lines 751..754

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

                          for node in nodes:
                              if 'name' in node:
                                  node['location'] = location
                                  ret[node['name']] = reformat_node(item=node, full=full)
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 2 hrs to fix
          salt/cloud/clouds/joyent.py on lines 763..766

          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

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

              try:
                  # Check for required profile parameters before sending any API calls.
                  if vm_['profile'] and config.is_profile_configured(__opts__,
                                                                     __active_provider_name__ or 'joyent',
                                                                     vm_['profile'],
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 17 other locations - About 1 hr to fix
          salt/cloud/clouds/aliyun.py on lines 615..622
          salt/cloud/clouds/azurearm.py on lines 1384..1392
          salt/cloud/clouds/cloudstack.py on lines 270..277
          salt/cloud/clouds/digitalocean.py on lines 277..284
          salt/cloud/clouds/ec2.py on lines 2554..2561
          salt/cloud/clouds/gce.py on lines 2451..2458
          salt/cloud/clouds/gogrid.py on lines 86..93
          salt/cloud/clouds/linode.py on lines 328..335
          salt/cloud/clouds/msazure.py on lines 419..426
          salt/cloud/clouds/nova.py on lines 938..945
          salt/cloud/clouds/parallels.py on lines 277..284
          salt/cloud/clouds/proxmox.py on lines 566..573
          salt/cloud/clouds/qingcloud.py on lines 658..665
          salt/cloud/clouds/scaleway.py on lines 190..197
          salt/cloud/clouds/softlayer.py on lines 248..255
          salt/cloud/clouds/softlayer_hw.py on lines 216..223
          salt/cloud/clouds/vmware.py on lines 2532..2540

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

          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

              with salt.utils.files.fopen(kwargs['keyfile'], 'r') as fp_:
                  kwargs['key'] = salt.utils.stringutils.to_unicode(fp_.read())
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 1 hr to fix
          salt/cloud/clouds/ec2.py on lines 4904..4906

          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

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

              __utils__['cloud.fire_event'](
                  'event',
                  'querying instance',
                  'salt/cloud/{0}/querying'.format(vm_['name']),
                  sock_dir=__opts__['sock_dir'],
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 1 hr to fix
          salt/cloud/clouds/ec2.py on lines 2117..2122

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

          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

                  for ip in item['ips']:
                      if salt.utils.cloud.is_public_ip(ip):
                          item['public_ips'].append(ip)
                      else:
                          item['private_ips'].append(ip)
          Severity: Minor
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 55 mins to fix
          salt/cloud/clouds/profitbricks.py on lines 612..615

          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/joyent.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/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/clouds/xen.py on lines 1046..1050
          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

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

          def get_location(vm_=None):
              '''
              Return the joyent data center to use, in this order:
                  - CLI parameter
                  - VM parameter
          Severity: Major
          Found in salt/cloud/clouds/joyent.py and 2 other locations - About 45 mins to fix
          salt/cloud/clouds/aliyun.py on lines 204..216
          salt/cloud/clouds/ec2.py on lines 1110..1122

          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 metadata is not None:
                  for key, value in six.iteritems(metadata):
                      create_data['metadata.{0}'.format(key)] = value
          Severity: Minor
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 40 mins to fix
          salt/cloud/clouds/joyent.py on lines 366..368

          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 tag is not None:
                  for key, value in six.iteritems(tag):
                      create_data['tag.{0}'.format(key)] = value
          Severity: Minor
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 40 mins to fix
          salt/cloud/clouds/joyent.py on lines 362..364

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

              try:
                  from Cryptodome.Hash import SHA256
                  from Cryptodome.Signature import PKCS1_v1_5
                  HAS_REQUIRED_CRYPTO = True
              except ImportError:
          Severity: Minor
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 35 mins to fix
          salt/utils/http.py on lines 26..37

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 41.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              if not os.path.isfile(kwargs['keyfile']):
                  log.error('The specified keyfile (%s) does not exist.', kwargs['keyfile'])
                  return False
          Severity: Minor
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 35 mins to fix
          salt/auth/file.py on lines 138..141

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 41.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          def __virtual__():
              '''
              Check for Joyent configs
              '''
              if HAS_REQUIRED_CRYPTO is False:
          Severity: Minor
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 35 mins to fix
          salt/cloud/clouds/packet.py on lines 95..104

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 41.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          def has_method(obj, method_name):
              '''
              Find if the provided object has a specific method
              '''
              if method_name in dir(obj):
          Severity: Minor
          Found in salt/cloud/clouds/joyent.py and 1 other location - About 30 mins to fix
          salt/cloud/libcloudfuncs.py on lines 519..527

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

          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