expertiza/expertiza

View on GitHub
app/controllers/password_retrieval_controller.rb

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

Assignment Branch Condition size for update_password is too high. [43.61/15]
Open

  def update_password
    if params[:reset][:password] == params[:reset][:repassword]
      user = User.find_by(email: params[:reset][:email])
      user.password = params[:reset][:password]
      user.password_confirmation = params[:reset][:repassword]

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

  def send_password
    if params[:user][:email].nil? || params[:user][:email].strip.empty?
      flash[:error] = 'Please enter an e-mail address.'
    else
      user = User.find_by(email: params[:user][:email])

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

  def check_reset_url
    if params[:token].nil?
      flash[:error] = 'Password reset page can only be accessed with a generated link, sent to your email'
      render template: 'password_retrieval/forgotten'
    else

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

  def check_reset_url
    if params[:token].nil?
      flash[:error] = 'Password reset page can only be accessed with a generated link, sent to your email'
      render template: 'password_retrieval/forgotten'
    else

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 send_password
    if params[:user][:email].nil? || params[:user][:email].strip.empty?
      flash[:error] = 'Please enter an e-mail address.'
    else
      user = User.find_by(email: params[:user][:email])

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 update_password
    if params[:reset][:password] == params[:reset][:repassword]
      user = User.find_by(email: params[:reset][:email])
      user.password = params[:reset][:password]
      user.password_confirmation = params[:reset][:repassword]

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 check_reset_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def check_reset_url
    if params[:token].nil?
      flash[:error] = 'Password reset page can only be accessed with a generated link, sent to your email'
      render template: 'password_retrieval/forgotten'
    else
Severity: Minor
Found in app/controllers/password_retrieval_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_password has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def send_password
    if params[:user][:email].nil? || params[:user][:email].strip.empty?
      flash[:error] = 'Please enter an e-mail address.'
    else
      user = User.find_by(email: params[:user][:email])
Severity: Minor
Found in app/controllers/password_retrieval_controller.rb - About 25 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

Missing top-level class documentation comment.
Open

class PasswordRetrievalController < ApplicationController

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

There are no issues that match your filters.

Category
Status