WeAreFarmGeek/diplomat

View on GitHub
lib/diplomat/kv.rb

Summary

Maintainability
C
1 day
Test Coverage

Method get has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def get(key, options = {}, not_found = :reject, found = :return)
      @options = options
      return_nil_values = @options && @options[:nil_values]
      transformation = @options && @options[:transformation] && @options[:transformation].methods.find_index(:call) ? @options[:transformation] : nil
      raw = get_raw(key, options)
Severity: Minor
Found in lib/diplomat/kv.rb - About 3 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 get_all has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def get_all(key, options = {}, not_found = :reject, found = :return)
      @options = options
      @options[:recurse] = true
      return_nil_values = @options && @options[:nil_values]
      transformation = @options && @options[:transformation] && @options[:transformation].methods.find_index(:call) ? @options[:transformation] : nil
Severity: Minor
Found in lib/diplomat/kv.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 get has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def get(key, options = {}, not_found = :reject, found = :return)
      @options = options
      return_nil_values = @options && @options[:nil_values]
      transformation = @options && @options[:transformation] && @options[:transformation].methods.find_index(:call) ? @options[:transformation] : nil
      raw = get_raw(key, options)
Severity: Minor
Found in lib/diplomat/kv.rb - About 1 hr to fix

    Method get_all has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def get_all(key, options = {}, not_found = :reject, found = :return)
          @options = options
          @options[:recurse] = true
          return_nil_values = @options && @options[:nil_values]
          transformation = @options && @options[:transformation] && @options[:transformation].methods.find_index(:call) ? @options[:transformation] : nil
    Severity: Minor
    Found in lib/diplomat/kv.rb - About 1 hr to fix

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

          def decode_transaction(transaction)
            return transaction if transaction['Results'].nil? || transaction['Results'].empty?
      
            transaction.tap do |txn|
              txn['Results'].each do |resp|
      Severity: Minor
      Found in lib/diplomat/kv.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 transaction_verification has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def transaction_verification(transaction)
            raise Diplomat::InvalidTransaction unless transaction.is_a?(Array)
      
            transaction.each do |req|
              raise Diplomat::InvalidTransaction unless transaction_type_verification(req)
      Severity: Minor
      Found in lib/diplomat/kv.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

      Avoid too many return statements within this method.
      Open

                return convert_to_hash(return_value(return_nil_values, transformation, true)) if @options && @options[:convert_to_hash]
      Severity: Major
      Found in lib/diplomat/kv.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return return_value(return_nil_values, transformation)
        Severity: Major
        Found in lib/diplomat/kv.rb - About 30 mins to fix

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

              def transaction_consistency(options)
                return [] unless options
          
                if options[:consistency] && options[:consistency] == 'stale'
                  ['stale']
          Severity: Minor
          Found in lib/diplomat/kv.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

          There are no issues that match your filters.

          Category
          Status