File course.rb
has 471 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'gdocs_export'
require 'system_commands'
require 'date_and_time_utils'
class Course < ApplicationRecord
Class Course
has 51 methods (exceeds 20 allowed). Consider refactoring. Open
class Course < ApplicationRecord
include SystemCommands
include Swagger::Blocks
swagger_schema :Course do
Method exercise_group_completion_counts_for_user
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def exercise_group_completion_counts_for_user(user)
# TODO: clean up exercise group discovery
groups = exercises.enabled.map(&:name).map { |name| name =~ /^(.+)-[^-]+$/ ? Regexp.last_match(1) : '' }.uniq.sort
- 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 exercise_group_completion_by_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def exercise_group_completion_by_user
# TODO: clean up exercise group discovery
groups = exercises
.where(disabled_status: 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 visible_to?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def visible_to?(user)
user.administrator? ||
user.teacher?(organization) ||
user.assistant?(self) || (
initial_refresh_ready? &&
- 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"