remomueller/tasktracker

View on GitHub

Showing 957 of 957 total issues

Cyclomatic complexity for index is too high. [16/6]
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'

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for destroy is too high. [25.5/15]
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

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 search is too high. [24.27/15]
Open

  def search
    @projects = current_user.all_viewable_projects.search(params[:search]).order('name').limit(10)
    @groups = current_user.all_viewable_groups.search(params[:search]).order('description').limit(10)
    @objects = @projects + @groups
    if @objects.empty?

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. [19/10]
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,

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.

Method has too many lines. [19/10]
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

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.

Perceived complexity for index is too high. [15/7]
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'

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Assignment Branch Condition size for add_stickies is too high. [23.69/15]
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

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 description_html is too high. [22.49/15]
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
Severity: Minor
Found in app/models/sticky.rb by rubocop

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. [17/10]
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(
Severity: Minor
Found in app/models/template.rb by rubocop

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 change_password is too high. [22.09/15]
Open

  def change_password
    if current_user.valid_password?(params[:user][:current_password])
      if current_user.reset_password(params[:user][:password], params[:user][:password_confirmation])
        bypass_sign_in current_user
        redirect_to settings_path, notice: 'Your password has been changed.'

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 shift_group is too high. [21.59/15]
Open

  def shift_group(days_to_shift, shift)
    all_dates = []
    if days_to_shift != 0 && group && %w(incomplete all).include?(shift)
      sticky_scope = group.stickies.where.not(id: id)
      sticky_scope = sticky_scope.where(completed: false) if shift == 'incomplete'
Severity: Minor
Found in app/models/sticky.rb by rubocop

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 toggle_tag_selection is too high. [21.12/15]
Open

  def toggle_tag_selection
    tag_filter = current_user.tag_filters.find_by tag_id: params[:tag_id]
    if tag_filter
      tag_filter.destroy
    elsif params[:tag_id].blank?

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 toggle_project_selection is too high. [21.12/15]
Open

  def toggle_project_selection
    project_filter = current_user.project_filters.find_by project_id: params[:project_id]
    if project_filter
      project_filter.destroy
    elsif params[:project_id].blank?

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 toggle_owner_selection is too high. [21.12/15]
Open

  def toggle_owner_selection
    owner_filter = current_user.owner_filters.find_by owner_id: params[:owner_id]
    if owner_filter
      owner_filter.destroy
    elsif params[:owner_id].blank?

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 update is too high. [21.79/15]
Open

  def update
    @from_date = @sticky.due_date

    respond_to do |format|
      if @sticky.update(sticky_params)

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. [16/10]
Open

  def edit
    respond_to do |format|
      if @sticky
        @project = @sticky.project
        format.html

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 create is too high. [21.12/15]
Open

  def create
    @project = current_user.projects.new(project_params)

    respond_to do |format|
      if @project.save

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. [16/10]
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])

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.

Method has too many lines. [16/10]
Open

  def group_params
    params[:group] ||= { blank: '1' } # {}

    if @project && params[:create_new_board] == '1'
      if params[:group_board_name].to_s.strip.blank?

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.

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]
Severity: Minor
Found in app/controllers/stickies_controller.rb - About 2 hrs to fix
    Severity
    Category
    Status
    Source
    Language