Showing 13 of 22 total issues
Method index
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def index
@product_categories = ProductCategory.roots.order(title: :asc)
@post_category = Category.friendly.find(params[:post_category_id]) unless params[:post_category_id].nil?
if params[: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 call
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def call
# Get products
category_ids = context.parent_product_category ? context.parent_product_category.subtree.map(&:subtree_ids).flatten.uniq : nil
products = Product.where(category_id: category_ids)
if context.post_category.present?
- 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 find_for_oauth
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.find_for_oauth(auth, signed_in_resource = nil)
identity = Identity.find_for_oauth(auth)
user = signed_in_resource ? signed_in_resource : identity.user
if user.nil?
email_is_verified = auth.info.email && (auth.info.verified || auth.info.verified_email)
- 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 call
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def call
context.fail!(error: 'Product not found') unless context.product.present?
product = context.product
records = ActiveRecord::Base.connection.execute(raw_query(product.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 call
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call
# Get products
category_ids = context.parent_product_category ? context.parent_product_category.subtree.map(&:subtree_ids).flatten.uniq : nil
products = Product.where(category_id: category_ids)
if context.post_category.present?
Method update
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update
respond_to do |format|
update_method = user_params[:password].present? ? 'update_with_password' : 'update'
if @user.send(update_method, user_params)
user_params[:subscriber_agreement] == '1' ? @user.add_as_subscriber : @user.opt_out_from_subscription
- 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 finish_signup
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def finish_signup
if request.patch? && @user.present? && params[:user] && params[:user][:email]
if @user.update(sign_up_params)
sign_up_params[:subscriber_agreement] == '1' ? @user.add_as_subscriber : @user.opt_out_from_subscription
bypass_sign_in(@user)
- 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 index
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@product_categories = ProductCategory.roots.order(title: :asc)
@post_category = Category.friendly.find(params[:post_category_id]) unless params[:post_category_id].nil?
if params[:id]
Method create
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create
@result = false
@message = nil
subscriber = Subscriber.find_by(email: subscriber_params[:email])
if subscriber
- 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 set_facets
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_facets
@facets.keys.each do |k|
@facets['Kategoriler'] = @facets.delete(k) if k == 'categories'
@facets['Kullanılan Ekipmanlar'] = @facets.delete(k) if k == 'products'
@facets['Çalıştığı Şirket'] = @facets.delete(k) if k == 'company'
- 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 call
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def call
post = context.post
if post.present? && post.decorate.notifiable?
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
return unless user
return if user.role == 'user'
can :access, :rails_admin
can :dashboard
- 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 facet_filters
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def facet_filters
filters = []
filters << "categories:#{@params[:category]}" unless @params[:category].blank?
filters << "company:#{@params[:company]}" unless @params[:company].blank?
filters << "products:#{@params[:product]}" unless @params[:product].blank?
- 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"