Showing 12 of 16 total issues
Class WorkshiftAssignment
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class WorkshiftAssignment < ActiveRecord::Base
belongs_to :workshifter, class_name: "User", foreign_key: "workshifter_id"
belongs_to :verifier, class_name: "User", foreign_key: "verifier_id"
belongs_to :workshift
belongs_to :unit
Method best_assignment_candidates
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def best_assignment_candidates(unit)
best_candidates = {
highest_pref: [],
most_needed_hours: []
}
- 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 best_assignment_candidates
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def best_assignment_candidates(unit)
best_candidates = {
highest_pref: [],
most_needed_hours: []
}
Method profile
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def profile
id = params[:id] || current_user.id
@user = User.where(unit_id: current_user.unit).find(id)
@other_units = (Unit.all.size == 1) ? Unit.all : Unit.find(:all, :conditions => ["id != ?", @user.id])
if not @user.unit.nil?
- 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 hours_multiplier
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def hours_multiplier
return -1 if status == 'missed'
return 1 if status == 'complete'
if purchased?
return -1 if status == 'blown'
- 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 time_to_hour_string
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.time_to_hour_string(time)
hour = time.hour
if hour <= 12
period = (hour > 10) ? "PM" : "AM"
if (hour == 12)
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def create
authorize :workshift
days = params[:workshift].delete('day')
days.pop # remove added empty string ('') entry
if days.length == 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
Avoid too many return
statements within this method. Open
return -2 if status == 'blown'
Avoid too many return
statements within this method. Open
return -1 if status == 'sold'
Method add_users
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_users
authorize :user
@user_info = params[:user_info]
begin
if current_user.workshift_manager? or current_user.unit_level_admin?
- 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_workshifter_hours_balance
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_workshifter_hours_balance
case status
when "complete"
if purchased?
self.workshifter.hours_balance += self.hours
- 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_users_in_units
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.invite_users_in_units(user_info)
fail ArgumentError, 'Must input at least one userattr_accessible' if user_info.length == 0
num_invited = 0
CSV.parse(user_info) do |row|
fail ArgumentError, 'Improperly formatted user information on row '\
- 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"