remomueller/tasktracker

View on GitHub

Showing 957 of 957 total issues

Assignment Branch Condition size for recent_activity is too high. [20.35/15]
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"
Severity: Minor
Found in app/helpers/application_helper.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. [15/10]
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
Severity: Minor
Found in app/controllers/tags_controller.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 move_to_board is too high. [20.35/15]
Open

  def move_to_board
    @board = current_user.all_boards.find_by_id(params[:board_id])
    @original_board = @sticky.board if @sticky

    if @sticky && @board && @sticky.board != @board

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

  def sticky_params
    params[:sticky] ||= { blank: '1' }

    params[:sticky][:due_date] = parse_date(params[:sticky][:due_date]) unless params[:sticky][:due_date].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.

Assignment Branch Condition size for index is too high. [20.25/15]
Open

  def index
    @order = scrub_order(Template, params[:order], 'templates.name')
    template_scope = (params[:editable_only] == '1') ? current_user.all_templates : current_user.all_viewable_templates
    @templates = template_scope.search(params[:search]).filter(params).order(@order).page(params[:page]).per(40)
  end

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

  def accept
    invite_token = session.delete(:invite_token)
    @project_user = ProjectUser.find_by_invite_token invite_token
    if @project_user && @project_user.user == current_user
      redirect_to @project_user.project, notice: "You have already been added to #{@project_user.project.name}."

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

  def create
    g_params = group_params

    @template = @project.templates.find_by_id(params[:group][:template_id]) if @project && params[:group]

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

  def update
    @from_date = @sticky.due_date

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

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

  def show
    params[:status] ||= ['planned','completed']
    @template = @project.templates.find_by_id(params[:template_id])

    unless @template

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

  def destroy
    @project_user = ProjectUser.find_by_id(params[:id])
    @project = current_user.all_projects.find_by_id(@project_user.project_id) if @project_user
    if @project.blank? && @project_user && current_user == @project_user.user
      @project = current_user.all_viewable_projects.find_by_id(@project_user.project_id)

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. [19.21/15]
Open

  def create
    @sticky = current_user.all_viewable_stickies.find_by(id: params[:sticky_id])
    @comment = @sticky ? @sticky.comments.new(comment_params) : Comment.new(comment_params)

    respond_to do |format|

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 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]

Severity: Minor
Found in app/controllers/groups_controller.rb - About 2 hrs to fix

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

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

  def tag_params
    params[:tag] ||= { blank: '1' }

    unless params[:tag][:project_id].blank?
      project = current_user.all_projects.find_by_id(params[:tag][:project_id])
Severity: Minor
Found in app/controllers/tags_controller.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 month is too high. [18.06/15]
Open

  def month
    flash.delete(:notice)
    if current_user.calendar_view == '4week'
      @start_date = @anchor_date.beginning_of_week(:sunday)
      @end_date = @start_date + 27.days

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

  def template_params
    params[:template] ||= { blank: '1' }

    unless params[:template][:project_id].blank?
      project = current_user.all_projects.find_by_id(params[:template][:project_id])

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

Perceived complexity for move is too high. [10/7]
Open

  def move
    params[:due_date] = parse_date(params[:due_date])
    @all_dates = []

    if @sticky && params[:due_date].present?

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

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

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. [18.14/15]
Open

  def create
    @sticky = @project.stickies.where(user_id: current_user.id).new(sticky_params)

    respond_to do |format|
      if @sticky.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

Assignment Branch Condition size for board_params is too high. [18.36/15]
Open

  def board_params
    params[:board] ||= { blank: '1' }

    unless params[:board][:project_id].blank?
      project = current_user.all_projects.find_by_id(params[:board][:project_id])

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

Severity
Category
Status
Source
Language