cloudfoundry/vmc

View on GitHub
lib/vmc/cli.rb

Summary

Maintainability
D
2 days
Test Coverage

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

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

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

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

    require "yaml"
    require "socket"
    require "net/http"
    require "multi_json"
    require "fileutils"
    Severity: Minor
    Found in lib/vmc/cli.rb - About 4 hrs to fix

      Method client has a Cognitive Complexity of 20 (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/vmc/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 31 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/vmc/cli.rb - About 1 hr to fix

        Method client has 31 lines of code (exceeds 25 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/vmc/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/vmc/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/vmc/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 wrap_errors has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def wrap_errors
                  yield
                rescue CFoundry::Timeout => e
                  err(e.message)
                rescue Interrupt
            Severity: Minor
            Found in lib/vmc/cli.rb - About 55 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 precondition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def precondition
                  check_target
                  check_logged_in
            
                  return unless v2?
            Severity: Minor
            Found in lib/vmc/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 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/vmc/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