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"
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)
}
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
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
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
- Read upRead up
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}"
- Read upRead up
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}"
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
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
- Read upRead up
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"