cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

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

      def crashed_instances_for_app(process)
        crashed_instances = []
        bbs_instances_client.lrp_instances(process).each do |actual_lrp|
          next unless actual_lrp.state == ::Diego::ActualLRPState::CRASHED
          next unless actual_lrp.actual_lrp_key.index < process.instances
Severity: Minor
Found in lib/cloud_controller/diego/reporters/instances_reporter.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 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 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 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 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

    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

      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 to_hash has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def to_hash
                          {
                            guid: deployment.guid,
                            created_at: deployment.created_at,
                            updated_at: deployment.updated_at,
                    Severity: Minor
                    Found in app/presenters/v3/deployment_presenter.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

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

                            def self.can_be_decorated_with_include_binding_service_instance_decorator(klazz)
                              RSpec.describe IncludeBindingServiceInstanceDecorator do
                                subject(:decorator) { described_class }
                        
                                let(:bindings) do

                          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

                                Severity
                                Category
                                Status
                                Source
                                Language