Showing 27 of 957 total issues
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
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
File stickies_controller.rb
has 265 lines of code (exceeds 250 allowed). Consider refactoring. Open
class StickiesController < ApplicationController
before_action :authenticate_user!
before_action :set_viewable_sticky, only: [:show]
before_action :find_editable_project_or_first_project, only: [:new, :create, :edit, :update]
before_action :set_editable_sticky, only: [:edit, :move, :move_to_board, :complete, :update, :destroy]
Method create
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def create
g_params = group_params
@template = @project.templates.find_by_id(params[:group][:template_id]) if @project && params[:group]
- 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 generate_csv
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. 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
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 sticky_params
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. 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
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 add_stickies
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. 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
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 generate_stickies!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. 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
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 reassign
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. 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
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 index
has 29 lines of code (exceeds 25 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'
Method show
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def show
params[:status] ||= ['planned','completed']
@template = @project.templates.find_by_id(params[:template_id])
unless @template
- 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 move
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def move
params[:due_date] = parse_date(params[:due_date])
@all_dates = []
if @sticky && params[:due_date].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
Method set_items
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. 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
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 index
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. 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
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 recent_activity
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def recent_activity(past_time)
return '' unless past_time.is_a? Time
time_ago_in_words(past_time)
seconds_ago = (Time.zone.now - past_time)
color = if seconds_ago < 60.minute then "#6DD1EC"
- 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 set_filtered_sticky_scope
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. 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
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 group_params
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. 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
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 description_html
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def description_html
result = full_description.to_s
result += "\n\n<hr style=\"margin-top:5px;margin-bottom:5px\">"
result += "<div style='white-space:nowrap'><strong>Assigned</strong> #{owner.name} <img alt='' src='#{owner.avatar_url(18, "identicon")}' class='img-rounded'></div>" if owner
result += "<strong>Board</strong> #{board ? board.name : 'Holding Pen'}<br />" if project.boards.size > 0
- 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 destroy
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def destroy
if @sticky.group && params[:discard] == 'following'
@sticky.group.stickies.where('due_date >= ?', @sticky.due_date).destroy_all
elsif @sticky.group && params[:discard] == 'all'
@sticky.group.destroy
- 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 add_stickies
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_stickies
@board = current_user.all_boards.find_by_id(params[:board_id])
@stickies = @project.stickies.where(id: params[:sticky_ids].split(','))
if (@board || params[:board_id].to_s == '0') && @stickies.size > 0
- 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"