cloudfoundry/cf

View on GitHub
lib/manifests/manifests.rb

Summary

Maintainability
D
2 days
Test Coverage

Method setup_services has a Cognitive Complexity of 23 (exceeds 5 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 3 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 apps_in_manifest has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def apps_in_manifest(input = nil, use_name = true, &blk)
    names_or_paths =
      if input.has?(:apps)
        # names may be given but be [], which will still cause
        # interaction, so use #direct instead of #[] here
Severity: Minor
Found in lib/manifests/manifests.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

File manifests.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "yaml"
require "set"
require "cf/cli/service/create"

require "manifests/loader"
Severity: Minor
Found in lib/manifests/manifests.rb - About 2 hrs to fix

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

      def manifest_file
        return @manifest_file if @manifest_file
    
        unless path = input[:manifest]
          where = Dir.pwd
    Severity: Minor
    Found in lib/manifests/manifests.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 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 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 apps_in_manifest has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def apps_in_manifest(input = nil, use_name = true, &blk)
              names_or_paths =
                if input.has?(:apps)
                  # names may be given but be [], which will still cause
                  # interaction, so use #direct instead of #[] here
          Severity: Minor
          Found in lib/manifests/manifests.rb - About 1 hr to fix

            Method create_manifest_for has a Cognitive Complexity of 11 (exceeds 5 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

            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