npolar/api.npolar.no

View on GitHub

Showing 206 of 227 total issues

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

  def simple_fixes
    lambda {|d|
      
      d.schema = "http://api.npolar.no/schema/publication-1.0-rc4"
      unless d.publication_lang?
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 add_edit_and_alternate_links has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def add_edit_and_alternate_links
      api = ENV["NPOLAR_API"] ||= "https://api.npolar.no"

      self[:links] = links||[]

Severity: Minor
Found in lib/metadata/dataset.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 to_solr has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def self.to_solr
      lambda {|doc| # Hash with symbolized keys

        # Force workspace/collection
        doc[:workspace] = "biology"
Severity: Minor
Found in lib/biology/sighting.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 gn_named_place has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def gn_named_place(placename)
        
        id = uuid(placename[:ident]) # @todo check if placename id is uuid or uri 
        latitude = placename[:latitude] || placename[:north] || 0.0
        longitude = placename[:longitude] || placename[:east] || 0.0
Severity: Minor
Found in lib/npolar/rack/placename_inspire_feed.rb - About 1 hr to fix

    Method gn_name has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def gn_name(placename)
            # gn:name
            name = node "gn:name"
            
            # gn:GeographicalNames
    Severity: Minor
    Found in lib/npolar/rack/placename_inspire_feed.rb - About 1 hr to fix

      Method links has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def links
            links = []
      
            # 1. Related_URL
            if dif.Related_URL?
      Severity: Minor
      Found in lib/metadata/dif_transformer.rb - About 1 hr to fix

        Method domain_name_from_name has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def domain_name_from_name(name)
        
              case name.strip
                when "University of Innsbruck, Institute of Meteorology and Geophysics"
                  "imgi.uibk.ac.at"
        Severity: Minor
        Found in migration/dataset/dataset_migration1.rb - About 1 hr to fix

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

            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 atom_feed_builder has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                  def atom_feed_builder(feed)
                    feed_builder = Atom::Feed.new do |f|
                          f.title = "Norwegian Polar Data #{request["q"]}"
                          f.links << Atom::Link.new(:href => request.url, :rel => "self")
                          f.links << Atom::Link.new(:href => "NEXT", :rel => "next")
            Severity: Minor
            Found in lib/npolar/rack/atomizer.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 doi has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              def doi
                lambda {|d|
                  if d.links? and not d.doi
                    dois = d.links.select {|l| l["rel"] =~ /doi/i }
                    if dois.any?
            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 data_link has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              def data_link
                lambda {|d|
            
                  if not d.links?
                    d.links = []
            Severity: Minor
            Found in migration/dataset/dataset_doi.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 gn_name has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                  def gn_name(placename)
                    # gn:name
                    name = node "gn:name"
                    
                    # gn:GeographicalNames
            Severity: Minor
            Found in lib/npolar/rack/placename_inspire_feed.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 parse has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse(data)
            
                    # convert to utf-8
                    data_utf8 = data.encode('UTF-8', :invalid => :replace, :replace => "")
            
            
            Severity: Minor
            Found in lib/npolar/rack/zeppelin_tsv_parser.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 fix_changes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def fix_changes
                  lambda {|d|
                    if idx = @@changes.index {|a| a.any? {|c| c.key? "id" and c["id"] == d.id } }
                      d[:changes] = @@changes[idx].map {|c|
                        { email: c["email"], name: c["name"], datetime: c["datetime"], comment: c["comment"] }
            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 xml_from_json has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def xml_from_json(request)
            
                    response = app.call(request.env)
            
                    if response.status < 300
            Severity: Minor
            Found in lib/metadata/rack/dif_jsonizer.rb - About 1 hr to fix

              Method atom_entry has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                    def atom_entry(placename)
                      placename = Hashie::Mash.new(placename) #Placename.new(placename)
                      entry = ::Atom::Entry.new do |e|
                        uuid = placename.id =~ /^\w{8}[-]\w{4}-\w{4}-\w{4}-\w{12}$/ ?  placename.id : uuid(placename.ident)
                        e.id = "http://api.npolar.no/placename/#{uuid}"
              Severity: Minor
              Found in lib/npolar/rack/placename_inspire_feed.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 handle_search has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                    def handle_search(request)
                      log.debug self.class.name+"#handle_search #{uri} #{solr_params}"
                      begin
                        
                        #fq_bbox = []
              Severity: Minor
              Found in lib/npolar/rack/solrizer.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 after has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def after(request, response)
                    
                    # Force response to Rack::Response   
                    if response.is_a? Rack::Response
                      headers = response.headers
              Severity: Minor
              Found in lib/npolar/api/core.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 links has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def links
                    links = []
              
                    # 1. Related_URL
                    if dif.Related_URL?
              Severity: Minor
              Found in lib/metadata/dif_transformer.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