Showing 4 of 6 total issues
Method create
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@lt = LabTime.new(lt_params)
days_of_week = {
"Monday" => Date.new(2000, 1, 3),
"Tuesday" => Date.new(2000, 1, 4),
Method match
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def match
las = LabAssistant.includes(:lab_times).where('validated =?', true).order(preferred_lab_times: :asc)
las.to_a.each do |la|
# only assign lab assistants without lab time
if not la.lab_times.to_a.size > 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 initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
return unless user
if user.is_a? Admin
can :manage, :admin_dashboard
can [:edit, :update], Admin, 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 create_contract
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_contract
la = LabAssistant.find_by_email(contract_params[:email_address])
if la.nil?
la = LabAssistant.new
la.first_name = contract_params[:first_name]
- 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"