ece517-p3/expertiza

View on GitHub
app/controllers/application_controller.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Assignment Branch Condition size for undo_link is too high. [20.32/15]
Open

  def undo_link(message)
    version = Version.where('whodunnit = ?', session[:user].id).last
    return unless version.try(:created_at) && Time.now.in_time_zone - version.created_at < 5.0
    link_name = params[:redo] == 'true' ? 'redo' : 'undo'
    message + "<a href = #{url_for(controller: :versions, action: :revert, id: version.id, redo: !params[:redo])}>#{link_name}</a>"

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

Class ApplicationController has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class ApplicationController < ActionController::Base
  include AccessHelper

  # You want to get exceptions in development, but not in production.
  unless Rails.application.config.consider_all_requests_local
Severity: Minor
Found in app/controllers/application_controller.rb - About 2 hrs to fix

    Rename is_available to available?.
    Open

      def is_available(user, owner_id)

    This cop makes sure that predicates are named properly.

    Example:

    # bad
    def is_even?(value)
    end
    
    # good
    def even?(value)
    end
    
    # bad
    def has_value?
    end
    
    # good
    def value?
    end

    Method ApplicationController#current_user_role? is defined at both app/controllers/application_controller.rb:26 and app/controllers/application_controller.rb:70.
    Open

      alias current_user_role? current_user_role

    This cop checks for duplicated instance (or singleton) method definitions.

    Example:

    # bad
    
    def duplicated
      1
    end
    
    def duplicated
      2
    end

    Example:

    # bad
    
    def duplicated
      1
    end
    
    alias duplicated other_duplicated

    Example:

    # good
    
    def duplicated
      1
    end
    
    def other_duplicated
      2
    end

    There are no issues that match your filters.

    Category
    Status