apimatic/core-lib-ruby

View on GitHub

Showing 40 of 42 total issues

Method match_body has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

    def self.match_body(expected_body,
                        actual_body,
                        check_values: false,
                        check_order: false,
                        check_count: false)
Severity: Minor
Found in lib/apimatic-core/utilities/comparison_helper.rb - About 7 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 form_encode has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def self.form_encode(obj, instance_name, formatting: ArraySerializationFormat::INDEXED)
      retval = {}

      # If this is a structure, resolve it's field names.
      obj = obj.to_hash if obj.is_a? BaseModel
Severity: Minor
Found in lib/apimatic-core/utilities/api_helper.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 append_url_with_template_parameters has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def self.append_url_with_template_parameters(query_builder, parameters)
      # perform parameter validation
      unless query_builder.instance_of? String
        raise ArgumentError, 'Given value for parameter \"query_builder\" is
          invalid.'
Severity: Minor
Found in lib/apimatic-core/utilities/api_helper.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 update_user_agent_value_with_parameters has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def self.update_user_agent_value_with_parameters(user_agent, parameters)
      # perform parameter validation
      unless user_agent.instance_of? String
        raise ArgumentError, 'Given value for \"user_agent\" is
          invalid.'
Severity: Minor
Found in lib/apimatic-core/utilities/api_helper.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 append_url_with_query_parameters has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def self.append_url_with_query_parameters(query_builder, parameters,
                                              array_serialization = ArraySerializationFormat::INDEXED)
      # Perform parameter validation.
      unless query_builder.instance_of? String
        raise ArgumentError, 'Given value for parameter \"query_builder\"
Severity: Minor
Found in lib/apimatic-core/utilities/api_helper.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 custom_merge has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def self.custom_merge(a, b)
      x = {}
      a.each do |key, value_a|
        b.each do |k, value_b|
          next unless key == k
Severity: Minor
Found in lib/apimatic-core/utilities/api_helper.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 resolve_template_placeholders has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def self.resolve_template_placeholders(placeholders, values, template)
      values = values.map { |key, value| [key.to_s, value.to_s] }.to_h if values.is_a? Hash

      placeholders.each do |placeholder|
        extracted_value = ''
Severity: Minor
Found in lib/apimatic-core/utilities/api_helper.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 process_body has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def process_body
      _has_form_params = !@form_params.nil? && @form_params.any?
      _has_additional_form_params = !@additional_form_params.nil? && @additional_form_params.any?
      _has_multipart_param = !@multipart_params.nil? && @multipart_params.any?
      _has_body_param = !@body_param.nil?
Severity: Minor
Found in lib/apimatic-core/request_builder.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 deserialize_datetime has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def self.deserialize_datetime(response, datetime_format, is_array, should_symbolize)
      decoded = json_deserialize(response, should_symbolize) if is_array

      case datetime_format
      when DateTimeFormat::HTTP_DATE_TIME
Severity: Minor
Found in lib/apimatic-core/utilities/api_helper.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 convert has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def convert(value, clazz, datetime_format)
        if clazz == DateTime
          return DateTime.rfc3339(value) if datetime_format == 'RFC3339DateTime'
          return DateTime.httpdate(value) if datetime_format == 'HttpDateTime'
          return DateTime.strptime(value, '%s') if datetime_format == 'UnixDateTime'
Severity: Minor
Found in lib/apimatic-core/utilities/xml_helper.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 match_headers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def self.match_headers(expected_headers,
                           actual_headers,
                           allow_extra: true)
      return false if ((actual_headers.length < expected_headers.length) ||
        ((allow_extra == false) && (actual_headers.length > expected_headers.length)))
Severity: Minor
Found in lib/apimatic-core/utilities/comparison_helper.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
Confirmed

      log_body,
      log_headers,
      headers_to_exclude,
      headers_to_include,
      headers_to_unmask,
Severity: Minor
Found in lib/apimatic-core/logger/configurations/api_logging_configuration.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                  return false if (i != 0 && matches.map{|x| previous_matches.map{|y| y > x}.all?}.all?)
    Severity: Major
    Found in lib/apimatic-core/utilities/comparison_helper.rb - About 45 mins to fix

      Method map_response has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.map_response(obj, keys)
            val = obj
            begin
              keys.each do |key|
                val = if val.is_a? Array
      Severity: Minor
      Found in lib/apimatic-core/utilities/api_helper.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(status_code,
                         reason_phrase,
                         headers,
                         raw_body,
                         request)
      Severity: Minor
      Found in lib/apimatic-core/http/response/http_response.rb - About 35 mins to fix

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

              log_body,
              log_headers,
              headers_to_exclude,
              headers_to_include,
              headers_to_unmask
        Severity: Minor
        Found in lib/apimatic-core/logger/configurations/api_logging_configuration.rb - About 35 mins to fix

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

                def deserialize_xml_to_array(xml, root_element_name, item_name, clazz,
                                             datetime_format = nil)
          Severity: Minor
          Found in lib/apimatic-core/utilities/xml_helper.rb - About 35 mins to fix

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

                def create(_status_code, _reason_phrase, _headers, _raw_body, _request)
            Severity: Minor
            Found in lib/apimatic-core/factories/http_response_factory.rb - About 35 mins to fix

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

                    logger,
                    log_level,
                    request_logging_config,
                    response_logging_config,
                    mask_sensitive_headers
              Severity: Minor
              Found in lib/apimatic-core/logger/configurations/api_logging_configuration.rb - About 35 mins to fix

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

                    def self.process_errors(value, union_types, error_messages, is_nested, is_for_one_of)
                Severity: Minor
                Found in lib/apimatic-core/utilities/union_type_helper.rb - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language