Showing 1,608 of 1,614 total issues
Complex method TodosController#update_project (55.1) Open
def update_project
@project_changed = false
if params['todo']['project_id'].blank? && !params['project_name'].nil?
if params['project_name'].blank?
project = Project.null_object
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method TodosController#count_old_due_empty (54.9) Open
def count_old_due_empty(id)
due_today_date = Time.zone.now
due_this_week_date = Time.zone.now.end_of_week
due_next_week_date = due_this_week_date + 7.days
due_this_month_date = Time.zone.now.end_of_month
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ContextsController#index (53.9) Open
def index
@all_contexts = current_user.contexts
@active_contexts = current_user.contexts.active
@hidden_contexts = current_user.contexts.hidden
@closed_contexts = current_user.contexts.closed
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method DataController#csv_actions (53.6) Open
def csv_actions
content_type = 'text/csv'
CSV.generate(result = "") do |csv|
csv << ["id", "Context", "Project", "Description", "Notes", "Tags",
"Created at", "Due", "Completed at", "User ID", "Show from",
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ProjectsController#create (52.8) Open
def create
if params[:format] == 'application/xml' && params['exception']
render_failure "Expected post format is valid xml like so: <project><name>project name</name></project>.", 400
return
end
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ProjectsController#review (50.1) Open
def review
@source_view = params['_source_view'] || 'review'
@page_title = t('projects.list_reviews')
projects = current_user.projects
@projects_to_review = projects.select { |p| p.needs_review?(current_user) }
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ContextsController#create (49.4) Open
def create
if params[:format] == 'application/xml' && params['exception']
render_failure "Expected post format is valid xml like so: <context><name>context name</name></context>.", 400
return
end
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method TodosHelper#update_needs_to_remove_todo_from_container (49.3) Open
def update_needs_to_remove_todo_from_container
source_view do |page|
page.context { return @context_changed || @todo_deferred_state_changed || @todo_pending_state_changed || @todo_should_be_hidden }
page.project { return @context_changed || @todo_deferred_state_changed || @todo_pending_state_changed || @project_changed }
page.deferred { return todo_moved_out_of_container || !(@todo.deferred? || @todo.pending?) }
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method TodosController#list_deferred (48.9) Open
def list_deferred
@source_view = 'deferred'
@page_title = t('todos.deferred_tasks_title')
@contexts_to_show = @contexts = current_user.contexts
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Class TodoCreateParamsHelper
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class TodoCreateParamsHelper
attr_reader :new_project_created, :new_context_created, :attributes
def initialize(params, user)
set_params(params)
Complex method TodosController#new (47.9) Open
def new
@projects = current_user.projects.active
@contexts = current_user.contexts
respond_to do |format|
format.m do
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method TodosHelper#feed_content_for_todo (47.6) Open
def feed_content_for_todo(todo)
item_notes = todo.notes ? render_text(todo.notes) : ''
due = todo.due ? content_tag(:div, t('todos.feeds.due', :date => format_date(todo.due))) : ''
done = todo.completed? ? content_tag(:div, t('todos.feeds.completed', :date => format_date(todo.completed_at))) : ''
context_link = link_to(context_url(todo.context), todo.context.name)
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Method create
has a Cognitive Complexity of 64 (exceeds 50 allowed). Consider refactoring. Open
def create
@source_view = params['_source_view'] || 'todo'
@default_context = current_user.contexts.where(:name => params['default_context_name']).first
@default_project = current_user.projects.where(:name => params['default_project_name']).first if params['default_project_name'].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
Complex method TodosController#update_context (46.3) Open
def update_context
@context_changed = false
if params['todo']['context_id'].blank? && params['context_name'].present?
@context = current_user.contexts.where(:name => params['context_name'].strip).first
if @context.nil?
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method TodosController#determine_completed_count (45.5) Open
def determine_completed_count
todos = nil
source_view do |from|
from.todo { todos = current_user.todos.not_hidden.completed }
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method TodosController#determine_changes_by_this_update (45.1) Open
def determine_changes_by_this_update
@todo_was_activated_from_deferred_state = @todo.active? && @original_item.deferred?
@todo_was_activated_from_pending_state = @todo.active? && @original_item.pending?
@todo_was_deferred_from_active_state = @todo.deferred? && !@original_item.deferred?
@todo_was_blocked_from_active_state = @todo.pending? && !@original_item.pending?
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method TodosController#get_params_for_tag_view (44.3) Open
def get_params_for_tag_view
filter_format_for_tag_view
# Don't use sanitize here because these are only used for a DB query.
@tag_expr = []
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Consider simplifying this complex logical expression. Open
if source_view_is_one_of(:tag, :context, :project)
return @remaining_in_context == 0 && (
todo_moved_out_of_container ||
(@todo_hidden_state_changed && @todo.hidden?) ||
@todo_was_deferred_from_active_state ||
Class AbstractRecurringTodosBuilder
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class AbstractRecurringTodosBuilder
attr_reader :mapped_attributes, :pattern
def initialize(user, attributes, pattern_class)
@user = user
Class AttributeHandler
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class AttributeHandler
attr_reader :attributes
def initialize(user, attributes)
@user = user