assemblymade/coderwall

View on GitHub
app/controllers/users_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

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

  def show
    @user = User.find_by_username!(params[:username])

    respond_to do |format|
      format.html do
Severity: Minor
Found in app/controllers/users_controller.rb - About 3 hrs 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

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

class UsersController < ApplicationController
  after_action :track_referrer, only: :show
  skip_before_action :require_registration, only: [:edit, :update]

  layout 'coderwallv2', only: :edit
Severity: Minor
Found in app/controllers/users_controller.rb - About 2 hrs to fix

    File users_controller.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class UsersController < ApplicationController
      after_action :track_referrer, only: :show
      skip_before_action :require_registration, only: [:edit, :update]
    
      layout 'coderwallv2', only: :edit
    Severity: Minor
    Found in app/controllers/users_controller.rb - About 2 hrs to fix

      Method edit has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def edit
          respond_to do |format|
            format.json do
              settings
            end
      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 update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
      
          user_id = params[:id]
      
          @user = user_id.blank? ? current_user : User.find(user_id)
      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 user_update_params has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def user_update_params
          params.require(:user).permit(:about,
                                       :avatar,
                                       :avatar_cache,
                                       :banner,
      Severity: Minor
      Found in app/controllers/users_controller.rb - About 1 hr to fix

        Method show has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def show
            @user = User.find_by_username!(params[:username])
        
            respond_to do |format|
              format.html do
        Severity: Minor
        Found in app/controllers/users_controller.rb - About 1 hr to fix

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

            def create
              @user = User.for_omniauth(oauth)
          
              ucp = user_create_params.dup
          
          
          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