Showing 17 of 23 total issues
Method initialize
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
user ||= User.new
# Idea permissions
draft_or_submitted = [:draft, :submitted].map { |sym| IdeaStateMachine.state_value(sym) }
Class Idea
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Idea < ActiveRecord::Base
# attr_accessible :title, :problem, :solution, :metrics, :deadline, :author, :design_size, :development_size, :rating, :category, :product_manager, :active_at
belongs_to :author, :class_name => 'User'
belongs_to :account
Class IdeasController
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class IdeasController < ApplicationController
include Traits::RequiresLogin
before_filter :require_account!
before_filter :cleanup_session
Method initialize
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
user ||= User.new
# Idea permissions
draft_or_submitted = [:draft, :submitted].map { |sym| IdeaStateMachine.state_value(sym) }
- 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 votes_message
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def votes_message(record, action)
if record.subject.kind_of?(Idea)
case action
when :ok then _('You have endorsed the idea.')
when :fail then _('Failed to endorse the idea.')
- 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 idea_copy_for_state
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def idea_copy_for_state(state_name)
case state_name
when :archived
_("This idea is archived: It has been moved out of the stack to make way for other ideas.")
when :graveyarded
Method create
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create
@comment = Comment.new(comment_params)
@comment.author = current_user
authorize! :create, @comment if @comment.valid?
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
def update
@idea = find_idea(params[:id])
# specifics on account change
if new_account_id = idea_params.delete(:account_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 index
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def index
@angle = set_angle_from_params
@order = set_order_from_params_and_angle
@filter = set_filter_from_params_and_angle
@category = set_category_from_params_and_angle
- 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 act_as_user
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def act_as_user(user_id)
assumed_user = current_account.users.find_by_id(user_id)
unless assumed_user
flash[:error] = _("Oops, we could not find the user you're trying to act as.")
return
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def update
notifications = if params[:id] == 'all'
current_user.notifications
else
current_user.notifications.where(id: params[:id].to_i)
- 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 after_create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def after_create(record)
return unless record.subject # happens in a few tests
case record.subject
when Comment
Notification::NewVoteOnComment.create! recipient:record.subject.author, subject:record
- 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 can_link_to
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def can_link_to(*args, &block)
options = args.last { |arg| arg.kind_of?(Hash) }.dup
auth_criteria = options.delete(:auth)
auth_condition = auth_criteria.nil? ? true : can?(*auth_criteria)
- 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 idea_unavailable_action_tooptip
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def idea_unavailable_action_tooptip(idea, state)
if idea.is_state_in_future?(state)
case state
when :vetted
s_('Tooltip|This idea cannot be vetted yet.')
- 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 after_save
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def after_save(record)
return unless record.account && record.account_id_changed?
record.account.users.each do |account_user|
next if account_user == record # don't get notified when I join
Notification::NewUser.create!(recipient:account_user, subject:record)
- 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_category_from_params_and_angle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_category_from_params_and_angle
session[:ideas_category] ||= {}
params[:category] =
session[:ideas_category][@angle] = begin
valid_categories = (current_user.account.andand.categories || []) + %w(all none)
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def create
idea = current_account.ideas.find(params[:user_bookmark][:idea_id])
@user_bookmark = current_user.bookmarks.new(idea: idea)
if @user_bookmark.save
flash[:success] = _('Bookmark successfuly added.')
- 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"