Class SchoolSelector
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class Portal::SchoolSelector
USA = "United States"
NO_STATE = "XX" # db field width is 2 chars. :
CHOICES_FILE = File.join(Rails.root, "resources", "country_list.txt")
@@country_choices = nil
Method add_portal_resource
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_portal_resource(symbol)
attribute_name = get_attr("#{symbol}_name")
attribute = get_attr(symbol)
portal_clazz = "Portal::#{symbol.to_s.capitalize}".constantize
if self.allow_teacher_creation(symbol)
- 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
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate
@needs = nil
@choices = {}
previous_change = false
attr_order.each do |attr|
- 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_district
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_district
return true if add_district
if @district && (@district.kind_of? String)
@district = Portal::District.find(@district)
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 allow_teacher_creation
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def allow_teacher_creation(field=:school)
acceptable_fields = []
if self.country == USA
acceptable_fields << [:district] if self.state
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"