Showing 1,608 of 1,614 total issues
Complex method TodosController#check_for_next_todo (41.9) Open
def check_for_next_todo(todo)
# check if this todo has a related recurring_todo. If so, create next todo
new_recurring_todo = nil
recurring_todo = nil
if todo.from_recurring_todo?
- 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#xml_export (41.9) Open
def xml_export
todo_tag_ids = Tag.find_by_sql([
"SELECT DISTINCT tags.id
FROM tags, taggings, todos
WHERE todos.user_id = ?
- 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 ConsoleOptions#initialize (41.9) Open
def initialize
@options = {}
@parser = OptionParser.new do |cmd|
cmd.banner = "Ruby Gtd CLI - takes todos input from STDIN"
- 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 CalendarController#show (41.6) Open
def show
@source_view = 'calendar'
@page_title = t('todos.calendar_page_title')
@calendar = Todos::Calendar.new(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 TodosHelper#replace_with_updated_todo (41.3) Open
def replace_with_updated_todo
source_view do |page|
page.context { return !update_needs_to_remove_todo_from_container }
page.project { return !update_needs_to_remove_todo_from_container }
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 ContextsController#update (41.2) Open
def update
process_params_for_update
@context.attributes = context_params
@saved = @context.save
- 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
File projects_controller.rb
has 304 lines of code (exceeds 300 allowed). Consider refactoring. Open
class ProjectsController < ApplicationController
helper :application, :todos, :notes
before_action :set_source_view
before_action :set_project_from_params, :only => [:update, :destroy, :show, :edit, :set_reviewed]
before_action :default_context_filter, :only => [:create, :update]
File todo.rb
has 304 lines of code (exceeds 300 allowed). Consider refactoring. Open
class Todo < ApplicationRecord
MAX_DESCRIPTION_LENGTH = 300
MAX_NOTES_LENGTH = 60_000
after_save :save_predecessors
File actions.rb
has 301 lines of code (exceeds 300 allowed). Consider refactoring. Open
module Stats
class Actions
SECONDS_PER_DAY = 86_400
attr_reader :user
Complex method namespace(tracks)::task#password (40.1) Open
task :password => :environment do
require "io/console"
user = User.find_by_login(ENV['USER'])
if user.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 StatsController#actions_done_lastyears_data (39.8) Open
def actions_done_lastyears_data
actions_last_months = current_user.todos.select("completed_at,created_at")
month_count = difference_in_months(@today, actions_last_months.minimum(:created_at))
# because this action is not scoped by date, the minimum created_at should always be
- 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#add_predecessor (39.7) Open
def add_predecessor
@source_view = params['_source_view'] || 'todo'
@predecessor = current_user.todos.find(params['predecessor'])
@predecessors = @predecessor.predecessors
@todo = current_user.todos.includes(Todo::DEFAULT_INCLUDES).find(params['successor'])
- 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_import (39.6) Open
def csv_import
begin
filename = sanitize_filename(params[:file])
path_and_file = Rails.root.join('public', 'uploads', 'csv', filename)
case params[:import_to]
- 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#toggle_star (39.5) Open
def toggle_star
@todo = current_user.todos.find(params['id'])
@todo.toggle_star!
@saved = true # cannot determine error
respond_to do |format|
- 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#append_updated_todo (37.6) Open
def append_updated_todo
source_view do |page|
page.context { return @todo_deferred_state_changed || @todo_pending_state_changed }
page.project { return @context_changed || @todo_deferred_state_changed || @todo_pending_state_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 Stats::Actions#done_last12months_data (37.4) Open
def done_last12months_data
# get actions created and completed in the past 12+3 months. +3 for running
# - outermost set of entries needed for these calculations
actions_last12months = @user.todos.created_or_completed_after(@cut_off_year_plus3).select("completed_at,created_at")
- 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_multiple
has a Cognitive Complexity of 59 (exceeds 50 allowed). Consider refactoring. Open
def create_multiple
p = Todos::TodoCreateParamsHelper.new(params, current_user)
tag_list = p.tag_list
@not_done_todos = []
- 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 ApplicationController#count_undone_todos (36.6) Open
def count_undone_todos(todos_parent)
if todos_parent.nil?
count = 0
elsif (todos_parent.is_a?(Project) && todos_parent.hidden?)
init_hidden_todo_counts(['project']) if !@project_hidden_todo_counts
- 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 UsersController#destroy (36.3) Open
def destroy
@deleted_user = User.find(params[:id])
# Remove the user
@saved = @deleted_user.destroy
- 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#yaml_export (36.2) Open
def yaml_export
all_tables = {}
all_tables['todos'] = current_user.todos.includes(:tags).load
all_tables['contexts'] = current_user.contexts.load
- 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