saltstack/salt

View on GitHub
salt/states/boto_datapipeline.py

Summary

Maintainability
F
4 days
Test Coverage

File boto_datapipeline.py has 480 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Manage Data Pipelines

.. versionadded:: 2016.3.0
Severity: Minor
Found in salt/states/boto_datapipeline.py - About 7 hrs to fix

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

    def _recursive_compare(v1, v2):
        '''
        Return v1 == v2. Compares list, dict, recursively.
        '''
        if isinstance(v1, list):
    Severity: Minor
    Found in salt/states/boto_datapipeline.py - About 3 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function present has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def present(name, pipeline_objects=None,
                pipeline_objects_from_pillars='boto_datapipeline_pipeline_objects',
                parameter_objects=None,
                parameter_objects_from_pillars='boto_datapipeline_parameter_objects',
                parameter_values=None,
    Severity: Minor
    Found in salt/states/boto_datapipeline.py - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

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

    def _cleaned(_pipeline_objects):
        """Return standardized pipeline objects to be used for comparing
    
        Remove year, month, and day components of the startDateTime so that data
        pipelines with the same time of day but different days are considered
    Severity: Minor
    Found in salt/states/boto_datapipeline.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 _standardize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def _standardize(structure):
        '''
        Return standardized format for lists/dictionaries.
    
        Lists of dictionaries are sorted by the value of the dictionary at
    Severity: Minor
    Found in salt/states/boto_datapipeline.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 too many return statements within this function.
    Open

            return v1 == v2
    Severity: Major
    Found in salt/states/boto_datapipeline.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return ret
      Severity: Major
      Found in salt/states/boto_datapipeline.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return ret
        Severity: Major
        Found in salt/states/boto_datapipeline.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return ret
          Severity: Major
          Found in salt/states/boto_datapipeline.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return ret
            Severity: Major
            Found in salt/states/boto_datapipeline.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

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

                Avoid too many return statements within this function.
                Open

                        return True
                Severity: Major
                Found in salt/states/boto_datapipeline.py - About 30 mins to fix

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

                  def _immutable_fields_error(result_pipeline_definition):
                      '''Return true if update pipeline failed due to immutable fields
                  
                      Some fields cannot be changed after a pipeline has been activated.
                  
                  
                  Severity: Minor
                  Found in salt/states/boto_datapipeline.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 _parameter_objects(parameter_objects_from_pillars, parameter_object_overrides):
                      '''
                      Return a list of parameter objects that configure the pipeline
                  
                      parameter_objects_from_pillars
                  Severity: Major
                  Found in salt/states/boto_datapipeline.py and 1 other location - About 4 hrs to fix
                  salt/states/boto_datapipeline.py on lines 433..448

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

                  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 _pipeline_objects(pipeline_objects_from_pillars, pipeline_object_overrides):
                      '''
                      Return a list of pipeline objects that compose the pipeline
                  
                      pipeline_objects_from_pillars
                  Severity: Major
                  Found in salt/states/boto_datapipeline.py and 1 other location - About 4 hrs to fix
                  salt/states/boto_datapipeline.py on lines 451..466

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

                  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

                      result_pipeline_definition = __salt__['boto_datapipeline.put_pipeline_definition'](
                          pipeline_id,
                          _pipeline_objects(pipeline_objects_from_pillars, pipeline_objects),
                          parameter_objects=_parameter_objects(parameter_objects_from_pillars, parameter_objects),
                          parameter_values=_parameter_values(parameter_values_from_pillars, parameter_values),
                  Severity: Major
                  Found in salt/states/boto_datapipeline.py and 1 other location - About 2 hrs to fix
                  salt/states/boto_datapipeline.py on lines 200..204

                  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

                              result_pipeline_definition = __salt__['boto_datapipeline.put_pipeline_definition'](
                                  pipeline_id,
                                  _pipeline_objects(pipeline_objects_from_pillars, pipeline_objects),
                                  parameter_objects=_parameter_objects(parameter_objects_from_pillars, parameter_objects),
                                  parameter_values=_parameter_values(parameter_values_from_pillars, parameter_values),
                  Severity: Major
                  Found in salt/states/boto_datapipeline.py and 1 other location - About 2 hrs to fix
                  salt/states/boto_datapipeline.py on lines 158..162

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

                              if 'error' in result_create_pipeline:
                                  ret['result'] = False
                                  ret['comment'] = 'Failed to create data pipeline {0}: {1}'.format(
                                      name, result_create_pipeline['error'])
                                  return ret
                  Severity: Major
                  Found in salt/states/boto_datapipeline.py and 10 other locations - About 1 hr to fix
                  salt/states/boto_apigateway.py on lines 1771..1774
                  salt/states/boto_apigateway.py on lines 1806..1809
                  salt/states/boto_cloudfront.py on lines 133..139
                  salt/states/boto_cloudfront.py on lines 158..164
                  salt/states/boto_cloudfront.py on lines 226..232
                  salt/states/boto_datapipeline.py on lines 150..154
                  salt/states/boto_datapipeline.py on lines 178..182
                  salt/states/boto_datapipeline.py on lines 211..216
                  salt/states/boto_datapipeline.py on lines 225..229
                  salt/states/boto_s3.py on lines 298..304

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 48.

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

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

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

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

                  Refactorings

                  Further Reading

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

                      if 'error' in result_create_pipeline:
                          ret['result'] = False
                          ret['comment'] = 'Failed to create data pipeline {0}: {1}'.format(
                              name, result_create_pipeline['error'])
                          return ret
                  Severity: Major
                  Found in salt/states/boto_datapipeline.py and 10 other locations - About 1 hr to fix
                  salt/states/boto_apigateway.py on lines 1771..1774
                  salt/states/boto_apigateway.py on lines 1806..1809
                  salt/states/boto_cloudfront.py on lines 133..139
                  salt/states/boto_cloudfront.py on lines 158..164
                  salt/states/boto_cloudfront.py on lines 226..232
                  salt/states/boto_datapipeline.py on lines 178..182
                  salt/states/boto_datapipeline.py on lines 192..196
                  salt/states/boto_datapipeline.py on lines 211..216
                  salt/states/boto_datapipeline.py on lines 225..229
                  salt/states/boto_s3.py on lines 298..304

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 48.

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

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

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

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

                  Refactorings

                  Further Reading

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

                          if 'error' in result_pipeline_definition:
                              # Still erroring after possible retry
                              ret['result'] = False
                              ret['comment'] = 'Failed to create data pipeline {0}: {1}'.format(
                                  name, result_pipeline_definition['error'])
                  Severity: Major
                  Found in salt/states/boto_datapipeline.py and 10 other locations - About 1 hr to fix
                  salt/states/boto_apigateway.py on lines 1771..1774
                  salt/states/boto_apigateway.py on lines 1806..1809
                  salt/states/boto_cloudfront.py on lines 133..139
                  salt/states/boto_cloudfront.py on lines 158..164
                  salt/states/boto_cloudfront.py on lines 226..232
                  salt/states/boto_datapipeline.py on lines 150..154
                  salt/states/boto_datapipeline.py on lines 178..182
                  salt/states/boto_datapipeline.py on lines 192..196
                  salt/states/boto_datapipeline.py on lines 225..229
                  salt/states/boto_s3.py on lines 298..304

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 48.

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

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

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

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

                  Refactorings

                  Further Reading

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

                      if 'error' in result_activate_pipeline:
                          ret['result'] = False
                          ret['comment'] = 'Failed to create data pipeline {0}: {1}'.format(
                              name, result_pipeline_definition['error'])
                          return ret
                  Severity: Major
                  Found in salt/states/boto_datapipeline.py and 10 other locations - About 1 hr to fix
                  salt/states/boto_apigateway.py on lines 1771..1774
                  salt/states/boto_apigateway.py on lines 1806..1809
                  salt/states/boto_cloudfront.py on lines 133..139
                  salt/states/boto_cloudfront.py on lines 158..164
                  salt/states/boto_cloudfront.py on lines 226..232
                  salt/states/boto_datapipeline.py on lines 150..154
                  salt/states/boto_datapipeline.py on lines 178..182
                  salt/states/boto_datapipeline.py on lines 192..196
                  salt/states/boto_datapipeline.py on lines 211..216
                  salt/states/boto_s3.py on lines 298..304

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 48.

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

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

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

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

                  Refactorings

                  Further Reading

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

                              if 'error' in result_delete_pipeline:
                                  ret['result'] = False
                                  ret['comment'] = 'Failed to delete data pipeline {0}: {1}'.format(
                                      pipeline_id, result_delete_pipeline['error'])
                                  return ret
                  Severity: Major
                  Found in salt/states/boto_datapipeline.py and 10 other locations - About 1 hr to fix
                  salt/states/boto_apigateway.py on lines 1771..1774
                  salt/states/boto_apigateway.py on lines 1806..1809
                  salt/states/boto_cloudfront.py on lines 133..139
                  salt/states/boto_cloudfront.py on lines 158..164
                  salt/states/boto_cloudfront.py on lines 226..232
                  salt/states/boto_datapipeline.py on lines 150..154
                  salt/states/boto_datapipeline.py on lines 192..196
                  salt/states/boto_datapipeline.py on lines 211..216
                  salt/states/boto_datapipeline.py on lines 225..229
                  salt/states/boto_s3.py on lines 298..304

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 48.

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

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

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

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

                  Refactorings

                  Further Reading

                  There are no issues that match your filters.

                  Category
                  Status