Coursemology/coursemology2

View on GitHub

Showing 1,214 of 1,261 total issues

Method zip_test_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def zip_test_files(test_type, zip) # rubocop:disable Metrics/AbcSize
    # Print test class preamble
    test_class_name = "#{test_type}_tests_grader".camelize
    class_definition = <<~PYTHON
      class #{test_class_name}(unittest.TestCase):

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 explanations_for_incorrect_point_missing_keywords has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def explanations_for_incorrect_point_missing_keywords(answer_text_lemma_status, point)
    empty_information = I18n.t('course.assessment.answer.text_response_comprehension_auto_grading.explanations.empty_information')
    missing_keywords = point.
                       solutions.
                       select(&:compre_keyword?).

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 switch_mcq_mrq_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def switch_mcq_mrq_type(is_mcq, unsubmit)
    grading_scheme = is_mcq ? :any_correct : :all_correct

    result = @multiple_response_question.update(grading_scheme: grading_scheme)
    if result

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 get_token_from_bearer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def get_token_from_bearer
    authorization_header_elements = request.headers['Authorization']&.split

    # render json: REQUIRES_AUTHENTICATION, status: :unauthorized and return unless authorization_header_elements
    return nil unless authorization_header_elements
Severity: Minor
Found in app/controllers/concerns/application_authentication_concern.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 zip_test_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def zip_test_files(test_type, zip) # rubocop:disable Metrics/AbcSize
    tests = @test_params[:test_cases]
    tests[test_type]&.each&.with_index(1) do |test, index|
      # String types should be displayed with quotes, other types will be converted to string
      # with the str method.

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

Function afterDraw has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  afterDraw(chart) {
    if (
      chart.data.datasets.length === 0 ||
      chart.data.datasets.every((d) => d.data.length === 0)
    ) {
Severity: Minor
Found in client/app/lib/components/core/charts/emptyChartPlugin.ts - 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

Function AssessmentConditionForm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const AssessmentConditionForm = (
  props: AnyConditionProps<AssessmentConditionData> & {
    assessments: AvailableAssessments;
  },
): JSX.Element => {

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 create_success_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create_success_response(submission)
    is_course_koditsu_enabled = current_course.component_enabled?(Course::KoditsuPlatformComponent)

    if is_course_koditsu_enabled && @assessment.is_koditsu_enabled
      submission.create_new_answers
Severity: Minor
Found in app/controllers/course/assessment/submission/submissions_controller.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 submission_files= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def submission_files=(files)
    ensure_file_open!
    remove_folder_files(SUBMISSION_PATH)

    files.each do |path, file|
Severity: Minor
Found in lib/autoload/course/assessment/programming_package.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

Function useDynamicNest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const useDynamicNest = (): UseDynamicNestHook => {
  const matches = useMatches();
  const location = useLocation();

  const [state, setState] = useState<CrumbState>({});
Severity: Minor
Found in client/app/lib/hooks/router/dynamicNest/useDynamicNest.ts - 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 highlight_code_block has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def highlight_code_block(code, language = nil)
    return if code_size_exceeds_limit?(code)

    code = html_escape(code) unless code.html_safe?
    code = code.gsub(/\r\n|\r/, "\n").html_safe
Severity: Minor
Found in app/helpers/application_html_formatters_helper.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 deduce_tenant_host has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def deduce_tenant_host
    if Rails.env.development?
      default_app_host = Application::Application.config.x.default_app_host

      if request.host.downcase.ends_with?(default_app_host)
Severity: Minor
Found in app/controllers/concerns/application_multitenancy.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 closing_reminder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def closing_reminder(survey, token)
    email_enabled = survey.course.email_enabled(:surveys, :closing_reminder)
    return unless survey.closing_reminder_token == token && survey.published?
    return unless email_enabled.phantom || email_enabled.regular

Severity: Minor
Found in app/services/course/survey/reminder_service.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 view has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def view(data)
    session_id, limit = data['session_id'], data['limit'] || DEFAULT_VIEW_HEARTBEATS_LIMIT
    return unless (session = @monitor.sessions.find(session_id))

    recent_heartbeats = (limit == -1 ? session.heartbeats : session.heartbeats.last(limit)).map do |heartbeat|
Severity: Minor
Found in app/channels/course/monitoring/live_monitoring_channel.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 create_koditsu_invitation_job has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create_koditsu_invitation_job
    is_course_koditsu_enabled = current_course.component_enabled?(Course::KoditsuPlatformComponent)
    is_assessment_koditsu_enabled = @assessment.koditsu_assessment_id && @assessment.is_koditsu_enabled

    return unless is_course_koditsu_enabled && is_assessment_koditsu_enabled
Severity: Minor
Found in app/controllers/course/assessment/assessments_controller.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 uncompleted_subscribed_students has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def uncompleted_subscribed_students(survey, include_phantom, include_unsubscribed)
    course_users = survey.course.course_users.student
    email_enabled = survey.course.email_enabled(:surveys, :closing_reminder)
    # Eager load :user as it's needed for the recipient email.
    students = if (email_enabled.regular && !email_enabled.phantom) || !include_phantom
Severity: Minor
Found in app/services/course/survey/reminder_service.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 top_level_split has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def top_level_split(text, delimiter)
    opening = '([{'
    closing = ')]}'
    balance = 0
    idx = 0

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 pending_assessment_submissions_count has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def pending_assessment_submissions_count
    self.class.include Course::Assessment::SubmissionsHelper

    if current_course_user&.manager_or_owner?
      (my_students_pending_submissions_count > 0) ? my_students_pending_submissions_count : pending_submissions_count
Severity: Minor
Found in app/controllers/concerns/course/unread_counts_concern.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 poll_codaveri_evaluation_results has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def poll_codaveri_evaluation_results(response_status, response_body, evaluation_id)
    poll_count = 0
    until ![201, 202].include?(response_status) || poll_count >= MAX_POLL_RETRIES
      sleep(POLL_INTERVAL_SECONDS)
      response_status, response_body = fetch_codaveri_evaluation(evaluation_id)

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 get_output has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def get_output(test_case_result)
    if test_case_result
      output = test_case_result.messages['output']
      output = test_case_result.messages['failure'] if output.blank?
      # For codaveri programming test output, the stderror for each test case
Severity: Minor
Found in app/helpers/course/assessment/answer/programming_test_case_helper.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

Severity
Category
Status
Source
Language