app/models/automation_task_leadership.rb
Method perform_task
has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring. Open
Open
def perform_task(user=self.user)
ret_val = {log_lines: log_lines=[], errors: errors=[]}
section = Osm::Section.get(user.osm_api, section_id)
if section.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 perform_task
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def perform_task(user=self.user)
ret_val = {log_lines: log_lines=[], errors: errors=[]}
section = Osm::Section.get(user.osm_api, section_id)
if section.nil?
Avoid deeply nested control flow statements. Open
Open
rescue Osm::Error => exception
member_lines.push "Couldn't mark the \"#{badge.name}\" badge as due. OSM said \"#{exception.message}\"."
errors.push "Couldn't mark badge as due for \"#{badge.name}\" & \"#{member.name}\". OSM said \"#{exception.message}\"."
Avoid deeply nested control flow statements. Open
Open
if badge_data.mark_due(user.osm_api)
member_lines.push "Marked the \"#{badge.name}\" badge as due."
else
member_lines.push "Couldn't mark the \"#{badge.name}\" badge as due."
errors.push "Couldn't mark badge as due for \"#{badge.name}\" & \"#{member.name}\"."