Showing 16 of 16 total issues
Method update_sources
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def update_sources(opml_file)
document = Nokogiri::XML.parse(opml_file.source)
outlines = document.search('outline')
if outlines.count ==0
@log << t('no_entries_found')
- 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 run
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def run
sources.each do |source|
doc = nil
begin
doc = Nokogiri::XML.parse(open(source.url))
- 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 validate_each
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
return if value.length == 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"
Further reading
Method check_validity!
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def check_validity!
keys = CHECKS & options.keys
if keys.empty?
raise ArgumentError, 'Patterns unspecified. Specify the :content_type option.'
- 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 merge_urls_to_podcast
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def merge_urls_to_podcast(urls)
sources = []
missing = []
main = nil
urls.each do |url|
Method by_episode_title
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.by_episode_title(limit: 50, modus: :auto)
all = Episode.joins(:source).group('episodes.title').where('length(title) > 12').having('count(distinct podcast_id) > 1').pluck('title, array_agg(distinct podcast_id)').map{|title, podcast_ids| [title, podcast_ids.sort ]}.select{|t,_| t.present? and t.length > 11 }
descending = all.group_by{|t,p| p}.map{|p, ps| [p, ps.count]}.select{|p,c| c >= limit }.sort_by{|p,c| -c}
j = 0
Method update_podcast_meta_information
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_podcast_meta_information(podcast)
podcast.title ||= parsed_feed.title if parsed_feed.title
podcast.description ||= take_first(parsed_feed, [:itunes_summary, :description, :title]).strip rescue nil
text = ActionController::Base.new.view_context.strip_tags [ parsed_feed.entries.map(&:summary), podcast.description, podcast.title].join('. ')
podcast.language = text.language
- 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 update_entries
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def update_entries
parsed_feed.entries.each do |entry|
guid = entry.respond_to?(:entry_id) ? entry.entry_id : entry.guid
if guid.blank?
guid = entry.published && entry.published.to_s
- 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 by_episode_title
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.by_episode_title(limit: 50, modus: :auto)
all = Episode.joins(:source).group('episodes.title').where('length(title) > 12').having('count(distinct podcast_id) > 1').pluck('title, array_agg(distinct podcast_id)').map{|title, podcast_ids| [title, podcast_ids.sort ]}.select{|t,_| t.present? and t.length > 11 }
descending = all.group_by{|t,p| p}.map{|p, ps| [p, ps.count]}.select{|p,c| c >= limit }.sort_by{|p,c| -c}
j = 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"
Further reading
Method merge_urls_to_podcast
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def merge_urls_to_podcast(urls)
sources = []
missing = []
main = nil
urls.each do |url|
- 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 do_validation
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def do_validation(value, pattern, key, record, attribute)
Method current_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def current_user(create=false)
owner = if params[:token]
Owner.where(token: params[:token]).first
elsif session[:owner_id]
Owner.find(session[:owner_id])
- 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 check_redirect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_redirect
if source.url != parsed_feed.feed_url
parent = Source.where(url: parsed_feed.feed_url).first_or_initialize
parent.podcast ||= source.podcast
parent.save
- 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 do_validation
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def do_validation(value, pattern, key, record, attribute)
return if value.file.content_type.send((pattern.is_a?(String) ? "==" : "=~" ), pattern)
errors_options = options.except(*RESERVED_OPTIONS)
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
can [:show], OpmlFile
can [:index, :show], Source
if user && user.opml_files.count > 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"
Further reading
Method badges
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def badges
b = []
if active? and !offline?
b << :active
elsif active == false and !offline?
- 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"