cloudfoundry/cloud_controller_ng

View on GitHub

Showing 583 of 2,698 total issues

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

    def data_content
      return if data.nil?

      errors.add(:data, 'can only accept one key') unless data.keys.length == 1
      errors.add(:data, "can only accept key 'guid'") unless data.key?(:guid)
Severity: Minor
Found in app/messages/orgs_default_iso_seg_update_message.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 destroy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def destroy
    sidecar = SidecarModel.find(guid: hashed_params[:guid])
    resource_not_found!(:sidecar) unless sidecar
    space = sidecar.app.space
    resource_not_found!(:sidecar) unless permission_queryer.can_read_from_space?(space.id, space.organization_id)
Severity: Minor
Found in app/controllers/v3/sidecars_controller.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=nil)
Severity: Minor
Found in app/presenters/v2/route_presenter.rb - About 45 mins to fix

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

        def size_validator(size)
          unless size.is_a?(Integer)
            errors.add(:resources, "#{RESOURCE_ERROR_PREAMBLE} a non-integer size_in_bytes") unless errors.added?(
              :resources, "#{RESOURCE_ERROR_PREAMBLE} a non-integer size_in_bytes"
            )
    Severity: Minor
    Found in app/messages/resource_match_create_message.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_icmp_protocol has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def validate_icmp_protocol(rule, record, index)
        add_rule_error('code is required for protocols of type ICMP', record, index) unless rule[:code]
        add_rule_error('code must be an integer between -1 and 255 (inclusive)', record, index) unless valid_icmp_format(rule[:code])
    
        add_rule_error('type is required for protocols of type ICMP', record, index) unless rule[:type]
    Severity: Minor
    Found in app/messages/validators/security_group_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 validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate(record)
            return unless record.requested?(:include)
    
            key_counts = Hash.new(0)
            record.include.each do |include_candidate|
    Severity: Minor
    Found in app/messages/base_message.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, route_mapping, opts, depth, parents, orphans=nil)
    Severity: Minor
    Found in app/presenters/v2/route_mapping_presenter.rb - About 45 mins to fix

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

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

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

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

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

              def summary(guid)
                org = find_guid_and_validate_access(:read, guid)
                spaces = visible_spaces(org).map do |space|
                  # when we do the quota work, this and the service counts will be kept
                  # as a running total so that we don't have to compute them on the
          Severity: Minor
          Found in app/controllers/runtime/organization_summaries_controller.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, org, opts, depth, parents, orphans=nil)
          Severity: Minor
          Found in app/presenters/v2/organization_presenter.rb - About 45 mins to fix

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

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

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

                    def filter(message, dataset)
                      dataset = dataset.where(name: message.names) if message.requested?(:names)
              
                      dataset = dataset.where(space_guid: message.space_guids) if message.requested?(:space_guids)
              
              
              Severity: Minor
              Found in app/fetchers/app_list_fetcher.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, staging_details, lifecycle_data, prefix, app_destination_path, cache_source)
              Severity: Minor
              Found in lib/cloud_controller/diego/staging_action_builder.rb - About 45 mins to fix

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

                      def define_to_many_routes
                        to_many_relationships.each do |name, attr|
                          route_for = Array(attr.route_for)
                
                          if route_for.include?(:get)
                Severity: Minor
                Found in lib/cloud_controller/rest_controller/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 sync has a Cognitive Complexity of 8 (exceeds 5 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 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 add_relationship_url_to_response has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        def add_relationship_url_to_response(response, controller, associated_controller, relationship_name, association, obj)
                Severity: Minor
                Found in app/presenters/v2/relations_presenter.rb - About 45 mins to fix

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

                    def self.is_cnb_buildpack_uri?(candidate)
                      return false unless candidate.is_a?(String)
                      return is_uri?(candidate) if candidate.start_with?(%r{\Ahttp(s)?://}x)
                      return !!parse_docker_uri(candidate.split('://').last) if candidate.start_with?('docker://')
                  
                  
                  Severity: Minor
                  Found in lib/utils/uri_utils.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 to_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

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

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

                          def traverse_secrets_hash(secrets_hash)
                            secrets_hash.each do |k, v|
                              if v.is_a? Hash
                                traverse_secrets_hash(v)
                              else
                    Severity: Minor
                    Found in lib/cloud_controller/secrets_fetcher.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

                    Severity
                    Category
                    Status
                    Source
                    Language