call4paperz/call4paperz

View on GitHub
app/controllers/authentications_controller.rb

Summary

Maintainability
A
35 mins
Test Coverage

Method create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    destination_url = stored_location_for(:user) || root_path

    if user_signed_in?
      auth = authentication(current_user.authentications)
Severity: Minor
Found in app/controllers/authentications_controller.rb - About 35 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 magic comment # frozen_string_literal: true.
Open

class AuthenticationsController < ApplicationController

This cop is designed to help upgrade to after Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default after Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

Example: EnforcedStyle: always (default)

# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
  # ...
end

# good
# frozen_string_literal: true

module Bar
  # ...
end

Example: EnforcedStyle: never

# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true

module Baz
  # ...
end

# good
module Baz
  # ...
end

Missing top-level class documentation comment.
Open

class AuthenticationsController < 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

Line is too long. [89/80]
Open

    redirect_to destination_url, notice: "Welcome #{current_user.name}!" if will_redirect

Line is too long. [86/80]
Open

    redirect_to root_url, notice: "Authentication error: #{params[:message].humanize}"

Line is too long. [83/80]
Open

      redirect_to new_user_session_path, notice: I18n.t('auth.cant_create_twitter')

There are no issues that match your filters.

Category
Status