npolar/api.npolar.no

View on GitHub

Showing 227 of 227 total issues

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

  def self.feed(response, request)
    facets = {}

    base = request.path.gsub(/\/$/, "")+"/"
    
Severity: Minor
Found in lib/npolar/api/solr_feed_writer.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 xml_from_json has a Cognitive Complexity of 20 (exceeds 5 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 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_save has a Cognitive Complexity of 20 (exceeds 5 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 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 kernel has 68 lines of code (exceeds 25 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: Major
Found in lib/metadata/datacite_xml.rb - About 2 hrs to fix

    Method to_hash has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def to_hash
    
            unless gcmd?
              self[:gcmd]=Hashie::Mash.new
            end
    Severity: Major
    Found in lib/metadata/dif_hashifier.rb - About 2 hrs to fix

      Method find has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def find(selector, options={})
      
            if :all == selector
      
              storage.param = {"include_docs" => true}
      Severity: Major
      Found in lib/metadata/oai_dumb_couchdb_model.rb - About 2 hrs to fix

        Method geojson_feature_collection has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.geojson_feature_collection(response,request, lat_field="latitude", long_field="longitude", geometry="Point")
            if not ["Point", "LineString"].include? geometry
              raise ArgumentError, "Unsupported GeoJSON geometry type: #{geometry}"
            end
            feed = feed(response, request)["feed"].reject {|k,v| k =~ /^entries/}
        Severity: Minor
        Found in lib/npolar/api/solr_feed_writer.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 new_sets has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def new_sets
              lambda {|d|
                if d.sets?
                  if d.sets.any? {|set| set =~ /^(nmdc|gcmd|ipy)$/ui }
                    d.sets = d.sets.reject {|set| set =~ /dokipy/ui }
        Severity: Minor
        Found in migration/dataset/dataset_migration4.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 activity has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def activity
              periods = []
              object.Temporal_Coverage.each do | period |
        
                start = ""
        Severity: Minor
        Found in lib/metadata/dif_transformer.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 atom_entry has 64 lines of code (exceeds 25 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: Major
        Found in lib/metadata/rack/dif_jsonizer.rb - About 2 hrs to fix

          Method fq has 63 lines of code (exceeds 25 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: Major
          Found in lib/npolar/rack/solrizer.rb - About 2 hrs to fix

            Method atom_feed has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def atom_feed   
                    atom_entries = @json_feed[:entries].map {|placename|
                      atom_entry(placename)
                    }
                    
            Severity: Major
            Found in lib/npolar/rack/placename_inspire_feed.rb - About 2 hrs to fix

              Method parse_preamble has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_preamble(input, map=PREAMBLE_KEY_MAP)
              
                    @headers_row = nil
                    h = { preamble: {}}
              
              
              Severity: Minor
              Found in external/telonics.com/lib/telonics/telonics_condensed_csv_parser.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 doi has 58 lines of code (exceeds 25 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: Major
              Found in migration/dataset/dataset_doi.rb - About 2 hrs to fix

                Method locations_as_object has a Cognitive Complexity of 17 (exceeds 5 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 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 related_url has a Cognitive Complexity of 17 (exceeds 5 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 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 data_set_citation has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def data_set_citation
                      if gcmd.citation? and gcmd.citation.any?
                        return gcmd.citation
                      end
                
                
                Severity: Minor
                Found in lib/metadata/dif_hashifier.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 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 location_fixer has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def location_fixer(locations)
                      fixed = []
                  
                      fixed += locations.select {|l| l=~ /Svalbard/ui }.map {|l|
                        placename = l.split("-").last.strip   
                  Severity: Major
                  Found in migration/publication/publication_migration0.rb - About 2 hrs to fix

                    Method location has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def location
                          location =  gcmd.locations? ? gcmd.locations  : []
                    
                          polar = {"Location_Category" => "GEOGRAPHIC REGION", "Location_Type" => "POLAR"}
                          arctic = {"Location_Category" => "GEOGRAPHIC REGION", "Location_Type" => "ARCTIC"}
                    Severity: Major
                    Found in lib/metadata/dif_hashifier.rb - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language