Showing 67 of 122 total issues
Method export
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.export(user)
# Compose the OPML file (actually XML)
feeds_outside_folders = user.folder_feeds Folder::NO_FOLDER, include_read: true
# Sort feeds by title, mainly for easier testing
feeds_outside_folders.sort_by!{|a| a.title}
Method fix_encoding
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.fix_encoding(feed_response)
return nil if feed_response.nil?
# Detect encoding from HTTP content-type header, in case RestClient has detected the wrong encoding
headers = feed_response.try :headers
- 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 entry_to_hash
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.entry_to_hash(entry, guid)
# Some feed parser types do not give a "content" attribute to their entries. In
# this case we default to the entry summary.
if entry.respond_to? :content
content = entry.content
- 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 folder_entries
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.folder_entries(folder, user, include_read: false, page: nil)
if folder == Folder::ALL_FOLDERS
if include_read && !page.present?
entries = user.entries.order 'entries.published desc, entries.created_at desc, entries.id desc'
elsif include_read && page.present?
- 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 handle_error
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def handle_error(error)
if error.is_a? ActiveRecord::RecordNotFound
head 404
elsif error.is_a? AlreadySubscribedError
# If user is already subscribed to the feed, return 304
- 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 reset_folders
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def reset_folders(demo_user)
already_existing_default_folders = []
not_existing_default_folders = []
# Find out which folders are already created and which ones are not
- 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 index
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def index
@include_read = param_str_to_boolean :include_read, params
if params[:feed_id].present?
index_feed
- 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 show
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def show
@subscription = FeedSubscription.find_by user_id: current_user.id, feed_id: params[:id]
if @subscription.present?
# If feed subscription has not changed, return a 304
- 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 feed_schedule_count
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.feed_schedule_count(feed_id, queued_ids, scheduled_ids, retry_ids, worker_ids)
Method up
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def up
rename_column :entries, :content_hash, :unique_hash
change_column_default :entries, :unique_hash, ''
remove_index :entries, name: "index_entries_on_guid_feed_id"
add_index :entries, [:feed_id, :unique_hash, :guid], name: 'index_feedid_guid_hash_on_entries'
- 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 convert
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.convert(code, locale)
if code.chr =~ /^[[:alnum:]]$/
str = code.chr
else
unless I18n.available_locales.include? locale
- 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 show
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def show
@folder = current_user.folders.find params[:id]
if @folder.present?
# If folder has not changed, return a 304
- 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 refresh
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.refresh(feed, user)
# If feed has never fetched, refresh it.
if feed.last_fetched.blank?
refresh_feed = true
else
- 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 default_attribute_values
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def default_attribute_values
# GUID defaults to the url attribute
self.guid = self.url if self.guid.blank?
# title defaults to the url attribute
- 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 notify_error
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.notify_error(user, error=nil)
# If an exception is raised, set the import process state to ERROR
if user.present?
user.create_opml_import_job_state if user.opml_import_job_state.blank?
user.opml_import_job_state.update state: OpmlImportJobState::ERROR
- 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 perform
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def perform(user_id)
# Check if the user actually exists
if !User.exists? user_id
Rails.logger.error "Trying to export OPML file for non-existing user #{user_id}"
return
- 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 index
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def index
# If subscribe job states have not changed, return a 304
if stale? etag: EtagCalculator.etag(current_user.subscribe_jobs_updated_at),
last_modified: current_user.subscribe_jobs_updated_at
if SubscribeJobState.exists? user_id: current_user.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 index
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def index
# If refresh feed job states have not changed, return a 304
if stale? etag: EtagCalculator.etag(current_user.refresh_feed_jobs_updated_at),
last_modified: current_user.refresh_feed_jobs_updated_at
if RefreshFeedJobState.exists? user_id: current_user.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
Avoid too many return
statements within this method. Open
return nil
Method update_config
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_config(show_main_tour: nil, show_mobile_tour: nil, show_feed_tour: nil, show_entry_tour: nil,
show_kb_shortcuts_tour: nil)
new_config = {}
new_config[:show_main_tour] = show_main_tour if !show_main_tour.nil?
new_config[:show_mobile_tour] = show_mobile_tour if !show_mobile_tour.nil?
- 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"