saltstack/salt

View on GitHub
salt/states/boto_apigateway.py

Summary

Maintainability
F
2 wks
Test Coverage

File boto_apigateway.py has 1684 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Manage Apigateway Rest APIs
===========================

Severity: Major
Found in salt/states/boto_apigateway.py - About 4 days to fix

    _Swagger has 47 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class _Swagger(object):
        '''
        this is a helper class that holds the swagger definition file and the associated logic
        related to how to interpret the file and apply it to AWS Api Gateway.
    
    
    Severity: Minor
    Found in salt/states/boto_apigateway.py - About 6 hrs to fix

      Function _validate_error_response_model has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

          def _validate_error_response_model(self, paths, mods):
              '''
              Helper function to help validate the convention established in the swagger file on how
              to handle response code mapping/integration
              '''
      Severity: Minor
      Found in salt/states/boto_apigateway.py - About 6 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function _object_reducer has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

      def _object_reducer(o, names=('id', 'name', 'path', 'httpMethod',
                                    'statusCode', 'Created', 'Deleted',
                                    'Updated', 'Flushed', 'Associated', 'Disassociated')):
          '''
          Helper function to reduce the amount of information that will be kept in the change log
      Severity: Minor
      Found in salt/states/boto_apigateway.py - About 5 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 usage_plan_present has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      def usage_plan_present(name, plan_name, description=None, throttle=None, quota=None, region=None, key=None, keyid=None,
                             profile=None):
          '''
          Ensure the spcifieda usage plan with the corresponding metrics is deployed
      
      
      Severity: Minor
      Found in salt/states/boto_apigateway.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 deploy_models has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def deploy_models(self, ret):
              '''
              Method to deploy swagger file's definition objects and associated schema to AWS Apigateway as Models
      
              ret
      Severity: Minor
      Found in salt/states/boto_apigateway.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 _deploy_method has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _deploy_method(self, ret, resource_path, method_name, method_data, api_key_required,
                             lambda_integration_role, lambda_region, authorization_type):
              '''
              Method to create a method for the given resource path, along with its associated
              request and response integrations.
      Severity: Minor
      Found in salt/states/boto_apigateway.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 _build_dependent_model_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def _build_dependent_model_list(self, obj_schema):
              '''
              Helper function to build the list of models the given object schema is referencing.
              '''
              dep_models_list = []
      Severity: Minor
      Found in salt/states/boto_apigateway.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 delete_stage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def delete_stage(self, ret):
              '''
              Method to delete the given stage_name.  If the current deployment tied to the given
              stage_name has no other stages associated with it, the deployment will be removed
              as well
      Severity: Minor
      Found in salt/states/boto_apigateway.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 _cleanup_api has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def _cleanup_api(self):
              '''
              Helper method to clean up resources and models if we detected a change in the swagger file
              for a stage
              '''
      Severity: Minor
      Found in salt/states/boto_apigateway.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 _parse_method_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _parse_method_data(self, method_name, method_data):
              '''
              Helper function to construct the method request params, models, request_templates and
              integration_type values needed to configure method request integration/mappings.
              '''
      Severity: Minor
      Found in salt/states/boto_apigateway.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 present has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def present(name, api_name, swagger_file, stage_name, api_key_required,
                  lambda_integration_role, lambda_region=None, stage_variables=None,
                  region=None, key=None, keyid=None, profile=None,
                  lambda_funcname_format='{stage}_{api}_{resource}_{method}',
                  authorization_type='NONE', error_response_template=None, response_template=None):
      Severity: Minor
      Found in salt/states/boto_apigateway.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 _find_patterns has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _find_patterns(self, o):
              result = []
              if isinstance(o, dict):
                  for k, v in six.iteritems(o):
                      if isinstance(v, dict):
      Severity: Minor
      Found in salt/states/boto_apigateway.py - About 1 hr to fix

      Cognitive Complexity

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

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

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

      Further reading

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

      def _get_stage_variables(stage_variables):
          '''
          Helper function to retrieve stage variables from pillars/options, if the
          input is a string
          '''
      Severity: Minor
      Found in salt/states/boto_apigateway.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 usage_plan_association_absent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def usage_plan_association_absent(name, plan_name, api_stages, region=None, key=None, keyid=None, profile=None):
          '''
          Ensures usage plan identified by name is removed from provided api_stages
          If a plan is associated to stages not listed in api_stages parameter,
          those associations remain intact.
      Severity: Minor
      Found in salt/states/boto_apigateway.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 absent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def absent(name, api_name, stage_name, nuke_api=False, region=None, key=None, keyid=None, profile=None):
          '''
          Ensure the stage_name associated with the given api_name deployed by boto_apigateway's
          present state is removed.  If the currently associated deployment to the given stage_name has
          no other stages associated with it, the deployment will also be removed.
      Severity: Minor
      Found in salt/states/boto_apigateway.py - About 55 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function usage_plan_association_present has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def usage_plan_association_present(name, plan_name, api_stages, region=None, key=None, keyid=None, profile=None):
          '''
          Ensures usage plan identified by name is added to provided api_stages
      
          .. versionadded:: 2017.7.0
      Severity: Minor
      Found in salt/states/boto_apigateway.py - About 55 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function delete_api has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def delete_api(self, ret):
              '''
              Method to delete a Rest Api named defined in the swagger file's Info Object's title value.
      
              ret
      Severity: Minor
      Found in salt/states/boto_apigateway.py - About 55 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          def _validate_swagger_file(self):
              '''
              High level check/validation of the input swagger file based on
              https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md
      
      
      Severity: Minor
      Found in salt/states/boto_apigateway.py - About 45 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          def publish_api(self, ret, stage_variables):
              '''
              this method tie the given stage_name to a deployment matching the given swagger_file
              '''
              stage_desc = dict()
      Severity: Minor
      Found in salt/states/boto_apigateway.py - About 45 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          def _get_model_without_dependencies(self, models_dict):
              '''
              Helper function to find the next model that should be created
              '''
              next_model = None
      Severity: Minor
      Found in salt/states/boto_apigateway.py - About 45 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      Avoid deeply nested control flow statements.
      Open

                          if reduced or _name_matches(k, names):
                              newlist.append(reduced)
                      if newlist:
      Severity: Major
      Found in salt/states/boto_apigateway.py - About 45 mins to fix

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

            def deploy_resources(self, ret, api_key_required, lambda_integration_role, lambda_region, authorization_type):
                '''
                Method to deploy resources defined in the swagger file.
        
                ret
        Severity: Minor
        Found in salt/states/boto_apigateway.py - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

        def _name_matches(name, matches):
            '''
            Helper function to see if given name has any of the patterns in given matches
            '''
            for m in matches:
        Severity: Minor
        Found in salt/states/boto_apigateway.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 verify_api has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def verify_api(self, ret):
                '''
                this method helps determine if the given stage_name is already on a deployment
                label matching the input api_name, swagger_file.
        
        
        Severity: Minor
        Found in salt/states/boto_apigateway.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_response_template has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_response_template(self, method_name, http_status):
                if method_name == 'options' or not self._is_http_error_rescode(http_status):
                    response_templates = {'application/json': self._response_template} \
                        if self._response_template else self.RESPONSE_OPTION_TEMPLATE
                else:
        Severity: Minor
        Found in salt/states/boto_apigateway.py - About 35 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

        Avoid too many return statements within this function.
        Open

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

          Avoid too many return statements within this function.
          Open

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

            Avoid too many return statements within this function.
            Open

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

              Avoid too many return statements within this function.
              Open

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

                Avoid too many return statements within this function.
                Open

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

                  Avoid too many return statements within this function.
                  Open

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

                    Avoid too many return statements within this function.
                    Open

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

                      Avoid too many return statements within this function.
                      Open

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

                        Avoid too many return statements within this function.
                        Open

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

                          Avoid too many return statements within this function.
                          Open

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

                            Avoid too many return statements within this function.
                            Open

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

                              Avoid too many return statements within this function.
                              Open

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

                                Avoid too many return statements within this function.
                                Open

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

                                  Avoid too many return statements within this function.
                                  Open

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

                                    Avoid too many return statements within this function.
                                    Open

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

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

                                          def no_more_deployments_remain(self):
                                              '''
                                              Helper function to find whether there are deployments left with stages associated
                                              '''
                                              no_more_deployments = True
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.py - About 25 mins to fix

                                      Cognitive Complexity

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

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

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

                                      Further reading

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

                                              def schema(self):
                                                  '''
                                                  returns the name of the schema given the reference in the swagger parameter object
                                                  '''
                                                  if self.location == 'body':
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.py - About 25 mins to fix

                                      Cognitive Complexity

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

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

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

                                      Further reading

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

                                          def _set_current_deployment(self, stage_desc_json, stage_variables):
                                              '''
                                              Helper method to associate the stage_name to the given deploymentId and make this current
                                              '''
                                              stage = __salt__['boto_apigateway.describe_api_stage'](restApiId=self.restApiId,
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.py - About 25 mins to fix

                                      Cognitive Complexity

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

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

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

                                      Further reading

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

                                          def deploy_api(self, ret):
                                              '''
                                              this method create the top level rest api in AWS apigateway
                                              '''
                                              if self.restApiId:
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.py - About 25 mins to fix

                                      Cognitive Complexity

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

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

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

                                      Further reading

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

                                          def _get_desired_deployment_id(self):
                                              '''
                                              Helper method to return the deployment id matching the desired deployment label for
                                              this Swagger object based on the given api_name, swagger_file
                                              '''
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.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

                                                      if not update_model_schema_response.get('updated'):
                                                          ret['result'] = False
                                                          ret['abort'] = True
                                                          if 'error' in update_model_schema_response:
                                                              ret['comment'] = ('Failed to update existing model {0} with schema {1}, '
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 4 hrs to fix
                                      salt/states/boto_apigateway.py on lines 1405..1412

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 84.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                                      if not create_model_response.get('created'):
                                                          ret['result'] = False
                                                          ret['abort'] = True
                                                          if 'error' in create_model_response:
                                                              ret['comment'] = ('Failed to create model {0}, schema {1}, '
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 4 hrs to fix
                                      salt/states/boto_apigateway.py on lines 1387..1394

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 84.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                              if not response.get('created'):
                                                  ret['result'] = False
                                                  ret['abort'] = True
                                                  if 'error' in response:
                                                      ret['comment'] = 'Failed to create rest api: {0}.'.format(response['error']['message'])
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 3 hrs to fix
                                      salt/states/boto_apigateway.py on lines 1266..1271

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

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                                  if not delete_api_response.get('deleted'):
                                                      ret['result'] = False
                                                      ret['abort'] = True
                                                      if 'error' in delete_api_response:
                                                          ret['comment'] = 'Failed to delete rest api: {0}.'.format(delete_api_response['error']['message'])
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 3 hrs to fix
                                      salt/states/boto_apigateway.py on lines 1234..1239

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

                                      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 isinstance(stage_variables, six.string_types):
                                              if stage_variables in __opts__:
                                                  ret = __opts__[stage_variables]
                                              master_opts = __pillar__.get('master', {})
                                              if stage_variables in master_opts:
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 3 hrs to fix
                                      salt/states/boto_cognitoidentity.py on lines 76..83

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

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                                  if not res.get('created'):
                                                      ret['abort'] = True
                                                      ret['result'] = False
                                                      ret['comment'] = res.get('error')
                                                  else:
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 2 other locations - About 3 hrs to fix
                                      salt/states/boto_apigateway.py on lines 1042..1049
                                      salt/states/boto_apigateway.py on lines 1165..1172

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 71.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                              if not res.get('overwrite'):
                                                  ret['result'] = False
                                                  ret['abort'] = True
                                                  ret['comment'] = res.get('error')
                                              else:
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 2 other locations - About 3 hrs to fix
                                      salt/states/boto_apigateway.py on lines 1165..1172
                                      salt/states/boto_apigateway.py on lines 1181..1186

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 71.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                                  if not res.get('set'):
                                                      ret['abort'] = True
                                                      ret['result'] = False
                                                      ret['comment'] = res.get('error')
                                                  else:
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 2 other locations - About 3 hrs to fix
                                      salt/states/boto_apigateway.py on lines 1042..1049
                                      salt/states/boto_apigateway.py on lines 1181..1186

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 71.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                              if len(existing['plans']) != 1:
                                                  ret['comment'] = 'There are multiple usage plans with the same name - it is not supported'
                                                  ret['result'] = False
                                                  return ret
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 2046..2049

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 45.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                              if not existing['plans']:
                                                  ret['comment'] = 'Usage plan {0} does not exist'.format(plan_name)
                                                  ret['result'] = False
                                                  return ret
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 1946..1949

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 45.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                              if not existing['plans']:
                                                  ret['comment'] = 'Usage plan {0} does not exist'.format(plan_name)
                                                  ret['result'] = False
                                                  return ret
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 2041..2044

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 45.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                              if len(existing['plans']) != 1:
                                                  ret['comment'] = 'There are multiple usage plans with the same name - it is not supported'
                                                  ret['result'] = False
                                                  return ret
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 1951..1954

                                      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

                                                  for resource in res:
                                                      delres = __salt__['boto_apigateway.delete_api_resources'](restApiId=self.restApiId,
                                                                                                                path=resource.get('path'),
                                                                                                                **self._common_aws_args)
                                                      if not delres.get('deleted'):
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 1208..1213

                                      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

                                                  for model in models.get('models'):
                                                      delres = __salt__['boto_apigateway.delete_api_model'](restApiId=self.restApiId,
                                                                                                            modelName=model.get('name'),
                                                                                                            **self._common_aws_args)
                                                      if not delres.get('deleted'):
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 1199..1204

                                      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 'error' in result:
                                                  ret['comment'] = 'Failed to disassociate a usage plan {0} from the apis {1}, {2}'.format(plan_name,
                                                                                                                                           stages_to_remove,
                                                                                                                                           result['error'])
                                                  ret['result'] = False
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 1970..1975

                                      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

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

                                              if 'error' in result:
                                                  ret['comment'] = 'Failed to associate a usage plan {0} to the apis {1}, {2}'.format(plan_name,
                                                                                                                                      stages_to_add,
                                                                                                                                      result['error'])
                                                  ret['result'] = False
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 2069..2074

                                      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

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

                                                  if 'error' in result:
                                                      ret['result'] = False
                                                      ret['comment'] = 'Failed to update a usage plan {0}, {1}'.format(plan_name, result['error'])
                                                      return ret
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 10 other locations - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 1771..1774
                                      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_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:
                                                      ret['result'] = False
                                                      ret['comment'] = 'Failed to create a usage plan {0}, {1}'.format(plan_name, result['error'])
                                                      return ret
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 10 other locations - About 1 hr to fix
                                      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_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 2 locations. Consider refactoring.
                                      Open

                                                  if not result.get('deleted'):
                                                      ret['abort'] = True
                                                      ret['result'] = False
                                                      ret['comment'] = 'delete_stage delete_api_stage, {0}'.format(result.get('error'))
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 1118..1121

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 46.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                                          if not result.get('deleted'):
                                                              ret['abort'] = True
                                                              ret['result'] = False
                                                              ret['comment'] = 'delete_stage delete_api_deployment, {0}'.format(result.get('error'))
                                      Severity: Major
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 1 hr to fix
                                      salt/states/boto_apigateway.py on lines 1108..1111

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 46.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                                  if not res.get('deleted'):
                                                      ret['comment'] = 'Failed to cleanup restAreId {0}'.format(self.restApiId)
                                                      ret['abort'] = True
                                                      ret['result'] = False
                                                      return ret
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 55 mins to fix
                                      salt/states/boto_apigateway.py on lines 1257..1261

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 45.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                                  if __opts__['test']:
                                                      ret['comment'] = 'Rest API named {0} is set to be deleted.'.format(self.rest_api_name)
                                                      ret['result'] = None
                                                      ret['abort'] = True
                                                      return ret
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 55 mins to fix
                                      salt/states/boto_apigateway.py on lines 1223..1227

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 45.

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

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

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

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

                                      Refactorings

                                      Further Reading

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

                                              if __opts__['test']:
                                                  ret['comment'] = ('There is no deployment matching the given [api_name: {0}] '
                                                                    'and [swagger_file: {1}].  A new deployment will be '
                                                                    'created and the [stage_name: {2}] will then be associated '
                                                                    'to the newly created deployment.\n'
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 50 mins to fix
                                      salt/states/boto_apigateway.py on lines 283..290

                                      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 __opts__['test']:
                                                      ret['comment'] = ('[stage: {0}] will be reassociated to an already available '
                                                                        'deployment that matched the given [api_name: {1}] '
                                                                        'and [swagger_file: {2}].\n'
                                                                        'Stage variables will be set '
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 50 mins to fix
                                      salt/states/boto_apigateway.py on lines 307..315

                                      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

                                          @property
                                          def rest_api_version(self):
                                              '''
                                              returns the version field in the swagger info object
                                              '''
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 40 mins to fix
                                      salt/states/boto_apigateway.py on lines 853..861

                                      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

                                          @property
                                          def info(self):
                                              '''
                                              returns the swagger info object as a dictionary
                                              '''
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.py and 1 other location - About 40 mins to fix
                                      salt/states/boto_apigateway.py on lines 877..886

                                      Duplicated Code

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

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

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

                                      Tuning

                                      This issue has a mass of 42.

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

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

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

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

                                      Refactorings

                                      Further Reading

                                      There are no issues that match your filters.

                                      Category
                                      Status