roseweixel/lacquer-lover

View on GitHub
app/controllers/users_controller.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method new_transactional_message has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def new_transactional_message
    if !@user
      if request.env['REQUEST_URI']
        session[:intended_uri] = request.env['REQUEST_URI']
        flash[:notice] = %Q[ #{ view_context.link_to("Sign in", login_path, id:"brand-show-sign-in", class:'light-blue-link')} to send a message! ]
Severity: Minor
Found in app/controllers/users_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 show has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    if current_user
      [{"OPI" => [@new_opi_lacquer, @opi_lacquers]}, {"Essie" => [@new_essie_lacquer, @essie_lacquers]}, {"Butter London" => [@new_butter_lacquer, @butter_lacquers]}, {"Deborah Lippmann" => [@new_deborah_lacquer, @deborah_lacquers]}].each do |brand_hash|
        brand_hash.each do |brand, variables|
          if !Brand.where(name: brand).empty?
Severity: Minor
Found in app/controllers/users_controller.rb - About 1 hr to fix

    Method invite_friends has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def invite_friends
        if !@user
          flash[:alert] = "You need to be logged in to invite friends!"
          redirect_to :back
        else
    Severity: Minor
    Found in app/controllers/users_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 new_transactional_message has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def new_transactional_message
        if !@user
          if request.env['REQUEST_URI']
            session[:intended_uri] = request.env['REQUEST_URI']
            flash[:notice] = %Q[ #{ view_context.link_to("Sign in", login_path, id:"brand-show-sign-in", class:'light-blue-link')} to send a message! ]
    Severity: Minor
    Found in app/controllers/users_controller.rb - About 1 hr to fix

      Method show has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          if current_user
            [{"OPI" => [@new_opi_lacquer, @opi_lacquers]}, {"Essie" => [@new_essie_lacquer, @essie_lacquers]}, {"Butter London" => [@new_butter_lacquer, @butter_lacquers]}, {"Deborah Lippmann" => [@new_deborah_lacquer, @deborah_lacquers]}].each do |brand_hash|
              brand_hash.each do |brand, variables|
                if !Brand.where(name: brand).empty?
      Severity: Minor
      Found in app/controllers/users_controller.rb - About 55 mins 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 send_transactional_message has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def send_transactional_message
          if params[:reply_address] == current_user.email
            reply_address = "#{current_user.name} via Lacquer Love&Lend <#{params[:reply_address]}>"
          elsif params[:reply_address] == "do not provide a reply address"
            reply_address = "#{current_user.name} via Lacquer Love&Lend <noreply@lacquerloveandlend.com>"
      Severity: Minor
      Found in app/controllers/users_controller.rb - About 45 mins 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