cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

Method threaded_start has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def threaded_start
      self.class.lifecycle.run_callbacks(:execute, self) do
        loop do
          self.class.lifecycle.run_callbacks(:loop, self) do
            @realtime = Benchmark.realtime do
Severity: Minor
Found in lib/delayed_job/threaded_worker.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 number_of_starting_and_running_instances_for_process has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def number_of_starting_and_running_instances_for_process(process)
        return 0 unless process.started?

        running_indices = Set.new
        bbs_instances_client.lrp_instances(process).each do |actual_lrp|
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 install has a Cognitive Complexity of 14 (exceeds 5 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

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 add_column_missing_name? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def add_column_missing_name?(opts)
          return true if opts.type == :sym && %i[index primary_key unique].include?(sym_opts_name(opts))

          needs_named_index             = false
          needs_named_primary_key       = false
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 start_cc has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def start_cc(opts={})
    @cc_pids ||= []

    config_file = opts[:config] || 'config/cloud_controller.yml'
    config = VCAP::CloudController::YAMLConfig.safe_load_file(config_file)
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 generate_diff has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def generate_diff(app_manifests, space)
        json_diff = []

        recognized_top_level_keys = AppManifestMessage.allowed_keys.map(&:to_s).map(&:dasherize)

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

    Function name has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $.fn[ name ] = function( options ) {
          var isMethodCall = typeof options === "string",
              args = widget_slice.call( arguments, 1 ),
              returnValue = this;
    
    
    Severity: Minor
    Found in docs/v3/source/javascripts/lib/_jquery_ui.js - About 1 hr to fix

      Method extract_table_of_contents has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def extract_table_of_contents(html)
          page = Nokogiri::HTML(html)
      
          headings = []
          page.css('h1,h2,h3').each do |heading|
      Severity: Minor
      Found in docs/v3/helpers/docs_helpers.rb - About 1 hr to fix

        Method to_hash has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def to_hash
              {
                guid: usage_event.guid,
                created_at: usage_event.created_at,
                updated_at: usage_event.created_at,
        Severity: Minor
        Found in app/presenters/v3/app_usage_event_presenter.rb - About 1 hr to fix

          Method create has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def create
              message = BuildCreateMessage.new(Oj.load(request.body))
              unprocessable!(message.errors.full_messages) unless message.valid?
          
              package = PackageModel.where(guid: message.package_guid).
          Severity: Minor
          Found in app/controllers/v3/builds_controller.rb - About 1 hr to fix

            Method build_eager_load_hash has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def build_eager_load_hash(controller_class, model_class, default_visibility_filter, additional_visibility_filters, depth)
                  associated_controller = controller_class
            
                  # model_class cannot just be inferred from controller_class.model
                  # because ServiceInstancesController can be used to present objects
            Severity: Minor
            Found in lib/cloud_controller/rest_controller/secure_eager_loader.rb - About 1 hr to fix

              Method to_hash has 41 lines of code (exceeds 25 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

                Method entity_hash has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def entity_hash(controller, process, opts, depth, parents, orphans=nil)
                          entity = {
                            'name' => process.name,
                            'production' => process.production,
                            'space_guid' => process.space.guid,
                Severity: Minor
                Found in app/presenters/v2/process_model_presenter.rb - About 1 hr to fix

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

                          def cleanup(day_of_week)
                            logger.info("Started orphaned blobs cleanup job for day of week: #{day_of_week}")
                  
                            update_existing_orphaned_blobs
                  
                  
                  Severity: Minor
                  Found in app/jobs/runtime/orphaned_blobs_cleanup.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 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def update(package, message)
                        validate_package_state!(package)
                        validate_package_checksum!(package, message)
                        @logger.info("Updating package #{package.guid}")
                  
                  
                  Severity: Minor
                  Found in app/actions/internal_package_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

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

                      def version_needs_to_be_updated?
                        # change version if:
                        #
                        # * transitioning to STARTED
                        # * memory is changed
                  Severity: Minor
                  Found in app/models/runtime/process_model.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 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def update(sidecar, message)
                          validate_memory_allocation!(message, sidecar) if message.requested?(:memory_in_mb) || message.requested?(:process_types)
                  
                          sidecar.name    = message.name    if message.requested?(:name)
                          sidecar.command = message.command if message.requested?(:command)
                  Severity: Minor
                  Found in app/actions/sidecar_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

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

                    def update
                      message = VCAP::CloudController::UpdateEnvironmentVariablesMessage.for_env_var_group(hashed_params[:body])
                      unprocessable!(message.errors.full_messages) unless message.valid?
                      unauthorized! unless permission_queryer.can_write_globally?
                  
                  
                  Severity: Minor
                  Found in app/controllers/v3/environment_variable_groups_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 checksum_validator has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def checksum_validator(checksum)
                        unless checksum.is_a?(Hash)
                          errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-object checksum") unless errors.added?(
                            :resources, "#{RESOURCE_ERROR_PREAMBLE} a non-object checksum"
                          )
                  Severity: Minor
                  Found in app/messages/resource_match_create_message.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 extract_from_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def self.extract_from_file(bits_file_path)
                          bits_file_path = bits_file_path.path if bits_file_path.respond_to?(:path)
                          Zip::File.open(bits_file_path) do |zip_file|
                            zip_file.each do |entry|
                              next unless entry.name == 'manifest.yml'
                  Severity: Minor
                  Found in lib/cloud_controller/buildpacks/stack_name_extractor.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