npolar/api.npolar.no

View on GitHub
lib/npolar/storage/couch.rb

Summary

Maintainability
D
2 days
Test Coverage

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

require "rack/client"

module Npolar
  module Storage

Severity: Minor
Found in lib/npolar/storage/couch.rb - About 6 hrs to fix

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

        class Couch
    
          # Delegate validation to model
          #extend Forwardable # http://www.ruby-doc.org/stdlib-1.9.3/libdoc/forwardable/rdoc/Forwardable.html
          #def_delegators :model, :valid?
    Severity: Minor
    Found in lib/npolar/storage/couch.rb - About 4 hrs to fix

      Method post_many has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def post_many(data, params={})        
              if data !~ JSON_ARRAY_REGEX
                raise ArgumentException, "Please provide data as JSON Array"
              end
              t0 = Time.now
      Severity: Major
      Found in lib/npolar/storage/couch.rb - About 2 hrs to fix

        Method post has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def post(data, params={})
                #unless valid? data
                #  raise Exception
                #end
        
        
        Severity: Minor
        Found in lib/npolar/storage/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 post_many has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def post_many(data, params={})        
                if data !~ JSON_ARRAY_REGEX
                  raise ArgumentException, "Please provide data as JSON Array"
                end
                t0 = Time.now
        Severity: Minor
        Found in lib/npolar/storage/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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(read, write = nil, config = {})
                if read.respond_to? :key? and read.key? "read"
                  if write.nil? and read.key? "write"
                    write = read["write"]
                  end
        Severity: Minor
        Found in lib/npolar/storage/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 valid? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def valid? data, context="POST"
                @errors = []
        
                # First, check JSON syntax
                begin
        Severity: Minor
        Found in lib/npolar/storage/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 valid? has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def valid? data, context="POST"
                @errors = []
        
                # First, check JSON syntax
                begin
        Severity: Minor
        Found in lib/npolar/storage/couch.rb - About 1 hr to fix

          Method post has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def post(data, params={})
                  #unless valid? data
                  #  raise Exception
                  #end
          
          
          Severity: Minor
          Found in lib/npolar/storage/couch.rb - About 1 hr to fix

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

                  def feed(params={})
                    response = couch.get(all_docs_uri(true))
            
                    if 200 == response.status
            
            
            Severity: Minor
            Found in lib/npolar/storage/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

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

                  def fetch(id,key=nil)
            
                    begin
                
                      status, headers, jsonstring = get(id)
            Severity: Minor
            Found in lib/npolar/storage/couch.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 put has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def put(id, data, params={})
            
                    if data.is_a? Hash
                      data = data.to_json
                    end
            Severity: Minor
            Found in lib/npolar/storage/couch.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