Showing 67 of 122 total issues
Method fetch_feed
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.fetch_feed(url)
Rails.logger.info "URL #{url} belongs to a Tumblr domain possibly with a GDPR interstitial page, using a full browser to fetch it"
if Feedbunch::Application.config.headless_browser_location == 'remote'
Rails.logger.info "Using a remote browser in host #{Feedbunch::Application.config.headless_browser_host}, port #{Feedbunch::Application.config.headless_browser_port}"
Method default_fetch
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.default_fetch(url, http_caching)
if http_caching
Rails.logger.info "Fetching URL #{url} using HTTP caching if possible"
RestClient.enable Rack::Cache,
verbose: false,
Method folder_feeds
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.folder_feeds(folder, user, include_read: false)
if folder == Folder::NO_FOLDER
feeds = Feed.arel_table
folders = Folder.arel_table
feed_subscriptions = FeedSubscription.arel_table
Method reset_feed_subscriptions
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reset_feed_subscriptions(demo_user)
already_subscribed_default_feeds = []
not_subscribed_default_feeds = []
Feedbunch::Application.config.demo_subscriptions.keys.each do |folder|
Method perform
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def perform(opml_import_job_state_id, url, folder_id=nil)
# Check if the opml import state actually exists
if !OpmlImportJobState.exists? opml_import_job_state_id
Rails.logger.error "Trying to perform ImportSubscriptionWorker as part of non-existing job state #{opml_import_job_state_id}. Aborting"
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 import_feed
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_feed(user, url)
Rails.logger.info "As part of OPML import, subscribing user #{user.id} - #{user.email} to feed #{url}"
feed = user.subscribe url
return feed
rescue AlreadySubscribedError => e
Method save_new_entries
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.save_new_entries(feed, entries, encoding)
entries.reverse_each do |entry_parsed|
begin
guid = entry_parsed.entry_id || entry_parsed.url
Method process_opml
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.process_opml(filename, user)
# Open file and check if it actually exists
xml_contents = Feedbunch::Application.config.uploads_manager.read user.id, FOLDER, filename
if xml_contents == nil
Rails.logger.error "Trying to import for user #{user.id} from non-existing OPML file: #{filename}"
Method normalize_entry_url
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.normalize_entry_url(url, entry)
# Check that the passed string contains something
return nil if url.blank?
normalized_url = strip_url url
Consider simplifying this complex logical expression. Open
if saved_change_to_quick_reading? || saved_change_to_open_all_entries? ||
saved_change_to_show_main_tour? || saved_change_to_show_mobile_tour? ||
saved_change_to_show_feed_tour? || saved_change_to_show_entry_tour? ||
saved_change_to_show_kb_shortcuts_tour? || saved_change_to_kb_shortcuts_enabled?
update_column :config_updated_at, Time.zone.now
Method discover
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.discover(feed, feed_response)
Rails.logger.info "Trying to perform feed autodiscovery on url #{feed.fetch_url}"
doc = Nokogiri::HTML feed_response
# In this order, give preference to Atom, then to RSS, then to generic "feed" links
Method before_save_user
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def before_save_user
self.encrypted_password.encode! 'utf-8'
# If demo is enabled, demo user cannot change email or password nor be locked
if Feedbunch::Application.config.demo_enabled
- 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 class_for_url
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.class_for_url(url, type)
return nil if url.blank?
return nil if type!=HANDLER && type!=FETCHER
# Add uri-scheme if missing, convert to downcase and remove extra whitespaces so that it can be parsed
- 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 change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
change_column_null :active_admin_comments, :created_at, false, Time.zone.now
change_column_null :active_admin_comments, :updated_at, false
add_timestamps :deleted_entries, null: true
Method change
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
remove_foreign_key :deleted_entries, :feeds
remove_foreign_key :entries, :feeds
remove_foreign_key :entry_states, :entries
remove_foreign_key :entry_states, :users
Method perform
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(opml_import_job_state_id, url, folder_id=nil)
# Check if the opml import state actually exists
if !OpmlImportJobState.exists? opml_import_job_state_id
Rails.logger.error "Trying to perform ImportSubscriptionWorker as part of non-existing job state #{opml_import_job_state_id}. Aborting"
return
Method fix_scheduled_updates
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.fix_scheduled_updates
Rails.logger.debug 'Fixing scheduled feed updates'
queue = Sidekiq::Queue.new 'update_feeds'
queued_ids = queue.select{|job| job.klass == 'ScheduledUpdateFeedWorker'}.map{|job| job.args[0]}
Method index_feeds
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def index_feeds
if @feeds.present?
# Compose an array; each element is a hash containing the data necessary to render a feed in the JSON response
@feeds_data = []
@feeds.each do |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 folder_feeds
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.folder_feeds(folder, user, include_read: false)
if folder == Folder::NO_FOLDER
feeds = Feed.arel_table
folders = Folder.arel_table
feed_subscriptions = FeedSubscription.arel_table
- 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_fetch
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.default_fetch(url, http_caching)
if http_caching
Rails.logger.info "Fetching URL #{url} using HTTP caching if possible"
RestClient.enable Rack::Cache,
verbose: false,
- 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"