cloudfoundry/cf

View on GitHub

Showing 102 of 102 total issues

Method logs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def logs
      app = input[:app]

      instances =
        if input[:all] || input[:instance] == "all"
Severity: Minor
Found in lib/cf/cli/app/logs.rb - About 35 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    input(:service_auth_token, :argument => :optional,
          :from_given => proc { |guid| client.service_auth_token(guid) },
          :desc => "Auth token to delete") {
      tokens = client.service_auth_tokens
      fail "No tokens!" if tokens.empty?
Severity: Minor
Found in lib/admin/service_auth_token.rb and 1 other location - About 30 mins to fix
lib/admin/service_auth_token.rb on lines 54..60

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    input(:service_auth_token, :argument => :optional,
          :from_given => proc { |guid| client.service_auth_token(guid) },
          :desc => "Auth token to delete") {
      tokens = client.service_auth_tokens
      fail "No tokens!" if tokens.empty?
Severity: Minor
Found in lib/admin/service_auth_token.rb and 1 other location - About 30 mins to fix
lib/admin/service_auth_token.rb on lines 77..83

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid too many return statements within this method.
Open

    return no_apps if fail_without_app && apps.empty?
Severity: Major
Found in lib/manifests/plugin.rb - About 30 mins to fix

    Method stream_start_log has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def stream_start_log(log)
          offset = 0
    
          while true
            begin
    Severity: Minor
    Found in lib/cf/cli/app/start.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 display_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def display_user(u)
          if quiet?
            puts u.email
          else
            line "#{c(u.email, :name)}:"
    Severity: Minor
    Found in lib/cf/cli/user/users.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/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 app_matches? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def app_matches?(a, options)
          if name = options[:name]
            return false if a.name !~ /#{name}/
          end
    
    
    Severity: Minor
    Found in lib/cf/cli/app/apps.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 create_org has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_org
          org = client.organization
          org.name = input[:name]
          org.users = [client.current_user] if input[:add_self]
    
    
    Severity: Minor
    Found in lib/cf/cli/organization/create.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 display_tunnel_connection_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def display_tunnel_connection_info(info)
          line "Service connection info:"
    
          to_show = [nil, nil, nil] # reserved for user, pass, db name
          info.keys.each do |k|
    Severity: Minor
    Found in lib/tunnel/plugin.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 display_instance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def display_instance(i)
          start_line "instance #{c("\##{i.id}", :instance)}: "
          puts "#{b(c(i.state.downcase, state_color(i.state)))}"
    
          indented do
    Severity: Minor
    Found in lib/cf/cli/app/instances.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 start_local_prog has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def start_local_prog(clients, command, info, port)
          client = clients[File.basename(command)]
    
          cmdline = "#{command} "
    
    
    Severity: Minor
    Found in lib/tunnel/plugin.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 display_service has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def display_service(i)
          if quiet?
            line i.name
          else
            plan = i.service_plan
    Severity: Minor
    Found in lib/cf/cli/service/service.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 running? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def running?
          vms = list
          if @platform == :windows
            vms.any? { |x|
              x.downcase == @vmx.downcase
    Severity: Minor
    Found in lib/micro/vmrun.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 health has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def health
          apps = input[:apps]
          fail "No applications given." if apps.empty?
    
          health =
    Severity: Minor
    Found in lib/cf/cli/app/health.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 stream_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def stream_path(lines, instance, path)
          if verbose?
            lines << [instance, path, c("streaming...", :good) + "\n"]
          end
    
    
    Severity: Minor
    Found in lib/cf/cli/app/files.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

    Method stop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def stop
          apps = input[:all] ? client.apps : input[:apps]
          fail "No applications given." if apps.empty?
    
          apps.each do |app|
    Severity: Minor
    Found in lib/cf/cli/app/stop.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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

              if input[:full]
                line
                line "apps:"
    
                spaced(space.apps(:depth => 2)) do |a|
    Severity: Minor
    Found in lib/cf/cli/space/space.rb and 1 other location - About 25 mins to fix
    lib/cf/cli/space/space.rb on lines 49..58

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 29.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

              if input[:full]
                line
                line "services:"
                spaced(space.service_instances(:depth => 2)) do |s|
                  indented do
    Severity: Minor
    Found in lib/cf/cli/space/space.rb and 1 other location - About 25 mins to fix
    lib/cf/cli/space/space.rb on lines 36..46

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 29.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Severity
    Category
    Status
    Source
    Language