bbean86/jsonapi_rails

View on GitHub

Showing 4 of 4 total issues

Method relationships has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def relationships
      @relationships.flat_map do |relationship_name, rel|
        next unless rel.key?(:data)
        if rel[:data].nil?
          {name: relationship_name, relations: nil}
Severity: Minor
Found in lib/jsonapi_rails/params_to_object.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 assign_relationships has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def assign_relationships
      relationships.each do |rel|
        next if rel.blank?
        json_api_relationship = resource.relationships.detect do |relationship|
          relationship.name == rel[:name].to_s
Severity: Minor
Found in lib/jsonapi_rails/params_to_object.rb - About 55 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 assign_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def assign_attributes
      attributes.each_with_object({}) do |(attr, value), hsh|
        unless permitted?(attr)
          message = "`#{resource.class}' does not have attribute " \
                    "`#{attr.to_s.gsub('=', '')}'"
Severity: Minor
Found in lib/jsonapi_rails/params_to_object.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 setup_object has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def setup_object(data, ar_relation)
      type = data[:type]
      klass = ar_relation || type.classify.constantize

      return klass.new if data[:id].blank?
Severity: Minor
Found in lib/jsonapi_rails/params_to_object.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

Severity
Category
Status
Source
Language