apimatic/core-lib-ruby

View on GitHub

Showing 40 of 42 total issues

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

    def validate_value(value, context)
      if @type_to_match == DateTime
        dt_string = if value.instance_of?(DateTime) && context.date_time_converter
                      context.date_time_converter.call(value)
                    else
Severity: Minor
Found in lib/apimatic-core/types/union_types/leaf_type.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 clean_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.clean_url(url)
      # Perform parameter validation.
      raise ArgumentError, 'Invalid Url.' unless url.instance_of? String

      # Ensure that the urls are absolute.
Severity: Minor
Found in lib/apimatic-core/utilities/api_helper.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 valid_type? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.valid_type?(value, type_callable, is_model_hash: false, is_inner_model_hash: false)
      if value.is_a?(Array)
        value.all? do |item|
          valid_type?(item, type_callable,
                      is_model_hash: is_model_hash,
Severity: Minor
Found in lib/apimatic-core/utilities/api_helper.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 apply_deserializer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def apply_deserializer(response, should_symbolize_hash)
      return apply_xml_deserializer(response) if @is_xml_response
      return response.raw_body if @deserializer.nil?

      if @datetime_format
Severity: Minor
Found in lib/apimatic-core/response_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 validate_value_against_case has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_value_against_case(value, context)
      if context.is_array && context.is_dict && context.is_array_of_dict
        validate_array_of_dict_case(value)
      elsif context.is_array && context.is_dict
        validate_dict_of_array_case(value)
Severity: Minor
Found in lib/apimatic-core/types/union_types/leaf_type.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def validate_value_against_case(value, context)
      if context.is_array && context.is_dict && context.is_array_of_dict
        validate_array_of_dict_case(value)
      elsif context.is_array && context.is_dict
        validate_dict_of_array_case(value)
Severity: Minor
Found in lib/apimatic-core/types/union_types/leaf_type.rb and 1 other location - About 30 mins to fix
lib/apimatic-core/types/union_types/leaf_type.rb on lines 156..167

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def serialize_value_against_case(value, context)
      if context.is_array && context.is_dict && context.is_array_of_dict
        serialize_array_of_dict_case(value)
      elsif context.is_array && context.is_dict
        serialize_dict_of_array_case(value)
Severity: Minor
Found in lib/apimatic-core/types/union_types/leaf_type.rb and 1 other location - About 30 mins to fix
lib/apimatic-core/types/union_types/leaf_type.rb on lines 47..58

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    def self.to_unix_map(date_time, hash, key)
      return if date_time.nil?

      hash[key] = {}
      date_time.each do |k, v|
Severity: Minor
Found in lib/apimatic-core/utilities/date_time_helper.rb and 2 other locations - About 25 mins to fix
lib/apimatic-core/utilities/date_time_helper.rb on lines 14..22
lib/apimatic-core/utilities/date_time_helper.rb on lines 78..86

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 31.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    def self.to_rfc3339_map(date_time, hash, key)
      return if date_time.nil?

      hash[key] = {}
      date_time.each do |k, v|
Severity: Minor
Found in lib/apimatic-core/utilities/date_time_helper.rb and 2 other locations - About 25 mins to fix
lib/apimatic-core/utilities/date_time_helper.rb on lines 14..22
lib/apimatic-core/utilities/date_time_helper.rb on lines 46..54

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 31.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    def self.to_rfc1123_map(date_time, hash, key)
      return if date_time.nil?

      hash[key] = {}
      date_time.each do |k, v|
Severity: Minor
Found in lib/apimatic-core/utilities/date_time_helper.rb and 2 other locations - About 25 mins to fix
lib/apimatic-core/utilities/date_time_helper.rb on lines 46..54
lib/apimatic-core/utilities/date_time_helper.rb on lines 78..86

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 31.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    def self.valid_date?(date_value)
      if date_value.instance_of?(Date)
        true
      elsif date_value.instance_of?(String) && date_value.match?(/^\d{4}-\d{2}-\d{2}$/)
        DateTime.strptime(date_value, '%Y-%m-%d')
Severity: Minor
Found in lib/apimatic-core/utilities/date_time_helper.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 resolve_template_placeholders_using_json_pointer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.resolve_template_placeholders_using_json_pointer(placeholders, value, template)
      placeholders.each do |placeholder|
        extracted_value = ''
        if placeholder.include? '#'
          # pick the 2nd chunk then remove the last character (i.e. `}`) of the string value
Severity: Minor
Found in lib/apimatic-core/utilities/api_helper.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 _validate_value_against_case has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _validate_value_against_case(value, context)
      if context.is_array && context.is_dict && context.is_array_of_dict
        @is_valid, @collection_cases = UnionTypeHelper.validate_array_of_dict_case(@union_types, value,
                                                                                   true)
      elsif context.is_array && context.is_dict
Severity: Minor
Found in lib/apimatic-core/types/union_types/one_of.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

Similar blocks of code found in 2 locations. Consider refactoring.
Confirmed

    def apply_log_response_options(response)
      headers_to_log = LoggerHelper.extract_headers_to_log(
        @response_logging_config,
        response.headers
      )
Severity: Minor
Found in lib/apimatic-core/logger/sdk_logger.rb and 1 other location - About 25 mins to fix
lib/apimatic-core/logger/sdk_logger.rb on lines 40..56

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      def from_element_to_array(parent, item_name, clazz,
                                wrapping_element_name: nil,
                                datetime_format: nil)
        elements = if wrapping_element_name.nil?
                     parent.xpath(item_name)
Severity: Minor
Found in lib/apimatic-core/utilities/xml_helper.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 deserialize_value_against_case has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def deserialize_value_against_case(value, context, should_symbolize: false)
      if context.is_array && context.is_dict && context.is_array_of_dict
        deserialize_array_of_dict_case(value, should_symbolize: should_symbolize)
      elsif context.is_array && context.is_dict
        deserialize_dict_of_array_case(value, should_symbolize: should_symbolize)
Severity: Minor
Found in lib/apimatic-core/types/union_types/leaf_type.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

Similar blocks of code found in 2 locations. Consider refactoring.
Confirmed

    def apply_log_request_options(request)
      headers_to_log = LoggerHelper.extract_headers_to_log(
        @request_logging_config,
        request.headers
      )
Severity: Minor
Found in lib/apimatic-core/logger/sdk_logger.rb and 1 other location - About 25 mins to fix
lib/apimatic-core/logger/sdk_logger.rb on lines 59..75

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    def execute
      _client_configuration = @global_configuration.client_configuration
      begin
        if _client_configuration.http_client.nil?
          raise ArgumentError, 'An HTTP client instance is required to execute an Api call.'
Severity: Minor
Found in lib/apimatic-core/api_call.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 validate_value_against_case has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_value_against_case(value, context)
      if context.is_array && context.is_dict && context.is_array_of_dict
        @is_valid, @collection_cases = UnionTypeHelper.validate_array_of_dict_case(@union_types, value,
                                                                                   false)
      elsif context.is_array && context.is_dict
Severity: Minor
Found in lib/apimatic-core/types/union_types/any_of.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 serialize_value_against_case has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def serialize_value_against_case(value, context)
      if context.is_array && context.is_dict && context.is_array_of_dict
        serialize_array_of_dict_case(value)
      elsif context.is_array && context.is_dict
        serialize_dict_of_array_case(value)
Severity: Minor
Found in lib/apimatic-core/types/union_types/leaf_type.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