saltstack/salt

View on GitHub
salt/states/smartos.py

Summary

Maintainability
F
3 wks
Test Coverage

Function vm_present has a Cognitive Complexity of 387 (exceeds 5 allowed). Consider refactoring.
Open

def vm_present(name, vmconfig, config=None):
    '''
    Ensure vm is present on the computenode

    name : string
Severity: Minor
Found in salt/states/smartos.py - About 1 wk to fix

Cognitive Complexity

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

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

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

Further reading

Cyclomatic complexity is too high in function vm_present. (124)
Open

def vm_present(name, vmconfig, config=None):
    '''
    Ensure vm is present on the computenode

    name : string
Severity: Minor
Found in salt/states/smartos.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

File smartos.py has 919 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Management of SmartOS Standalone Compute Nodes

:maintainer:    Jorge Schrauwen <sjorge@blackdot.be>
Severity: Major
Found in salt/states/smartos.py - About 2 days to fix

    Function _copy_lx_vars has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

    def _copy_lx_vars(vmconfig):
        # NOTE: documentation on dockerinit: https://github.com/joyent/smartos-live/blob/master/src/dockerinit/README.md
        if 'image_uuid' in vmconfig:
            # NOTE: retrieve tags and type from image
            imgconfig = __salt__['imgadm.get'](vmconfig['image_uuid']).get('manifest', {})
    Severity: Minor
    Found in salt/states/smartos.py - About 1 day 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 image_vacuum has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

    def image_vacuum(name):
        '''
        Delete images not in use or installed via image_present
    
        .. warning::
    Severity: Minor
    Found in salt/states/smartos.py - About 7 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 image_absent has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def image_absent(name):
        '''
        Ensure image is absent on the computenode
    
        name : string
    Severity: Minor
    Found in salt/states/smartos.py - About 4 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 image_present has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def image_present(name):
        '''
        Ensure image is present on the computenode
    
        name : string
    Severity: Minor
    Found in salt/states/smartos.py - About 4 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 _parse_vmconfig has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_vmconfig(config, instances):
        '''
        Parse vm_present vm config
        '''
        vmconfig = None
    Severity: Minor
    Found in salt/states/smartos.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

    Cyclomatic complexity is too high in function image_vacuum. (22)
    Open

    def image_vacuum(name):
        '''
        Delete images not in use or installed via image_present
    
        .. warning::
    Severity: Minor
    Found in salt/states/smartos.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function config_present has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def config_present(name, value):
        '''
        Ensure configuration property is set to value in /usbkey/config
    
        name : string
    Severity: Minor
    Found in salt/states/smartos.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 source_absent has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def source_absent(name):
        '''
        Ensure an image source is absent on the computenode
    
        name : string
    Severity: Minor
    Found in salt/states/smartos.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 vm_absent has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def vm_absent(name, archive=False):
        '''
        Ensure vm is absent on the computenode
    
        name : string
    Severity: Minor
    Found in salt/states/smartos.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 source_present has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def source_present(name, source_type='imgapi'):
        '''
        Ensure an image source is present on the computenode
    
        name : string
    Severity: Minor
    Found in salt/states/smartos.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 _load_config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def _load_config():
        '''
        Loads and parses /usbkey/config
        '''
        config = {}
    Severity: Minor
    Found in salt/states/smartos.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

    Avoid deeply nested control flow statements.
    Open

                        if not isinstance(rret, (bool)) and 'Error' in rret:
                            ret['result'] = False
                            ret['comment'] = 'vm {0} updated, reprovision failed'.format(
                                vmconfig['state']['hostname']
                            )
    Severity: Major
    Found in salt/states/smartos.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if vmconfig['state']['hostname'] in __salt__['vmadm.list'](order='hostname', search='state=running'):
                              __salt__['vmadm.reboot'](vm=vmconfig['state']['hostname'], key='hostname')
                          if kvm_needs_start:
      Severity: Major
      Found in salt/states/smartos.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if not enforce and prop in vmconfig['current'][collection]:
                                continue
        
                            # create set_ dict
                            if 'set_{0}'.format(collection) not in vmconfig['changed']:
        Severity: Major
        Found in salt/states/smartos.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if disk['image_uuid'] not in res:
                                  ret['result'] = False
                                  ret['comment'] = 'failed to import image {0}'.format(disk['image_uuid'])
                      else:
          Severity: Major
          Found in salt/states/smartos.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                while image:
                                    image_count += 1
                                    __salt__['imgadm.delete'](image['manifest']['uuid'])
                                    if 'origin' in image['manifest']:
                                        image = __salt__['imgadm.get'](image['manifest']['origin'])
            Severity: Major
            Found in salt/states/smartos.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if 'remove_{0}'.format(collection) not in vmconfig['changed']:
                                      vmconfig['changed']['remove_{0}'.format(collection)] = []
              
                                  # remove property
                                  vmconfig['changed']['remove_{0}'.format(collection)].append(prop)
              Severity: Major
              Found in salt/states/smartos.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if "{0}".format(vmconfig['current'][prop]) == "{0}".format(vmconfig['state'][prop]):
                                        continue
                
                            # add property to changeset
                            vmconfig['changed'][prop] = vmconfig['state'][prop]
                Severity: Major
                Found in salt/states/smartos.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if remove_instance:
                                          # create remove_ array
                                          if 'remove_{0}'.format(instance) not in vmconfig['changed']:
                                              vmconfig['changed']['remove_{0}'.format(instance)] = []
                  
                  
                  Severity: Major
                  Found in salt/states/smartos.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if kvm_needs_start:
                                            __salt__['vmadm.start'](vm=vmconfig['state']['hostname'], key='hostname')
                                else:
                    Severity: Major
                    Found in salt/states/smartos.py - About 45 mins to fix

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

                      def _write_config(config):
                          '''
                          writes /usbkey/config
                          '''
                          try:
                      Severity: Minor
                      Found in salt/states/smartos.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

                                          for cdisk in vmconfig['current']['disks']:
                                              if cdisk['path'].endswith(disk['path']):
                                                  path = cdisk['path']
                                                  break
                                      if not path:
                      Severity: Major
                      Found in salt/states/smartos.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if 'mac' in instance_config:
                                                instance_config['mac'] = instance_config['mac'].lower()
                                            vmconfig[prop].append(instance_config)
                        Severity: Major
                        Found in salt/states/smartos.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              for config_env_var in val_config if isinstance(val_config, list) else json.loads(val_config):
                                                  config_env_var = config_env_var.split('=')
                                                  for img_env_var in val:
                                                      if img_env_var.startswith('{0}='.format(config_env_var[0])):
                                                          val.remove(img_env_var)
                          Severity: Major
                          Found in salt/states/smartos.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if prop in vmconfig['current'][collection] and \
                                                    vmconfig['current'][collection][prop] == vmconfig['state'][collection][prop]:
                                                    continue
                            
                                                # skip update if not enforcing
                            Severity: Major
                            Found in salt/states/smartos.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  for current_cfg in vmconfig['current'][instance]:
                                                      if vmconfig_type['instance'][instance] not in state_cfg:
                                                          continue
                              
                                                      if state_cfg[vmconfig_type['instance'][instance]] == current_cfg[vmconfig_type['instance'][instance]]:
                              Severity: Major
                              Found in salt/states/smartos.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if instance in vmconfig['state'] and vmconfig['state'][instance] is not None:
                                                        for state_cfg in vmconfig['state'][instance]:
                                                            if vmconfig_type['instance'][instance] not in state_cfg:
                                                                continue
                                
                                
                                Severity: Major
                                Found in salt/states/smartos.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if val is not None:
                                                          vmconfig['state']['internal_metadata'][var] = val
                                  
                                              # process add and update for collection
                                              if collection in vmconfig['state'] and vmconfig['state'][collection] is not None:
                                  Severity: Major
                                  Found in salt/states/smartos.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if 'set_{0}'.format(collection) not in vmconfig['changed']:
                                                            vmconfig['changed']['set_{0}'.format(collection)] = {}
                                    
                                                        # add property to changeset
                                                        vmconfig['changed']['set_{0}'.format(collection)][prop] = vmconfig['state'][collection][prop]
                                    Severity: Major
                                    Found in salt/states/smartos.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                          if collection in vmconfig['state'] and vmconfig['state'][collection] is not None:
                                                              if prop in vmconfig['state'][collection]:
                                                                  continue
                                      
                                                          # create remove_ array
                                      Severity: Major
                                      Found in salt/states/smartos.py - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                            if vmconfig['current'][prop] == vmconfig['state'][prop]:
                                                                continue
                                                        else:
                                        Severity: Major
                                        Found in salt/states/smartos.py - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                              if vmconfig['state']['hostname'] in __salt__['vmadm.list'](order='hostname', search='state=running'):
                                                                  kvm_needs_start = True
                                                                  __salt__['vmadm.stop'](vm=vmconfig['state']['hostname'], key='hostname')
                                          
                                                      # do update
                                          Severity: Major
                                          Found in salt/states/smartos.py - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                                if add_instance:
                                                                    # create add_ array
                                                                    if 'add_{0}'.format(instance) not in vmconfig['changed']:
                                                                        vmconfig['changed']['add_{0}'.format(instance)] = []
                                            
                                            
                                            Severity: Major
                                            Found in salt/states/smartos.py - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                                  if vmconfig['image_uuid'] not in res:
                                                                      ret['result'] = False
                                                                      ret['comment'] = 'failed to import image {0}'.format(vmconfig['image_uuid'])
                                                          else:
                                              Severity: Major
                                              Found in salt/states/smartos.py - About 45 mins to fix

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

                                                def vm_running(name):
                                                    '''
                                                    Ensure vm is in the running state on the computenode
                                                
                                                    name : string
                                                Severity: Minor
                                                Found in salt/states/smartos.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 vm_stopped has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                Open

                                                def vm_stopped(name):
                                                    '''
                                                    Ensure vm is in the stopped state on the computenode
                                                
                                                    name : string
                                                Severity: Minor
                                                Found in salt/states/smartos.py - About 35 mins to fix

                                                Cognitive Complexity

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

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

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

                                                Further reading

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

                                                def _get_instance_changes(current, state):
                                                    '''
                                                    get modified properties
                                                    '''
                                                    # get keys
                                                Severity: Minor
                                                Found in salt/states/smartos.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 vm_stopped(name):
                                                    '''
                                                    Ensure vm is in the stopped state on the computenode
                                                
                                                    name : string
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 2 days to fix
                                                salt/states/smartos.py on lines 1168..1200

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

                                                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 vm_running(name):
                                                    '''
                                                    Ensure vm is in the running state on the computenode
                                                
                                                    name : string
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 2 days to fix
                                                salt/states/smartos.py on lines 1203..1235

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

                                                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 ret['result']:
                                                            ret['comment'] = 'image source {0} added'.format(name)
                                                            ret['changes'][name] = 'added'
                                                        else:
                                                            ret['comment'] = 'image source {0} not added'.format(name)
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 5 hrs to fix
                                                salt/states/smartos.py on lines 477..483

                                                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

                                                        if ret['result']:
                                                            ret['comment'] = 'image source {0} deleted'.format(name)
                                                            ret['changes'][name] = 'deleted'
                                                        else:
                                                            ret['comment'] = 'image source {0} not deleted'.format(name)
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 5 hrs to fix
                                                salt/states/smartos.py on lines 441..447

                                                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

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

                                                def _split_docker_uuid(uuid):
                                                    '''
                                                    Split a smartos docker uuid into repo and tag
                                                    '''
                                                    if uuid:
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 3 hrs to fix
                                                salt/modules/smartos_imgadm.py on lines 104..114

                                                Duplicated Code

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

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

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

                                                Tuning

                                                This issue has a mass of 72.

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

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

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

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

                                                Refactorings

                                                Further Reading

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

                                                        if image['manifest']['name'] == 'docker-layer':
                                                            # NOTE: docker images are made of multiple layers, loop over them
                                                            while image:
                                                                image_uuid = image['manifest']['uuid']
                                                                if image_uuid in __salt__['imgadm.delete'](image_uuid):
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 2 hrs to fix
                                                salt/states/smartos.py on lines 663..667

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

                                                                if image_uuid in __salt__['imgadm.delete'](image_uuid):
                                                                    ret['changes'][image_uuid] = None
                                                                else:
                                                                    ret['result'] = False
                                                                    ret['comment'] = 'failed to delete images'
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 2 hrs to fix
                                                salt/states/smartos.py on lines 659..678

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

                                                def _is_uuid(uuid):
                                                    '''
                                                    Check if uuid is a valid smartos uuid
                                                
                                                    Example: e69a0918-055d-11e5-8912-e3ceb6df4cf8
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 2 hrs to fix
                                                salt/modules/smartos_imgadm.py on lines 117..125

                                                Duplicated Code

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

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

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

                                                Tuning

                                                This issue has a mass of 58.

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

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

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

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

                                                Refactorings

                                                Further Reading

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

                                                        if six.text_type(config[name]) == six.text_type(value):
                                                            # we're good
                                                            ret['result'] = True
                                                            ret['comment'] = 'property {0} already has value "{1}"'.format(name, value)
                                                        else:
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 2 hrs to fix
                                                salt/states/smartos.py on lines 354..370

                                                Duplicated Code

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

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

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

                                                Tuning

                                                This issue has a mass of 58.

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

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

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

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

                                                Refactorings

                                                Further Reading

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

                                                    if name in config:
                                                        if six.text_type(config[name]) == six.text_type(value):
                                                            # we're good
                                                            ret['result'] = True
                                                            ret['comment'] = 'property {0} already has value "{1}"'.format(name, value)
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 2 hrs to fix
                                                salt/states/smartos.py on lines 355..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 58.

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

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

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

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

                                                Refactorings

                                                Further Reading

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

                                                                if 'origin' in image['manifest']:
                                                                    image = __salt__['imgadm.get'](image['manifest']['origin'])
                                                                else:
                                                                    image = None
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 1 hr to fix
                                                salt/states/smartos.py on lines 589..592

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

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

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

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

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

                                                Refactorings

                                                Further Reading

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

                                                                        if 'origin' in image['manifest']:
                                                                            image = __salt__['imgadm.get'](image['manifest']['origin'])
                                                                        else:
                                                                            image = None
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 1 hr to fix
                                                salt/states/smartos.py on lines 668..671

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

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

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

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

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

                                                Refactorings

                                                Further Reading

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

                                                                        if state_cfg[vmconfig_type['instance'][instance]] == current_cfg[vmconfig_type['instance'][instance]]:
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 1 hr to fix
                                                salt/states/smartos.py on lines 1019..1019

                                                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

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

                                                                            if state_cfg[vmconfig_type['instance'][instance]] == current_cfg[vmconfig_type['instance'][instance]]:
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 1 hr to fix
                                                salt/states/smartos.py on lines 971..971

                                                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 disk['image_uuid'] not in res:
                                                                        ret['result'] = False
                                                                        ret['comment'] = 'failed to import image {0}'.format(disk['image_uuid'])
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 1 hr to fix
                                                salt/states/smartos.py on lines 805..807

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

                                                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 vmconfig['image_uuid'] not in res:
                                                                        ret['result'] = False
                                                                        ret['comment'] = 'failed to import image {0}'.format(vmconfig['image_uuid'])
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 1 hr to fix
                                                salt/states/smartos.py on lines 818..820

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

                                                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

                                                def _is_docker_uuid(uuid):
                                                    '''
                                                    Check if uuid is a valid smartos docker uuid
                                                
                                                    Example plexinc/pms-docker:plexpass
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 1 hr to fix
                                                salt/modules/smartos_imgadm.py on lines 128..135

                                                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

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

                                                    if not __opts__['test'] and ret['changes']:
                                                        ret['result'] = _write_config(config)
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 1 hr to fix
                                                salt/states/smartos.py on lines 373..374

                                                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

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

                                                    if not __opts__['test'] and ret['changes']:
                                                        ret['result'] = _write_config(config)
                                                Severity: Major
                                                Found in salt/states/smartos.py and 1 other location - About 1 hr to fix
                                                salt/states/smartos.py on lines 408..409

                                                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

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

                                                                                if 'update_{0}'.format(instance) not in vmconfig['changed']:
                                                                                    vmconfig['changed']['update_{0}'.format(instance)] = []
                                                Severity: Major
                                                Found in salt/states/smartos.py and 3 other locations - About 55 mins to fix
                                                salt/states/smartos.py on lines 949..950
                                                salt/states/smartos.py on lines 1002..1003
                                                salt/states/smartos.py on lines 1025..1026

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

                                                                        if 'remove_{0}'.format(instance) not in vmconfig['changed']:
                                                                            vmconfig['changed']['remove_{0}'.format(instance)] = []
                                                Severity: Major
                                                Found in salt/states/smartos.py and 3 other locations - About 55 mins to fix
                                                salt/states/smartos.py on lines 949..950
                                                salt/states/smartos.py on lines 994..995
                                                salt/states/smartos.py on lines 1002..1003

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

                                                                        if 'add_{0}'.format(instance) not in vmconfig['changed']:
                                                                            vmconfig['changed']['add_{0}'.format(instance)] = []
                                                Severity: Major
                                                Found in salt/states/smartos.py and 3 other locations - About 55 mins to fix
                                                salt/states/smartos.py on lines 949..950
                                                salt/states/smartos.py on lines 994..995
                                                salt/states/smartos.py on lines 1025..1026

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

                                                                    if 'remove_{0}'.format(collection) not in vmconfig['changed']:
                                                                        vmconfig['changed']['remove_{0}'.format(collection)] = []
                                                Severity: Major
                                                Found in salt/states/smartos.py and 3 other locations - About 55 mins to fix
                                                salt/states/smartos.py on lines 994..995
                                                salt/states/smartos.py on lines 1002..1003
                                                salt/states/smartos.py on lines 1025..1026

                                                Duplicated Code

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

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

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

                                                Tuning

                                                This issue has a mass of 45.

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

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

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

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

                                                Refactorings

                                                Further Reading

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

                                                def __virtual__():
                                                    '''
                                                    Provides smartos state provided for SmartOS
                                                    '''
                                                    if 'vmadm.create' in __salt__ and 'imgadm.list' in __salt__:
                                                Severity: Minor
                                                Found in salt/states/smartos.py and 1 other location - About 50 mins to fix
                                                salt/states/zone.py on lines 136..145

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

                                                        if change in changed and changed[change]['new'] == "":
                                                            del changed[change]
                                                Severity: Minor
                                                Found in salt/states/smartos.py and 1 other location - About 40 mins to fix
                                                salt/states/smartos.py on lines 267..268

                                                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 change in changed and changed[change]['old'] == "":
                                                            del changed[change]
                                                Severity: Minor
                                                Found in salt/states/smartos.py and 1 other location - About 40 mins to fix
                                                salt/states/smartos.py on lines 269..270

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

                                                                    if not isinstance(rret, (bool)) and 'Error' in rret:
                                                                        ret['result'] = False
                                                                        ret['comment'] = 'vm {0} updated, reprovision failed'.format(
                                                                            vmconfig['state']['hostname']
                                                Severity: Major
                                                Found in salt/states/smartos.py and 3 other locations - About 35 mins to fix
                                                salt/states/boto_kms.py on lines 275..277
                                                salt/states/boto_kms.py on lines 294..296
                                                salt/states/boto_lambda.py on lines 262..265

                                                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

                                                There are no issues that match your filters.

                                                Category
                                                Status