Showing 11 of 17 total issues
Method convert_exam
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def convert_exam(exam)
ImportedExam.played_by(exam) do |exam|
Event.new(
starts_at: exam.start_date,
ends_at: exam.end_date,
- 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 plan_events
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def plan_events(slot, teacher)
periods_query = @semester.semester_periods_dataset
.where(type: ['teaching', 'exams'])
.order(:starts_at)
periods = periods_query.map { |p| PlannedSemesterPeriod.new(p) }
Method then
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def then *guards, &block
if guards.empty?
return self if not self
else
guards.each do |cond|
- 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 week_parity
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def week_parity(date)
return unless teaching?
if date < starts_at.start_of_week || date > ends_at.end_of_week then
fail ArgumentError, "The date's week is not within this period"
- 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 perform
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def perform(events: , params: {}, format: :jsonapi)
@format = format
# XXX: This is a hack for backward compatibility. Parameter "deleted"
# used to be a Boolean and we added additional value "all".
- 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_enum_setter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_enum_setter(column, column_schema)
enum_values = column_schema[:enum_values].to_set
if column_schema[:allow_null]
enum_values.add(nil)
end
- 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_token
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_token(token)
if token.status == 400
"Invalid access token."
elsif token.status != 200
"Unable to verify access token (status: #{token.status}).".tap do |msg|
- 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 has_any_role?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def has_any_role?(*roles)
fail 'Cannot check roles without username.' unless username
roles = Set.new(roles)
- 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 convert_slot
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def convert_slot(slot, parallel_id)
room_code = slot.room.link_id if slot.room
slot_hash = slot.to_hash.select { |key, _| DB_KEYS.include? key }
weeks = parse_weeks(slot.weeks)
- 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 user_has_roles?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def user_has_roles?(username, roles, operator: :all)
fail ArgumentError, "Parameter 'username' must not be blank." if username.blank?
fail ArgumentError, "Parameter 'roles' must not be empty." if roles.nil? || roles.empty?
unless operator.to_s.in? %(all any 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 receive_hungry
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def receive_hungry
return if output_hungry?
if buffer_empty?
@_output_state = :hungry
else
- 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"