<commit_before>class Course::Controller < ApplicationController
  load_and_authorize_resource :course

  # Gets the sidebar elements.
  #
  # Sidebar elements have the given format:
  #
  # ```
  # {
  #    title: 'Sidebar Item Title'
  #    unread: 0 # or nil
  # }
  # ```
  #
  # The elements are rendered on all Course controller subclasses as part of a nested template.
  def sidebar
    array_of_module_arrays = Course::CoursesController.modules.map do |module_|
      module_.get_sidebar_items(self)
    end

    array_of_module_arrays.flatten!
  end<commit_msg>refator sidebar to prevent nil result<commit_after>class Course::Controller < ApplicationController
  load_and_authorize_resource :course

  # Gets the sidebar elements.
  #
  # Sidebar elements have the given format:
  #
  # ```
  # {
  #    title: 'Sidebar Item Title'
  #    unread: 0 # or nil
  # }
  # ```
  #
  # The elements are rendered on all Course controller subclasses as part of a nested template.
  def sidebar
    array_of_module_arrays = Course::CoursesController.modules.map do |module_|
      module_.get_sidebar_items(self)
    end

    array_of_module_arrays.tap { |arr| arr.flatten! }
  end
{'fraction_non_alphanumeric': 0.08389830508474576, 'fraction_numerical': 0.001694915254237288, 'mean_word_length': 3.4232209737827715, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6870452', 'n_tokens_mistral': 377, 'n_tokens_neox': 364, 'n_words': 102}