testmycode/tmc-server

View on GitHub
lib/course_refresh_database_updater.rb

Summary

Maintainability
C
1 day
Test Coverage

Method update_available_points has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def update_available_points
        @rust_data['exercises'].each do |exercise|
          added = []
          removed = []

Severity: Minor
Found in lib/course_refresh_database_updater.rb - About 2 hrs 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 refresh_course has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def refresh_course(course, data)
        @report = Report.new
        @rust_data = data['output-data']
        Course.transaction(requires_new: true) do
          @course = Course.find(course.id)
Severity: Minor
Found in lib/course_refresh_database_updater.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 update_exercise_checksums has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def update_exercise_checksums
        @rust_data['exercises'].each do |exercise|
          ex = @course.exercises.find { |e| e.name == exercise['name'] }
          next unless ex
          if ex.checksum != exercise['checksum']
Severity: Minor
Found in lib/course_refresh_database_updater.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 update_available_points has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def update_available_points
        @rust_data['exercises'].each do |exercise|
          added = []
          removed = []

Severity: Minor
Found in lib/course_refresh_database_updater.rb - About 1 hr to fix

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

          def set_memory_limit
            @rust_data['exercises'].each do |exercise|
              ex = @course.exercises.find { |e| e.name == exercise['name'] }
              next unless ex
              if (exercise['tmcproject-yml'] || {}).include? 'memory_gb'
    Severity: Minor
    Found in lib/course_refresh_database_updater.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 set_docker_image has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def set_docker_image
            default_image = Exercise.new.docker_image
            @rust_data['exercises'].each do |exercise|
              ex = @course.exercises.find { |e| e.name == exercise['name'] }
              next unless ex
    Severity: Minor
    Found in lib/course_refresh_database_updater.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 set_cpu_limit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def set_cpu_limit
            @rust_data['exercises'].each do |exercise|
              ex = @course.exercises.find { |e| e.name == exercise['name'] }
              next unless ex
              if (exercise['tmcproject-yml'] || {}).include? 'cpus'
    Severity: Minor
    Found in lib/course_refresh_database_updater.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

    There are no issues that match your filters.

    Category
    Status