remiprev/her

View on GitHub

Showing 11 of 13 total issues

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

        def fetch(opts = {})
          attribute_value = @parent.attributes[@name]
          return @opts[:default].try(:dup) if @parent.attributes.include?(@name) && (attribute_value.nil? || !attribute_value.nil? && attribute_value.empty?) && @params.empty?

          return @cached_result unless @params.any? || @cached_result.nil?
Severity: Minor
Found in lib/her/model/associations/association.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 request has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def request(opts = {})
      method = opts.delete(:_method)
      path = opts.delete(:_path)
      headers = opts.delete(:_headers)
      opts.delete_if { |key, _| key.to_s =~ /^_/ } # Remove all internal parameters
Severity: Minor
Found in lib/her/api.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 fetch has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def fetch
          foreign_key_value = @parent.attributes[@opts[:foreign_key].to_sym]
          data_key_value = @parent.attributes[@opts[:data_key].to_sym]
          return @opts[:default].try(:dup) if (@parent.attributes.include?(@name) && @parent.attributes[@name].nil? && @params.empty?) || (foreign_key_value.blank? && data_key_value.blank?)

Severity: Minor
Found in lib/her/model/associations/belongs_to_association.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 build_request_path has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def build_request_path(path = nil, parameters = {})
          parameters = parameters.try(:with_indifferent_access)

          unless path.is_a?(String)
            parameters = path.try(:with_indifferent_access) || parameters
Severity: Minor
Found in lib/her/model/paths.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 included has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.included(klass)
        klass.class_eval do
          include Her::Model

          [:parse_root_in_json, :include_root_in_json, :root_element, :primary_key].each do |method|
Severity: Minor
Found in lib/her/json_api/model.rb - About 1 hr to fix

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

          def find(*ids)
            params = @params.merge(ids.last.is_a?(Hash) ? ids.pop : {})
            ids = Array(params[@parent.primary_key]) if params.key?(@parent.primary_key)
    
            results = ids.flatten.compact.uniq.map do |id|
    Severity: Minor
    Found in lib/her/model/relation.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 to_params has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def to_params(attributes, changes = {})
              filtered_attributes = attributes.each_with_object({}) do |(key, value), memo|
                case value
                when Her::Model
                when ActiveModel::Serialization
    Severity: Minor
    Found in lib/her/model/parse.rb - About 45 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 to_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

              def self.to_params(attributes, changes = {})
                request_data = { type: @type }.tap do |request_body|
                  attrs = attributes.dup.symbolize_keys.tap do |filtered_attributes|
                    if her_api.options[:send_only_modified_attributes]
                      filtered_attributes.slice! *changes.keys.map(&:to_sym)
    Severity: Minor
    Found in lib/her/json_api/model.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 save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def save
            callback = new? ? :create : :update
            method = self.class.method_for(callback)
    
            run_callbacks :save do
    Severity: Minor
    Found in lib/her/model/orm.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 use_api has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def use_api(value = nil)
              @_her_use_api ||= begin
                superclass.use_api if superclass.respond_to?(:use_api)
              end
    
    
    Severity: Minor
    Found in lib/her/model/http.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def parse(data)
              if parse_root_in_json? && root_element_included?(data)
                if json_api_format?
                  data.fetch(parsed_root_element).first
                else
    Severity: Minor
    Found in lib/her/model/parse.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