Showing 16 of 31 total issues
Class User
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
has_many :access_grants, class_name: "Doorkeeper::AccessGrant",
foreign_key: :resource_owner_id,
dependent: :delete_all # or :destroy if you need callbacks
Class Lab
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Lab < ApplicationRecord
include RocketPants::Cacheable
include Authority::Abilities
include Workflow
include WorkflowActiverecord
Method included
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.workflow_column :workflow_state
base.workflow do
state :unverified do
Method parse
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.parse(payload, sso_secret = nil)
sso = new
sso.sso_secret = sso_secret if sso_secret
parsed = Rack::Utils.parse_query(payload)
- 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 lab_params
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def lab_params
params.require(:lab).permit(
:activity_status,
:activity_start_at,
:activity_inaugurated_at,
Method parse
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse(payload, sso_secret = nil)
sso = new
sso.sso_secret = sso_secret if sso_secret
parsed = Rack::Utils.parse_query(payload)
Method url_icon
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def url_icon(url)
case url
when /twitter\.com/
icon('twitter')
when /github\.com/
Method project_params
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def project_params
attributes = [
:type,
:title,
:description,
Method create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create
return render plain: "Please go back and ensure that the 'ignore' field is EMPTY." if params[:name].present?
logger.info 'Creating user through Users controller'
- 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
def update
@user = current_user
authorize_action_for @user
email_changed = (@user.email != user_params[:email])
if email_changed
- 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 generate_fab10_coupon_code
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def generate_fab10_coupon_code
if self.fab10_coupon_code.blank?
self.fab10_coupon_code = loop do
random_token = SecureRandom.urlsafe_base64[0..10].gsub(/[^0-9a-zA-Z]/i, '')
break random_token unless User.exists?(fab10_coupon_code: random_token)
- 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
Avoid too many return
statements within this method. Open
return 0
Method consensus
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def consensus
votes_up = referee_approval_processes.where(approved: true).count
votes_down = referee_approval_processes.where(approved: false).count
if votes_up >= 2
update_attributes(workflow_state: :approved)
- 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 require_admin
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def require_admin
if current_user
unless superadmin or referee
return redirect_to root_url, notice: "Not authorized"
end
- 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 guardian
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def guardian
votes_up = referee_approval_processes.where(approved: true).count
votes_down = referee_approval_processes.where(approved: false).count
if votes_up >= 2
return 1
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def update
@recovery = Recovery.where(key: params[:id]).first
user_params = recovery_params[:user_attributes].slice(:password, :password_confirmation)
if @recovery.user and user_params[:password].present?
if @recovery.user.update_attributes user_params
- 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"