JumpstartLab/tracks

View on GitHub
app/controllers/application_controller.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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

class ApplicationController < ActionController::Base

  protect_from_forgery

  include LoginSystem
Severity: Minor
Found in app/controllers/application_controller.rb - About 4 hrs to fix

    Method create_todo_from_recurring_todo has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_todo_from_recurring_todo(rt, date=nil)
        # create todo and initialize with data from recurring_todo rt
        todo = current_user.todos.build( { :description => rt.description, :notes => rt.notes, :project_id => rt.project_id, :context_id => rt.context_id})
        todo.recurring_todo_id = rt.id
    
    
    Severity: Minor
    Found in app/controllers/application_controller.rb - About 1 hr 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 set_session_expiration has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_session_expiration
        # http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions
        unless session == nil
          return if self.controller_name == 'feed' or session['noexpiry'] == "on"
          # If the method is called by the feed controller (which we don't have
    Severity: Minor
    Found in app/controllers/application_controller.rb - About 1 hr 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 set_locale has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_locale
        locale = params[:locale] # specifying a locale in the request takes precedence
        locale = locale || prefs.locale unless current_user.nil? # otherwise, the locale of the currently logged in user takes over
        locale = locale || request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']
        I18n.locale = locale.nil? ? I18n.default_locale : (I18n::available_locales.include?(locale.to_sym) ? locale : I18n.default_locale)
    Severity: Minor
    Found in app/controllers/application_controller.rb - About 1 hr 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

    There are no issues that match your filters.

    Category
    Status