npolar/api.npolar.no

View on GitHub

Showing 206 of 227 total issues

Method remove_title has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def remove_title
      lambda {|d|
        if not d.first_name? 
          raise "No first name"
        end
Severity: Minor
Found in migration/person/person_migration0.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

Class Dataset has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Dataset < Hashie::Mash

    include Npolar::Validation::MultiJsonSchemaValidator

    BASE = "http://api.npolar.no/dataset/"
Severity: Minor
Found in lib/metadata/dataset.rb - About 3 hrs to fix

    File placename_inspire_feed.rb has 326 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "atom"
    require "yajl"
    require "uuidtools"
    require "nokogiri"
    require "uri"
    Severity: Minor
    Found in lib/npolar/rack/placename_inspire_feed.rb - About 3 hrs to fix

      Method feed has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.feed(response, request)
          facets = {}
      
          base = request.path.gsub(/\/$/, "")+"/"
          
      Severity: Major
      Found in lib/npolar/api/solr_feed_writer.rb - About 3 hrs to fix

        Method handle has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle(request)
              log.debug self.class.name+"#handle #{request.request_method} #{request.url}"
        
              if storage.nil?
                return http_error(501, "No storage set for API endpoint, cannot handle request")
        Severity: Minor
        Found in lib/npolar/api/core.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 before_lambda has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.before_lambda
                lambda {|request|
                  if ["POST", "PUT"].include? request.request_method and "application/json" == request.media_type
                    begin
        
        
        Severity: Minor
        Found in lib/npolar/api/json.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 atom_entry has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

              def atom_entry(metadata_dataset)
                dataset = dataset = Metadata::Dataset.new(metadata_dataset)
                entry = ::Atom::Entry.new do |e|
                  e.id = dataset.id =~ /^\w{8}[-]\w{4}-\w{4}-\w{4}-\w{12}$/ ? "urn:uuid:#{dataset.id}" : dataset.id
        
        
        Severity: Minor
        Found in lib/metadata/rack/dif_jsonizer.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 constantize has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.constantize(camel_cased_word)
              names = camel_cased_word.split('::')
        
              # Trigger a builtin NameError exception including the ill-formed constant in the message.
              #Object.const_get(camel_cased_word) if names.empty?
        Severity: Minor
        Found in lib/npolar/factory.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 download has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            def download(destination, earliest=nil, latest=nil)
              if auth.nil?
                raise ArgumentError, "Please set auth -> Followit::AuthService"
              end
              log.debug "Starting #{auth.username} download of Followit XML to #{destination} [#{ earliest.nil? ? '': "earliest date: #{earliest.to_date}"}]"
        Severity: Minor
        Found in external/followit.se/ruby/lib/followit/tracker_service.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

        File dataset_doi.rb has 308 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require "date"
        require "time"
        require "json"
        require "uri"
        require "open-uri"
        Severity: Minor
        Found in migration/dataset/dataset_doi.rb - About 3 hrs to fix

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

            def self.seed(filename_xml="/mnt/public/Datasets/Skipsregister/xml/Skip.xml")
              nori = Nori.new
              dataroot = nori.parse(File.read(filename_xml))["dataroot"]
                                                                         
              dataroot["Skip"].map {|v|
          Severity: Minor
          Found in lib/historic/vessel.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 after_lambda has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.after_lambda
                  lambda {|request, response|
          
                    # Location header on POST, PUT, DELETE
                    # @todo Absolute URI
          Severity: Minor
          Found in lib/npolar/api/json.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

          File index.rb has 302 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Views
            module Api  
              class Index < Npolar::Mustache::JsonView
          
                # Coming APIs: Tracking, Monitoring, Placenames,Ecotox
          Severity: Minor
          Found in views/api/index.rb - About 3 hrs to fix

            File dataset.rb has 296 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require "hashie"
            require "date"
            
            module Metadata
            
            
            Severity: Minor
            Found in lib/metadata/dataset.rb - About 3 hrs to fix

              Method to_hash has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  def to_hash
              
                      unless gcmd?
                        self[:gcmd]=Hashie::Mash.new
                      end
              Severity: Minor
              Found in lib/metadata/dif_hashifier.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

              File dataset_migration7.rb has 294 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require "logger"
              
              module Metadata
              
                # Schema 1.0.0.pre
              Severity: Minor
              Found in migration/dataset/dataset_migration7.rb - About 3 hrs to fix

                Method indexer has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                      def indexer
                        log.debug "Indexing #{service.search.engine}"
                        case service.search.engine
                          when /Solr/
                            lambda { |changes|
                Severity: Minor
                Found in lib/npolar/api/couchdb_changes_indexer.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 before_valid has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                    def before_valid
                
                      if activity?
                        activity.map {|a|
                          if a.start? and a.start == ""
                Severity: Minor
                Found in lib/metadata/dataset.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 run has 72 lines of code (exceeds 25 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: Major
                Found in lib/npolar/api/migrator.rb - About 2 hrs to fix

                  Method unescape has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def unescape
                        lambda {|d|
                          if d.to_json =~ /\&\#x[\dA-F][\dA-F]/
                            
                            d.each do |k,v|
                  Severity: Minor
                  Found in migration/dataset/dataset_migration6.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

                  Severity
                  Category
                  Status
                  Source
                  Language