autolab/Autolab

View on GitHub
app/controllers/lti_nrps_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

Method parse_members_data has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_members_data(lcd, members_data)
    cuds = @course.course_user_data.all.to_set
    email_to_cud = {}
    cuds.each do |cud|
      email_to_cud[cud.user.email] = cud
Severity: Minor
Found in app/controllers/lti_nrps_controller.rb - About 3 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 request_access_token has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def request_access_token
    # get private key from JSON file to sign Autolab's client assertion as a JWK
    unless File.size?("#{Rails.configuration.config_location}/lti_tool_jwk.json")
      flash[:error] = "Autolab's JWK JSON file was not found"
      redirect_to([:users, @course]) && return
Severity: Major
Found in app/controllers/lti_nrps_controller.rb - About 2 hrs to fix

    Method parse_members_data has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def parse_members_data(lcd, members_data)
        cuds = @course.course_user_data.all.to_set
        email_to_cud = {}
        cuds.each do |cud|
          email_to_cud[cud.user.email] = cud
    Severity: Minor
    Found in app/controllers/lti_nrps_controller.rb - About 1 hr to fix

      Method request_access_token has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def request_access_token
          # get private key from JSON file to sign Autolab's client assertion as a JWK
          unless File.size?("#{Rails.configuration.config_location}/lti_tool_jwk.json")
            flash[:error] = "Autolab's JWK JSON file was not found"
            redirect_to([:users, @course]) && return
      Severity: Minor
      Found in app/controllers/lti_nrps_controller.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 sync_roster has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def sync_roster
          lcd = LtiCourseDatum.find(params[:lcd_id])
          if lcd.nil? || lcd.membership_url.nil? || lcd.course_id.nil?
            raise LtiLaunchController::LtiError.new("Unable to update roster", :bad_request)
          end
      Severity: Minor
      Found in app/controllers/lti_nrps_controller.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 query_nrps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def query_nrps
          # Initially use the context membership url to start querying NRPS
          next_page_url = @lti_context_membership_url
          members = []
          while !next_page_url.nil?
      Severity: Minor
      Found in app/controllers/lti_nrps_controller.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

      Avoid too many return statements within this method.
      Open

            redirect_to([:users, @course]) && return
      Severity: Major
      Found in app/controllers/lti_nrps_controller.rb - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status