testmycode/tmc-server

View on GitHub
app/models/course.rb

Summary

Maintainability
D
2 days
Test Coverage

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

    Class Course has 51 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Course < ApplicationRecord
      include SystemCommands
      include Swagger::Blocks
    
      swagger_schema :Course do
    Severity: Major
    Found in app/models/course.rb - About 7 hrs to fix

      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
      
      
      Severity: Minor
      Found in app/models/course.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 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)
      Severity: Minor
      Found in app/models/course.rb - About 35 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 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? &&
      Severity: Minor
      Found in app/models/course.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