cloudfoundry/cf

View on GitHub
lib/cf/cli.rb

Summary

Maintainability
D
2 days
Test Coverage

Class CLI has 44 methods (exceeds 20 allowed). Consider refactoring.
Open

  class CLI < Mothership
    include CF::Interactive
    include CF::Spacing

    option :help, :desc => "Show command usage", :alias => "-h",
Severity: Minor
Found in lib/cf/cli.rb - About 6 hrs to fix

    File cli.rb has 383 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "yaml"
    require "socket"
    require "net/http"
    require "json/ext"
    require "multi_json"
    Severity: Minor
    Found in lib/cf/cli.rb - About 5 hrs to fix

      Method client has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def client(target = client_target)
            return @@client if defined?(@@client) && @@client
            return unless target
      
            info = target_info(target)
      Severity: Minor
      Found in lib/cf/cli.rb - About 2 hrs 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 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 log_error has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def log_error(e)
              ensure_config_dir
        
              msg = e.class.name
              msg << ": #{e}" unless e.to_s.empty?
        Severity: Minor
        Found in lib/cf/cli.rb - About 1 hr to fix

          Method log_error has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def log_error(e)
                ensure_config_dir
          
                msg = e.class.name
                msg << ": #{e}" unless e.to_s.empty?
          Severity: Minor
          Found in lib/cf/cli.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 save_token_if_it_changes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def save_token_if_it_changes
                return yield unless client && client.token
          
                before_token = client.token
          
          
          Severity: Minor
          Found in lib/cf/cli.rb - About 25 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 help has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def help
                if name = input[:command]
                  if cmd = @@commands[name.gsub("-", "_").to_sym]
                    Mothership::Help.command_help(cmd)
                  else
          Severity: Minor
          Found in lib/cf/cli.rb - About 25 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

          There are no issues that match your filters.

          Category
          Status