cloudfoundry/cfoundry

View on GitHub

Showing 46 of 46 total issues

Method request_uri has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    def request_uri(method, uri, options = {})
      uri = URI.parse(uri)

      unless uri.is_a?(URI::HTTP)
        raise InvalidTarget.new(@target)
Severity: Minor
Found in lib/cfoundry/rest_client.rb - About 6 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 succeed_to_load has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

      def succeed_to_load(options={})
        response_body = Helper.load_fixtures(options[:fixture] || "fake_cc_user")
        response_body["metadata"]["guid"] = options[:id] || "user-id-1"

        if options[:no_organizations]
Severity: Minor
Found in lib/cc_api_stub/users.rb - About 5 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 to_many has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def to_many(plural, opts = {})
      to_many_relations[plural] = opts

      singular = plural.to_s.sub(/s$/, "").to_sym

Severity: Minor
Found in lib/cfoundry/v2/model_magic/to_many.rb - About 4 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 add_client_methods has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def add_client_methods(klass)
          singular = klass.object_name
          plural = klass.plural_object_name

          define_base_client_methods do
Severity: Major
Found in lib/cfoundry/v2/model_magic/client_extensions.rb - About 3 hrs to fix

    Class App has 31 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class App < Model
        include CFoundry::UploadHelpers
    
        attribute :name,             :string
        to_one    :space
    Severity: Minor
    Found in lib/cfoundry/v2/app.rb - About 3 hrs to fix

      Method to_one has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_one(name, opts = {})
            to_one_relations[name] = opts
      
            association_name = opts[:as] || name
            default = opts[:default]
      Severity: Minor
      Found in lib/cfoundry/v2/model_magic/to_one.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 to_many has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def to_many(plural, opts = {})
            to_many_relations[plural] = opts
      
            singular = plural.to_s.sub(/s$/, "").to_sym
      
      
      Severity: Major
      Found in lib/cfoundry/v2/model_magic/to_many.rb - About 3 hrs to fix

        Class Model has 26 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Model
            include ActiveModel::Validations
        
            @@objects = {}
        
        
        Severity: Minor
        Found in lib/cfoundry/v2/model.rb - About 3 hrs to fix

          Method request_uri has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def request_uri(method, uri, options = {})
                uri = URI.parse(uri)
          
                unless uri.is_a?(URI::HTTP)
                  raise InvalidTarget.new(@target)
          Severity: Major
          Found in lib/cfoundry/rest_client.rb - About 2 hrs to fix

            Method add_client_methods has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                    def add_client_methods(klass)
                      singular = klass.object_name
                      plural = klass.plural_object_name
            
                      define_base_client_methods do
            Severity: Minor
            Found in lib/cfoundry/v2/model_magic/client_extensions.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 attribute has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                def attribute(name, type, opts = {})
                  attributes[name] = opts
                  json_name = opts[:at] || name
            
                  default = opts[:default]
            Severity: Minor
            Found in lib/cfoundry/v2/model_magic/attribute.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

            Class BaseClient has 22 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class BaseClient # :nodoc:
                include CFoundry::ProxyOptions
            
                extend Forwardable
            
            
            Severity: Minor
            Found in lib/cfoundry/baseclient.rb - About 2 hrs to fix

              Method to_one has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def to_one(name, opts = {})
                    to_one_relations[name] = opts
              
                    association_name = opts[:as] || name
                    default = opts[:default]
              Severity: Minor
              Found in lib/cfoundry/v2/model_magic/to_one.rb - About 1 hr to fix

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

                  module OrganizationUsers
                    extend Helper
                
                    class << self
                      def succeed_to_delete(options = {})
                Severity: Major
                Found in lib/cc_api_stub/organization_users.rb and 1 other location - About 1 hr to fix
                lib/cc_api_stub/space_users.rb on lines 2..23

                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 66.

                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

                  module SpaceUsers
                    extend Helper
                
                    class << self
                      def succeed_to_delete(options = {})
                Severity: Major
                Found in lib/cc_api_stub/space_users.rb and 1 other location - About 1 hr to fix
                lib/cc_api_stub/organization_users.rb on lines 2..23

                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 66.

                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

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

                    def health
                      if state == "STARTED"
                        healthy_count = running_instances
                        expected = total_instances
                
                
                Severity: Minor
                Found in lib/cfoundry/v2/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 create! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def create!
                      payload = {}
                
                      @manifest ||= {}
                      @manifest[:entity] ||= {}
                Severity: Minor
                Found in lib/cfoundry/v2/model.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 log_request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def log_request(time, request, response)
                      return unless @log
                
                      data = log_data(time, request, response)
                
                
                Severity: Minor
                Found in lib/cfoundry/rest_client.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 create! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def create!
                      payload = {}
                
                      @manifest ||= {}
                      @manifest[:entity] ||= {}
                Severity: Minor
                Found in lib/cfoundry/v2/model.rb - About 1 hr to fix

                  Method attribute has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def attribute(name, type, opts = {})
                        attributes[name] = opts
                        json_name = opts[:at] || name
                  
                        default = opts[:default]
                  Severity: Minor
                  Found in lib/cfoundry/v2/model_magic/attribute.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language