cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

Method scale_deployment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def scale_deployment
        deployment.db.transaction do
          app.lock!
          return unless deployment.lock!.state == DeploymentModel::DEPLOYING_STATE

Severity: Minor
Found in lib/cloud_controller/deployment_updater/updater.rb - 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

Method actual_lrp_info has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def actual_lrp_info(process, stats=nil, quota_stats=nil, log_cache_errors=nil, isolation_segment=nil, state=nil)
Severity: Minor
Found in lib/cloud_controller/diego/reporters/instances_stats_reporter.rb - About 45 mins to fix

    Method build has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def build(app, space, lifecycle, memory_limit, staging_disk_in_mb, vars_from_message=nil)
    Severity: Minor
    Found in lib/cloud_controller/backends/staging_environment_builder.rb - About 45 mins to fix

      Method url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def url(controller, path, page, page_size, order_direction, opts, request_params)
            params = {
              'page' => page,
              'results-per-page' => page_size,
              'order-direction' => order_direction
      Severity: Minor
      Found in lib/cloud_controller/rest_controller/paginated_collection_renderer.rb - 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

      Method relationship_link_only? has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def relationship_link_only?(association, associated_controller, relationship_name, opts, depth, parents)
      Severity: Minor
      Found in app/presenters/v2/relations_presenter.rb - About 45 mins to fix

        Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(config, logger, env, params, body, sinatra=nil)
        Severity: Minor
        Found in lib/cloud_controller/controller_factory.rb - About 45 mins to fix

          Method render_json has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def render_json(controller, dataset, path, opts, request_params)
                page = opts[:page] || 1
                order_applicator = OrderApplicator.new(opts)
                order_direction = opts[:order_direction] || 'asc'
                page_size = opts[:results_per_page] || @default_results_per_page
          Severity: Minor
          Found in lib/cloud_controller/rest_controller/paginated_collection_renderer.rb - 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

          Method build_info has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def build_info(state, actual_lrp, process, stats, quota_stats, log_cache_errors)
          Severity: Minor
          Found in lib/cloud_controller/diego/reporters/instances_stats_reporter.rb - About 45 mins to fix

            Method create_or_update_app has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def create_or_update_app(process, client)
                      if (existing_lrp = client.get_app(process))
                        client.update_app(process, existing_lrp)
                      else
                        begin
            Severity: Minor
            Found in lib/cloud_controller/diego/desire_app_handler.rb - 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

            Method actual_lrp_info has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def actual_lrp_info(process, stats=nil, quota_stats=nil, log_cache_errors=nil, isolation_segment=nil, state=nil)
                    # rubocop:enable Metrics/ParameterLists
                    result = {}
                    bbs_instances_client.lrp_instances(process).each do |actual_lrp|
                      next unless actual_lrp.actual_lrp_key.index < process.instances
            Severity: Minor
            Found in lib/cloud_controller/diego/reporters/instances_stats_reporter.rb - 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

            Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def initialize(config, task, lifecycle_data, run_user, launcher_args, prefix)
            Severity: Minor
            Found in lib/cloud_controller/diego/buildpack/task_action_builder.rb - About 45 mins to fix

              Method serializer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.serializer
                  lambda do |array|
                    return nil if array.nil?
                    raise ArgumentError.new('Integer array columns must be passed an array') unless array.is_a?(Array)
                    raise ArgumentError.new('All members of the array must be integers') unless array.all? { |v| v.is_a? Integer }
              Severity: Minor
              Found in lib/cloud_controller/integer_array_serializer.rb - 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

              Method validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.validate(rule)
                    errs = validate_fields(rule)
                    return errs unless errs.empty?
              
                    destination = rule['destination']
              Severity: Minor
              Found in lib/cloud_controller/rule_validator.rb - 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

              Method entity_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      def entity_hash(controller, app_usage_event, opts, depth, parents, orphans=nil)
              Severity: Minor
              Found in app/presenters/v2/app_usage_event_presenter.rb - About 45 mins to fix

                Method handle_no_running_instances has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def handle_no_running_instances(process)
                        # case when no actual_lrp exists
                        if bbs_instances_client.lrp_instances(process).empty?
                          [fill_unreported_instances_with_down_instances({}, process, flat: false), []]
                        else
                Severity: Minor
                Found in lib/cloud_controller/diego/reporters/instances_stats_reporter.rb - 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

                Method handle_errors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def handle_errors(actions_that_should_not_exist, actions_that_should_exist, controller, association_name, errors)
                    error_root_path = "#{controller.path_guid}/#{association_name}"
                    error_full_path = "#{error_root_path}/:guid"
                
                    actions_that_should_not_exist.each do |action|
                Severity: Minor
                Found in spec/support/matchers/have_nested_routes.rb - 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

                Method set_column_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def set_column_type(name, type, opts={})
                    if type.to_s == 'String' && opts[:case_insensitive]
                      raise Error.new('DB adapter does not support case insensitive strings') unless @db.respond_to?(:case_insensitive_string_column_type)
                
                      set_column_type_original(
                Severity: Minor
                Found in lib/vcap/sequel_case_insensitive_string_monkeypatch.rb - 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

                Method entity_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        def entity_hash(controller, obj, opts, depth, parents, orphans)
                Severity: Minor
                Found in spec/unit/presenters/v2/base_presenter_spec.rb - About 45 mins to fix

                  Method validate_all_plan_ids_are_unique has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def validate_all_plan_ids_are_unique
                        catalog_plans = {}
                        services.each do |s|
                          s.plans.each do |p|
                            if catalog_plans[p.broker_provided_id]
                  Severity: Minor
                  Found in lib/services/service_brokers/v2/catalog.rb - 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

                  Consider simplifying this complex logical expression.
                  Open

                      if((!e.simulated && (timeDiff < 500 || (timeDiff < 1500 && xyDiff[0] < 50 && xyDiff[1] < 50))) || standAlone) {
                        e.preventDefault();
                        e.stopPropagation();
                        if(!standAlone) return false;
                      }
                  Severity: Major
                  Found in docs/v3/source/javascripts/lib/_energize.js - About 40 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language