concord-consortium/rigse

View on GitHub
rails/app/models/portal/school_selector.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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
Severity: Minor
Found in rails/app/models/portal/school_selector.rb - About 3 hrs to fix

    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)
    Severity: Minor
    Found in rails/app/models/portal/school_selector.rb - About 1 hr to fix

    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|
    Severity: Minor
    Found in rails/app/models/portal/school_selector.rb - About 55 mins to fix

    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
    Severity: Minor
    Found in rails/app/models/portal/school_selector.rb - About 25 mins to fix

    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
    Severity: Minor
    Found in rails/app/models/portal/school_selector.rb - About 25 mins to fix

    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

    There are no issues that match your filters.

    Category
    Status