rails/app/models/portal/learner.rb
Method elastic_search_learner_model
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def elastic_search_learner_model
{
learner_id: self.id,
report_learner_id: self.report_learner_only_id.id,
student_id: self.student.id,
Method update_report_model_cache
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def update_report_model_cache(skip_report_learner_update = false)
unless (skip_report_learner_update)
# We need to keep this in for now, to keep the ReportLearner up-to-date for the built-in reports.
# update_fields also updates the activity completion status as a side-effect, something that would
# be easy to re-add here if/when we remove ReportLearners
- 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"