moneta-rb/moneta

View on GitHub
lib/moneta/adapters/couch.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Couch has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Couch
      include Defaults

      # @api private
      class HTTPError < StandardError
Severity: Minor
Found in lib/moneta/adapters/couch.rb - About 3 hrs to fix

    File couch.rb has 312 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'faraday'
    require 'multi_json'
    
    module Moneta
      module Adapters
    Severity: Minor
    Found in lib/moneta/adapters/couch.rb - About 3 hrs to fix

      Method delete has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def delete(key, options = {})
              get_response = get(key, returns: :response)
              if get_response.success?
                value = body_to_value(get_response.body)
                existing_rev = parse_rev(get_response)
      Severity: Minor
      Found in lib/moneta/adapters/couch.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 clear has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def clear(options = {})
              loop do
                docs = all_docs(limit: 10_000)
                break if docs['rows'].empty?
                deletions = docs['rows'].map do |row|
      Severity: Minor
      Found in lib/moneta/adapters/couch.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 merge! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def merge!(pairs, options = {})
              keys = pairs.map { |key, _| key }.to_a
              cache_revs(*keys.reject { |key| @rev_cache[key] })
      
              if block_given?
      Severity: Minor
      Found in lib/moneta/adapters/couch.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 store has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def store(key, value, options = {})
              put(key, value_to_doc(value, rev(key)),
                  headers: full_commit_header(options[:full_commit]),
                  query: options[:batch] ? { batch: 'ok' } : {},
                  cache_rev: options[:cache_rev] != false,
      Severity: Minor
      Found in lib/moneta/adapters/couch.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 merge! has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def merge!(pairs, options = {})
              keys = pairs.map { |key, _| key }.to_a
              cache_revs(*keys.reject { |key| @rev_cache[key] })
      
              if block_given?
      Severity: Minor
      Found in lib/moneta/adapters/couch.rb - About 1 hr to fix

        Method request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def request(method, key, body = nil, returns: :nil, cache_rev: false, expect: nil, query: nil, headers: {})
                url = @backend.build_url(key, query)
                headers['Content-Type'] = 'application/json' if %i{put post}.include?(method)
                response = @backend.run_request(method, url, body || '', headers)
        
        
        Severity: Minor
        Found in lib/moneta/adapters/couch.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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def create(key, value, options = {})
                cache_rev = options[:cache_rev] != false
                doc = value_to_doc(value, nil)
                response = put(key, doc, cache_rev: cache_rev, returns: :response)
                case response.status
        Severity: Minor
        Found in lib/moneta/adapters/couch.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 create_db has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def create_db
                loop do
                  response = put('', returns: :response)
                  case response.status
                  when 201
        Severity: Minor
        Found in lib/moneta/adapters/couch.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

        There are no issues that match your filters.

        Category
        Status