artirix/artirix_data_models

View on GitHub

Showing 35 of 35 total issues

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

  def self.set_options_from_config(service)
    options = ArtirixDataModels.configuration.try(:cache_options)
    if options
      options = options.to_hash if options.respond_to?(:to_hash) && !options.respond_to?(:each)
      options.each do |name, opts|
Severity: Minor
Found in lib/artirix_data_models/cache_service.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 get_cached_result has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def get_cached_result
    return nil unless enabled?

    c = cache_read
    return nil unless c.present?
Severity: Minor
Found in lib/artirix_data_models/cached_action_adaptor.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 normalise_element has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def normalise_element(name, value)
      return unless Hash === value

      if value.key?(:buckets)
        add_normalised_buckets_element_to_list(name, value)
Severity: Minor
Found in lib/artirix_data_models/raw_aggregation_data_normaliser.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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(*args)
      case args.size
      when 0
        message = nil
        options = {}
Severity: Minor
Found in lib/artirix_data_models/gateways/data_gateway.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 parse_response has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_response(result:, response_adaptor:, path:, method:, json_parse_response: true)
    if result.blank?
      parsed_response = nil
    elsif json_parse_response
      parsed_response = Oj.load result, symbol_keys: true
Severity: Minor
Found in lib/artirix_data_models/gateways/data_gateway.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 _define_getter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def _define_getter(attribute, options)
          skip_option = Array(options.fetch(:skip, []))
          return nil if skip_option.include?(:reader) || skip_option.include?(:getter)

          variable_name = "@#{attribute}"
Severity: Minor
Found in lib/artirix_data_models/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

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

  describe '#get' do
    When(:result) { subject.get primary_key }
    Then { result.is_a? model_class }
    Then { result.primary_key == primary_key }
    Then { result.send(partial_mode_attribute) == partial_mode_attribute_value }
lib/artirix_data_models/spec_support/shared_examples/an_artirix_data_model_dao.rb on lines 73..78

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 34.

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

  describe '#get_full' do
    When(:result) { subject.get_full(primary_key) }
    Then { result.is_a? model_class }
    Then { result.primary_key == primary_key }
    Then { result.send(partial_mode_attribute) == partial_mode_attribute_value }
lib/artirix_data_models/spec_support/shared_examples/an_artirix_data_model_dao.rb on lines 64..69

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 34.

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 get(model_pk, cache_adaptor: nil, **extra_options)
      model = adm_registry.get_model model_name, model_pk
      return model if model.present?

      cache_adaptor ||= cache_model_adaptor_for_get(model_pk, **extra_options)
Severity: Minor
Found in lib/artirix_data_models/dao.rb and 1 other location - About 30 mins to fix
lib/artirix_data_models/dao.rb on lines 167..175

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 find(model_pk, cache_adaptor: nil, **extra_options)
      model = adm_registry.get_model model_name, model_pk
      return model if model.present?

      cache_adaptor ||= cache_model_adaptor_for_find(model_pk, **extra_options)
Severity: Minor
Found in lib/artirix_data_models/dao.rb and 1 other location - About 30 mins to fix
lib/artirix_data_models/dao.rb on lines 156..164

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

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

    def self.from_array(array, total: nil, page_number: nil, per_page: nil)
      self.new(-> (x) { x }, response: {}).tap do |obj|
        total    ||= array.length
        per_page = per_page.to_i

Severity: Minor
Found in lib/artirix_data_models/es_collection.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 mock_gateway_not_found_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def mock_gateway_not_found_response(method:,
                                    path:,
                                    body: nil,
                                    json_body: true,
                                    timeout: nil,
Severity: Minor
Found in lib/artirix_data_models/spec_support/gateway_mock.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 get_model has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get_model(model_dao_name, primary_key)
      model_dao_name = model_dao_name.to_s
      primary_key = primary_key.to_s
      return nil unless model_dao_name.present? && primary_key.present?

Severity: Minor
Found in lib/artirix_data_models/adm_registry.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.
Open

  def set_persistent_loader(key, loader = nil, &block)
    key = key.to_sym

    if block
      value_to_store = block
Severity: Minor
Found in lib/artirix_data_models/adm_registry.rb and 1 other location - About 25 mins to fix
lib/artirix_data_models/adm_registry.rb on lines 75..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 29.

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 set_transient_loader(key, loader = nil, &block)
    key = key.to_sym

    if block
      value_to_store = block
Severity: Minor
Found in lib/artirix_data_models/adm_registry.rb and 1 other location - About 25 mins to fix
lib/artirix_data_models/adm_registry.rb on lines 89..100

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 29.

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

Severity
Category
Status
Source
Language