Showing 33 of 59 total issues
Class User
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
has_many :user_lacquers, -> { order(:updated_at => :desc) }, dependent: :destroy
has_many :lacquers, through: :user_lacquers
has_many :brands, -> { uniq }, through: :lacquers
Class Lacquer
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Lacquer < ActiveRecord::Base
belongs_to :brand
has_many :user_lacquers, dependent: :destroy
has_many :colors, through: :user_lacquers
has_many :finishes, through: :user_lacquers
Method create
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def create
if request.env['omniauth.auth'].present?
existing_user = User.find_by(uid: request.env['omniauth.auth']['uid'])
user = User.from_omniauth(request.env['omniauth.auth'])
session[:user_id] = user.id
- 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 18 (exceeds 5 allowed). Consider refactoring. Open
def update
@transaction = Transaction.find(params[:id])
original_state = @transaction.state
if params[:state]
@transaction.update(state: params[:state])
- 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 large_picture_for
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def large_picture_for(lacquer)
if lacquer.picture && valid?(lacquer.picture)
begin
if lacquer.brand.name == "Deborah Lippmann"
image_tag(lacquer.picture, :size => "360x360", :class => "padded_lacquer_pic_large deborah")
- 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 small_picture_for
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def small_picture_for(lacquer)
if lacquer.picture && valid?(lacquer.picture)
begin
if lacquer.brand.name == "Deborah Lippmann"
image_tag(lacquer.picture, :size => "31x50", :class => "padded_lacquer_pic_small")
- 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 picture_for
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def picture_for(lacquer)
if lacquer.picture && valid?(lacquer.picture)
begin
if lacquer.brand.name == "Zoya" || lacquer.brand.name == "Nars" || lacquer.brand.name == "I Love Nail Polish (ILNP)" || lacquer.brand.name == "Formula X by Sephora"
image_tag(lacquer.picture, :size => "90x90", :class => "chunky_image")
- 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 edit
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def edit
session[:originated_from_uri] = request.env["HTTP_REFERER"] if request.env["HTTP_REFERER"]
if !current_user
flash[:alert] = "You must be signed in to edit a lacquer!"
redirect_to root_path
- 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 new_transactional_message
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def new_transactional_message
if !@user
if request.env['REQUEST_URI']
session[:intended_uri] = request.env['REQUEST_URI']
flash[:notice] = %Q[ #{ view_context.link_to("Sign in", login_path, id:"brand-show-sign-in", class:'light-blue-link')} to send a message! ]
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
def update
@user_lacquer = UserLacquer.find(params[:lacquer][:user_lacquer_id])
if @lacquer.user_added_by_id != @user.id && params[:lacquer][:name] || params[:lacquer][:brand_id]
flash[:alert] = "You do not have permission to change the name or brand of this lacquer."
- 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 new
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def new
if !@user && request.env['REQUEST_URI']
if request.env['REQUEST_URI'].scan(/(?<=friend_id=)\d+/)[0]
session[:intended_uri] = request.env['REQUEST_URI']
@friend = User.find("#{session[:intended_uri].scan(/(?<=friend_id=)\d+/)[0]}")
- 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 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
@transaction = Transaction.find(params[:id])
original_state = @transaction.state
if params[:state]
@transaction.update(state: params[:state])
Method send_feedback_email
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def send_feedback_email
if current_user && params[:reply_address] == current_user.email
reply_address = "#{current_user.name} <#{params[:reply_address]}>"
elsif is_an_email_address?(params[:other_reply_address])
reply_address = params[:other_reply_address]
- 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 create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
if request.env['omniauth.auth'].present?
existing_user = User.find_by(uid: request.env['omniauth.auth']['uid'])
user = User.from_omniauth(request.env['omniauth.auth'])
session[:user_id] = user.id
Method show
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
if current_user
[{"OPI" => [@new_opi_lacquer, @opi_lacquers]}, {"Essie" => [@new_essie_lacquer, @essie_lacquers]}, {"Butter London" => [@new_butter_lacquer, @butter_lacquers]}, {"Deborah Lippmann" => [@new_deborah_lacquer, @deborah_lacquers]}].each do |brand_hash|
brand_hash.each do |brand, variables|
if !Brand.where(name: brand).empty?
Method update
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update
if current_user && @review.user.id == current_user.id
if @review.update(review_params)
flash[:notice] = "Your review for #{@review.lacquer.name} was successfully updated!"
else
- 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 invite_friends
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def invite_friends
if !@user
flash[:alert] = "You need to be logged in to invite friends!"
redirect_to :back
else
- 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 create
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def create
if params[:friendship] && params[:friendship].has_key?(:friend_id)
@friend = User.find(params[:friendship][:friend_id])
@friendship = Friendship.new(friend: @friend, user: @user)
if @friendship.save
- 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 large_picture_for
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def large_picture_for(lacquer)
if lacquer.picture && valid?(lacquer.picture)
begin
if lacquer.brand.name == "Deborah Lippmann"
image_tag(lacquer.picture, :size => "360x360", :class => "padded_lacquer_pic_large deborah")
Method new_transactional_message
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_transactional_message
if !@user
if request.env['REQUEST_URI']
session[:intended_uri] = request.env['REQUEST_URI']
flash[:notice] = %Q[ #{ view_context.link_to("Sign in", login_path, id:"brand-show-sign-in", class:'light-blue-link')} to send a message! ]