cloudfoundry/cloud_controller_ng

View on GitHub

Showing 570 of 2,679 total issues

Method run_cmd has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def run_cmd(cmd, opts={})
    opts[:env] ||= {}
    project_path = File.join(File.dirname(__FILE__), '../../..')

    spawn_opts = { chdir: project_path }
Severity: Minor
Found in spec/support/integration/setup.rb - 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

Method on_block has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def on_block(node)
          node.each_descendant(:send) do |send_node|
            method = method_name(send_node)
            next unless constraint_adding_method?(method) || column_adding_method?(method)

Severity: Minor
Found in spec/linters/migration/add_constraint_name.rb - 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

Method to_hash has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def to_hash
      app_name = @process.name

      if @process.is_a?(VCAP::CloudController::AppModel)
        uris = @process.routes.map(&:uri)
Severity: Minor
Found in lib/vcap/vars_builder.rb - 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

Method create_and_stage has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def create_and_stage(package:, lifecycle:, metadata: nil, start_after_staging: false)
      logger.info("creating build for package #{package.guid}")
      staging_in_progress! if package.app.staging_in_progress?
      raise InvalidPackage.new('Cannot stage package whose state is not ready.') if package.state != PackageModel::READY_STATE

Severity: Minor
Found in app/actions/build_create.rb - About 1 hr to fix

    Method stage has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def stage(process)
            @stagers.validate_process(process)
    
            message = BuildCreateMessage.new({
                                               staging_memory_in_mb: process.memory,
    Severity: Minor
    Found in app/actions/v2/app_stage.rb - About 1 hr to fix

      Function _on has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _on: function( suppressDisabledCheck, element, handlers ) {
            var delegateElement,
                instance = this;
      
            // no suppressDisabledCheck flag, shuffle arguments
      Severity: Minor
      Found in docs/v3/source/javascripts/lib/_jquery_ui.js - About 1 hr to fix

        Method update has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def update(app_guid, message, user_audit_info)
                return unless message.requested?(:routes)
        
                app = AppModel.find(guid: app_guid)
                not_found! unless app
        Severity: Minor
        Found in app/actions/manifest_route_update.rb - About 1 hr to fix

          Method update has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def update(process, message, strategy_class)
                raise InvalidProcess.new('Cannot update this process while a deployment is in flight.') if process.web? && process.app.deploying?
          
                strategy = strategy_class.new(message, process)
                process.db.transaction do
          Severity: Minor
          Found in app/actions/process_update.rb - About 1 hr to fix

            Method sync has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def sync
                    logger.info('run-process-sync')
                    @bump_freshness = true
                    diego_lrps = bbs_apps_client.fetch_scheduling_infos.index_by { |d| d.desired_lrp_key.process_guid }
                    logger.info('fetched-scheduling-infos')
            Severity: Minor
            Found in lib/cloud_controller/diego/processes_sync.rb - About 1 hr to fix

              Method fetch has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def fetch(klass, message, omniscient: false, readable_orgs_query: nil, readable_spaces_query: nil, eager_loaded_associations: [])
                      # The base dataset for the given model; other tables might be joined later on for filtering,
                      # but we are only interested in the columns from the base table.
                      dataset = klass.dataset.select_all(klass.table_name)
              
              
              Severity: Minor
              Found in app/fetchers/base_service_list_fetcher.rb - About 1 hr to fix

                Function search has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  lunr.Index.prototype.search = function (query) {
                    var queryTokens = this.pipeline.run(lunr.tokenizer(query)),
                        queryVector = new lunr.Vector,
                        documentSets = [],
                        fieldBoosts = this._fields.reduce(function (memo, f) { return memo + f.boost }, 0)
                Severity: Minor
                Found in docs/v3/source/javascripts/lib/_lunr.js - About 1 hr to fix

                  Method upload has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def upload(guid)
                        process = find_guid_and_validate_access(:upload, guid)
                  
                        raise CloudController::Errors::ApiError.new_from_details('UnprocessableEntity', 'cannot upload bits to a docker app') if process.docker?
                  
                  
                  Severity: Minor
                  Found in app/controllers/runtime/app_bits_upload_controller.rb - About 1 hr to fix

                    Method filter has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def filter(message, dataset)
                            dataset = dataset.where(host: message.hosts) if message.requested?(:hosts)
                    
                            dataset = dataset.where(path: message.paths) if message.requested?(:paths)
                    
                    
                    Severity: Minor
                    Found in app/fetchers/route_fetcher.rb - About 1 hr to fix

                      Function _setEventHandlers has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              _setEventHandlers: function() {
                                  var self = this;
                      
                                  this.element.on("click.tocify", "a", function() {
                                      self.element.find("." + self.focusClass).removeClass(self.focusClass);
                      Severity: Minor
                      Found in docs/v3/source/javascripts/lib/_jquery.tocify.js - About 1 hr to fix

                        Method install has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def install(buildpacks)
                              return unless buildpacks
                        
                              CloudController::DependencyLocator.instance.buildpack_blobstore.ensure_bucket_exists
                              job_factory = VCAP::CloudController::Jobs::Runtime::BuildpackInstallerFactory.new
                        Severity: Minor
                        Found in lib/cloud_controller/install_buildpacks.rb - About 1 hr to fix

                          Method generate_default_org_quota_response has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          def generate_default_org_quota_response(global_read)
                            # our request specs are seeded with an org that uses the default org quota
                            # the visibility of this org depends on the user's permissions
                            seeded_org_guid = VCAP::CloudController::Organization.where(name: 'the-system_domain-org-name').first.guid
                            seeded_org = global_read ? [{ guid: seeded_org_guid }] : []
                          Severity: Minor
                          Found in spec/request/organization_quotas_spec.rb - About 1 hr to fix

                            Method error has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                  def error(job, exception)
                                    begin
                                      api_error = convert_to_v3_api_error(exception)
                                      save_error(api_error, job)
                                    rescue Sequel::DatabaseError
                            Severity: Minor
                            Found in app/jobs/pollable_job_wrapper.rb - 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

                            Method copy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def copy(destination_app_guid:, source_package:, user_audit_info:, record_event: true)
                                  raise InvalidPackage.new('Source and destination app cannot be the same') if destination_app_guid == source_package.app_guid
                            
                                  logger.info("copying package #{source_package.guid} to app #{destination_app_guid}")
                            
                            
                            Severity: Minor
                            Found in app/actions/package_copy.rb - 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

                            Method find_process_and_space has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def find_process_and_space
                                if app_nested?
                                  @process, app, @space = ProcessFetcher.fetch_for_app_by_type(app_guid: hashed_params[:app_guid], process_type: hashed_params[:type])
                            
                                  app_not_found! unless app && permission_queryer.can_read_from_space?(@space.id, @space.organization_id)
                            Severity: Minor
                            Found in app/controllers/v3/processes_controller.rb - 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

                            Method update_lifecycle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                  def update_lifecycle(app, process, request_attrs)
                                    buildpack_type_requested = request_attrs.key?('buildpack') || request_attrs.key?('stack_guid')
                                    docker_type_requested    = request_attrs.key?('docker_image') || request_attrs.key?('docker_credentials')
                            
                                    if buildpack_type_requested
                            Severity: Minor
                            Found in app/actions/v2/app_update.rb - 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

                            Severity
                            Category
                            Status
                            Source
                            Language