vegantech/sims

View on GitHub
lib/training_district/student.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method add_extended_profile has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.add_extended_profile(student)
    FactoryGirl.create :ext_summary, student: student
    FactoryGirl.create :ext_adult_contact, student: student
    FactoryGirl.create :ext_sibling, student: student
    student.ext_test_scores.create!( [
Severity: Minor
Found in lib/training_district/student.rb - About 1 hr to fix

    Method generate_other_students has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.generate_other_students(district,school,group)
        grades= ['K', '1', '2', '3', '4', '5']
    
        31.upto(60) do |i|
          esl=rand(3) == 1
    Severity: Minor
    Found in lib/training_district/student.rb - About 45 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 generate_students has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.generate_students(district,school,group)
        1.upto(30) do |i|
          s=FactoryGirl.create(:student, :district => district, :birthdate=>10.years.ago, :first_name => first_names[i-1+ 50*(i %2)].strip, :last_name => "#{i.to_s.rjust(2,'0')}-#{last_names[i-1].capitalize.strip}",
            :number => (i-1).to_s)
          s.enrollments.create!(:school => school, :grade => 5)
    Severity: Minor
    Found in lib/training_district/student.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