Showing 957 of 957 total issues
Assignment Branch Condition size for index is too high. [88.17/15] Open
def index
sticky_scope = current_user.all_stickies
sticky_scope = sticky_scope.with_owner(current_user.id) if params[:assigned_to_me] == '1'
sticky_scope = sticky_scope.where(project_id: params[:project_id]) unless params[:project_id].blank?
sticky_scope = sticky_scope.where.not(owner_id: nil) if params[:unassigned].to_s != '1'
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for set_filtered_sticky_scope is too high. [60.05/15] Open
def set_filtered_sticky_scope
@anchor_date = (Date.parse(params[:date]) rescue Date.today)
sticky_scope = current_user.all_viewable_stickies
sticky_scope = sticky_scope.with_tag(current_user.all_viewable_tags.where(name: params[:tags].to_s.split(',')).select(:id)) unless params[:tags].blank?
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for sticky_params is too high. [58.84/15] Open
def sticky_params
params[:sticky] ||= { blank: '1' }
params[:sticky][:due_date] = parse_date(params[:sticky][:due_date]) unless params[:sticky][:due_date].blank?
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for week is too high. [49.13/15] Open
def week
flash.delete(:notice)
week_padding = 12
@beginning_of_anchor_week = @anchor_date.wday == 0 ? @anchor_date : @anchor_date.beginning_of_week - 1.day
@beginning = @beginning_of_anchor_week - week_padding.weeks
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for index is too high. [45.22/15] Open
def index
unless current_user.system_admin? || params[:format] == 'json'
redirect_to root_path, alert: 'You do not have sufficient privileges to access that page.'
return
end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Class User
has 38 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :encryptable, :confirmable, :lockable and :omniauthable
devise :database_authenticatable, :timeoutable, # , :registerable
:recoverable, :rememberable, :trackable, :validatable
Assignment Branch Condition size for group_params is too high. [43.85/15] Open
def group_params
params[:group] ||= { blank: '1' } # {}
if @project && params[:create_new_board] == '1'
if params[:group_board_name].to_s.strip.blank?
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for reassign is too high. [40.87/15] Open
def reassign
original_user_id = User.with_project(@project.id, [true]).find_by_id(params[:from_user_id]).id rescue original_user_id = nil # Editors only
reassign_to_user_id = User.with_project(@project.id, [true]).find_by_id(params[:to_user_id]).id rescue reassign_to_user_id = nil # Editors only
params[:sticky_status] = 'not_completed' unless ['not_completed', 'completed', 'all'].include?(params[:sticky_status])
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for create is too high. [36.72/15] Open
def create
g_params = group_params
@template = @project.templates.find_by_id(params[:group][:template_id]) if @project && params[:group]
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method index
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def index
sticky_scope = current_user.all_stickies
sticky_scope = sticky_scope.with_owner(current_user.id) if params[:assigned_to_me] == '1'
sticky_scope = sticky_scope.where(project_id: params[:project_id]) unless params[:project_id].blank?
sticky_scope = sticky_scope.where.not(owner_id: nil) if params[:unassigned].to_s != '1'
- 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
Assignment Branch Condition size for generate_csv is too high. [35.24/15] Open
def generate_csv(task_scope)
@csv_string = CSV.generate do |csv|
csv << ['Name', 'Due Date', 'Description', 'Completed', 'Assigned To', 'Tags', 'Project', 'Creator', 'Board', 'Due Time', 'Duration', 'Duration Units']
task_scope.each do |sticky|
csv << [sticky.name,
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [29/10] Open
def index
sticky_scope = current_user.all_stickies
sticky_scope = sticky_scope.with_owner(current_user.id) if params[:assigned_to_me] == '1'
sticky_scope = sticky_scope.where(project_id: params[:project_id]) unless params[:project_id].blank?
sticky_scope = sticky_scope.where.not(owner_id: nil) if params[:unassigned].to_s != '1'
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for generate_stickies! is too high. [33.91/15] Open
def generate_stickies!(current_user, board_id, initial_date = Date.today, additional_text = nil)
group = project.groups.create(user_id: current_user.id, description: additional_text, template_id: id)
template_items.each do |template_item|
due_date = (initial_date.nil? ? nil : initial_date + template_item.interval.send(template_item.interval_units))
if avoid_weekends? && due_date
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for move is too high. [32.19/15] Open
def move
params[:due_date] = parse_date(params[:due_date])
@all_dates = []
if @sticky && params[:due_date].present?
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for add_stickies is too high. [29.5/15] Open
def add_stickies
@tag = current_user.all_tags.find_by_id(params[:tag_id])
@stickies = @project.stickies.where(id: params[:sticky_ids].split(',')) if @project
if @tag && @stickies.size > 0
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [24/10] Open
def generate_stickies!(current_user, board_id, initial_date = Date.today, additional_text = nil)
group = project.groups.create(user_id: current_user.id, description: additional_text, template_id: id)
template_items.each do |template_item|
due_date = (initial_date.nil? ? nil : initial_date + template_item.interval.send(template_item.interval_units))
if avoid_weekends? && due_date
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for set_items is too high. [28.46/15] Open
def set_items
return unless item_hashes && item_hashes.is_a?(Array)
template_items.destroy_all
sorted_item_hashes.each_with_index do |hash, index|
template_item = template_items.create(
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for clone_repeat is too high. [28.6/15] Open
def clone_repeat
if saved_changes[:completed] && self.saved_changes[:completed][1] == true && repeat != 'none' && repeated_sticky.blank? && due_date.present?
new_sticky = user.stickies.new(attributes.reject { |key, val| ['id', 'user_id', 'deleted', 'created_at', 'updated_at', 'start_date', 'end_date', 'repeated_sticky_id', 'completed'].include?(key.to_s) })
new_sticky.due_date += (repeat_amount).send(new_sticky.repeat)
new_sticky.tag_ids = tags.pluck(:id)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [22/10] Open
def move
params[:due_date] = parse_date(params[:due_date])
@all_dates = []
if @sticky && params[:due_date].present?
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for short_time is too high. [26.32/15] Open
def short_time
result = ''
if start_date && start_date.year == Time.zone.today.year
result += start_date.strftime('%m/%d')
elsif start_date
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric