cloudfoundry/cloud_controller_ng

View on GitHub
app/presenters/v2/relations_presenter.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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

        def serialize_relationships(relationships, controller, depth, obj, opts, parents, orphans)
          response = {}
          (relationships || {}).each do |relationship_name, association|
            associated_model = get_associated_model_class_for(obj, association.association_name)
            next unless associated_model
Severity: Minor
Found in app/presenters/v2/relations_presenter.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 serialize_to_one_relationship has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def serialize_to_one_relationship(response, associated_model_instance, associated_controller, relationship_name, depth, opts, parents, orphans)
Severity: Major
Found in app/presenters/v2/relations_presenter.rb - About 1 hr to fix

    Method serialize_to_many_relationship has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def serialize_to_many_relationship(response, associated_model_instances, associated_controller, relationship_name, depth, opts, parents, orphans)
    Severity: Major
    Found in app/presenters/v2/relations_presenter.rb - About 1 hr to fix

      Method serialize_relationships has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def serialize_relationships(relationships, controller, depth, obj, opts, parents, orphans)
      Severity: Major
      Found in app/presenters/v2/relations_presenter.rb - About 50 mins to fix

        Method to_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def to_hash(controller, obj, opts, depth, parents, orphans=nil)
        Severity: Minor
        Found in app/presenters/v2/relations_presenter.rb - About 45 mins to fix

          Method add_relationship_url_to_response has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def add_relationship_url_to_response(response, controller, associated_controller, relationship_name, association, obj)
          Severity: Minor
          Found in app/presenters/v2/relations_presenter.rb - About 45 mins to fix

            Method relationship_link_only? has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def relationship_link_only?(association, associated_controller, relationship_name, opts, depth, parents)
            Severity: Minor
            Found in app/presenters/v2/relations_presenter.rb - About 45 mins to fix

              There are no issues that match your filters.

              Category
              Status