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 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
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'
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 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 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"