platehub/plate_api

View on GitHub
lib/plate_api/object_handler.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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 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(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

There are no issues that match your filters.

Category
Status