seratch/gistub

View on GitHub

Showing 3 of 5 total issues

Class GistsController has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

class GistsController < ApplicationController

  before_action :login_required,               only: [:mine, :mine_page, :fork]
  before_action :deny_anonymous_if_disallowed, only: [:new, :create, :edit, :update]

Severity: Minor
Found in app/controllers/gists_controller.rb - About 3 hrs to fix

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

      def load_current_user
        if @cached_current_user.present?
          @cached_current_user
        else
          begin
    Severity: Minor
    Found in app/controllers/application_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

    Method update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    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.'
    Severity: Minor
    Found in app/controllers/users_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

    Severity
    Category
    Status
    Source
    Language