npolar/api.npolar.no

View on GitHub

Showing 227 of 227 total issues

Method hashi has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def hashi
    lambda {|d|

      d.title = d.title.strip
      begin
Severity: Minor
Found in migration/dataset/dataset_doi.rb - About 2 hrs to fix

    Method download has 49 lines of code (exceeds 25 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 1 hr to fix

      Method handle has 49 lines of code (exceeds 25 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 1 hr to fix

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

          def fix_conference_dates
            lambda {|d|
              if d.conference? and d.conference.dates? and d.conference.dates.any?
                 d.conference.dates.each_with_index do |dt,idx|
        
        
        Severity: Minor
        Found in migration/publication/publication_migration0.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 set_id_and_gcmd_shortname_for_organisations has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def set_id_and_gcmd_shortname_for_organisations
              lambda {|d|
                if d.organisations? and d.organisations.any?
                  
                  d.organisations.select {|o| o.id.nil? or o.gcmd_short_name.nil? }.each {|o|
        Severity: Minor
        Found in migration/dataset/dataset_migration3.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 link_facet has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def link_facet(field, value, count)
        
                value = value == "" ? "∅" : value
        
                if  filtered?(field,value)
        Severity: Minor
        Found in views/api/index.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 changes_not_edits has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

             def changes_not_edits
              lambda {|d|
                if d.edits?
                  
                  users = d.edits.map {|e| e.email }.uniq
        Severity: Minor
        Found in migration/dataset/dataset_migration6.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 run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def run
        
                buffer = []
        
                param[:slice] = param[:slice].to_i
        Severity: Minor
        Found in lib/npolar/api/couchdb_changes_indexer.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 rename has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def rename
            lambda {|d|
              if not d.published? and d.published_sort?
                #log.warn d.published_helper
                if d.published_sort.nil?
        Severity: Minor
        Found in migration/publication/publication_migration5.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 kernel has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.kernel(dataset,doi)
              publicationYear = (!dataset.released.nil? and dataset.released =~ /^\d{4}-/) ? dataset.released.split("-").first : dataset.created.split("-").first
              publisher = (dataset.organisations||[]).select {|o| o.roles.include? "publisher"}.map {|p| p.id||p.name }.join(", ")
              creators = (dataset.people||[]).select {|p| p.roles.include? "author"}.map {|p| {
                  creatorName: "#{p.last_name}, #{p.first_name}",
        Severity: Minor
        Found in lib/metadata/datacite_xml.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 seed has 47 lines of code (exceeds 25 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 1 hr to fix

          Method data_center has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def data_center
                data_center = (organisations||[]).reject {|o| not o.gcmd_short_name or o.gcmd_short_name.to_s == "" }.select {|o|
                  o.roles.include?("owner") or o.roles.include?("resourceProvider") or o.roles.include?("publisher")
                }.map {|o|
          
          
          Severity: Minor
          Found in lib/metadata/dif_hashifier.rb - About 1 hr to fix

            Method indexer has 45 lines of code (exceeds 25 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 1 hr to fix

              Method GeoJSON has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def GeoJSON(opts={ })
              
                    features = parse
              
                    features = features.select {|m|
              Severity: Minor
              Found in external/telonics.com/lib/telonics/telonics_condensed_csv_parser.rb - About 1 hr to fix

                Method related_url has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def related_url
                
                      typer = lambda {|type| case type
                        when "dataset", "data"
                          "GET DATA"
                Severity: Minor
                Found in lib/metadata/dif_hashifier.rb - About 1 hr to fix

                  Method locations_as_object has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def locations_as_object
                      lambda {|d|
                  
                        if d.locations? and d.locations.any? and d.locations.all? {|l| l.is_a? String }
                          log.info d.title.to_json
                  Severity: Minor
                  Found in migration/publication/publication_migration0.rb - About 1 hr to fix

                    Method before_save has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def before_save(request=nil)
                            username = request.nil? ? "anonymous" : request.username
                    
                            self[:collection] = "dataset"
                    
                    
                    Severity: Minor
                    Found in lib/metadata/dataset.rb - About 1 hr to fix

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

                        def force_country
                          lambda {|d|
                           if d.locations? and d.locations.any?
                              d.locations.each do |l|
                                if l.country.nil? or l.country.to_s == ""
                      Severity: Minor
                      Found in migration/publication/publication_migration0.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 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 add_past_edits has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def add_past_edits
                      
                          lambda {|d|
                      
                      
                      
                      Severity: Minor
                      Found in migration/dataset/dataset_migration1.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

                      Severity
                      Category
                      Status
                      Source
                      Language