Showing 213 of 251 total issues
Class User
has 74 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ApplicationRecord
# Virtual attribute, which can be used in member lists to add a note in memory when the user
# has joined a group or list.
#
Method country_codes_3_letters_from_2_letters
has 254 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.country_codes_3_letters_from_2_letters
{
"AD" => "AND",
"AE" => "ARE",
"AF" => "AFG",
File schema.rb
has 588 lines of code (exceeds 250 allowed). Consider refactoring. Open
ActiveRecord::Schema.define(version: 20200917171018) do
create_table "activities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
t.string "trackable_type"
t.integer "trackable_id"
Method index
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
def index
authorize! :index, Event
respond_to do |format|
format.html do
- 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 initialize
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
def initialize(address_labels, options = {title: '', updated_at: Time.zone.now, sender: '', book_rate: false})
super(page_size: 'A4', top_margin: 0.mm, bottom_margin: 0.mm, left_margin: 0.mm, right_margin: 0.mm)
@document_title = options[:title]
@document_updated_at = options[:updated_at]
- 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 <<
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
def <<(object)
begin
if object.kind_of? User
raise RuntimeError 'Users can only be assigned to groups.' unless self.kind_of? Group
self.assign_user(object) unless self.child_users.include? object
- 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 ability.rb
has 401 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Ability
include CanCan::Ability
def ability_classes
[
Method initialize
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user, options = {})
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # guest user (not logged in)
# if user.admin?
- 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 381 lines of code (exceeds 250 allowed). Consider refactoring. Open
class User < ApplicationRecord
# Virtual attribute, which can be used in member lists to add a note in memory when the user
# has joined a group or list.
#
Method user_params
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def user_params
permitted_keys = []
if @user
permitted_keys += [:avatar, :remove_avatar, :avatar_background] if can? :update, @user
unless params[:user].try(:[], :avatar).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
File icon_helper.rb
has 378 lines of code (exceeds 250 allowed). Consider refactoring. Open
module IconHelper
def icon(icon_key)
if icon_key.to_s.in? ['beer', 'coffee', 'key', 'lock', 'unlock', 'unlock-alt', 'archive', 'undo', 'history', 'folder-open', 'sort-alpha-asc', 'sort-numeric-asc', 'sort-numeric-desc']
awesome_icon(icon_key)
Method search
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def search(query, limit: 10000, current_user: nil)
if current_user
result = search_in_my_groups(query, user: current_user)
result = search_in_my_corporations(query, user: current_user) unless result.present?
end
- 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 store_as_posts_when_authorized
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def store_as_posts_when_authorized
recipient_emails.collect do |recipient_email|
if group = ProfileFields::MailingListEmail.where(value: recipient_email).first.try(:profileable)
if no_duplicates_exist?(group) || Rails.env.development?
ability = Ability.new(self.sender_user)
- 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
Class Page
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
class Page < ApplicationRecord
has_dag_links ancestor_class_names: %w(Page User Group Event), descendant_class_names: %w(Page User Group Event Post), link_class_name: 'DagLink'
#after_save { parent.try(:touch) } # This causes some specs to fail. TODO: Check if this is a spec issue or has destructive implications.
Class Address
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
class Address < ProfileField
def self.model_name; ProfileField.model_name; end
def as_json(*args)
super.merge({
Method initialize
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def initialize(address_labels, options = {title: '', updated_at: Time.zone.now, sender: '', book_rate: false})
super(page_size: 'A4', top_margin: 8.mm, bottom_margin: 8.mm, left_margin: 10.mm, right_margin: 10.mm)
@document_title = options[:title]
@document_updated_at = options[:updated_at]
- 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
Class Event
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class Event < ApplicationRecord
validates :start_at, presence: true
before_validation -> { self.start_at ||= self.created_at || Time.zone.now }
Method processed_data
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def processed_data
if preset.to_s.in?(['birthday_list', 'address_list', 'dpag_internetmarke', 'phone_list']) && @data.kind_of?(Group)
# To be able to generate lists from Groups as well as search results, these presets expect
# an Array of Users as data. If a Group is given instead, just take the group members as data.
#
- 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 geo_location.rb
has 329 lines of code (exceeds 250 allowed). Consider refactoring. Open
class GeoLocation < ApplicationRecord
# When to perform geocoding queries (to google)
# ==========================================================================================
Class ListExportUser
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class ListExportUser < User
attr_accessor :list_export_group
def personal_title_and_name