Showing 3 of 5 total issues
Class GistsController
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class GistsController < ApplicationController
before_action :login_required, only: [:mine, :mine_page, :fork]
before_action :deny_anonymous_if_disallowed, only: [:new, :create, :edit, :update]
Method load_current_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def load_current_user
if @cached_current_user.present?
@cached_current_user
else
begin
- Read upRead up
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 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def update
if current_user.try(:id) == params[:id].to_i
@user = User.find(params[:id])
if params[:user][:nickname].blank?
flash[:notice] = 'Nickname is required.'
- Read upRead up
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"