Showing 67 of 122 total issues
Method perform
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def perform(refresh_feed_job_state_id, feed_id, user_id)
# Check if refresh_feed_job_state actually exists
job_state = nil
if RefreshFeedJobState.exists? refresh_feed_job_state_id
job_state = RefreshFeedJobState.find refresh_feed_job_state_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 perform
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def perform(feed_id)
# Check that feed actually exists
if !Feed.exists? feed_id
Rails.logger.warn "Feed #{feed_id} scheduled to be updated, but it does not exist in the database. Unscheduling further updates."
ScheduleManager.unschedule_feed_updates feed_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 fetch_valid_feed
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def self.fetch_valid_feed(feed, http_caching, perform_autodiscovery)
if perform_autodiscovery
Rails.logger.info "Performing autodiscovery on feed #{feed.id} - URL #{feed.url}"
url = feed.url
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_values
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
def default_values
# Convert the symbols for the available locales to strings, to be able to compare with the user locale
# NOTE.- don't do the opposite (converting the user locale to a symbol before checking if it's included in the
# array of available locales) because memory allocated for symbols is never released by ruby, which means an
# attacker could cause a memory leak by creating users with weird unavailable locales.
Class User
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
Method perform
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(feed_id)
# Check that feed actually exists
if !Feed.exists? feed_id
Rails.logger.warn "Feed #{feed_id} scheduled to be updated, but it does not exist in the database. Unscheduling further updates."
ScheduleManager.unschedule_feed_updates feed_id
Method save_new_entries
has a Cognitive Complexity of 21 (exceeds 5 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
- 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_values
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def default_values
# Convert the symbols for the available locales to strings, to be able to compare with the user locale
# NOTE.- don't do the opposite (converting the user locale to a symbol before checking if it's included in the
# array of available locales) because memory allocated for symbols is never released by ruby, which means an
# attacker could cause a memory leak by creating users with weird unavailable locales.
- 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 a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def change
Entry.all.find_each do |entry|
begin
entry.title = entry.title.try(:strip) if entry.title != entry.title.try(:strip)
entry.url = entry.url.try(:strip) if entry.url != entry.url.try(:strip)
- 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
File user.rb
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'folder_manager'
require 'url_subscriber'
require 'feed_refresh_manager'
require 'entry_state_manager'
require 'entries_pagination'
Method perform
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def perform(user_id, feed_url, job_state_id)
# Find the SubscribeJobState instance for this job, if it exists
if SubscribeJobState.exists? job_state_id
job_state = SubscribeJobState.find job_state_id
# Check that the subscribe_job_state is in state "RUNNING"
- 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 normalize_entry_url
has a Cognitive Complexity of 18 (exceeds 5 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
- 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 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(refresh_feed_job_state_id, feed_id, user_id)
# Check if refresh_feed_job_state actually exists
job_state = nil
if RefreshFeedJobState.exists? refresh_feed_job_state_id
job_state = RefreshFeedJobState.find refresh_feed_job_state_id
Class Entry
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Entry < ApplicationRecord
LOADING_IMAGE_GIF = '/images/Ajax-loader.gif'
belongs_to :feed
Method convert
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.convert(code, locale)
if code.chr =~ /^[[:alnum:]]$/
str = code.chr
else
unless I18n.available_locales.include? locale
Method change_entries_state
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.change_entries_state(entry, state, user, whole_feed: false, whole_folder: false, all_entries: false)
if state == 'read'
read = true
elsif state == 'unread'
read = 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"
Further reading
Method reset_feed_subscriptions
has a Cognitive Complexity of 14 (exceeds 5 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|
- 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 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(user_id, feed_url, job_state_id)
# Find the SubscribeJobState instance for this job, if it exists
if SubscribeJobState.exists? job_state_id
job_state = SubscribeJobState.find job_state_id
# Check that the subscribe_job_state is in state "RUNNING"
Method discover
has a Cognitive Complexity of 13 (exceeds 5 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
- 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 fetch_valid_feed
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.fetch_valid_feed(feed, http_caching, perform_autodiscovery)
if perform_autodiscovery
Rails.logger.info "Performing autodiscovery on feed #{feed.id} - URL #{feed.url}"
url = feed.url
else