app/services/leave_time_usage_builder.rb
Method build_leave_time_usages
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
Open
def build_leave_time_usages
ActiveRecord::Base.transaction do
validate_application_covered_by_leave_time_interval
@available_leave_times.each do |lt|
- 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 validate_application_covered_by_leave_time_interval
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def validate_application_covered_by_leave_time_interval
include_start_time = include_end_time = false
@available_leave_times.each do |lt|
include_start_time = true if lt.cover?(@leave_hours_by_date.keys.first) # leave_time start_date 跟 date 相同會不會 cover 到
include_end_time = true if lt.cover?(@leave_hours_by_date.keys.last)
- 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"