npolar/api.npolar.no

View on GitHub

Showing 206 of 227 total issues

Method initialize has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(api, config={})

        @config = Hashie::Mash.new(config)
        @app = ::Rack::Builder.new do
          map "/" do
Severity: Minor
Found in lib/npolar/api/json.rb - About 1 day 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 fq has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
Open

      def fq

        # config[:fq] should contain a lambda that will extract fq from a request
        if config[:fq].respond_to?(:call)
          config_fq = config[:fq].call(request)
Severity: Minor
Found in lib/npolar/rack/solrizer.rb - About 1 day 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

File dif_transformer.rb has 529 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "hashie"
require "uuidtools"
require "uri"
require "gcmd"

Severity: Major
Found in lib/metadata/dif_transformer.rb - About 1 day to fix

    File dif_hashifier.rb has 517 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "uri"
    
    module Metadata
    
      # GCMD [DIF Hash](https://github.com/npolar/gcmd/blob/master/lib/gcmd/dif.rb) from [Npolar API dataset](http://api.npolar.no/schema/dataset)
    Severity: Major
    Found in lib/metadata/dif_hashifier.rb - About 1 day to fix

      Class DifTransformer has 56 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class DifTransformer
          include ::Npolar::Api
      
          BASE = "http://api.npolar.no/dataset/"
      
      
      Severity: Major
      Found in lib/metadata/dif_transformer.rb - About 1 day to fix

        Method doi has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
        Open

          def doi
            lambda {|d|
        
              doi = self.class.doi(d) # remember: a different doi may be registered for various reasons, see line #240
              dataset_is_updated_after_doi = false
        Severity: Minor
        Found in migration/dataset/dataset_doi.rb - About 7 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

        Class Index has 51 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class Index < Npolar::Mustache::JsonView
        
              # Coming APIs: Tracking, Monitoring, Placenames,Ecotox
        
              def initialize(app=nil, hash={})
        Severity: Major
        Found in views/api/index.rb - About 7 hrs to fix

          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

            File solrizer.rb has 411 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require "time"
            module Npolar
            
              module Rack
            
            
            Severity: Minor
            Found in lib/npolar/rack/solrizer.rb - About 5 hrs to fix

              Method hashi has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                def hashi
                  lambda {|d|
              
                    d.title = d.title.strip
                    begin
              Severity: Minor
              Found in migration/dataset/dataset_doi.rb - About 5 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 run has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                    def run(really=false)
                      log.info "#{self.class.name}#run #{uri} [Migrations: #{migrations.size}] --really=#{really}"
                      log.debug "Migrations: #{migrations}"
              
                      # 1. Get (all) documents
              Severity: Minor
              Found in lib/npolar/api/migrator.rb - About 5 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 find has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

                  def find(selector, options={})
              
                    if :all == selector
              
                      storage.param = {"include_docs" => true}
              Severity: Minor
              Found in lib/metadata/oai_dumb_couchdb_model.rb - About 4 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

              Class Solrizer has 36 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class Solrizer < Npolar::Rack::Middleware
              
                    YEAR_REGEX = /^([-])?\d{4,}/
                    DATE_REGEX = /(-)?(\d{4,})-(0[1-9]|1[0-2])-([12]\d|0[1-9]|3[01])/
                    ISODATE_REGEX = /^#{DATE_REGEX}$/
              Severity: Minor
              Found in lib/npolar/rack/solrizer.rb - About 4 hrs to fix

                Class DifHashifier has 36 methods (exceeds 20 allowed). Consider refactoring.
                Open

                  class DifHashifier < Hashie::Mash
                
                    # Map [topics](http://api.npolar.no/schema/npolar_topic)to DIF Parameters (Science Keywords)
                    # DIF Parameters: http://api.npolar.no/gcmd/concept/?q=&filter-concept=sciencekeywords
                    # The main trouble is that 3 levels (down to Topic) are required by DIF - impossible for just "biology"/"geology"/"atmosphere"
                Severity: Minor
                Found in lib/metadata/dif_hashifier.rb - About 4 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 edit has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def edit(request, response)
                            if not config[:edit].nil?
                              return config[:edit].call(edit)
                            end
                    
                    
                    Severity: Minor
                    Found in lib/npolar/rack/edit_log.rb - About 4 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 call has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def call(env)
                        request = Npolar::Rack::Request.new(env)
                    
                        if "json" == request.format
                          if request["q"].nil?
                    Severity: Minor
                    Found in lib/npolar/mustache/json_view.rb - About 4 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 decode_sensor_data has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def decode_sensor_data
                    
                        # For Argos data data prior to 2014-03-01 (DS/DIAG data) the sensor data may either integer or hex
                        # Argos data from 2014-03-01 and onwards (XML from SOAP web service) contain both integer and hex data,
                        # as well as platform_model string
                    Severity: Minor
                    Found in lib/tracking.rb - About 4 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 initialize has 100 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def initialize(api, config={})
                    
                            @config = Hashie::Mash.new(config)
                            @app = ::Rack::Builder.new do
                              map "/" do
                    Severity: Major
                    Found in lib/npolar/api/json.rb - About 4 hrs to fix

                      Method edit has 99 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def edit(request, response)
                              if not config[:edit].nil?
                                return config[:edit].call(edit)
                              end
                      
                      
                      Severity: Major
                      Found in lib/npolar/rack/edit_log.rb - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language