codebar/planner

View on GitHub
app/controllers/application_controller.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Class has too many lines. [130/100]
Open

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  include Pundit::Authorization
  include Pagy::Backend

Checks if the length of a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

You can set constructs you want to fold with CountAsOne. Available are: 'array', 'hash', 'heredoc', and 'method_call'. Each construct will be counted as one line regardless of its actual size.

Example: CountAsOne: ['array', 'heredoc', 'method_call']

class Foo
  ARRAY = [         # +1
    1,
    2
  ]

  HASH = {          # +3
    key: 'value'
  }

  MSG = <<~HEREDOC  # +1
    Heredoc
    content.
  HEREDOC

  foo(              # +1
    1,
    2
  )
end                 # 6 points

NOTE: This cop also applies for Struct definitions.

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

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  include Pundit::Authorization
  include Pagy::Backend
Severity: Minor
Found in app/controllers/application_controller.rb - About 2 hrs to fix

    Use request.referer instead of request.referrer.
    Open

        request.referrer || root_path

    This cop checks for consistent uses of request.referer or request.referrer, depending on the cop's configuration.

    Example: EnforcedStyle: referer (default)

    # bad
    request.referrer
    
    # good
    request.referer

    Example: EnforcedStyle: referrer

    # bad
    request.referer
    
    # good
    request.referrer

    Use == if you meant to do a comparison or move the assignment up out of the condition.
    Open

        if referer = request.headers['Referer']

    Checks for assignments in the conditions of if/while/until.

    AllowSafeAssignment option for safe assignment. By safe assignment we mean putting parentheses around an assignment to indicate "I know I'm using an assignment as a condition. It's not a mistake."

    Safety:

    This cop's autocorrection is unsafe because it assumes that the author meant to use an assignment result as a condition.

    Example:

    # bad
    if some_var = true
      do_something
    end
    
    # good
    if some_var == true
      do_something
    end

    Example: AllowSafeAssignment: true (default)

    # good
    if (some_var = true)
      do_something
    end

    Example: AllowSafeAssignment: false

    # bad
    if (some_var = true)
      do_something
    end

    Rename has_access? to access?.
    Open

      def has_access?

    Checks that predicate methods names end with a question mark and do not start with a forbidden prefix.

    A method is determined to be a predicate method if its name starts with one of the prefixes defined in the NamePrefix configuration. You can change what prefixes are considered by changing this option. Any method name that starts with one of these prefixes is required by the cop to end with a ?. Other methods can be allowed by adding to the AllowedMethods configuration.

    NOTE: The is_a? method is allowed by default.

    If ForbiddenPrefixes is set, methods that start with the configured prefixes will not be allowed and will be removed by autocorrection.

    In other words, if ForbiddenPrefixes is empty, a method named is_foo will register an offense only due to the lack of question mark (and will be autocorrected to is_foo?). If ForbiddenPrefixes contains is_, is_foo will register an offense both because the ? is missing and because of the is_ prefix, and will be corrected to foo?.

    NOTE: ForbiddenPrefixes is only applied to prefixes in NamePrefix; a prefix in the former but not the latter will not be considered by this cop.

    Example:

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

    Example: AllowedMethods: ['is_a?'] (default)

    # good
    def is_a?(value)
    end

    Consider merging nested conditions into outer if conditions.
    Open

          redirect_to edit_member_details_path unless providing_additional_details?

    If the branch of a conditional consists solely of a conditional node, its conditions can be combined with the conditions of the outer branch. This helps to keep the nesting level from getting too deep.

    Example:

    # bad
    if condition_a
      if condition_b
        do_something
      end
    end
    
    # bad
    if condition_b
      do_something
    end if condition_a
    
    # good
    if condition_a && condition_b
      do_something
    end

    Example: AllowModifier: false (default)

    # bad
    if condition_a
      do_something if condition_b
    end
    
    # bad
    if condition_b
      do_something
    end if condition_a

    Example: AllowModifier: true

    # good
    if condition_a
      do_something if condition_b
    end
    
    # good
    if condition_b
      do_something
    end if condition_a

    Rename is_logged_in? to logged_in?.
    Open

      def is_logged_in?

    Checks that predicate methods names end with a question mark and do not start with a forbidden prefix.

    A method is determined to be a predicate method if its name starts with one of the prefixes defined in the NamePrefix configuration. You can change what prefixes are considered by changing this option. Any method name that starts with one of these prefixes is required by the cop to end with a ?. Other methods can be allowed by adding to the AllowedMethods configuration.

    NOTE: The is_a? method is allowed by default.

    If ForbiddenPrefixes is set, methods that start with the configured prefixes will not be allowed and will be removed by autocorrection.

    In other words, if ForbiddenPrefixes is empty, a method named is_foo will register an offense only due to the lack of question mark (and will be autocorrected to is_foo?). If ForbiddenPrefixes contains is_, is_foo will register an offense both because the ? is missing and because of the is_ prefix, and will be corrected to foo?.

    NOTE: ForbiddenPrefixes is only applied to prefixes in NamePrefix; a prefix in the former but not the latter will not be considered by this cop.

    Example:

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

    Example: AllowedMethods: ['is_a?'] (default)

    # good
    def is_a?(value)
    end

    There are no issues that match your filters.

    Category
    Status