npolar/api.npolar.no

View on GitHub

Showing 206 of 227 total issues

Method next_deployment_after_measured has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def next_deployment_after_measured
    measured = Time.parse(self[:measured]||self[:positioned])
    
    # Simple case first: measured is after deployed and before terminated    
    if idx = deployments.find_index { |d|
Severity: Minor
Found in lib/tracking.rb - About 35 mins 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 dcat_catalog_response has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def dcat_catalog_response(request)

        response = app.call(request.env)

        status = response.is_a?(Array) ? response[0] : response.status
Severity: Minor
Found in lib/metadata/rack/dcat.rb - About 35 mins 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 parameters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def parameters
      parameters = gcmd.sciencekeywords? ? gcmd.sciencekeywords : []
      parameters += topics.map {|topic| self.class.dif_Parameter(topic) }
      parameters = parameters.uniq

Severity: Minor
Found in lib/metadata/dif_hashifier.rb - About 35 mins 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 condition? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def condition?( request )
        # GET
        if (FORMATS.include? request.format or request.content_type =~ /application\/xml/) and "GET" == request.request_method
          true
        # POST, PUT
Severity: Minor
Found in lib/metadata/rack/dif_jsonizer.rb - About 35 mins 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 guess_topic_from_title has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def guess_topic_from_title(title)
      if title =~ /geology|geological/i
        "geology"
      elsif title =~ /bird|reindeer|fauna|ecology|faeces|fox|seal|walrus|vegetation|population dynamics|lichen/i
        "biology"
Severity: Minor
Found in lib/metadata/dif_transformer.rb - About 35 mins 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

Avoid too many return statements within this method.
Open

          return http_error(422, errors)
Severity: Major
Found in lib/npolar/api/core.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return http_error(415, "Unsupported: #{request.media_type}. Acceptable POST/PUT media types are: '#{accepts.join(", ")}'")
    Severity: Major
    Found in lib/npolar/api/core.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                return http_error(400, "#{request.request_method} document with no body")
      Severity: Major
      Found in lib/npolar/api/core.rb - About 30 mins to fix

        Method accept_format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def accept_format
                return "" if env['HTTP_ACCEPT'].nil?
          
                format = env['HTTP_ACCEPT'].scan(/[^;,\s]*\/[^;,\s]*/)[0].split("/")[1]
                
        Severity: Minor
        Found in lib/npolar/rack/request.rb - About 25 mins 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 authenticated? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def authenticated?
                begin
                  if config[:authenticated?].is_a? Proc
                    config[:authenticated?].call(auth, request)
                  else
        Severity: Minor
        Found in lib/npolar/rack/authorizer.rb - About 25 mins 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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def before(request)
        
              before = config[:before]||[]
              if storage.respond_to? :model and storage.model.class.respond_to? :before
                before << storage.model.class.before
        Severity: Minor
        Found in lib/npolar/api/core.rb - About 25 mins 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 force_schema has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def force_schema
            lambda {|d|
              d.schema = "http://api.npolar.no/schema/publication-1"
              if not d.topics?
                d.topics = ["other"]
        Severity: Minor
        Found in migration/publication/publication_migration5.rb - About 25 mins 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 remove_positions_and_source_from_root has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def remove_positions_and_source_from_root
            lambda {|d|
              if d.latitude?
                d.delete :latitude
              end
        Severity: Minor
        Found in migration/polar-bear/polarbear_incident_migration0.rb - About 25 mins 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 id has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def id
          
                id = path_info.split("/")[1]
        
                # Fix for /path/id.with.dot like /person/full.name - where format is "json" (derived from either Accept or Content-Type)
        Severity: Minor
        Found in lib/npolar/rack/request.rb - About 25 mins 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 fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def fetch(id,key=nil)
        
                begin
            
                  status, headers, jsonstring = get(id)
        Severity: Minor
        Found in lib/npolar/storage/couch.rb - About 25 mins 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 options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def options
              # OK <- An Allow header field MUST be present in a 405 (Method Not Allowed) response.
              # @todo <- If the Request-URI is an asterisk ("*"), the OPTIONS request is intended to apply to the server in general rather than to a specific resource.
              # OK <- If no response body is included, the response MUST include a Content-Length field with a field-value of "0".
              
        Severity: Minor
        Found in lib/npolar/api/core.rb - About 25 mins 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 6 (exceeds 5 allowed). Consider refactoring.
        Open

                    def parse(data)
                        docs = []
        
                        fields = data["head"]["fields"]
                        values = data["data"]
        Severity: Minor
        Found in lib/npolar/rack/bouvet_data_logger.rb - About 25 mins 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 authorized? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def authorized?
                begin
                  if config[:authorized?].is_a? Proc
                    config[:authorized?].call(auth, system, request)
                  else
        Severity: Minor
        Found in lib/npolar/rack/authorizer.rb - About 25 mins 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 is_doi_metadata_changed? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def is_doi_metadata_changed? d,k
            if not k.respond_to? :xpath
              log.warn "No existing kernel provided for #{d.id}"
              return true
            end
        Severity: Minor
        Found in migration/dataset/dataset_doi.rb - About 25 mins 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 format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def format
           
                # If &format= is present we let that win
                if params.size > 0 and params.key?("format")
                  format = params["format"]
        Severity: Minor
        Found in lib/npolar/rack/request.rb - About 25 mins 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