cloudfoundry/cf

View on GitHub

Showing 96 of 102 total issues

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

    def map_domain
      domain = client.domain_by_name(input[:name])

      given_org = input.has?(:organization)
      given_space = input.has?(:space)
Severity: Minor
Found in lib/cf/cli/domain/map.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

Consider simplifying this complex logical expression.
Open

        if svc[:label] == "user-provided"
          invoke :create_service,
            name: name,
            offering: CF::Service::UPDummy.new,
            app: app,
Severity: Critical
Found in lib/manifests/manifests.rb - About 1 hr to fix

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

        def delete
          apps = client.apps
    
          if input[:all]
            return unless input[:really, "ALL APPS", :bad]
    Severity: Minor
    Found in lib/cf/cli/app/delete.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 handler has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def handler(event, state)
          ans = state.answer
    
          exit if event == :eof
    
    
    Severity: Minor
    Found in lib/cf/cli/interactive.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 get_connection_info has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def get_connection_info(token)
        response = nil
        10.times do
          begin
            response =
    Severity: Minor
    Found in lib/tunnel/tunnel.rb - About 1 hr to fix

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

        def setup_services(app, info)
          return if !info[:services] || info[:services].empty?
      
          offerings = client.services
      
      
      Severity: Minor
      Found in lib/manifests/manifests.rb - About 1 hr to fix

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

              def space
                space = CF::Populators::Space.new(input, org).populate_and_save!
        
                unless space
                  return if quiet?
        Severity: Minor
        Found in lib/cf/cli/space/space.rb - About 1 hr to fix

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

            def create_manifest_for(app, path)
              meta = {
                "name" => app.name,
                "memory" => human_size(app.memory * 1024 * 1024, 0),
                "instances" => app.total_instances,
          Severity: Minor
          Found in lib/manifests/manifests.rb - About 1 hr to fix

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

                def delete_service
                  if input[:all]
                    return unless input[:really, "ALL SERVICES", :bad]
            
                    client.service_instances.each do |i|
            Severity: Minor
            Found in lib/cf/cli/service/delete.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 locate_file has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def locate_file(file, directory, search_paths)
                search_paths.each do |path|
                  expanded_path = File.expand_path(path)
                  next unless File.exists?(expanded_path)
                  Find.find(expanded_path) do |current|
            Severity: Minor
            Found in lib/micro/micro.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 target has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def target
                  unless input.has?(:url) || input.has?(:organization) || input.has?(:space)
                    TargetPrettifier.prettify(client, self)
                    return
                  end
            Severity: Minor
            Found in lib/cf/cli/start/target.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 display_app has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def display_app(a)
                  status = app_status(a)
            
                  line "#{c(a.name, :name)}: #{status}"
            
            
            Severity: Minor
            Found in lib/cf/cli/app/app.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 check_application has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def check_application(app)
                  if app.debug == "suspend"
                    line "Application is in suspended debugging mode."
                    line "It will wait for you to attach to it before starting."
                    return
            Severity: Minor
            Found in lib/cf/cli/app/start.rb - About 1 hr to fix

              Method tail has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def tail
                    app = input[:app]
              
                    lines = Queue.new
                    max_len = 0
              Severity: Minor
              Found in lib/cf/cli/app/files.rb - About 1 hr to fix

                Method apps has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def apps
                      if space = input[:space]
                        begin
                          space.summarize!
                        rescue CFoundry::APIError
                Severity: Minor
                Found in lib/cf/cli/app/apps.rb - About 1 hr to fix

                  Method wrap_errors has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def wrap_errors
                        yield
                      rescue CFoundry::Timeout => e
                        err(e.message)
                      rescue Interrupt
                  Severity: Minor
                  Found in lib/cf/cli.rb - About 1 hr to fix

                    Method stats has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def stats
                          app = input[:app]
                          stats =
                            with_progress("Getting stats for #{c(app.name, :name)}") do |s|
                              begin
                    Severity: Minor
                    Found in lib/cf/cli/app/stats.rb - About 1 hr to fix

                      Method load_all has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def self.load_all
                            # auto-load gems with 'cf-plugin' in their name
                            matching =
                              if Gem::Specification.respond_to? :find_all
                                Gem::Specification.find_all do |s|
                      Severity: Minor
                      Found in lib/cf/plugin.rb - About 1 hr to fix

                        Method create_space has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def create_space
                                space = client.space
                                space.organization = org
                                space.name = input[:name]
                        
                        
                        Severity: Minor
                        Found in lib/cf/cli/space/create.rb - About 1 hr to fix

                          Method login has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def login(auth = get_credentials)
                              if !auth["username"] || !auth["password"]
                                raise "Unable to verify console credentials."
                              end
                          
                          
                          Severity: Minor
                          Found in lib/console/console.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language