Showing 122 of 122 total issues
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def show
if OpmlExportJobState.exists? user_id: current_user.id
@opml_export_job_state = OpmlExportJobState.find_by user_id: current_user.id
else
Rails.logger.warn "User #{current_user.id} - #{current_user.email} has no OpmlExportJobState, creating one with state NONE"
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 77.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def show
if OpmlImportJobState.exists? user_id: current_user.id
@opml_import_job_state = OpmlImportJobState.find_by user_id: current_user.id
else
Rails.logger.warn "User #{current_user.id} - #{current_user.email} has no OpmlImportJobState, creating one with state NONE"
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 77.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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"
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.send_second_confirmation_reminders
signups_older_than = Time.zone.now - Feedbunch::Application.config.second_confirmation_reminder_after
Rails.logger.info "Sending second confirmation reminder to unconfirmed users signed up before #{signups_older_than}"
old_unconfirmed_signups = User.
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 66.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.send_first_confirmation_reminders
signups_older_than = Time.zone.now - Feedbunch::Application.config.first_confirmation_reminder_after
Rails.logger.info "Sending first confirmation reminder to unconfirmed users signed up before #{signups_older_than}"
old_unconfirmed_signups = User.
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 66.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
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