platehub/plate_api

View on GitHub

Showing 11 of 13 total issues

Method index_block has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def index_block(parent_class, parent_id, extra_params = {}, &block)
      extra_params[:page] = extra_params.delete("page") if extra_params["page"]
      extra_params[:page] = 1 unless extra_params[:page]

      pagination = index_block_iteration(parent_class, parent_id, extra_params, &block)
Severity: Minor
Found in lib/plate_api/object_handler.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(public_key, secret, path, parameters={}, custom_server=nil)
Severity: Minor
Found in lib/plate_api/delete_request.rb - About 35 mins to fix

    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(public_key, secret, method, path, custom_server = nil)
    Severity: Minor
    Found in lib/plate_api/request.rb - About 35 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(public_key, secret, path, parameters = {}, custom_server = nil)
      Severity: Minor
      Found in lib/plate_api/post_multipart_request.rb - About 35 mins to fix

        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(public_key, secret, path, parameters={}, custom_server=nil)
        Severity: Minor
        Found in lib/plate_api/post_request.rb - About 35 mins to fix

          Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(public_key, secret, path, parameters={}, custom_server=nil)
          Severity: Minor
          Found in lib/plate_api/get_request.rb - About 35 mins to fix

            Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def initialize(public_key, secret, path, parameters={}, custom_server=nil)
            Severity: Minor
            Found in lib/plate_api/put_request.rb - About 35 mins to fix

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

                  def create(parent, attributes, create_method = :post)
                    raise ArgumentError, "`parent` given for #create is not valid" unless parent
                    raise ArgumentError, "`attributes` given for #create is not valid" unless attributes.is_a?(Hash)
              
                    parameters = case create_method
              Severity: Minor
              Found in lib/plate_api/object_handler.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

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

                  def index(parent_class, parent_id, extra_params = {}, return_raw = false)
                    raise ArgumentError, "`parent_id` given for #index is not valid" unless parent_id
                    raise ArgumentError, "`parent_class` given for #index is not valid" unless parent_class
              
                    result = @api_connector.get(collection_path(parent_class, parent_id), extra_params)
              Severity: Minor
              Found in lib/plate_api/object_handler.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

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

                  def update(attributes)
                    raise ArgumentError, "Input `attributes` is not a Hash" unless attributes.is_a?(Hash)
                    raise ArgumentError, "No object_handler is attached to this object" unless @object_handler
              
                    if new_object = @object_handler.update(@id, attributes)
              Severity: Minor
              Found in lib/plate_api/plate_object/base.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def update(id, attributes)
                    raise ArgumentError, "`id` given for #update is not valid" unless id
                    raise ArgumentError, "`attributes` given for #update is not valid" unless attributes.is_a?(Hash)
              
                    result = @api_connector.put(resource_path(id), { "data" => attributes })
              Severity: Minor
              Found in lib/plate_api/object_handler.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

              Severity
              Category
              Status
              Source
              Language