npolar/api.npolar.no

View on GitHub
lib/npolar/rack/placename_inspire_feed.rb

Summary

Maintainability
D
1 day
Test Coverage

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 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 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 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 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 atom_entry has 30 lines of code (exceeds 25 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

            Consider simplifying this complex logical expression.
            Open

                    if (placename.key?(:reference) and placename[:reference].size > 0) or (placename.key?(:proposer) and placename[:proposer].size > 0)
                      from = ([placename[:proposer]]||[]+placename[:reference]||[]).uniq.join(", ")
                      if from != ""
                        source_of_name.content += "; from #{from}"
                      end
            Severity: Major
            Found in lib/npolar/rack/placename_inspire_feed.rb - About 40 mins to fix

              Method gn_named_place has a Cognitive Complexity of 6 (exceeds 5 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 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

              There are no issues that match your filters.

              Category
              Status