diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 9f1f0fa706d30..ea4cda12eca40 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -649,7 +649,7 @@ def courses_api end if params[:sort] && params[:order] - order += (params[:order] == "desc" ? " DESC, id DESC" : ", id") + order += ((params[:order] == "desc") ? " DESC, id DESC" : ", id") end opts = { include_crosslisted_courses: value_to_boolean(params[:include_crosslisted_courses]) } @@ -1727,7 +1727,7 @@ def account_calendar_settings end def format_avatar_count(count = 0) - count > 99 ? "99+" : count + (count > 99) ? "99+" : count end private :format_avatar_count diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4e62a4725e302..235f2900a50af 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -676,7 +676,7 @@ def use_new_math_equation_handling? end def user_url(*opts) - opts[0] == @current_user ? user_profile_url(@current_user) : super + (opts[0] == @current_user) ? user_profile_url(@current_user) : super end protected @@ -1913,7 +1913,7 @@ def verified_file_request? # Retrieving wiki pages needs to search either using the id or # the page title. def get_wiki_page - GuardRail.activate(params[:action] == "edit" ? :primary : :secondary) do + GuardRail.activate((params[:action] == "edit") ? :primary : :secondary) do @wiki = @context.wiki @page_name = params[:wiki_page_id] || params[:id] || (params[:wiki_page] && params[:wiki_page][:title]) @@ -1937,7 +1937,7 @@ def get_wiki_page end def content_tag_redirect(context, tag, error_redirect_symbol, tag_type = nil) - url_params = tag.tag_type == "context_module" ? { module_item_id: tag.id } : {} + url_params = (tag.tag_type == "context_module") ? { module_item_id: tag.id } : {} if tag.content_type == "Assignment" use_edit_url = params[:build].nil? && Account.site_admin.feature_enabled?(:new_quizzes_modules_support) && diff --git a/app/controllers/assignments_api_controller.rb b/app/controllers/assignments_api_controller.rb index 9de067c3a98d7..c74a2d3dbd957 100644 --- a/app/controllers/assignments_api_controller.rb +++ b/app/controllers/assignments_api_controller.rb @@ -1470,7 +1470,7 @@ def render_create_or_update_result(result, opts = {}) if [:created, :ok].include?(result) render json: assignment_json(@assignment, @current_user, session, opts), status: result else - status = result == :forbidden ? :forbidden : :bad_request + status = (result == :forbidden) ? :forbidden : :bad_request errors = @assignment.errors.as_json[:errors] errors["published"] = errors.delete(:workflow_state) if errors.key?(:workflow_state) render json: { errors: errors }, status: status @@ -1486,7 +1486,7 @@ def invalid_bucket_error def require_user_visibility return render_unauthorized_action unless @current_user.present? - @user = params[:user_id] == "self" ? @current_user : api_find(User, params[:user_id]) + @user = (params[:user_id] == "self") ? @current_user : api_find(User, params[:user_id]) # teacher, ta return if @context.grants_right?(@current_user, :view_all_grades) && @context.students_visible_to(@current_user).include?(@user) diff --git a/app/controllers/brand_configs_controller.rb b/app/controllers/brand_configs_controller.rb index 8f953c45ad52d..28af24ef22c85 100644 --- a/app/controllers/brand_configs_controller.rb +++ b/app/controllers/brand_configs_controller.rb @@ -162,7 +162,7 @@ def save_to_user_session def save_to_account old_md5 = @account.brand_config_md5 session_config = session.delete(:brand_config) - new_md5 = session_config.nil? || session_config[:type] == :default ? nil : session_config[:md5] + new_md5 = (session_config.nil? || session_config[:type] == :default) ? nil : session_config[:md5] new_brand_config = new_md5 && BrandConfig.find(new_md5) progress = BrandConfigRegenerator.process(@account, @current_user, new_brand_config) diff --git a/app/controllers/calendar_events_api_controller.rb b/app/controllers/calendar_events_api_controller.rb index db2224c9a5634..f419fbecd76b9 100644 --- a/app/controllers/calendar_events_api_controller.rb +++ b/app/controllers/calendar_events_api_controller.rb @@ -920,7 +920,7 @@ def update_from_series(target_event, params_for_update, which) end all_events = find_which_series_events(target_event: target_event, which: "all", for_update: true) - events = which == "following" ? all_events.where("start_at >= ?", target_event.start_at) : all_events + events = (which == "following") ? all_events.where("start_at >= ?", target_event.start_at) : all_events if events.blank? # i don't believe we can get here, but cya render json: { message: t("No events were found to update") }, status: :bad_request @@ -1293,7 +1293,7 @@ def set_course_timetable updated_section_ids = [] timetable_data.each do |section_id, timetables| timetable_data[section_id] = Array(timetables) - section = section_id == "all" ? nil : api_find(@context.active_course_sections, section_id) + section = (section_id == "all") ? nil : api_find(@context.active_course_sections, section_id) updated_section_ids << section.id if section builder = Courses::TimetableEventBuilder.new(course: @context, course_section: section) @@ -1453,7 +1453,7 @@ def get_options(codes, user = @current_user) @end_date = @start_date.end_of_day if @end_date < @start_date end - @type ||= params[:type] == "assignment" ? :assignment : :event + @type ||= (params[:type] == "assignment") ? :assignment : :event @context ||= user include_accounts = Account.site_admin.feature_enabled?(:account_calendar_events) diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index a4d6fe527f8e1..24d7d7296a582 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -80,7 +80,7 @@ def show can_update_todo_date: context.grants_any_right?(@current_user, session, :manage_content, :manage_course_content_edit), can_update_discussion_topic: context.grants_right?(@current_user, session, :moderate_forum), can_update_wiki_page: context.grants_right?(@current_user, session, :update), - concluded: (context.is_a? Course) ? context.concluded? : false, + concluded: context.is_a?(Course) ? context.concluded? : false, k5_course: context.is_a?(Course) && context.elementary_enabled?, course_pacing_enabled: context.is_a?(Course) && @domain_root_account.feature_enabled?(:course_paces) && context.enable_course_paces, user_is_observer: context.is_a?(Course) && context.enrollments.where(user_id: @current_user).first&.observer?, diff --git a/app/controllers/communication_channels_controller.rb b/app/controllers/communication_channels_controller.rb index a640adafd7856..b72dc7da2674f 100644 --- a/app/controllers/communication_channels_controller.rb +++ b/app/controllers/communication_channels_controller.rb @@ -306,7 +306,7 @@ def confirm @merge_opportunities.last.last.sort! { |a, b| Canvas::ICU.compare(a.account.name, b.account.name) } end end - @merge_opportunities.sort_by! { |a| [a.first == @current_user ? CanvasSort::First : CanvasSort::Last, Canvas::ICU.collation_key(a.first.name)] } + @merge_opportunities.sort_by! { |a| [(a.first == @current_user) ? CanvasSort::First : CanvasSort::Last, Canvas::ICU.collation_key(a.first.name)] } else @merge_opportunities = [] end @@ -599,7 +599,7 @@ def bulk_confirm protected def account - @account ||= params[:account_id] == "self" ? @domain_root_account : Account.find(params[:account_id]) + @account ||= (params[:account_id] == "self") ? @domain_root_account : Account.find(params[:account_id]) end def bulk_action_args diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 59fbd19e61b67..b71cc098967db 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -366,7 +366,7 @@ def create end user_ids = member_ids @conference.add_initiator(@current_user) - user_ids.count > WebConference.max_invitees_sync_size ? @conference.delay.invite_users_from_context(user_ids) : @conference.invite_users_from_context(user_ids) + (user_ids.count > WebConference.max_invitees_sync_size) ? @conference.delay.invite_users_from_context(user_ids) : @conference.invite_users_from_context(user_ids) @conference.save format.html { redirect_to named_context_url(@context, :context_conference_url, @conference.id) } format.json do diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index 2b799504c230a..0eab09b52ad4d 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -446,7 +446,7 @@ def create shard.activate do if batch_private_messages || batch_group_messages - mode = params[:mode] == "async" ? :async : :sync + mode = (params[:mode] == "async") ? :async : :sync message.relativize_attachment_ids(from_shard: message.shard, to_shard: shard) message.shard = shard batch = ConversationBatch.generate(message, @recipients, mode, diff --git a/app/controllers/course_paces_controller.rb b/app/controllers/course_paces_controller.rb index 3b9e703e47947..24f04f0bfabff 100644 --- a/app/controllers/course_paces_controller.rb +++ b/app/controllers/course_paces_controller.rb @@ -615,7 +615,7 @@ def authorize_action def latest_progress progress = Progress.order(created_at: :desc).find_by(context: @course_pace, tag: "course_pace_publish") - progress&.workflow_state == "completed" ? nil : progress + (progress&.workflow_state == "completed") ? nil : progress end def load_and_run_progress diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 0d3ac738112fd..ed6307854a72b 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1894,7 +1894,7 @@ def check_enrollment(ignore_restricted_courses = false) if (enrollment = fetch_enrollment) if enrollment.state_based_on_date == :inactive && !ignore_restricted_courses flash[:notice] = t("notices.enrollment_not_active", "Your membership in the course, %{course}, is not yet activated", course: @context.name) - return !!redirect_to(enrollment.workflow_state == "invited" ? courses_url : dashboard_url) + return !!redirect_to((enrollment.workflow_state == "invited") ? courses_url : dashboard_url) end if enrollment.rejected? @@ -3177,7 +3177,7 @@ def update if (mc_restrictions_by_type = params[:course][:blueprint_restrictions_by_object_type]) parsed_restrictions_by_type = {} mc_restrictions_by_type.to_unsafe_h.each do |type, restrictions| - class_name = type == "quiz" ? "Quizzes::Quiz" : type.camelcase + class_name = (type == "quiz") ? "Quizzes::Quiz" : type.camelcase parsed_restrictions_by_type[class_name] = restrictions.to_h { |k, v| [k.to_sym, value_to_boolean(v)] } end template.default_restrictions_by_type = parsed_restrictions_by_type @@ -3954,7 +3954,7 @@ def courses_for_user(user, paginate_url: api_v1_courses_url) def require_user_or_observer return render_unauthorized_action unless @current_user.present? - @user = params[:user_id] == "self" ? @current_user : api_find(User, params[:user_id]) + @user = (params[:user_id] == "self") ? @current_user : api_find(User, params[:user_id]) authorized_action(@user, @current_user, :read) end diff --git a/app/controllers/discussion_topics_controller.rb b/app/controllers/discussion_topics_controller.rb index 6db56cd49538d..7a0745f217ff4 100644 --- a/app/controllers/discussion_topics_controller.rb +++ b/app/controllers/discussion_topics_controller.rb @@ -407,7 +407,7 @@ def index when Course context_url(@context, :context_settings_url, anchor: "tab-features") when Group - (@context.context&.is_a? Course) || (@context.context&.is_a? Account) ? context_url(@context.context, :context_settings_url, anchor: "tab-features") : nil + ((@context.context&.is_a? Course) || (@context.context&.is_a? Account)) ? context_url(@context.context, :context_settings_url, anchor: "tab-features") : nil else nil end @@ -504,7 +504,7 @@ def new js_env({ is_announcement: params[:is_announcement] }) js_bundle :discussion_topic_edit_v2 css_bundle :discussions_index, :learning_outcomes - render html: "", layout: params[:embed] == "true" ? "mobile_embed" : true + render html: "", layout: (params[:embed] == "true") ? "mobile_embed" : true return end edit @@ -661,7 +661,7 @@ def edit set_master_course_js_env_data(@topic, @context) conditional_release_js_env(@topic.assignment) - render :edit, layout: params[:embed] == "true" ? "mobile_embed" : true + render :edit, layout: (params[:embed] == "true") ? "mobile_embed" : true end def show @@ -816,7 +816,7 @@ def show js_bundle :discussion_topics_post css_bundle :discussions_index, :learning_outcomes - render html: "", layout: params[:embed] == "true" ? "mobile_embed" : true + render html: "", layout: (params[:embed] == "true") ? "mobile_embed" : true return end @@ -1369,7 +1369,7 @@ def process_discussion_topic_runner(is_new:) only_pinning = discussion_topic_hash.except(*%w[pinned]).blank? # allow pinning/unpinning if a subtopic and we can update the root - topic_to_check = only_pinning && @topic.root_topic ? @topic.root_topic : @topic + topic_to_check = (only_pinning && @topic.root_topic) ? @topic.root_topic : @topic return unless authorized_action(topic_to_check, @current_user, (is_new ? :create : :update)) process_podcast_parameters(discussion_topic_hash) @@ -1732,7 +1732,7 @@ def handle_assignment_edit_params(hash) unless hash[:assignment].nil? if params[:due_at] - hash[:assignment][:due_at] = params[:due_at].empty? || params[:due_at] == "null" ? nil : params[:due_at] + hash[:assignment][:due_at] = (params[:due_at].empty? || params[:due_at] == "null") ? nil : params[:due_at] end hash[:assignment][:points_possible] = params[:points_possible] if params[:points_possible] hash[:assignment][:assignment_group_id] = params[:assignment_group_id] if params[:assignment_group_id] diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index e9bc0b1eccd50..987d7bbc962f4 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -74,7 +74,7 @@ def require_view_error_reports end def index - params[:page] = params[:page].to_i > 0 ? params[:page].to_i : 1 + params[:page] = (params[:page].to_i > 0) ? params[:page].to_i : 1 @reports = ErrorReport.preload(:user, :account) @message = params[:message] diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c67b9596207a2..257bad1fae88e 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -327,7 +327,7 @@ def api_index Attachment.display_name_order_by_clause("attachments") end order_clause += " DESC" if params[:order] == "desc" - scope = scope.order(Arel.sql(order_clause)).order(id: params[:order] == "desc" ? :desc : :asc) + scope = scope.order(Arel.sql(order_clause)).order(id: (params[:order] == "desc") ? :desc : :asc) if params[:content_types].present? scope = scope.by_content_types(Array(params[:content_types])) @@ -403,7 +403,7 @@ def react_files { asset_string: context.asset_string, - name: context == @current_user ? t("my_files", "My Files") : context.name, + name: (context == @current_user) ? t("my_files", "My Files") : context.name, usage_rights_required: tool_context.respond_to?(:usage_rights_required?) && tool_context.usage_rights_required?, permissions: { manage_files_add: context.grants_right?(@current_user, session, :manage_files_add), diff --git a/app/controllers/folders_controller.rb b/app/controllers/folders_controller.rb index eedf9cc012a8d..ebad9f0e54e7c 100644 --- a/app/controllers/folders_controller.rb +++ b/app/controllers/folders_controller.rb @@ -583,7 +583,7 @@ def copy_file @attachment = @source_file.clone_for(@context, @attachment, force_copy: true) if @attachment.save # default to rename on race condition (if a file happened to be created after the check above, and on_duplicate was not given) - @attachment.handle_duplicates(on_duplicate == "overwrite" ? :overwrite : :rename, duplicate_options) + @attachment.handle_duplicates((on_duplicate == "overwrite") ? :overwrite : :rename, duplicate_options) render json: attachment_json(@attachment, @current_user, {}, { omit_verifier_in_app: true }) else render json: @attachment.errors diff --git a/app/controllers/gradebooks_controller.rb b/app/controllers/gradebooks_controller.rb index 213a22e8288bf..c3169427f5026 100644 --- a/app/controllers/gradebooks_controller.rb +++ b/app/controllers/gradebooks_controller.rb @@ -1289,7 +1289,7 @@ def gradebook_version def requested_gradebook_view return nil if params[:view].blank? - params[:view] == "learning_mastery" ? "learning_mastery" : "gradebook" + (params[:view] == "learning_mastery") ? "learning_mastery" : "gradebook" end def preferred_gradebook_view diff --git a/app/controllers/info_controller.rb b/app/controllers/info_controller.rb index 3a6e6e71bd827..25eaa6f9ead5b 100644 --- a/app/controllers/info_controller.rb +++ b/app/controllers/info_controller.rb @@ -211,7 +211,7 @@ def render_deep_json(critical, secondary, status_code) components = HealthChecks.process_readiness_checks(true) readiness_response = render_readiness_json(components, true) - status = readiness_response[:status] == 503 ? readiness_response[:status] : status_code + status = (readiness_response[:status] == 503) ? readiness_response[:status] : status_code response = { readiness: components, diff --git a/app/controllers/login/shared.rb b/app/controllers/login/shared.rb index 6141302e8491e..345c363e9215e 100644 --- a/app/controllers/login/shared.rb +++ b/app/controllers/login/shared.rb @@ -104,7 +104,7 @@ def successful_login(user, pseudonym, otp_passed = false) redirect_to(registration_confirmation_path(session.delete(:confirm), enrollment: session.delete(:enrollment), login_success: 1, - confirm: (user.id == session.delete(:expected_user_id) ? 1 : nil))) + confirm: ((user.id == session.delete(:expected_user_id)) ? 1 : nil))) end else # the URL to redirect back to is stored in the session, so it's diff --git a/app/controllers/lti/feature_flags_controller.rb b/app/controllers/lti/feature_flags_controller.rb index 54ecb127b1e36..55327428ba76c 100644 --- a/app/controllers/lti/feature_flags_controller.rb +++ b/app/controllers/lti/feature_flags_controller.rb @@ -68,7 +68,7 @@ def lti_service_context def context_from_id(context_type, context_id) # If the id is an integer, it's a Canvas id, not an LTI id - column_name = context_id.to_i.to_s == context_id ? :id : :lti_context_id + column_name = (context_id.to_i.to_s == context_id) ? :id : :lti_context_id context_type.find_by(column_name => context_id) end diff --git a/app/controllers/lti/ims/providers/group_memberships_provider.rb b/app/controllers/lti/ims/providers/group_memberships_provider.rb index 4dddffd485e33..c2dbd95b3ddf8 100644 --- a/app/controllers/lti/ims/providers/group_memberships_provider.rb +++ b/app/controllers/lti/ims/providers/group_memberships_provider.rb @@ -52,7 +52,7 @@ def apply_role_filter(scope) enrollment_types = queryable_roles(role) if enrollment_types.present? && group_role?(enrollment_types) - enrollment_types == [:group_leader] ? scope.where(user: context.leader_id) : scope + (enrollment_types == [:group_leader]) ? scope.where(user: context.leader_id) : scope else scope.none end @@ -92,7 +92,7 @@ def group end def lti_roles - @_lti_roles ||= user.id == context.leader_id ? group_leader_role_urns : group_member_role_urns + @_lti_roles ||= (user.id == context.leader_id) ? group_leader_role_urns : group_member_role_urns end private diff --git a/app/controllers/lti/ims/scores_controller.rb b/app/controllers/lti/ims/scores_controller.rb index 24a04ecac3f4d..b841b7e3756ea 100644 --- a/app/controllers/lti/ims/scores_controller.rb +++ b/app/controllers/lti/ims/scores_controller.rb @@ -389,7 +389,7 @@ def score_submission submission_hash = { grader_id: -tool.id } if line_item.assignment.grading_type == "pass_fail" # This reflects behavior/logic in Basic Outcomes. - submission_hash[:grade] = scores_params[:result_score].to_f > 0 ? "pass" : "fail" + submission_hash[:grade] = (scores_params[:result_score].to_f > 0) ? "pass" : "fail" else submission_hash[:score] = submission_score end diff --git a/app/controllers/lti/ims/tool_setting_controller.rb b/app/controllers/lti/ims/tool_setting_controller.rb index 0ca8c25ffbd13..128c42e044571 100644 --- a/app/controllers/lti/ims/tool_setting_controller.rb +++ b/app/controllers/lti/ims/tool_setting_controller.rb @@ -94,7 +94,7 @@ def lti2_service_name def tool_setting_json(tool_setting, bubble) if %w[all distinct].include?(bubble) graph = [] - distinct = bubble == "distinct" ? [] : nil + distinct = (bubble == "distinct") ? [] : nil while tool_setting graph << collect_tool_settings(tool_setting, distinct) distinct |= graph.last.custom.keys if distinct diff --git a/app/controllers/lti/message_controller.rb b/app/controllers/lti/message_controller.rb index d9b34d5d63ab0..84a20cd71d54b 100644 --- a/app/controllers/lti/message_controller.rb +++ b/app/controllers/lti/message_controller.rb @@ -143,7 +143,7 @@ def assignment (tag&.context_type == "Assignment" && tag.context.context == @context) ? tag.context : nil elsif params[:secure_params].present? assignment = Assignment.from_secure_lti_params(params[:secure_params]) - assignment&.root_account == @context.root_account ? assignment : nil + (assignment&.root_account == @context.root_account) ? assignment : nil end end diff --git a/app/controllers/master_courses/master_templates_controller.rb b/app/controllers/master_courses/master_templates_controller.rb index 40f9e782d634a..51d400ce05741 100644 --- a/app/controllers/master_courses/master_templates_controller.rb +++ b/app/controllers/master_courses/master_templates_controller.rb @@ -497,7 +497,7 @@ def unsynced_changes end remaining_count = max_records - items.size - condition = klass == "ContentTag" ? "#{ContentTag.quoted_table_name}.updated_at>?" : "updated_at>?" + condition = (klass == "ContentTag") ? "#{ContentTag.quoted_table_name}.updated_at>?" : "updated_at>?" items += item_scope.where(condition, cutoff_time).order(:id).limit(remaining_count).to_a break if items.size >= max_records end diff --git a/app/controllers/media_objects_controller.rb b/app/controllers/media_objects_controller.rb index dfb8f532d1735..b14064d5decca 100644 --- a/app/controllers/media_objects_controller.rb +++ b/app/controllers/media_objects_controller.rb @@ -147,7 +147,7 @@ def index url = api_v1_media_objects_url end - order_dir = params[:order] == "desc" ? "desc" : "asc" + order_dir = (params[:order] == "desc") ? "desc" : "asc" order_by = params[:sort] || "title" if order_by == "title" order_by = MediaObject.best_unicode_collation_key("COALESCE(user_entered_title, title)") diff --git a/app/controllers/oauth2_provider_controller.rb b/app/controllers/oauth2_provider_controller.rb index 6365e281215c3..d2f19b6e8de6e 100644 --- a/app/controllers/oauth2_provider_controller.rb +++ b/app/controllers/oauth2_provider_controller.rb @@ -201,7 +201,7 @@ def old_silly_behavior(exception) def grant_type @grant_type ||= params[:grant_type] || ( - !params[:grant_type] && params[:code] ? "authorization_code" : "__UNSUPPORTED_PLACEHOLDER__" + (!params[:grant_type] && params[:code]) ? "authorization_code" : "__UNSUPPORTED_PLACEHOLDER__" ) end diff --git a/app/controllers/outcome_results_controller.rb b/app/controllers/outcome_results_controller.rb index 1250d438a0341..1f73ba75e7433 100644 --- a/app/controllers/outcome_results_controller.rb +++ b/app/controllers/outcome_results_controller.rb @@ -558,7 +558,7 @@ def user_rollups_sorted_by_score_json # (sorting by name for duplicate scores), then reorder users # from those rollups, then paginate those users, and finally # only include rollups for those users - missing_score_sort = params[:sort_order] == "desc" ? CanvasSort::First : CanvasSort::Last + missing_score_sort = (params[:sort_order] == "desc") ? CanvasSort::First : CanvasSort::Last rollups = user_rollups.sort_by do |r| score = r.scores.find { |s| s.outcome.id.to_s == params[:sort_outcome_id] }&.score [score || missing_score_sort, Canvas::ICU.collation_key(r.context.sortable_name)] diff --git a/app/controllers/pseudonyms_controller.rb b/app/controllers/pseudonyms_controller.rb index fbaa5f3e371a0..638170b351654 100644 --- a/app/controllers/pseudonyms_controller.rb +++ b/app/controllers/pseudonyms_controller.rb @@ -530,7 +530,7 @@ def update_pseudonym_from_params if params[:pseudonym].key?(:password) && !@pseudonym.passwordable? @pseudonym.errors.add(:password, "password can only be set for Canvas authentication") respond_to do |format| - format.html { render(params[:action] == "edit" ? :edit : :new) } + format.html { render((params[:action] == "edit") ? :edit : :new) } format.json { render json: @pseudonym.errors, status: :bad_request } end return false @@ -547,7 +547,7 @@ def update_pseudonym_from_params if params[:pseudonym].key?(:workflow_state) && !%w[active suspended].include?(params[:pseudonym][:workflow_state]) @pseudonym.errors.add(:workflow_state, "invalid workflow_state") respond_to do |format| - format.html { render(params[:action] == "edit" ? :edit : :new) } + format.html { render((params[:action] == "edit") ? :edit : :new) } format.json { render json: @pseudonym.errors, status: :bad_request } end return false diff --git a/app/controllers/quizzes/quiz_reports_controller.rb b/app/controllers/quizzes/quiz_reports_controller.rb index 7eb952c444f3b..62e003a717899 100644 --- a/app/controllers/quizzes/quiz_reports_controller.rb +++ b/app/controllers/quizzes/quiz_reports_controller.rb @@ -260,7 +260,7 @@ def serialize_json(stats, includes = []) }).as_json end - serialized_set.length == 1 ? serialized_set[0] : serialized_set + (serialized_set.length == 1) ? serialized_set[0] : serialized_set end def serialize_jsonapi(stats, includes) diff --git a/app/controllers/role_overrides_controller.rb b/app/controllers/role_overrides_controller.rb index 7a40381aa49bd..a017478d1ede8 100644 --- a/app/controllers/role_overrides_controller.rb +++ b/app/controllers/role_overrides_controller.rb @@ -679,7 +679,7 @@ def set_permissions_for(role, context, permissions) end target_permissions.each do |permission| - perm_override = value_to_boolean(permission_updates[:explicit]) && override.nil? ? permission[:currently] : override + perm_override = (value_to_boolean(permission_updates[:explicit]) && override.nil?) ? permission[:currently] : override RoleOverride.manage_role_override( context, role, permission[:name].to_s, override: perm_override, locked: locked, applies_to_self: applies_to_self, applies_to_descendants: applies_to_descendants diff --git a/app/controllers/scopes_api_controller.rb b/app/controllers/scopes_api_controller.rb index 4f443e314672b..9a26b9017ce9e 100644 --- a/app/controllers/scopes_api_controller.rb +++ b/app/controllers/scopes_api_controller.rb @@ -74,7 +74,7 @@ class ScopesApiController < ApplicationController def index named_scopes = TokenScopes.named_scopes if authorized_action(@context, @current_user, :manage_developer_keys) - scopes = params[:group_by] == "resource_name" ? named_scopes.group_by { |route| route[:resource_name] } : named_scopes + scopes = (params[:group_by] == "resource_name") ? named_scopes.group_by { |route| route[:resource_name] } : named_scopes render json: scopes end end diff --git a/app/controllers/submissions_base_controller.rb b/app/controllers/submissions_base_controller.rb index ef4727eff6a3b..b511b3669e055 100644 --- a/app/controllers/submissions_base_controller.rb +++ b/app/controllers/submissions_base_controller.rb @@ -243,7 +243,7 @@ def originality_report private def update_student_entered_score(score) - new_score = score.present? && score != "null" ? score.to_f.round(2) : nil + new_score = (score.present? && score != "null") ? score.to_f.round(2) : nil # TODO: fix this by making the callback optional # intentionally skipping callbacks here to fix a bug where entering a # what-if grade for a quiz can put the submission back in a 'pending review' state @@ -257,7 +257,7 @@ def outcome_proficiency end def legacy_plagiarism_report(submission, asset_string, type) - plag_data = type == "vericite" ? submission.vericite_data : submission.turnitin_data + plag_data = (type == "vericite") ? submission.vericite_data : submission.turnitin_data if plag_data.dig(asset_string, :report_url).present? polymorphic_url([:retrieve, @context, :external_tools], url: plag_data[asset_string][:report_url], display: "borderless") diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 82a3a7750b25b..5f215ab8275c8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1327,7 +1327,7 @@ def show @context ||= @user - add_crumb(t("crumbs.profile", "%{user}'s profile", user: @user.short_name), @user == @current_user ? user_profile_path(@current_user) : user_path(@user)) + add_crumb(t("crumbs.profile", "%{user}'s profile", user: @user.short_name), (@user == @current_user) ? user_profile_path(@current_user) : user_path(@user)) @group_memberships = @user.cached_current_group_memberships_by_date @@ -2152,14 +2152,14 @@ def update next if p.active? && event == "unsuspend" next if p.suspended? && event == "suspend" - p.update!(workflow_state: event == "suspend" ? "suspended" : "active") + p.update!(workflow_state: (event == "suspend") ? "suspended" : "active") end end respond_to do |format| if @user.update(user_params) if admin_avatar_update - avatar_state = old_avatar_state == :locked ? old_avatar_state : "approved" + avatar_state = (old_avatar_state == :locked) ? old_avatar_state : "approved" @user.avatar_state = user_params[:avatar_image][:state] || avatar_state end @user.profile.save if @user.profile.changed? @@ -2879,7 +2879,7 @@ def require_self_registration def generate_grading_period_id(period_id) # nil and '' will get converted to 0 in the .to_i call id = period_id.to_i - id == 0 ? nil : id + (id == 0) ? nil : id end def render_new_user_tutorial_statuses(user) diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb index 91bd9f1df2b99..cefdacacdf58e 100644 --- a/app/controllers/wiki_pages_controller.rb +++ b/app/controllers/wiki_pages_controller.rb @@ -78,7 +78,7 @@ def index GuardRail.activate(:secondary) do if authorized_action(@context.wiki, @current_user, :read) && tab_enabled?(@context.class::TAB_PAGES) log_asset_access(["pages", @context], "pages", "other") - js_env((ConditionalRelease::Service.env_for(@context))) + js_env(ConditionalRelease::Service.env_for(@context)) wiki_pages_js_env(@context) set_tutorial_js_env @padless = true diff --git a/app/graphql/audit_log_field_extension.rb b/app/graphql/audit_log_field_extension.rb index 7ed4fdc8636ce..3503f13f031ff 100644 --- a/app/graphql/audit_log_field_extension.rb +++ b/app/graphql/audit_log_field_extension.rb @@ -116,7 +116,7 @@ def truncate_params!(o) when Array o.map! { |x| truncate_params!(x) } when String - o.size > 256 ? o.slice(0, 256) : o + (o.size > 256) ? o.slice(0, 256) : o else o end diff --git a/app/graphql/loaders/outcome_alignment_loader.rb b/app/graphql/loaders/outcome_alignment_loader.rb index 25e03a4533c81..fc87be2e9e237 100644 --- a/app/graphql/loaders/outcome_alignment_loader.rb +++ b/app/graphql/loaders/outcome_alignment_loader.rb @@ -168,7 +168,7 @@ def alignment_hash(alignment) def id(alignment) # prepend id with alignment type (D - direct/I - indirect) to ensure unique alignment id - base_id = [alignment[:alignment_type] == "direct" ? "D" : "I", alignment[:id]].join("_") + base_id = [(alignment[:alignment_type] == "direct") ? "D" : "I", alignment[:id]].join("_") # append id with module id to ensure unique alignment id when artifact is included in multiple modules return [base_id, alignment[:module_id]].join("_") if alignment[:module_id] diff --git a/app/graphql/mutations/create_conversation.rb b/app/graphql/mutations/create_conversation.rb index a5aba45678cb9..57d69ed3e64c5 100644 --- a/app/graphql/mutations/create_conversation.rb +++ b/app/graphql/mutations/create_conversation.rb @@ -94,7 +94,7 @@ def resolve(input:) batch = ConversationBatch.generate( message, recipients, - recipients.size > Conversation.max_group_conversation_size ? :async : :sync, + (recipients.size > Conversation.max_group_conversation_size) ? :async : :sync, subject: input[:subject], context_type: context_type, context_id: context_id, diff --git a/app/graphql/mutations/update_discussion_entries_read_state.rb b/app/graphql/mutations/update_discussion_entries_read_state.rb index cbd927c0027a7..4c52cad482343 100644 --- a/app/graphql/mutations/update_discussion_entries_read_state.rb +++ b/app/graphql/mutations/update_discussion_entries_read_state.rb @@ -42,7 +42,7 @@ def resolve(input:) # only run this if upsert_for_entries really returned ids if ids - offset = state == :read ? -ids.length : ids.length + offset = (state == :read) ? -ids.length : ids.length entry.discussion_topic.update_or_create_participant(current_user: current_user, offset: offset) end diff --git a/app/graphql/types/content_tag_connection.rb b/app/graphql/types/content_tag_connection.rb index 5fb70b36273b7..86e6164aeae74 100644 --- a/app/graphql/types/content_tag_connection.rb +++ b/app/graphql/types/content_tag_connection.rb @@ -39,7 +39,7 @@ def node field :can_unlink, Boolean, null: true def can_unlink if learning_outcome_link? - can_manage = object.context_type == "LearningOutcomeGroup" ? can_manage_global_outcomes : can_manage_context_outcomes + can_manage = (object.context_type == "LearningOutcomeGroup") ? can_manage_global_outcomes : can_manage_context_outcomes can_manage && object.can_destroy? end end diff --git a/app/graphql/types/course_type.rb b/app/graphql/types/course_type.rb index cf787a7c7d73f..47967f2fcf73d 100644 --- a/app/graphql/types/course_type.rb +++ b/app/graphql/types/course_type.rb @@ -253,7 +253,7 @@ def submissions_connection(student_ids: nil, order_by: [], filter: {}) end (order_by || []).each do |order| - direction = order[:direction] == "descending" ? "DESC NULLS LAST" : "ASC" + direction = (order[:direction] == "descending") ? "DESC NULLS LAST" : "ASC" submissions = submissions.order("#{order[:field]} #{direction}") end diff --git a/app/graphql/types/discussion_entry_type.rb b/app/graphql/types/discussion_entry_type.rb index 51d8c824fb51d..d95365a9ae6f7 100644 --- a/app/graphql/types/discussion_entry_type.rb +++ b/app/graphql/types/discussion_entry_type.rb @@ -108,7 +108,7 @@ def anonymous_author Loaders::DiscussionTopicParticipantLoader.for(topic.id).load(object.user_id).then do |participant| { id: participant.id.to_s(36), - short_name: object.user_id == current_user.id ? "current_user" : participant.id.to_s(36), + short_name: (object.user_id == current_user.id) ? "current_user" : participant.id.to_s(36), avatar_url: nil } end diff --git a/app/graphql/types/discussion_type.rb b/app/graphql/types/discussion_type.rb index 8f8f50e6362f2..6fc5dbce40be3 100644 --- a/app/graphql/types/discussion_type.rb +++ b/app/graphql/types/discussion_type.rb @@ -191,7 +191,7 @@ def anonymous_author else { id: participant.id.to_s(36), - short_name: object.user_id == current_user.id ? "current_user" : participant.id.to_s(36), + short_name: (object.user_id == current_user.id) ? "current_user" : participant.id.to_s(36), avatar_url: nil } end diff --git a/app/graphql/types/notification_preferences_type.rb b/app/graphql/types/notification_preferences_type.rb index 65b199786bfbe..89378e686f96d 100644 --- a/app/graphql/types/notification_preferences_type.rb +++ b/app/graphql/types/notification_preferences_type.rb @@ -63,7 +63,7 @@ def send_scores_in_emails(course_id: nil) field :send_observed_names_in_notifications, Boolean, null: true def send_observed_names_in_notifications user = object[:user] - user.observer_enrollments.any? || user.as_observer_observation_links.any? ? user.send_observed_names_in_notifications? : nil + (user.observer_enrollments.any? || user.as_observer_observation_links.any?) ? user.send_observed_names_in_notifications? : nil end field :read_privacy_notice_date, String, null: true diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d16535ffe1abe..0cebf7eaa7d17 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -87,7 +87,7 @@ def slugify(text = "") end def count_if_any(count = nil) - count && count > 0 ? "(#{count})" : "" + (count && count > 0) ? "(#{count})" : "" end # Used to generate context_specific urls, as in: @@ -621,7 +621,7 @@ def folders_as_options(folders, opts = {}) folders_as_options(child_folders, opts.merge({ depth: opts[:depth] + 1 })) end end - opts[:depth] == 0 ? raw(opts[:options_so_far].join("\n")) : nil + (opts[:depth] == 0) ? raw(opts[:options_so_far].join("\n")) : nil end # this little helper just allows you to do <% ot(...) %> and have it output the same as <%= t(...) %>. The upside though, is you can interpolate whole blocks of HTML, like: diff --git a/app/helpers/assignments_helper.rb b/app/helpers/assignments_helper.rb index 2c6aa490b62ff..b5bb01f63a94c 100644 --- a/app/helpers/assignments_helper.rb +++ b/app/helpers/assignments_helper.rb @@ -111,7 +111,7 @@ def vericite_active? def i18n_grade(grade, grading_type = nil) if grading_type == "pass_fail" && %w[complete incomplete].include?(grade) - return grade == "complete" ? I18n.t("Complete") : I18n.t("Incomplete") + return (grade == "complete") ? I18n.t("Complete") : I18n.t("Incomplete") end number = Float(grade.sub(/%$/, "")) rescue nil diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 4cf1f57a4af69..86b0d17b1933d 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -91,7 +91,7 @@ def recent_event_url(recent_event) # # Returns a text string. def user_count(count) - count == 0 ? t("#courses.settings.none", "None") : count + (count == 0) ? t("#courses.settings.none", "None") : count end # Public: check for permission on a new course diff --git a/app/helpers/quizzes_helper.rb b/app/helpers/quizzes_helper.rb index 38f14fa5e666e..39a0534ce718e 100644 --- a/app/helpers/quizzes_helper.rb +++ b/app/helpers/quizzes_helper.rb @@ -713,7 +713,7 @@ def point_value_for_input(user_answer, question) end def points_possible_display(quiz = @quiz) - quiz.quiz_type == "survey" ? "" : render_score(quiz.points_possible) + (quiz.quiz_type == "survey") ? "" : render_score(quiz.points_possible) end def label_for_question_type(question_type) diff --git a/app/helpers/rollup_score_aggregator_helper.rb b/app/helpers/rollup_score_aggregator_helper.rb index f9ff9f2691fbc..f2f0a855b0a1e 100644 --- a/app/helpers/rollup_score_aggregator_helper.rb +++ b/app/helpers/rollup_score_aggregator_helper.rb @@ -88,7 +88,7 @@ def get_aggregates(result) def alignment_aggregate_score(result_aggregates) return if result_aggregates[:total] == 0 - possible = @points_possible > 0 ? @points_possible : @mastery_points + possible = (@points_possible > 0) ? @points_possible : @mastery_points (result_aggregates[:weighted] / result_aggregates[:total]) * possible end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 0581c3a9baeda..9467e5a2d9421 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -97,7 +97,7 @@ def load_all_contexts(options = {}) name: group.name, type: :group, state: group.active? ? :active : :inactive, - parent: group.context_type == "Course" ? { course: group.context_id } : nil, + parent: (group.context_type == "Course") ? { course: group.context_id } : nil, context_name: (group_context || group.context).name, category: group.category }.tap do |hash| @@ -134,7 +134,7 @@ def load_all_contexts(options = {}) end when CourseSection visibility = context.course.enrollment_visibility_level_for(@current_user, context.course.section_visibilities_for(@current_user), require_message_permission: true) - sections = visibility == :restricted ? [] : [context] + sections = (visibility == :restricted) ? [] : [context] add_courses.call [context.course], :current add_sections.call context.course.sections_visible_to(@current_user, sections) else diff --git a/app/models/account.rb b/app/models/account.rb index 027f097d21c79..fdc5e0010c17d 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -1007,7 +1007,7 @@ def self.account_chain(starting_account_id) end if starting_account_id - guard_rail_env = Account.connection.open_transactions == 0 ? :secondary : GuardRail.environment + guard_rail_env = (Account.connection.open_transactions == 0) ? :secondary : GuardRail.environment GuardRail.activate(guard_rail_env) do chain.concat(Shard.shard_for(starting_account_id).activate do Account.find_by_sql(<<~SQL.squish) @@ -1135,7 +1135,7 @@ def self.sub_accounts_recursive(parent_account_id, pluck = false) original_shard = Shard.current result = Shard.shard_for(parent_account_id).activate do parent_account_id = Shard.relative_id_for(parent_account_id, original_shard, Shard.current) - guard_rail_env = Account.connection.open_transactions == 0 ? :secondary : GuardRail.environment + guard_rail_env = (Account.connection.open_transactions == 0) ? :secondary : GuardRail.environment GuardRail.activate(guard_rail_env) do sql = Account.sub_accounts_recursive_sql(parent_account_id) if pluck @@ -2119,7 +2119,7 @@ def format_referer(referer_url) return unless referer.host referer_with_port = "#{referer.scheme}://#{referer.host}" - referer_with_port += ":#{referer.port}" unless referer.port == (referer.scheme == "https" ? 443 : 80) + referer_with_port += ":#{referer.port}" unless referer.port == ((referer.scheme == "https") ? 443 : 80) referer_with_port end diff --git a/app/models/account/help_links.rb b/app/models/account/help_links.rb index 32a89b79b58a9..e89a9ee3e20bf 100644 --- a/app/models/account/help_links.rb +++ b/app/models/account/help_links.rb @@ -82,9 +82,9 @@ def default_links_hash def filtered_links(links) show_feedback_link = Setting.get("show_feedback_link", "false") == "true" links.select do |link| - link[:id].to_s == "covid" ? Account.site_admin.feature_enabled?(:featured_help_links) : true + (link[:id].to_s == "covid") ? Account.site_admin.feature_enabled?(:featured_help_links) : true end.select do |link| - link[:id].to_s == "report_a_problem" || link[:id].to_s == "instructor_question" ? show_feedback_link : true + (link[:id].to_s == "report_a_problem" || link[:id].to_s == "instructor_question") ? show_feedback_link : true end end diff --git a/app/models/appointment_group_sub_context.rb b/app/models/appointment_group_sub_context.rb index 4a74b8eb52d27..fa85d31d3d0f2 100644 --- a/app/models/appointment_group_sub_context.rb +++ b/app/models/appointment_group_sub_context.rb @@ -32,6 +32,6 @@ class AppointmentGroupSubContext < ActiveRecord::Base end def participant_type - sub_context_type == "GroupCategory" ? "Group" : "User" + (sub_context_type == "GroupCategory") ? "Group" : "User" end end diff --git a/app/models/assignment.rb b/app/models/assignment.rb index 04d3bbec821e4..428686f9aa43e 100644 --- a/app/models/assignment.rb +++ b/app/models/assignment.rb @@ -2620,7 +2620,7 @@ def visible_rubric_assessments_for(user, opts = {}) scope = scope.where(assessor_id: user.id) end end - scope.to_a.sort_by { |a| [a.assessment_type == "grading" ? CanvasSort::First : CanvasSort::Last, Canvas::ICU.collation_key(a.assessor_name)] } + scope.to_a.sort_by { |a| [(a.assessment_type == "grading") ? CanvasSort::First : CanvasSort::Last, Canvas::ICU.collation_key(a.assessor_name)] } end # Takes a zipped file full of assignment comments/annotated assignments @@ -2801,7 +2801,7 @@ def sorted_review_candidates(peer_review_params, current_submission, candidate_s candidates_for_review.sort_by do |c| [ # prefer those who need reviews done - assessor_id_map[c.id].count < peer_review_count ? CanvasSort::First : CanvasSort::Last, + (assessor_id_map[c.id].count < peer_review_count) ? CanvasSort::First : CanvasSort::Last, # then prefer those who are not reviewing this submission assessor_id_map[current_submission.id].include?(c.id) ? CanvasSort::Last : CanvasSort::First, # then prefer those who need the most reviews done (that way we don't run the risk of diff --git a/app/models/assignment_group.rb b/app/models/assignment_group.rb index fd170624176e8..63ff82c598e72 100644 --- a/app/models/assignment_group.rb +++ b/app/models/assignment_group.rb @@ -333,7 +333,7 @@ def set_scores_workflow_state_in_batches(new_workflow_state, exclude_workflow_st score_ids = Score.where( assignment_group_id: self, enrollment_id: student_enrollments, - workflow_state: new_workflow_state == :active ? :deleted : :active + workflow_state: (new_workflow_state == :active) ? :deleted : :active ).pluck(:id) score_ids.each_slice(1000) do |score_ids_batch| diff --git a/app/models/assignment_override.rb b/app/models/assignment_override.rb index 8e730c6141cb4..5a8fe2a1546c7 100644 --- a/app/models/assignment_override.rb +++ b/app/models/assignment_override.rb @@ -206,7 +206,7 @@ def destroy .distinct if visible_ids.is_a?(ActiveRecord::Relation) - column = visible_ids.klass == User ? :id : visible_ids.select_values.first + column = (visible_ids.klass == User) ? :id : visible_ids.select_values.first scope = scope.primary_shard.activate do scope.joins("INNER JOIN #{visible_ids.klass.quoted_table_name} ON assignment_override_students.user_id=#{visible_ids.klass.table_name}.#{column}") end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 99ba2e1291723..5d71077f177b0 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -1182,7 +1182,7 @@ def self.do_notifications recipient_keys = (to_list || []).compact.map(&:asset_string) next if recipient_keys.empty? - notification = BroadcastPolicy.notification_finder.by_name(count.to_i > 1 ? "New Files Added" : "New File Added") + notification = BroadcastPolicy.notification_finder.by_name((count.to_i > 1) ? "New Files Added" : "New File Added") data = { count: count, display_names: display_name } DelayedNotification.delay_if_production(priority: 30).process(record, notification, recipient_keys, data) end @@ -1479,7 +1479,7 @@ def hidden end def hidden=(val) - self.file_state = (val == true || val == "1" ? "hidden" : "available") + self.file_state = ((val == true || val == "1") ? "hidden" : "available") end def context_module_action(user, action) @@ -1909,7 +1909,7 @@ def submit_to_canvadocs(attempt = 1, **opts) Canvadocs::ServerError, Canvadocs::HeavyLoadError ] - error_level = warnable_errors.any? { |kls| e.is_a?(kls) } ? :warn : :error + error_level = (warnable_errors.any? { |kls| e.is_a?(kls) }) ? :warn : :error update_attribute(:workflow_state, "errored") error_data = { type: :canvadocs, attachment_id: id, annotatable: opts[:wants_annotation] } Canvas::Errors.capture(e, error_data, error_level) @@ -2068,7 +2068,7 @@ def self.make_unique_filename(filename, existing_files = [], attempts = 1, &bloc addition = attempts || 1 dir = File.dirname(filename) - dir = dir == "." ? "" : "#{dir}/" + dir = (dir == ".") ? "" : "#{dir}/" extname = filename[/(\.[A-Za-z][A-Za-z0-9]*)*(\.[A-Za-z0-9]*)$/] || "" basename = File.basename(filename, extname) diff --git a/app/models/authentication_provider/google.rb b/app/models/authentication_provider/google.rb index 91ad6451dc0c9..1d6c3863b3a5f 100644 --- a/app/models/authentication_provider/google.rb +++ b/app/models/authentication_provider/google.rb @@ -84,7 +84,7 @@ def client_options def authorize_options result = { scope: scope_for_options } if hosted_domain - result[:hd] = hosted_domains.length == 1 ? hosted_domain : "*" + result[:hd] = (hosted_domains.length == 1) ? hosted_domain : "*" end result end diff --git a/app/models/authentication_provider/open_id_connect.rb b/app/models/authentication_provider/open_id_connect.rb index 138a0563b1eac..9abc4cb594f9e 100644 --- a/app/models/authentication_provider/open_id_connect.rb +++ b/app/models/authentication_provider/open_id_connect.rb @@ -22,11 +22,11 @@ class AuthenticationProvider::OpenIDConnect < AuthenticationProvider::OAuth2 attr_accessor :instance_debugging def self.sti_name - self == OpenIDConnect ? "openid_connect" : super + (self == OpenIDConnect) ? "openid_connect" : super end def self.display_name - self == OpenIDConnect ? "OpenID Connect" : super + (self == OpenIDConnect) ? "OpenID Connect" : super end def self.open_id_connect_params diff --git a/app/models/big_blue_button_conference.rb b/app/models/big_blue_button_conference.rb index 08ef5e12dd173..37d0fb2f898ec 100644 --- a/app/models/big_blue_button_conference.rb +++ b/app/models/big_blue_button_conference.rb @@ -367,7 +367,7 @@ def join_url(user, type = :user) generate_request :join, fullName: user.short_name, meetingID: conference_key, - password: settings[(type == :user ? :user_key : :admin_key)], + password: settings[((type == :user) ? :user_key : :admin_key)], userID: user.id, createTime: settings[:create_time] end @@ -375,7 +375,7 @@ def join_url(user, type = :user) def end_meeting response = send_request(:end, { meetingID: conference_key, - password: settings[(type == :user ? :user_key : :admin_key)], + password: settings[((type == :user) ? :user_key : :admin_key)], }) response[:ended] if response end diff --git a/app/models/brand_config.rb b/app/models/brand_config.rb index 8da07eb841ef2..0bad57ca789ca 100644 --- a/app/models/brand_config.rb +++ b/app/models/brand_config.rb @@ -126,7 +126,7 @@ def chain_of_ancestor_configs def clone_with_new_parent(new_parent) attrs = attributes.with_indifferent_access.slice(*BrandConfig::ATTRS_TO_INCLUDE_IN_MD5) attrs[:parent_md5] = if new_parent - new_parent.shard.id == shard.id ? new_parent.md5 : "#{new_parent.shard.id}~#{new_parent.md5}" + (new_parent.shard.id == shard.id) ? new_parent.md5 : "#{new_parent.shard.id}~#{new_parent.md5}" else nil end diff --git a/app/models/calendar_event.rb b/app/models/calendar_event.rb index 3a707311c2a58..44049d2992249 100644 --- a/app/models/calendar_event.rb +++ b/app/models/calendar_event.rb @@ -541,7 +541,7 @@ def updating_user=(user) end def user - read_attribute(:user) || (context_type == "User" ? context : nil) + read_attribute(:user) || ((context_type == "User") ? context : nil) end def appointment_group? @@ -557,7 +557,7 @@ def appointment_group end def account - context_type == "Account" ? context : nil + (context_type == "Account") ? context : nil end class ReservationError < StandardError; end diff --git a/app/models/collaboration.rb b/app/models/collaboration.rb index ab91b3f2cbf78..bdcaaa7b07d7b 100644 --- a/app/models/collaboration.rb +++ b/app/models/collaboration.rb @@ -144,7 +144,7 @@ def parse_data # Returns a class or nil. def self.collaboration_class(type) if (klass = "#{type}Collaboration".constantize) - klass.ancestors.include?(Collaboration) && klass.config ? klass : nil + (klass.ancestors.include?(Collaboration) && klass.config) ? klass : nil end rescue NameError nil diff --git a/app/models/communication_channel/bulk_actions.rb b/app/models/communication_channel/bulk_actions.rb index eb5b069fe0ddf..a366a8e3b9ff0 100644 --- a/app/models/communication_channel/bulk_actions.rb +++ b/app/models/communication_channel/bulk_actions.rb @@ -30,7 +30,7 @@ def initialize(account:, after: nil, before: nil, order: nil, pattern: nil, path @account, @pattern, @path_type, @with_invalid_paths = account, pattern, path_type, with_invalid_paths @after = Time.zone.parse(after) if after @before = Time.zone.parse(before) if before - @order = order&.downcase == "desc" ? :desc : :asc + @order = (order&.downcase == "desc") ? :desc : :asc end def matching_channels(for_report: false) diff --git a/app/models/content_migration.rb b/app/models/content_migration.rb index 9cb4f118f1d4d..141e3d46f7328 100644 --- a/app/models/content_migration.rb +++ b/app/models/content_migration.rb @@ -1181,7 +1181,7 @@ def asset_id_mapping end else master_template.master_content_tags - .where(content_type: asset_type == "Announcement" ? "DiscussionTopic" : asset_type, + .where(content_type: (asset_type == "Announcement") ? "DiscussionTopic" : asset_type, migration_id: mig_id_to_dest_id.keys) .pluck(:content_id, :migration_id) .each do |src_id, mig_id| diff --git a/app/models/content_participation_count.rb b/app/models/content_participation_count.rb index c18c0ad3e7030..513cd5af53a7a 100644 --- a/app/models/content_participation_count.rb +++ b/app/models/content_participation_count.rb @@ -67,7 +67,7 @@ def self.set_unread_count(participant, opts = {}) unread_count = participant.unread_count(refresh: false) + offset.to_i end - participant.unread_count = unread_count > 0 ? unread_count : 0 + participant.unread_count = (unread_count > 0) ? unread_count : 0 end private_class_method :set_unread_count diff --git a/app/models/content_tag.rb b/app/models/content_tag.rb index 1c190882844d9..c10d1eadf3f1f 100644 --- a/app/models/content_tag.rb +++ b/app/models/content_tag.rb @@ -696,7 +696,7 @@ def set_root_account end def quiz_lti - @quiz_lti ||= has_attribute?(:content_type) && content_type == "Assignment" ? content&.quiz_lti? : false + @quiz_lti ||= (has_attribute?(:content_type) && content_type == "Assignment") ? content&.quiz_lti? : false end def to_json(options = {}) @@ -710,7 +710,7 @@ def as_json(options = {}) def clear_total_outcomes_cache return unless tag_type == "learning_outcome_association" && associated_asset_type == "LearningOutcomeGroup" - clear_context = context_type == "LearningOutcomeGroup" ? nil : context + clear_context = (context_type == "LearningOutcomeGroup") ? nil : context Outcomes::LearningOutcomeGroupChildren.new(clear_context).clear_total_outcomes_cache end diff --git a/app/models/context_external_tool.rb b/app/models/context_external_tool.rb index 252beafe64223..7a328e26ae11f 100644 --- a/app/models/context_external_tool.rb +++ b/app/models/context_external_tool.rb @@ -547,7 +547,7 @@ def process_extended_configuration return unless (config_type == "by_url" && config_url) || (config_type == "by_xml" && config_xml) @config_errors = [] - error_field = config_type == "by_xml" ? "config_xml" : "config_url" + error_field = (config_type == "by_xml") ? "config_xml" : "config_url" converter = CC::Importer::BLTIConverter.new tool_hash = if config_type == "by_url" uri = Addressable::URI.parse(config_url) diff --git a/app/models/context_module.rb b/app/models/context_module.rb index aadc23ce45f50..3c845b9d86cff 100644 --- a/app/models/context_module.rb +++ b/app/models/context_module.rb @@ -786,7 +786,7 @@ def insert_items(items, start_pos = nil) item = item.submittable_object if item.is_a?(Assignment) && item.submittable_object next if tags.any? { |tag| tag.content_type == item.class_name && tag.content_id == item.id } - state = item.respond_to?(:published?) && !item.published? ? "unpublished" : "active" + state = (item.respond_to?(:published?) && !item.published?) ? "unpublished" : "active" new_tags << content_tags.create!(context: context, title: Context.asset_name(item), content: item, tag_type: "context_module", indent: 0, position: next_pos, workflow_state: state) @@ -796,8 +796,8 @@ def insert_items(items, start_pos = nil) return unless start_pos tag_ids_to_move = {} - tags_before = start_pos < 2 ? [] : tags[0..start_pos - 2] - tags_after = start_pos > tags.length ? [] : tags[start_pos - 1..] + tags_before = (start_pos < 2) ? [] : tags[0..start_pos - 2] + tags_after = (start_pos > tags.length) ? [] : tags[start_pos - 1..] (tags_before + new_tags + tags_after).each_with_index do |item, index| index_change = index + 1 - item.position if index_change != 0 diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 46ebaf6c390cd..f7d6cf4186ea9 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -699,7 +699,7 @@ def self.preload_participants(conversations) # look up participants across all shards shards = conversations.map(&:associated_shards).flatten.uniq Shard.with_each_shard(shards) do - guard_rail_env = conversations.any? { |c| c.updated_at && c.updated_at > 10.seconds.ago } ? :primary : :secondary + guard_rail_env = (conversations.any? { |c| c.updated_at && c.updated_at > 10.seconds.ago }) ? :primary : :secondary user_map = GuardRail.activate(guard_rail_env) do User.select("users.id, users.updated_at, users.short_name, users.name, users.avatar_image_url, users.pronouns, users.avatar_image_source, last_authored_at, conversation_id") .joins(:all_conversations) diff --git a/app/models/conversation_participant.rb b/app/models/conversation_participant.rb index cad948bee60cd..71b2f0674750e 100644 --- a/app/models/conversation_participant.rb +++ b/app/models/conversation_participant.rb @@ -630,7 +630,7 @@ def destroy_conversation_message_participants def update_unread_count(direction = :up, user_id = self.user_id) User.where(id: user_id) - .update_all(["unread_conversations_count = GREATEST(unread_conversations_count + ?, 0), updated_at = ?", direction == :up ? 1 : -1, Time.now.utc]) + .update_all(["unread_conversations_count = GREATEST(unread_conversations_count + ?, 0), updated_at = ?", (direction == :up) ? 1 : -1, Time.now.utc]) end def update_unread_count_for_update @@ -638,7 +638,7 @@ def update_unread_count_for_update update_unread_count(:up) if unread? update_unread_count(:down, user_id_was) if workflow_state_was == "unread" elsif workflow_state_changed? && [workflow_state, workflow_state_was].include?("unread") - update_unread_count(workflow_state == "unread" ? :up : :down) + update_unread_count((workflow_state == "unread") ? :up : :down) end end diff --git a/app/models/course.rb b/app/models/course.rb index fc470e33c1f04..0b5c634415bb6 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -340,7 +340,7 @@ def inherited_assessment_question_banks(include_self = false) ].freeze def [](attr) - attr.to_s == "asset_string" ? asset_string : super + (attr.to_s == "asset_string") ? asset_string : super end def events_for(user) @@ -3207,7 +3207,7 @@ def uncached_tabs_available(user, opts) GuardRail.activate(:secondary) do # We will by default show everything in default_tabs, unless the teacher has configured otherwise. - tabs = elementary_subject_course? && !course_subject_tabs ? [] : tab_configuration.compact + tabs = (elementary_subject_course? && !course_subject_tabs) ? [] : tab_configuration.compact home_tab = default_tabs.find { |t| t[:id] == TAB_HOME } settings_tab = default_tabs.find { |t| t[:id] == TAB_SETTINGS } external_tabs = if opts[:include_external] @@ -4243,7 +4243,7 @@ def log_create_to_publish_time return unless publishing? publish_time = ((updated_at - created_at) * 1000).round - statsd_bucket = account.feature_enabled?(:course_paces) && enable_course_paces? ? "paced" : "unpaced" + statsd_bucket = (account.feature_enabled?(:course_paces) && enable_course_paces?) ? "paced" : "unpaced" InstStatsd::Statsd.timing("course.#{statsd_bucket}.create_to_publish_time", publish_time) end diff --git a/app/models/discussion_entry.rb b/app/models/discussion_entry.rb index a7672701dce9e..c707ab2107929 100644 --- a/app/models/discussion_entry.rb +++ b/app/models/discussion_entry.rb @@ -540,7 +540,7 @@ def change_read_state(new_state, current_user = nil, opts = {}) StreamItem.update_read_state_for_asset(self, new_state, current_user.id) if entry_participant.present? discussion_topic.update_or_create_participant( - opts.merge(current_user: current_user, offset: (new_state == "unread" ? 1 : -1)) + opts.merge(current_user: current_user, offset: ((new_state == "unread") ? 1 : -1)) ) end entry_participant diff --git a/app/models/discussion_topic.rb b/app/models/discussion_topic.rb index ec79742937847..598bca7a1b773 100644 --- a/app/models/discussion_topic.rb +++ b/app/models/discussion_topic.rb @@ -577,7 +577,7 @@ def update_participants_read_state(current_user, new_state, update_fields) update_or_create_participant(current_user: current_user, new_state: new_state, - new_count: new_state == "unread" ? default_unread_count : 0) + new_count: (new_state == "unread") ? default_unread_count : 0) end protected :update_participants_read_state diff --git a/app/models/discussion_topic/materialized_view.rb b/app/models/discussion_topic/materialized_view.rb index b193a28d2b9c3..a36777263c217 100644 --- a/app/models/discussion_topic/materialized_view.rb +++ b/app/models/discussion_topic/materialized_view.rb @@ -123,7 +123,7 @@ def materialized_view_json(opts = {}) if opts[:include_new_entries] @for_mobile = true if opts[:include_mobile_overrides] - new_entries = all_entries.count == entry_ids.count ? [] : all_entries.where.not(id: entry_ids).to_a + new_entries = (all_entries.count == entry_ids.count) ? [] : all_entries.where.not(id: entry_ids).to_a participant_ids = (Set.new(participant_ids) + new_entries.filter_map(&:user_id) + new_entries.filter_map(&:editor_id)).to_a entry_ids = (Set.new(entry_ids) + new_entries.map(&:id)).to_a new_entries_json_structure = discussion_entry_api_json(new_entries, discussion_topic.context, nil, nil, []) diff --git a/app/models/enrollment.rb b/app/models/enrollment.rb index a5afbbd354cc8..88abbae9f4943 100644 --- a/app/models/enrollment.rb +++ b/app/models/enrollment.rb @@ -900,7 +900,7 @@ def base_role_name def can_be_concluded_by(user, context, session) can_remove = [StudentEnrollment].include?(self.class) && context.grants_right?(user, session, :manage_students) && - context.id == ((context.is_a? Course) ? course_id : course_section_id) + context.id == (context.is_a?(Course) ? course_id : course_section_id) can_remove || context.grants_right?(user, session, manage_admin_users_perm) end diff --git a/app/models/eportfolio.rb b/app/models/eportfolio.rb index 4bac63f7902f4..052961519d7f0 100644 --- a/app/models/eportfolio.rb +++ b/app/models/eportfolio.rb @@ -153,7 +153,7 @@ def needs_spam_review? def self.spam_criteria_regexp(type: :title) setting_name = - type == :title ? "eportfolio_title_spam_keywords" : "eportfolio_content_spam_keywords" + (type == :title) ? "eportfolio_title_spam_keywords" : "eportfolio_content_spam_keywords" spam_keywords = Setting.get(setting_name, "").split(",").map(&:strip).reject(&:empty?) return nil if spam_keywords.blank? diff --git a/app/models/feature_flag.rb b/app/models/feature_flag.rb index b5970ea24f4ea..de6b68cdca498 100644 --- a/app/models/feature_flag.rb +++ b/app/models/feature_flag.rb @@ -113,11 +113,11 @@ def audit_log_destroy end def prior_flag_state(operation) - operation == :create ? default_for_flag : state_in_database + (operation == :create) ? default_for_flag : state_in_database end def post_flag_state(operation) - operation == :destroy ? default_for_flag : state + (operation == :destroy) ? default_for_flag : state end def default_for_flag diff --git a/app/models/folder.rb b/app/models/folder.rb index 325f898930373..80c7f7b1290dd 100644 --- a/app/models/folder.rb +++ b/app/models/folder.rb @@ -258,7 +258,7 @@ def hidden end def hidden=(val) - self.workflow_state = (val == true || val == "1" || val == "true" ? "hidden" : "visible") + self.workflow_state = ((val == true || val == "1" || val == "true") ? "hidden" : "visible") end def just_hide diff --git a/app/models/grading_period_group.rb b/app/models/grading_period_group.rb index 92a7dd9860528..8cfabc0c9d0b4 100644 --- a/app/models/grading_period_group.rb +++ b/app/models/grading_period_group.rb @@ -67,7 +67,7 @@ def self.for_course(context) return course_group if course_group.present? account_group = context.enrollment_term.grading_period_group - account_group.nil? || account_group.deleted? ? nil : account_group + (account_group.nil? || account_group.deleted?) ? nil : account_group end def recompute_scores_for_each_term(update_all_grading_period_scores, term_ids: nil) diff --git a/app/models/grading_standard.rb b/app/models/grading_standard.rb index b7befbcdb082a..c88f1a983b8b2 100644 --- a/app/models/grading_standard.rb +++ b/app/models/grading_standard.rb @@ -127,7 +127,7 @@ def score_to_grade(score) # assign the highest grade whose min cutoff is less than the score # if score is less than all scheme cutoffs, assign the lowest grade score = BigDecimal(score.to_s) # Cast this to a BigDecimal too or comparisons get wonky - ordered_scheme.max_by { |_, lower_bound| score >= lower_bound * 100.0.to_d ? lower_bound : -lower_bound }[0] + ordered_scheme.max_by { |_, lower_bound| (score >= lower_bound * 100.0.to_d) ? lower_bound : -lower_bound }[0] end def data=(new_val) diff --git a/app/models/group_category.rb b/app/models/group_category.rb index 9be820a7fb43e..b241b434b949c 100644 --- a/app/models/group_category.rb +++ b/app/models/group_category.rb @@ -430,7 +430,7 @@ def create_group_count=(num) end def create_group_member_count=(num) - @create_group_member_count = num && num > 0 ? num : nil + @create_group_member_count = (num && num > 0) ? num : nil end def set_root_account_id diff --git a/app/models/importers/course_content_importer.rb b/app/models/importers/course_content_importer.rb index 95969a4e65a89..749a98da166b2 100644 --- a/app/models/importers/course_content_importer.rb +++ b/app/models/importers/course_content_importer.rb @@ -601,7 +601,7 @@ def self.shift_date(time, options = {}) old_full_diff = old_end_date - old_start_date old_event_diff = old_date - old_start_date - old_event_percent = old_full_diff > 0 ? old_event_diff.to_f / old_full_diff.to_f : 0 + old_event_percent = (old_full_diff > 0) ? old_event_diff.to_f / old_full_diff.to_f : 0 new_full_diff = new_end_date - new_start_date new_event_diff = (new_full_diff.to_f * old_event_percent).round new_date = new_start_date + new_event_diff diff --git a/app/models/lti/launch.rb b/app/models/lti/launch.rb index 1c63f58479085..394db0f022c8b 100644 --- a/app/models/lti/launch.rb +++ b/app/models/lti/launch.rb @@ -60,7 +60,7 @@ def analytics_id def analytics_message_type @analytics_message_type || - (params["lti_message_type"] == "basic-lti-launch-request" ? "tool_launch" : params["lti_message_type"]) || + ((params["lti_message_type"] == "basic-lti-launch-request") ? "tool_launch" : params["lti_message_type"]) || "tool_launch" end end diff --git a/app/models/lti/lti_outbound_adapter.rb b/app/models/lti/lti_outbound_adapter.rb index 5535b3cd1d8e1..dfb03c85f3d0d 100644 --- a/app/models/lti/lti_outbound_adapter.rb +++ b/app/models/lti/lti_outbound_adapter.rb @@ -124,7 +124,7 @@ def generate_post_payload_for_homework_submission(assignment) def launch_url(post_only: false) raise("Called launch_url before calling prepare_tool_launch") unless @tool_launch - post_only && !disable_post_only? ? @tool_launch.url.split("?").first : @tool_launch.url + (post_only && !disable_post_only?) ? @tool_launch.url.split("?").first : @tool_launch.url end # this is the lis_result_sourcedid field in the launch, and the diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 4a99ef8518457..8f3c1040e13f9 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -40,8 +40,8 @@ def create_message(m) mail(params) do |format| [:body, :html_body].each do |attr| if m.send(attr) - body = m.send(attr).bytesize > Message.maximum_text_length ? Message.unavailable_message : m.send(attr) - attr == :body ? format.text { render plain: body } : format.html { render plain: body } + body = (m.send(attr).bytesize > Message.maximum_text_length) ? Message.unavailable_message : m.send(attr) + (attr == :body) ? format.text { render plain: body } : format.html { render plain: body } end end end diff --git a/app/models/message.rb b/app/models/message.rb index 72d69d73ac252..8b562a08d21db 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -849,7 +849,7 @@ def self.dashboard_messages(messages) end # not sure what this is even doing? - message_types.to_a.sort_by { |m| m[0] == "Other" ? CanvasSort::Last : m[0] } + message_types.to_a.sort_by { |m| (m[0] == "Other") ? CanvasSort::Last : m[0] } end # Public: Message to use if the message is unavailable to send. diff --git a/app/models/notification.rb b/app/models/notification.rb index 625867712d14d..144e85636eda9 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -294,7 +294,7 @@ def self.dashboard_categories(user = nil) res << n if n.category && n.dashboard? end end - res.sort_by { |n| n.category == "Other" ? CanvasSort::Last : n.category } + res.sort_by { |n| (n.category == "Other") ? CanvasSort::Last : n.category } end # Return a hash with information for a related user option if one exists. diff --git a/app/models/notification_policy.rb b/app/models/notification_policy.rb index 36cc332cdc7f7..5ed2a97720c28 100644 --- a/app/models/notification_policy.rb +++ b/app/models/notification_policy.rb @@ -72,7 +72,7 @@ def self.setup_for(user, params) # User preference change not being made. Make a notification policy change. # Using the category name, fetch all Notifications for the category. Will set the desired value on them. - notifications = Notification.all_cached.select { |n| (n.category&.underscore&.gsub(/\s/, "_")) == params[:category] }.map(&:id) + notifications = Notification.all_cached.select { |n| n.category&.underscore&.gsub(/\s/, "_") == params[:category] }.map(&:id) frequency = params[:frequency] cc = user.communication_channels.find(params[:channel_id]) diff --git a/app/models/page_view.rb b/app/models/page_view.rb index f564b4fff2148..1364b6199ac23 100644 --- a/app/models/page_view.rb +++ b/app/models/page_view.rb @@ -92,7 +92,7 @@ def url end def ensure_account - self.account_id ||= (context_type == "Account" ? context_id : context.account_id) rescue nil + self.account_id ||= ((context_type == "Account") ? context_id : context.account_id) rescue nil self.account_id ||= (context.is_a?(Account) ? context : context.account) if context end diff --git a/app/models/quizzes/quiz_question/multiple_choice_question.rb b/app/models/quizzes/quiz_question/multiple_choice_question.rb index 74dcd58870d3b..ec6c961208053 100644 --- a/app/models/quizzes/quiz_question/multiple_choice_question.rb +++ b/app/models/quizzes/quiz_question/multiple_choice_question.rb @@ -29,7 +29,7 @@ def correct_answer_parts(user_answer) return 0 unless answer user_answer.answer_id = answer[:id] || answer[:answer_id] - answer[:weight] == 100 ? 1 : 0 + (answer[:weight] == 100) ? 1 : 0 end end diff --git a/app/models/quizzes/quiz_statistics/item_analysis/item.rb b/app/models/quizzes/quiz_statistics/item_analysis/item.rb index 974453ccbdbdb..72b2a361194df 100644 --- a/app/models/quizzes/quiz_statistics/item_analysis/item.rb +++ b/app/models/quizzes/quiz_statistics/item_analysis/item.rb @@ -51,7 +51,7 @@ def add_response(answer, respondent_id) return unless answer[:answer_id] # blanks don't count for item stats answer_id = answer[:answer_id] - @scores << (answer_id == @answers.first ? question[:points_possible] : 0) + @scores << ((answer_id == @answers.first) ? question[:points_possible] : 0) @respondent_ids << respondent_id @respondent_map[answer_id] << respondent_id end diff --git a/app/models/quizzes/quiz_statistics/item_analysis/summary.rb b/app/models/quizzes/quiz_statistics/item_analysis/summary.rb index 032cd56ccb9ff..bbffdb20a2f01 100644 --- a/app/models/quizzes/quiz_statistics/item_analysis/summary.rb +++ b/app/models/quizzes/quiz_statistics/item_analysis/summary.rb @@ -98,7 +98,7 @@ def sorted_items def variance(respondent_ids = :all) @variance ||= {} @variance[respondent_ids] ||= begin - scores = (respondent_ids == :all ? @respondent_scores : @respondent_scores.slice(*respondent_ids)).values + scores = ((respondent_ids == :all) ? @respondent_scores : @respondent_scores.slice(*respondent_ids)).values SimpleStats.variance(scores) end end diff --git a/app/models/quizzes/quiz_statistics/student_analysis.rb b/app/models/quizzes/quiz_statistics/student_analysis.rb index 185dba50b4209..7a8a5b0659238 100644 --- a/app/models/quizzes/quiz_statistics/student_analysis.rb +++ b/app/models/quizzes/quiz_statistics/student_analysis.rb @@ -275,7 +275,7 @@ def to_csv blank_ids = question[:answers].pluck(:blank_id).uniq row << blank_ids.filter_map { |blank_id| answer["answer_for_#{blank_id}".to_sym].try(:gsub, /,/, "\\,") }.join(",") when "multiple_answers_question" - row << question[:answers].filter_map { |a| answer["answer_#{a[:id]}".to_sym] == "1" ? a[:text].gsub(/,/, "\\,") : nil }.join(",") + row << question[:answers].filter_map { |a| (answer["answer_#{a[:id]}".to_sym] == "1") ? a[:text].gsub(/,/, "\\,") : nil }.join(",") when "multiple_dropdowns_question" blank_ids = question[:answers].pluck(:blank_id).uniq answer_ids = blank_ids.map { |blank_id| answer["answer_for_#{blank_id}".to_sym] } diff --git a/app/models/quizzes/quiz_submission_history.rb b/app/models/quizzes/quiz_submission_history.rb index f7097c90be136..cac4daf46d877 100644 --- a/app/models/quizzes/quiz_submission_history.rb +++ b/app/models/quizzes/quiz_submission_history.rb @@ -42,7 +42,7 @@ def last_versions def version_models last_versions.map do |version| model = version.model - model&.attempt == @submission.attempt ? @submission : model + (model&.attempt == @submission.attempt) ? @submission : model end end diff --git a/app/models/quizzes/submission_grader.rb b/app/models/quizzes/submission_grader.rb index 23d0a2f7ef340..0f9429af42085 100644 --- a/app/models/quizzes/submission_grader.rb +++ b/app/models/quizzes/submission_grader.rb @@ -134,7 +134,7 @@ def update_outcomes(question_ids, submission_id, attempt) private def versioned_submission(submission, attempt) - submission.attempt == attempt ? submission : submission.versions.sort_by(&:created_at).map(&:model).reverse.detect { |s| s.attempt == attempt } + (submission.attempt == attempt) ? submission : submission.versions.sort_by(&:created_at).map(&:model).reverse.detect { |s| s.attempt == attempt } end def kept_score_updating?(original_score, original_workflow_state) diff --git a/app/models/rubric_assessment.rb b/app/models/rubric_assessment.rb index 07e459bd7c3fa..ec44f8a2c1789 100644 --- a/app/models/rubric_assessment.rb +++ b/app/models/rubric_assessment.rb @@ -188,7 +188,7 @@ def update_assessment_requests protected :update_assessment_requests def attempt - artifact_type == "Submission" ? artifact.attempt : nil + (artifact_type == "Submission") ? artifact.attempt : nil end def set_graded_anonymously diff --git a/app/models/sis_pseudonym.rb b/app/models/sis_pseudonym.rb index a2b6c728538a4..486793d66db0e 100644 --- a/app/models/sis_pseudonym.rb +++ b/app/models/sis_pseudonym.rb @@ -97,10 +97,10 @@ def find_in_other_accounts if include_deleted if user.all_pseudonyms_loaded? - return pick_user_pseudonym(user.all_pseudonyms, type == :trusted ? root_account.trusted_account_ids : nil) + return pick_user_pseudonym(user.all_pseudonyms, (type == :trusted) ? root_account.trusted_account_ids : nil) end elsif user.all_active_pseudonyms_loaded? - return pick_user_pseudonym(user.all_active_pseudonyms, type == :trusted ? root_account.trusted_account_ids : nil) + return pick_user_pseudonym(user.all_active_pseudonyms, (type == :trusted) ? root_account.trusted_account_ids : nil) end trusted_account_ids = root_account.trusted_account_ids.group_by { |id| Shard.shard_for(id) } if type == :trusted diff --git a/app/models/speed_grader/assignment.rb b/app/models/speed_grader/assignment.rb index 5b48fa36668a5..07b100db848f6 100644 --- a/app/models/speed_grader/assignment.rb +++ b/app/models/speed_grader/assignment.rb @@ -117,7 +117,7 @@ def json unless assignment.anonymize_students? # Ensure that any test students are sorted last - students = students.sort_by { |r| r.preferences[:fake_student] == true ? 1 : 0 } + students = students.sort_by { |r| (r.preferences[:fake_student] == true) ? 1 : 0 } end enrollments = diff --git a/app/models/stream_item.rb b/app/models/stream_item.rb index 7c30d4242f5a7..88dc215443994 100644 --- a/app/models/stream_item.rb +++ b/app/models/stream_item.rb @@ -243,7 +243,7 @@ def self.generate_or_update(object) item = new item.generate_data(object) StreamItem.unique_constraint_retry do |retry_count| - retry_count == 0 ? item.save! : item = nil # if it fails just carry on - it got created somewhere else so grab it later + (retry_count == 0) ? item.save! : item = nil # if it fails just carry on - it got created somewhere else so grab it later end item ||= object.reload.stream_item diff --git a/app/models/submission.rb b/app/models/submission.rb index 4595506bd353e..c56437dbbb085 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -853,7 +853,7 @@ def originality_report_url(asset_string, user, attempt = nil) return unless grants_right?(user, :view_turnitin_report) version_sub = if attempt.present? - attempt.to_i == self.attempt ? self : versions.find { |v| v.model&.attempt == attempt.to_i }&.model + (attempt.to_i == self.attempt) ? self : versions.find { |v| v.model&.attempt == attempt.to_i }&.model end requested_attachment = all_versioned_attachments.find_by_asset_string(asset_string) unless asset_string == self.asset_string scope = association(:originality_reports).loaded? ? versioned_originality_reports : originality_reports @@ -1615,9 +1615,9 @@ def score_missing(late_policy, points_possible, grading_type) private :score_missing def score_late_or_none(late_policy, points_possible, grading_type) - raw_score = score_changed? || @regraded ? score : entered_score + raw_score = (score_changed? || @regraded) ? score : entered_score deducted = late_points_deducted(raw_score, late_policy, points_possible, grading_type) - new_score = raw_score && (deducted > raw_score ? [0.0, raw_score].min : raw_score - deducted) + new_score = raw_score && ((deducted > raw_score) ? [0.0, raw_score].min : raw_score - deducted) self.points_deducted = late? ? deducted : nil self.score = new_score end @@ -2002,7 +2002,7 @@ def attachments=(attachments) # one student from sneakily getting access to files in another user's comments, # since they're all being held on the assignment for now. attachments ||= [] - old_ids = (Array(attachment_ids || "").join(",")).split(",").map(&:to_i) + old_ids = Array(attachment_ids || "").join(",").split(",").map(&:to_i) write_attribute(:attachment_ids, attachments.select { |a| (a && a.id && old_ids.include?(a.id)) || (a.recently_created? && a.context == assignment) || a.context != assignment }.map(&:id).join(",")) end @@ -2475,7 +2475,7 @@ def context end def to_atom(opts = {}) - author_name = assignment.present? && assignment.context.present? ? assignment.context.name : t("atom_no_author", "No Author") + author_name = (assignment.present? && assignment.context.present?) ? assignment.context.name : t("atom_no_author", "No Author") Atom::Entry.new do |entry| entry.title = "#{user.name} -- #{assignment.title}#{", " + assignment.context.name if opts[:include_context]}" entry.updated = updated_at @@ -2810,7 +2810,7 @@ def visible_rubric_assessments_for(viewing_user, attempt: nil) filtered_assessments.sort_by do |a| [ - a.assessment_type == "grading" ? CanvasSort::First : CanvasSort::Last, + (a.assessment_type == "grading") ? CanvasSort::First : CanvasSort::Last, Canvas::ICU.collation_key(a.assessor_name) ] end @@ -2822,7 +2822,7 @@ def rubric_assessments_for_attempt(attempt: nil) # If the requested attempt is 0, no attempt has actually been submitted. # The submission's attempt will be nil (not 0), so we do actually want to # find assessments with a nil artifact_attempt. - effective_attempt = attempt == 0 ? nil : attempt + effective_attempt = (attempt == 0) ? nil : attempt rubric_assessments.each_with_object([]) do |assessment, assessments_for_attempt| if assessment.artifact_attempt == effective_attempt @@ -3100,6 +3100,6 @@ def send_timing_data_if_needed InstStatsd::Statsd.gauge("submission.manually_graded.grading_time", time, Setting.get("submission_grading_timing_sample_rate", "1.0").to_f, - tags: { quiz_type: submission_type == "online_quiz" ? "classic_quiz" : "new_quiz" }) + tags: { quiz_type: (submission_type == "online_quiz") ? "classic_quiz" : "new_quiz" }) end end diff --git a/app/models/user.rb b/app/models/user.rb index 873ab6d9959e1..25fa49df204dd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -340,7 +340,7 @@ def self.public_lti_id def self.order_by_sortable_name(options = {}) clause = sortable_name_order_by_clause - sort_direction = options[:direction] == :descending ? "DESC" : "ASC" + sort_direction = (options[:direction] == :descending) ? "DESC" : "ASC" scope = order(Arel.sql("#{clause} #{sort_direction}")).order(Arel.sql("#{table_name}.id #{sort_direction}")) if scope.select_values.empty? scope = scope.select(arel_table[Arel.star]) @@ -356,7 +356,7 @@ def self.order_by_sortable_name(options = {}) def self.order_by_name(options = {}) clause = name_order_by_clause(options[:table]) - sort_direction = options[:direction] == :descending ? "DESC" : "ASC" + sort_direction = (options[:direction] == :descending) ? "DESC" : "ASC" scope = order(Arel.sql("#{clause} #{sort_direction}")).order(Arel.sql("#{table_name}.id #{sort_direction}")) if scope.select_values.empty? scope = scope.select(arel_table[Arel.star]) @@ -459,7 +459,7 @@ def courses_for_enrollments(enrollment_scope, associated_user = nil, include_com .merge(enrollment_scope.except(:joins)) .where(enrollments: { associated_user_id: associated_user.id }) else - join = associated_user == self ? :enrollments_excluding_linked_observers : :all_enrollments + join = (associated_user == self) ? :enrollments_excluding_linked_observers : :all_enrollments scope = Course.active.joins(join).merge(enrollment_scope.except(:joins)).distinct end @@ -971,7 +971,7 @@ def email email_channel.try(:path) || :none end # this sillyness is because rails equates falsey as not in the cache - value == :none ? nil : value + (value == :none) ? nil : value end end @@ -1024,7 +1024,7 @@ def google_drive_address def google_service_address(service_name) user_services.where(service: service_name) - .limit(1).pluck(service_name == "google_drive" ? :service_user_name : :service_user_id).first + .limit(1).pluck((service_name == "google_drive") ? :service_user_name : :service_user_id).first end def email=(e) @@ -1663,7 +1663,7 @@ def sorted_rubrics context_codes = ([self] + management_contexts).uniq.map(&:asset_string) rubrics = context_rubrics.active rubrics += Rubric.active.where(context_code: context_codes).to_a - rubrics.uniq.sort_by { |r| [(r.association_count || 0) > 3 ? CanvasSort::First : CanvasSort::Last, Canvas::ICU.collation_key(r.title || CanvasSort::Last)] } + rubrics.uniq.sort_by { |r| [((r.association_count || 0) > 3) ? CanvasSort::First : CanvasSort::Last, Canvas::ICU.collation_key(r.title || CanvasSort::Last)] } end def assignments_recently_graded(opts = {}) @@ -3101,7 +3101,7 @@ def self.initial_enrollment_type_from_text(type) def self.preload_shard_associations(users); end def associated_shards(strength = :strong) - strength == :strong ? [Shard.default] : [] + (strength == :strong) ? [Shard.default] : [] end def in_region_associated_shards diff --git a/app/models/user_learning_object_scopes.rb b/app/models/user_learning_object_scopes.rb index 04d1334e49540..a36438bb37fe6 100644 --- a/app/models/user_learning_object_scopes.rb +++ b/app/models/user_learning_object_scopes.rb @@ -166,7 +166,7 @@ def arguments_for_objects_needing( scope = scope.not_ignored_by(self, purpose) unless include_ignored scope = scope.for_course(shard_course_ids) if ["Assignment", "Quizzes::Quiz"].include?(object_type) if object_type == "Assignment" - scope = participation_type == :student ? scope.published : scope.active + scope = (participation_type == :student) ? scope.published : scope.active scope = scope.expecting_submission unless include_ungraded end [scope, shard_course_ids, shard_group_ids] diff --git a/app/models/web_conference.rb b/app/models/web_conference.rb index 9b1c2a97f902f..0fe3deb820ce7 100644 --- a/app/models/web_conference.rb +++ b/app/models/web_conference.rb @@ -460,7 +460,7 @@ def has_advanced_settings def has_calendar_event return 0 if calendar_event.nil? - calendar_event.workflow_state == "deleted" ? 0 : 1 + (calendar_event.workflow_state == "deleted") ? 0 : 1 end scope :after, ->(date) { where("web_conferences.start_at IS NULL OR web_conferences.start_at>?", date) } diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 65c9aa79a9f04..42910ce186df1 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -353,7 +353,7 @@ def can_edit_page?(user, session = nil) def effective_roles context_roles = context.default_wiki_editing_roles rescue nil roles = (editing_roles || context_roles || default_roles).split(",") - roles == %w[teachers] ? [] : roles # "Only teachers" option doesn't grant rights excluded by RoleOverrides + (roles == %w[teachers]) ? [] : roles # "Only teachers" option doesn't grant rights excluded by RoleOverrides end def available_for?(user, session = nil) diff --git a/app/presenters/quizzes/take_quiz_presenter.rb b/app/presenters/quizzes/take_quiz_presenter.rb index 51c5e766a20df..4fd06969e4f50 100644 --- a/app/presenters/quizzes/take_quiz_presenter.rb +++ b/app/presenters/quizzes/take_quiz_presenter.rb @@ -216,7 +216,7 @@ def form_action_params(session, user) def resolve_answers(dataset = submission_data) # get all the question status-entries and group them by the question id answers = dataset.keys.group_by do |k| - k =~ /question_(\d+)/ ? $1.to_i : :irrelevant + (k =~ /question_(\d+)/) ? $1.to_i : :irrelevant end # remove any non-question keys we've collected diff --git a/app/serializers/lti/ims/names_and_roles_serializer.rb b/app/serializers/lti/ims/names_and_roles_serializer.rb index 785d4fd06cc33..42ecc7e50691c 100644 --- a/app/serializers/lti/ims/names_and_roles_serializer.rb +++ b/app/serializers/lti/ims/names_and_roles_serializer.rb @@ -126,7 +126,7 @@ def member(enrollment, expander) def member_sourced_id(expander) expanded = expander.expand_variables!({ value: "$Person.sourcedId" })[:value] - expanded == "$Person.sourcedId" ? nil : expanded + (expanded == "$Person.sourcedId") ? nil : expanded end def message(enrollment, expander) diff --git a/build/dockerfile_writer.rb b/build/dockerfile_writer.rb index b69571d43f8ef..0caeb1c37b03b 100755 --- a/build/dockerfile_writer.rb +++ b/build/dockerfile_writer.rb @@ -89,7 +89,7 @@ def docker_compose_volume_paths path.sub("/usr/src/app/", "") end - paths.sort_by { |path| [path[0] == "/" ? 1 : 0, path] } + paths.sort_by { |path| [(path[0] == "/") ? 1 : 0, path] } end def docker_compose_config diff --git a/build/new-jenkins/skipped_specs_manager.rb b/build/new-jenkins/skipped_specs_manager.rb index 42eea2e8c357f..45f338d43a9bd 100644 --- a/build/new-jenkins/skipped_specs_manager.rb +++ b/build/new-jenkins/skipped_specs_manager.rb @@ -82,7 +82,7 @@ def resolve_maps end def write_to_file - path = @mode == "ruby" ? "/usr/src/app/out/" : "/tmp/" + path = (@mode == "ruby") ? "/usr/src/app/out/" : "/tmp/" full_path = "#{path}/#{FILENAME}" puts "writing #{@updated_map.keys.count} spec(s) to '#{full_path}'" diff --git a/config/application.rb b/config/application.rb index b75fa0bf3bcd8..60760bc46826c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -79,7 +79,7 @@ class Application < Rails::Application (log_config["facilities"] || []).each do |facility| facilities |= Syslog.const_get "LOG_#{facility.to_s.upcase}" end - ident = ENV["RUNNING_AS_DAEMON"] == "true" ? log_config["daemon_ident"] : log_config["app_ident"] + ident = (ENV["RUNNING_AS_DAEMON"] == "true") ? log_config["daemon_ident"] : log_config["app_ident"] opts[:include_pid] = true if log_config["include_pid"] == true config.logger = SyslogWrapper.new(ident, facilities, opts) config.logger.level = log_level diff --git a/config/initializers/active_record.rb b/config/initializers/active_record.rb index 9bdd6d02144dd..d513b53b7eb7d 100644 --- a/config/initializers/active_record.rb +++ b/config/initializers/active_record.rb @@ -1340,7 +1340,7 @@ def union(*scopes, from: false) end.join(" UNION ALL ") return unscoped.where("#{table}.#{connection.quote_column_name(primary_key)} IN (#{sub_query})") unless from - sub_query = +"(#{sub_query}) #{from == true ? table : from}" + sub_query = +"(#{sub_query}) #{(from == true) ? table : from}" unscoped.from(sub_query) end end diff --git a/config/routes.rb b/config/routes.rb index 647a9d91dde35..431fd32e5653b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2038,7 +2038,7 @@ scope(controller: :outcome_groups_api) do %w[global account course].each do |context| - prefix = (context == "global" ? context : "#{context}s/:#{context}_id") + prefix = ((context == "global") ? context : "#{context}s/:#{context}_id") unless context == "global" get "#{prefix}/outcome_groups", action: :index, as: "#{context}_outcome_groups" get "#{prefix}/outcome_group_links", action: :link_index, as: "#{context}_outcome_group_links" diff --git a/doc/api/fulldoc/html/swagger/method_view.rb b/doc/api/fulldoc/html/swagger/method_view.rb index 4461c04a2de26..66208b6149dbc 100644 --- a/doc/api/fulldoc/html/swagger/method_view.rb +++ b/doc/api/fulldoc/html/swagger/method_view.rb @@ -195,7 +195,7 @@ def calculate_unique_nicknames(url_list, idx, prefix, nickname_suffix) # There are at least two possible values for this segment. Handle each option. segments.each do |option, urls| # The path option forms part of the unique prefix, so add it to the prefix list. - p = option == :none ? prefix : prefix + [option.gsub(/\{|\}|\*/i, "")] + p = (option == :none) ? prefix : prefix + [option.gsub(/\{|\}|\*/i, "")] if urls.length == 1 # If there was only one URL with this value, we've found that URL's unique nickname. nickname_suffix[urls.join("/")] = p.join("_") diff --git a/doc/api/topic/html/setup.rb b/doc/api/topic/html/setup.rb index bbf5ed27a4c6c..49754469cac2a 100644 --- a/doc/api/topic/html/setup.rb +++ b/doc/api/topic/html/setup.rb @@ -67,7 +67,7 @@ def render_comment(property) indent_chars = "// " description = property["description"] ? indent(word_wrap(property["description"], 80 - indent_chars.length), 1, indent_chars) : "" deprecation = deprecation_message(property) - separator = description.present? && deprecation.present? ? "//\n" : "" + separator = (description.present? && deprecation.present?) ? "//\n" : "" "#{description}#{separator}#{deprecation}" end diff --git a/gems/acts_as_list/lib/active_record/acts/list.rb b/gems/acts_as_list/lib/active_record/acts/list.rb index 7e23b44e1668d..918fccb0db41a 100644 --- a/gems/acts_as_list/lib/active_record/acts/list.rb +++ b/gems/acts_as_list/lib/active_record/acts/list.rb @@ -83,7 +83,7 @@ def acts_as_list(options = {}) scope = new_scope # build the conditions hash, using literal values or the attribute if it's self - conditions = scope.to_h { |k, v| [k, v == self ? k : v.inspect] } + conditions = scope.to_h { |k, v| [k, (v == self) ? k : v.inspect] } conditions = conditions.map { |c, v| "#{c}: #{v}" }.join(", ") # build the in_scope method, matching literals or requiring a foreign keys # to be non-nil diff --git a/gems/attachment_fu/lib/attachment_fu.rb b/gems/attachment_fu/lib/attachment_fu.rb index 6958e5b126050..5ecd96d88b160 100644 --- a/gems/attachment_fu/lib/attachment_fu.rb +++ b/gems/attachment_fu/lib/attachment_fu.rb @@ -101,7 +101,7 @@ def has_attachment(options = {}) options[:thumbnails] ||= {} options[:thumbnail_class] ||= self options[:s3_access] ||= "public-read" - options[:content_type] = [options[:content_type]].flatten.collect! { |t| t == :image ? AttachmentFu.content_types : t }.flatten unless options[:content_type].nil? + options[:content_type] = [options[:content_type]].flatten.collect! { |t| (t == :image) ? AttachmentFu.content_types : t }.flatten unless options[:content_type].nil? unless options[:thumbnails].is_a?(Hash) raise ArgumentError, ":thumbnails option should be a hash: e.g. :thumbnails => { :foo => '50x50' }" @@ -120,7 +120,7 @@ def has_attachment(options = {}) attachment_options[:storage] ||= parent_options[:storage] attachment_options[:path_prefix] ||= attachment_options[:file_system_path] if attachment_options[:path_prefix].nil? - attachment_options[:path_prefix] = attachment_options[:storage] == :s3 ? table_name : File.join("public", table_name) + attachment_options[:path_prefix] = (attachment_options[:storage] == :s3) ? table_name : File.join("public", table_name) end attachment_options[:path_prefix] = attachment_options[:path_prefix][1..] if options[:path_prefix].first == "/" diff --git a/gems/canvas_color/lib/canvas_color.rb b/gems/canvas_color/lib/canvas_color.rb index 4839fb48b912e..31e68e0d66049 100644 --- a/gems/canvas_color/lib/canvas_color.rb +++ b/gems/canvas_color/lib/canvas_color.rb @@ -44,7 +44,7 @@ class Color attr_reader :r, :g, :b, :a # Table for conversion to hex - HEXVAL = (("0".."9").to_a).concat(("A".."F").to_a).freeze + HEXVAL = ("0".."9").to_a.concat(("A".."F").to_a).freeze # Default value for #darken, #lighten etc. BRIGHTNESS_DEFAULT = 0.2 diff --git a/gems/canvas_kaltura/lib/canvas_kaltura/kaltura_client_v3.rb b/gems/canvas_kaltura/lib/canvas_kaltura/kaltura_client_v3.rb index 944ba72970d1a..8dc7b3054c3d3 100644 --- a/gems/canvas_kaltura/lib/canvas_kaltura/kaltura_client_v3.rb +++ b/gems/canvas_kaltura/lib/canvas_kaltura/kaltura_client_v3.rb @@ -148,10 +148,10 @@ def sort_source_list(sources) suspicious_bitrate_threshold = original_source ? original_source[:bitrate].to_i * 5 : 0 sources = sources.sort_by do |a| - [a[:hasWarnings] || a[:isOriginal] != "0" ? CanvasSort::Last : CanvasSort::First, - a[:isOriginal] == "0" ? CanvasSort::First : CanvasSort::Last, + [(a[:hasWarnings] || a[:isOriginal] != "0") ? CanvasSort::Last : CanvasSort::First, + (a[:isOriginal] == "0") ? CanvasSort::First : CanvasSort::Last, PREFERENCE.index(a[:fileExt]) || (PREFERENCE.size + 1), - a[:bitrate].to_i < suspicious_bitrate_threshold ? CanvasSort::First : CanvasSort::Last, + (a[:bitrate].to_i < suspicious_bitrate_threshold) ? CanvasSort::First : CanvasSort::Last, 0 - a[:bitrate].to_i] end @@ -179,7 +179,7 @@ def thumbnail_url(entryId, opts = {}) def startSession(type = SessionType::USER, userId = nil) partnerId = @partnerId - secret = type == SessionType::USER ? @user_secret : @secret + secret = (type == SessionType::USER) ? @user_secret : @secret result = getRequest(:session, :start, secret: secret, partnerId: partnerId, diff --git a/gems/canvas_quiz_statistics/lib/canvas_quiz_statistics/analyzers/essay.rb b/gems/canvas_quiz_statistics/lib/canvas_quiz_statistics/analyzers/essay.rb index dc1ee916fd374..a219148e0b185 100644 --- a/gems/canvas_quiz_statistics/lib/canvas_quiz_statistics/analyzers/essay.rb +++ b/gems/canvas_quiz_statistics/lib/canvas_quiz_statistics/analyzers/essay.rb @@ -128,7 +128,7 @@ class Essay < Base graded_responses = [] ungraded_responses = [] - responses.each { |r| r[:correct] == "defined" ? graded_responses << r : ungraded_responses << r } + responses.each { |r| (r[:correct] == "defined") ? graded_responses << r : ungraded_responses << r } ranked_responses_by_score = graded_responses.sort_by { |h| h[:points] } previous_floor = ranked_responses_by_score.length diff --git a/gems/dynamic_settings/lib/dynamic_settings/prefix_proxy.rb b/gems/dynamic_settings/lib/dynamic_settings/prefix_proxy.rb index 2fd2d298160d9..ad559f4d4da45 100644 --- a/gems/dynamic_settings/lib/dynamic_settings/prefix_proxy.rb +++ b/gems/dynamic_settings/lib/dynamic_settings/prefix_proxy.rb @@ -117,7 +117,7 @@ def for_prefix(prefix_extension, default_ttl: @default_ttl) # @param global [boolean] Is it a global key? # @return Consul txn response def set_keys(kvs, global: false) - opts = @data_center.present? && global ? { dc: @data_center } : {} + opts = (@data_center.present? && global) ? { dc: @data_center } : {} value = kvs.map do |k, v| { "KV" => { @@ -248,7 +248,7 @@ def kv_fetch(full_key, **options) timing = format("CONSUL (%.2fms)", ms) status = "OK" unless error.nil? - status = error.is_a?(Diplomat::KeyNotFound) && error.message == full_key ? "NOT_FOUND" : "ERROR" + status = (error.is_a?(Diplomat::KeyNotFound) && error.message == full_key) ? "NOT_FOUND" : "ERROR" end DynamicSettings.logger.debug(" #{timing} get (#{full_key}) -> status:#{status}") if @query_logging return nil if status == "NOT_FOUND" diff --git a/gems/google_drive/lib/google_drive/entry.rb b/gems/google_drive/lib/google_drive/entry.rb index b0d5e1a4e514b..f2d8da3d7224b 100644 --- a/gems/google_drive/lib/google_drive/entry.rb +++ b/gems/google_drive/lib/google_drive/entry.rb @@ -26,7 +26,7 @@ def initialize(google_drive_entry, preferred_extensions = nil) @document_id = @entry["id"] @preferred_extensions = preferred_extensions parent = @entry["parents"].empty? ? nil : @entry["parents"][0] - @folder = (parent.nil? || parent["isRoot"] ? nil : parent["id"]) + @folder = ((parent.nil? || parent["isRoot"]) ? nil : parent["id"]) end def alternate_url diff --git a/gems/html_text_helper/lib/html_text_helper.rb b/gems/html_text_helper/lib/html_text_helper.rb index aba4128561f09..d7bed12e3c3c2 100644 --- a/gems/html_text_helper/lib/html_text_helper.rb +++ b/gems/html_text_helper/lib/html_text_helper.rb @@ -115,7 +115,7 @@ def html_node_to_text(node, opts = {}) rescue URI::Error # do nothing, let href pass through as is end - href == subtext ? subtext : "[#{subtext}] (#{href})" + (href == subtext) ? subtext : "[#{subtext}] (#{href})" end else subtext @@ -157,7 +157,7 @@ def word_wrap(text, options = {}) line_width = options.fetch(:line_width, 80) text.split("\n").collect do |line| - line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line + (line.length > line_width) ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line end * "\n" end diff --git a/gems/i18n_extraction/lib/i18n_extraction/i18nliner_extensions.rb b/gems/i18n_extraction/lib/i18n_extraction/i18nliner_extensions.rb index 3fa027986035f..80da34f1fbf61 100644 --- a/gems/i18n_extraction/lib/i18n_extraction/i18nliner_extensions.rb +++ b/gems/i18n_extraction/lib/i18n_extraction/i18nliner_extensions.rb @@ -175,7 +175,7 @@ def scope_for(filename) scope = case filename when %r{app/controllers/} scope = filename.gsub(%r{.*app/controllers/|_controller\.rb}, "").gsub(%r{/_?}, ".") - scope == "application." ? "" : scope + (scope == "application.") ? "" : scope when %r{app/models/} scope = filename.gsub(%r{.*app/models/|\.rb}, "") STI_SUPERCLASSES.include?(scope) ? "" : scope diff --git a/gems/i18n_tasks/lib/i18n_tasks/i18n_import.rb b/gems/i18n_tasks/lib/i18n_tasks/i18n_import.rb index 1733c0bab6916..c7da777761d3f 100644 --- a/gems/i18n_tasks/lib/i18n_tasks/i18n_import.rb +++ b/gems/i18n_tasks/lib/i18n_tasks/i18n_import.rb @@ -146,7 +146,7 @@ def markdown_and_wrappers(str) # only do fancy markdown checks on multi-line strings if dashed_str.include?("\n") matches.concat(scan_and_report(dashed_str, /^(\#{1,6})\s+[^#]*#*$/).map { |m| "h#{m.first.size}" }) # headings - .concat(scan_and_report(dashed_str, /^[^=\-\n]+\n^(=+|-+)$/).map { |m| m.first[0] == "=" ? "h1" : "h2" }) # moar headings + .concat(scan_and_report(dashed_str, /^[^=\-\n]+\n^(=+|-+)$/).map { |m| (m.first[0] == "=") ? "h1" : "h2" }) # moar headings .concat(scan_and_report(dashed_str, /^((\s*\*\s*){3,}|(\s*-\s*){3,}|(\s*_\s*){3,})$/).map { "hr" }) .concat(scan_and_report(dashed_str, LIST_ITEM_PATTERN).map { |m| /\d/.match?(m.first) ? "1." : "*" }) end diff --git a/gems/plugins/account_reports/lib/account_reports/report_helper.rb b/gems/plugins/account_reports/lib/account_reports/report_helper.rb index b7f229aa0857c..54b0676d37224 100644 --- a/gems/plugins/account_reports/lib/account_reports/report_helper.rb +++ b/gems/plugins/account_reports/lib/account_reports/report_helper.rb @@ -48,7 +48,7 @@ def default_timezone_format(datetime, account = root_account) # it will then format the datetime using the given format string def timezone_strftime(datetime, format, account = root_account) if (datetime = parse_utc_string(datetime)) - (datetime.in_time_zone(account.default_time_zone)).strftime(format) + datetime.in_time_zone(account.default_time_zone).strftime(format) end end diff --git a/gems/plugins/account_reports/lib/account_reports/sis_exporter.rb b/gems/plugins/account_reports/lib/account_reports/sis_exporter.rb index 9696ebebe04f1..83f983b10b0f3 100644 --- a/gems/plugins/account_reports/lib/account_reports/sis_exporter.rb +++ b/gems/plugins/account_reports/lib/account_reports/sis_exporter.rb @@ -648,10 +648,10 @@ def groups row << g.sis_source_id row << g.group_category_id unless @sis_format row << g.gc_sis_id - row << (g.context_type == "Account" ? g.context_id : nil) unless @sis_format - row << (g.context_type == "Account" ? g.account_sis_id : nil) - row << (g.context_type == "Course" ? g.context_id : nil) unless @sis_format - row << (g.context_type == "Course" ? g.course_sis_id : nil) + row << ((g.context_type == "Account") ? g.context_id : nil) unless @sis_format + row << ((g.context_type == "Account") ? g.account_sis_id : nil) + row << ((g.context_type == "Course") ? g.context_id : nil) unless @sis_format + row << ((g.context_type == "Course") ? g.course_sis_id : nil) row << g.name row << g.workflow_state row << g.sis_batch_id? unless @sis_format diff --git a/gems/plugins/qti_exporter/lib/qti/assessment_test_converter.rb b/gems/plugins/qti_exporter/lib/qti/assessment_test_converter.rb index 34c1c82431cfc..4d6702477887a 100644 --- a/gems/plugins/qti_exporter/lib/qti/assessment_test_converter.rb +++ b/gems/plugins/qti_exporter/lib/qti/assessment_test_converter.rb @@ -129,7 +129,7 @@ def parse_quiz_data(doc) max = -1 if /unlimited/i.match?(max) max = max.to_i # -1 means no limit in instructure, 0 means no limit in QTI - @quiz[:allowed_attempts] = max >= 1 ? max : -1 + @quiz[:allowed_attempts] = (max >= 1) ? max : -1 end if (show = control["showSolution"]) @quiz[:show_correct_answers] = show.casecmp?("true") @@ -194,7 +194,7 @@ def process_section(section) if (val = get_bool_val(section, "sourcebank_is_external")) group[:question_bank_is_external] = val end - group[:migration_id] = section["identifier"] && section["identifier"] != "" ? section["identifier"] : unique_local_id + group[:migration_id] = (section["identifier"] && section["identifier"] != "") ? section["identifier"] : unique_local_id questions_list = group[:questions] end if section["visible"] && section["visible"] =~ /true/i && (title = section["title"]) diff --git a/gems/plugins/qti_exporter/lib/qti/choice_interaction.rb b/gems/plugins/qti_exporter/lib/qti/choice_interaction.rb index d45f15a89df24..c1a4259af5645 100644 --- a/gems/plugins/qti_exporter/lib/qti/choice_interaction.rb +++ b/gems/plugins/qti_exporter/lib/qti/choice_interaction.rb @@ -100,7 +100,7 @@ def set_question_type if correct_answers == 0 @question[:import_error] = "The importer couldn't determine the correct answers for this question." end - @question[:question_type] ||= correct_answers == 1 ? "multiple_choice_question" : "multiple_answers_question" + @question[:question_type] ||= (correct_answers == 1) ? "multiple_choice_question" : "multiple_answers_question" @question[:question_type] = "multiple_choice_question" if @is_really_stupid_likert end diff --git a/gems/plugins/qti_exporter/lib/qti/fill_in_the_blank.rb b/gems/plugins/qti_exporter/lib/qti/fill_in_the_blank.rb index 7a4b0f1fc2542..92ddd93b174a4 100644 --- a/gems/plugins/qti_exporter/lib/qti/fill_in_the_blank.rb +++ b/gems/plugins/qti_exporter/lib/qti/fill_in_the_blank.rb @@ -86,7 +86,7 @@ def process_canvas end ci.search("simpleChoice").each do |choice| answer = {} - answer[:weight] = @type == "multiple_dropdowns_question" ? 0 : 100 + answer[:weight] = (@type == "multiple_dropdowns_question") ? 0 : 100 answer[:migration_id] = choice["identifier"] answer[:id] = get_or_generate_answer_id(answer[:migration_id]) answer[:text] = choice.text.strip diff --git a/gems/plugins/qti_exporter/lib/qti/respondus_settings.rb b/gems/plugins/qti_exporter/lib/qti/respondus_settings.rb index 1e1808b3d7880..14d6582884a8c 100644 --- a/gems/plugins/qti_exporter/lib/qti/respondus_settings.rb +++ b/gems/plugins/qti_exporter/lib/qti/respondus_settings.rb @@ -29,12 +29,12 @@ def apply(assessment) return unless read_setting("hasSettings") == "true" apply_if_set(assessment, :description, "instructions") - apply_if_set(assessment, :allowed_attempts, "attempts") { |v| v == "unlimited" ? -1 : v.to_i } - apply_if_set(assessment, :time_limit, "timeLimit") { |v| v == "unlimited" ? nil : v.to_f } + apply_if_set(assessment, :allowed_attempts, "attempts") { |v| (v == "unlimited") ? -1 : v.to_i } + apply_if_set(assessment, :time_limit, "timeLimit") { |v| (v == "unlimited") ? nil : v.to_f } apply_if_set(assessment, :unlock_at, "availableFrom") { |v| readtime(v) } apply_if_set(assessment, :lock_at, "availableTo") { |v| readtime(v) } apply_if_set(assessment, :access_code, "password") - apply_if_set(assessment, :ip_filter, "ipRestriction") { |v| v == "unlimited" ? nil : v } + apply_if_set(assessment, :ip_filter, "ipRestriction") { |v| (v == "unlimited") ? nil : v } apply_if_set(assessment, :shuffle_answers, "shuffleAnswers") { |v| v == "true" } apply_if_set(assessment, :due_at, "dueDate") { |v| readtime(v) } if read_setting("publishNow") == "true" @@ -81,7 +81,7 @@ def apply_if_set(assessment, key, setting_name) end def readtime(v) - v == "unlimited" ? nil : Time.at(v.to_i) + (v == "unlimited") ? nil : Time.at(v.to_i) end def read_setting(setting_name) diff --git a/gems/plugins/qti_exporter/spec_canvas/qti_helper.rb b/gems/plugins/qti_exporter/spec_canvas/qti_helper.rb index ebf0fd469fb70..10db95f0a8f77 100644 --- a/gems/plugins/qti_exporter/spec_canvas/qti_helper.rb +++ b/gems/plugins/qti_exporter/spec_canvas/qti_helper.rb @@ -62,7 +62,7 @@ def get_manifest_node(question, opts = {}) it = Object.new allow(it).to receive(:text).and_return(opts[:interaction_type]) end - allow(manifest_node).to receive(:at_css).with(("interactionType")).and_return(it) + allow(manifest_node).to receive(:at_css).with("interactionType").and_return(it) bbqt = nil if opts[:bb_question_type] @@ -70,7 +70,7 @@ def get_manifest_node(question, opts = {}) allow(bbqt).to receive(:text).and_return(opts[:bb_question_type]) bbqt["value"] = opts[:bb_question_type] end - allow(manifest_node).to receive(:at_css).with(("instructureMetadata instructureField[name=bb_question_type]")).and_return(bbqt) + allow(manifest_node).to receive(:at_css).with("instructureMetadata instructureField[name=bb_question_type]").and_return(bbqt) qt = nil if opts[:question_type] @@ -78,7 +78,7 @@ def get_manifest_node(question, opts = {}) allow(qt).to receive(:text).and_return(opts[:question_type]) qt["value"] = opts[:question_type] end - allow(manifest_node).to receive(:at_css).with(("instructureMetadata instructureField[name=question_type]")).and_return(qt) + allow(manifest_node).to receive(:at_css).with("instructureMetadata instructureField[name=question_type]").and_return(qt) bb8a = nil if opts[:quiz_type] @@ -86,7 +86,7 @@ def get_manifest_node(question, opts = {}) allow(bb8a).to receive(:text).and_return(opts[:quiz_type]) bb8a["value"] = opts[:quiz_type] end - allow(manifest_node).to receive(:at_css).with(("instructureField[name=bb8_assessment_type]")).and_return(bb8a) + allow(manifest_node).to receive(:at_css).with("instructureField[name=bb8_assessment_type]").and_return(bb8a) manifest_node end diff --git a/lib/api.rb b/lib/api.rb index 53675e3075942..b780351a63ebc 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -42,7 +42,7 @@ def api_find(collection, id, account: nil, writable: infer_writable_from_request def api_find_all(collection, ids, account: nil) if collection.table_name == User.table_name && @current_user - ids = ids.map { |id| id == "self" ? @current_user.id : id } + ids = ids.map { |id| (id == "self") ? @current_user.id : id } end if collection.table_name == Account.table_name ids = ids.map do |id| @@ -72,9 +72,9 @@ def api_find_all(collection, ids, account: nil) .where("(start_at<=? OR start_at IS NULL) AND (end_at >=? OR end_at IS NULL) AND NOT (start_at IS NULL AND end_at IS NULL)", Time.now.utc, Time.now.utc) .limit(2) .to_a - current_term = current_terms.length == 1 ? current_terms.first : :nil + current_term = (current_terms.length == 1) ? current_terms.first : :nil end - current_term == :nil ? nil : current_term + (current_term == :nil) ? nil : current_term else id end diff --git a/lib/api/v1/assignment.rb b/lib/api/v1/assignment.rb index 0b54390919dae..3d99ea314e080 100644 --- a/lib/api/v1/assignment.rb +++ b/lib/api/v1/assignment.rb @@ -714,7 +714,7 @@ def update_from_params(assignment, assignment_params, user, context = assignment if update_params["submission_types"].is_a? Array update_params["submission_types"] = update_params["submission_types"].map do |type| # TODO: remove. this was temporary backward support for a hotfix - type == "online_media_recording" ? "media_recording" : type + (type == "online_media_recording") ? "media_recording" : type end update_params["submission_types"] = update_params["submission_types"].join(",") end diff --git a/lib/api/v1/content_share.rb b/lib/api/v1/content_share.rb index d8a18767b39ef..a4926af2aa45e 100644 --- a/lib/api/v1/content_share.rb +++ b/lib/api/v1/content_share.rb @@ -34,7 +34,7 @@ module Api::V1::ContentShare def content_share_json(content_share, user, session, opts = {}) json = api_json(content_share, user, session, opts.merge(only: %w[id name created_at updated_at user_id read_state])) - json["sender"] = content_share.respond_to?(:sender) && content_share.sender ? user_display_json(content_share.sender) : nil + json["sender"] = (content_share.respond_to?(:sender) && content_share.sender) ? user_display_json(content_share.sender) : nil json["receivers"] = content_share.respond_to?(:receivers) ? content_share.receivers.map { |rec| user_display_json(rec) } : [] if content_share.content_export json["content_type"] = get_content_type_from_export_settings(content_share.content_export.settings) diff --git a/lib/api/v1/role.rb b/lib/api/v1/role.rb index b33c7188c7166..f7e1bdbf61fc4 100644 --- a/lib/api/v1/role.rb +++ b/lib/api/v1/role.rb @@ -28,7 +28,7 @@ def role_json(account, role, current_user, session, skip_permissions: false, pre role: role.name, label: role.label, last_updated_at: role.updated_at, - base_role_type: role.built_in? && role.account_role? ? Role::DEFAULT_ACCOUNT_TYPE : role.base_role_type, + base_role_type: (role.built_in? && role.account_role?) ? Role::DEFAULT_ACCOUNT_TYPE : role.base_role_type, workflow_state: role.workflow_state, created_at: role.created_at&.iso8601, permissions: {}, diff --git a/lib/authentication_methods.rb b/lib/authentication_methods.rb index a53bd67ff53ea..54f860745c5f4 100644 --- a/lib/authentication_methods.rb +++ b/lib/authentication_methods.rb @@ -104,7 +104,7 @@ def validate_scopes return unless @access_token developer_key = @access_token.developer_key - request_method = request.method.casecmp("HEAD") == 0 ? "GET" : request.method.upcase + request_method = (request.method.casecmp("HEAD") == 0) ? "GET" : request.method.upcase if developer_key.try(:require_scopes) scope_patterns = @access_token.url_scopes_for_method(request_method).concat(AccessToken.always_allowed_scopes) diff --git a/lib/base/canvas.rb b/lib/base/canvas.rb index 9fee3b3a864f6..b65b14fc46abd 100644 --- a/lib/base/canvas.rb +++ b/lib/base/canvas.rb @@ -86,7 +86,7 @@ def self.lookup_cache_store(config, cluster) if File.directory?("/proc") # linux w/ proc fs LINUX_PAGE_SIZE = (size = `getconf PAGESIZE`.to_i - size > 0 ? size : 4096) + (size > 0) ? size : 4096) def self.sample_memory s = File.read("/proc/#{Process.pid}/statm").to_i rescue 0 s * LINUX_PAGE_SIZE / 1024 diff --git a/lib/base/csv_with_i18n.rb b/lib/base/csv_with_i18n.rb index 8761c788ca5dc..9739427b331ef 100644 --- a/lib/base/csv_with_i18n.rb +++ b/lib/base/csv_with_i18n.rb @@ -55,7 +55,7 @@ def self.determine_column_separator(user) return ";" if user.feature_enabled?(:use_semi_colon_field_separators_in_gradebook_exports) return "," unless user.feature_enabled?(:autodetect_field_separators_for_gradebook_exports) - I18n.t("number.format.separator", ".") == "," ? ";" : "," + (I18n.t("number.format.separator", ".") == ",") ? ";" : "," end private_class_method :determine_column_separator end diff --git a/lib/basic_lti/basic_outcomes.rb b/lib/basic_lti/basic_outcomes.rb index 0b24db1fd72d0..87f5f375abbc5 100644 --- a/lib/basic_lti/basic_outcomes.rb +++ b/lib/basic_lti/basic_outcomes.rb @@ -356,7 +356,7 @@ def handle_replace_result(tool, assignment, user) # than the ltitool before the tool finished pushing it. We've seen this need with NewQuizzes LtiResponse.ensure_score_update_possible(submission: existing_submission, prioritize_non_tool_grade: prioritize_non_tool_grade?) do if assignment.grading_type == "pass_fail" && (raw_score || new_score) - submission_hash[:grade] = ((raw_score || new_score) > 0 ? "pass" : "fail") + submission_hash[:grade] = (((raw_score || new_score) > 0) ? "pass" : "fail") submission_hash[:grader_id] = -tool.id elsif raw_score submission_hash[:grade] = raw_score diff --git a/lib/basic_lti/quizzes_next_lti_response.rb b/lib/basic_lti/quizzes_next_lti_response.rb index 9a4f900d6a0ce..6b0f6b10e0063 100644 --- a/lib/basic_lti/quizzes_next_lti_response.rb +++ b/lib/basic_lti/quizzes_next_lti_response.rb @@ -108,7 +108,7 @@ def submission_reopened? end def grade(grading_type) - return ((raw_score || percentage_score) > 0 ? "pass" : "fail") if grading_type == "pass_fail" && (raw_score || percentage_score) + return (((raw_score || percentage_score) > 0) ? "pass" : "fail") if grading_type == "pass_fail" && (raw_score || percentage_score) return raw_score if raw_score.present? return nil unless valid_percentage_score? diff --git a/lib/basic_lti/quizzes_next_versioned_submission.rb b/lib/basic_lti/quizzes_next_versioned_submission.rb index 805bd09db3b70..9e17f0b4c7c9f 100644 --- a/lib/basic_lti/quizzes_next_versioned_submission.rb +++ b/lib/basic_lti/quizzes_next_versioned_submission.rb @@ -74,7 +74,7 @@ def grade_history last = attempt.last first = attempt.first last[:submitted_at] = first[:submitted_at] - last[:score].blank? && last[:workflow_state] != "graded" ? nil : last + (last[:score].blank? && last[:workflow_state] != "graded") ? nil : last end @_grade_history = attempts.compact end diff --git a/lib/brand_config_regenerator.rb b/lib/brand_config_regenerator.rb index d572f2e489bb9..70cb4d41c9ecf 100644 --- a/lib/brand_config_regenerator.rb +++ b/lib/brand_config_regenerator.rb @@ -73,7 +73,7 @@ def things_that_need_to_be_regenerated end sub_scope = if @account.root_account? - Account.active.where(root_account_id: [root_scope&.pluck(:id), Shard.current == @account.shard ? @account.id : nil].compact.flatten).preload(:brand_config) + Account.active.where(root_account_id: [root_scope&.pluck(:id), (Shard.current == @account.shard) ? @account.id : nil].compact.flatten).preload(:brand_config) else Account.active.where(id: Account.sub_account_ids_recursive(@account.id)) end diff --git a/lib/canvas/live_events.rb b/lib/canvas/live_events.rb index d5bd100efca60..0dd23b5d94579 100644 --- a/lib/canvas/live_events.rb +++ b/lib/canvas/live_events.rb @@ -1087,7 +1087,7 @@ def self.blueprint_restrictions_updated(master_content_tag) def self.blueprint_restrictions_updated_data(master_content_tag) lti_resource_link_id = - master_content_tag.content_type == "Assignment" ? master_content_tag.content.lti_resource_link_id : nil + (master_content_tag.content_type == "Assignment") ? master_content_tag.content.lti_resource_link_id : nil { canvas_assignment_id: master_content_tag.content_id, diff --git a/lib/cc/exporter/web_zip/zip_package.rb b/lib/cc/exporter/web_zip/zip_package.rb index 3a0a3ed2e9e15..97efa26089659 100644 --- a/lib/cc/exporter/web_zip/zip_package.rb +++ b/lib/cc/exporter/web_zip/zip_package.rb @@ -93,7 +93,7 @@ def filter_and_clean_files(files) def filter_for_export_safe_items(item_list, type) item_list.select do |export_item| - ident = type == :attachments ? export_item[:local_path].sub("media", "") : export_item[:identifier] + ident = (type == :attachments) ? export_item[:local_path].sub("media", "") : export_item[:identifier] next true if @linked_items.include?(ident) next unless [:quizzes, :discussion_topics].include?(type) @@ -157,7 +157,7 @@ def check_for_links_and_mark_exportable(export_item, linked_items, items_to_chec def format_linked_objects(canvas_objects) canvas_objects.map do |lo| - key, canvas_key = lo[:type] == "Attachment" ? [:content, :local_path] : [:exportId, :identifier] + key, canvas_key = (lo[:type] == "Attachment") ? [:content, :local_path] : [:exportId, :identifier] lo[key] = lo.delete(canvas_key) lo end @@ -267,7 +267,7 @@ def user_module_status(modul) return "locked" if modul.locked_for?(user, deep_check_if_needed: true) status = current_progress&.dig(modul.id, :status) || "unlocked" - status == "locked" ? "unlocked" : status + (status == "locked") ? "unlocked" : status end def item_completed?(item) @@ -402,7 +402,7 @@ def map_object_type_to_export_ids(type) type_export_hash = {} assignment_export_hash = {} course.send(type).each do |item| - tag = (type == :wiki_pages ? item.url : create_key(item)) + tag = ((type == :wiki_pages) ? item.url : create_key(item)) type_export_hash[tag] = item next unless (type == :discussion_topics || type == :quizzes) && item.assignment diff --git a/lib/cc/importer/standard/org_converter.rb b/lib/cc/importer/standard/org_converter.rb index 415336fe039f2..156f870b85ea8 100644 --- a/lib/cc/importer/standard/org_converter.rb +++ b/lib/cc/importer/standard/org_converter.rb @@ -55,7 +55,7 @@ def add_children(node, mod, indent = 0) if item_node.name == "title" if mod[:title] # This is a sub folder, or a "heading" in a canvas module - item = { title: item_node.text, indent: (indent > 0 ? indent - 1 : 0), type: "heading" } + item = { title: item_node.text, indent: ((indent > 0) ? indent - 1 : 0), type: "heading" } mod[:items] << item else mod[:title] = item_node.text diff --git a/lib/cc/qti/qti_generator.rb b/lib/cc/qti/qti_generator.rb index f92fd1d8351bd..0ef91d4d3c196 100644 --- a/lib/cc/qti/qti_generator.rb +++ b/lib/cc/qti/qti_generator.rb @@ -279,7 +279,7 @@ def generate_assessment(doc, quiz, migration_id, for_cc = true) meta_field(meta_node, "qmd_scoretype", "Percentage") end meta_field(meta_node, "qmd_timelimit", quiz.time_limit) if quiz.time_limit - allowed = quiz.allowed_attempts == -1 ? "unlimited" : quiz.allowed_attempts + allowed = (quiz.allowed_attempts == -1) ? "unlimited" : quiz.allowed_attempts meta_field(meta_node, "cc_maxattempts", allowed) end # meta_node diff --git a/lib/cc/qti/qti_items.rb b/lib/cc/qti/qti_items.rb index 6a86abb4e9a1d..0f2a583cf60bc 100644 --- a/lib/cc/qti/qti_items.rb +++ b/lib/cc/qti/qti_items.rb @@ -174,7 +174,7 @@ def presentation_options(node, question) end def multiple_choice_response_str(node, question) - card = question["question_type"] == "multiple_answers_question" ? "Multiple" : "Single" + card = (question["question_type"] == "multiple_answers_question") ? "Multiple" : "Single" node.response_lid( ident: "response1", rcardinality: card diff --git a/lib/course_pace_hard_end_date_compressor.rb b/lib/course_pace_hard_end_date_compressor.rb index 15333437a6ca3..5fab6c46fe79a 100644 --- a/lib/course_pace_hard_end_date_compressor.rb +++ b/lib/course_pace_hard_end_date_compressor.rb @@ -79,13 +79,13 @@ def self.compress(course_pace, items, enrollment: nil, compress_items_after: nil # This is how much time we're currently using plan_length_with_items = CoursePacesDateHelpers.days_between( start_date_of_item_group, - start_date_of_item_group > final_item_due_date ? start_date_of_item_group : final_item_due_date, + (start_date_of_item_group > final_item_due_date) ? start_date_of_item_group : final_item_due_date, course_pace.exclude_weekends, blackout_dates: blackout_dates ) # This is the percentage that we should modify the plan by, so it hits our specified end date - compression_percentage = plan_length_with_items == 0 ? 0 : actual_plan_length / plan_length_with_items.to_f + compression_percentage = (plan_length_with_items == 0) ? 0 : actual_plan_length / plan_length_with_items.to_f unrounded_durations = items.map { |ppmi| ppmi.duration * compression_percentage } rounded_durations = round_durations(unrounded_durations, actual_plan_length) diff --git a/lib/data_fixup/populate_root_account_id_on_models.rb b/lib/data_fixup/populate_root_account_id_on_models.rb index 1785862d5a01e..ca30274e17120 100644 --- a/lib/data_fixup/populate_root_account_id_on_models.rb +++ b/lib/data_fixup/populate_root_account_id_on_models.rb @@ -543,7 +543,7 @@ def self.create_column_names(assoc, columns) return columns if columns.is_a?(String) names = Array(columns).map { |column| "#{assoc.klass.table_name}.#{column}" } - names.count == 1 ? names.first : "COALESCE(#{names.join(", ")})" + (names.count == 1) ? names.first : "COALESCE(#{names.join(", ")})" end def self.fill_cross_shard_associations(table, scope, reflection, column) diff --git a/lib/gradebook_importer.rb b/lib/gradebook_importer.rb index e2e9fa027d8a4..65f69c02706b9 100644 --- a/lib/gradebook_importer.rb +++ b/lib/gradebook_importer.rb @@ -647,7 +647,7 @@ def identify_delimiter(rows) nil end - field_counts[";"] > field_counts[","] ? :semicolon : :comma + (field_counts[";"] > field_counts[","]) ? :semicolon : :comma end def semicolon_delimited?(csv_file) diff --git a/lib/gradebook_user_ids.rb b/lib/gradebook_user_ids.rb index f89b98003c0b9..38a6748e294cb 100644 --- a/lib/gradebook_user_ids.rb +++ b/lib/gradebook_user_ids.rb @@ -240,7 +240,7 @@ def sort_by_scores(type = :total_grade, id = nil) end def sort_direction - @direction == "ascending" ? :asc : :desc + (@direction == "ascending") ? :asc : :desc end def grading_period_id diff --git a/lib/locale_selection.rb b/lib/locale_selection.rb index ffd3d6f6054d2..6ed419796d7ab 100644 --- a/lib/locale_selection.rb +++ b/lib/locale_selection.rb @@ -74,7 +74,7 @@ def infer_browser_locale(accept_language, locales_with_aliases) quality = (range =~ QUALITY_VALUE) ? $1.to_f : 1 [range.sub(/\s*;.*/, ""), quality] end - ranges = ranges.sort_by { |r,| r == "*" ? 1 : -r.count("-") } + ranges = ranges.sort_by { |r,| (r == "*") ? 1 : -r.count("-") } # we want the longest ranges first (and * last of all), since the "quality # factor assigned to a [language] ... is the quality value of the longest # language-range ... that matches", e.g. @@ -84,7 +84,7 @@ def infer_browser_locale(accept_language, locales_with_aliases) # en-US range is a longer match, so it loses) best_locales = supported_locales.filter_map do |locale| - if (best_range = ranges.detect { |r, _q| "#{r}-" == ("#{locale.downcase}-")[0..r.size] || r == "*" }) && + if (best_range = ranges.detect { |r, _q| "#{r}-" == "#{locale.downcase}-"[0..r.size] || r == "*" }) && best_range.last != 0 [locale, best_range.last, ranges.index(best_range)] end diff --git a/lib/lti/membership_service/collator_base.rb b/lib/lti/membership_service/collator_base.rb index cebb8a0fff79c..21d77a8c081ec 100644 --- a/lib/lti/membership_service/collator_base.rb +++ b/lib/lti/membership_service/collator_base.rb @@ -26,7 +26,7 @@ def initialize(context, opts = {}) per_page = opts[:per_page].to_i @next_page = true @role = opts[:role] - @per_page = [(per_page > 0 ? per_page : Api.per_page), Api.max_per_page].min + @per_page = [((per_page > 0) ? per_page : Api.per_page), Api.max_per_page].min @page = [opts[:page].to_i, 1].max @context = context end diff --git a/lib/lti/substitutions_helper.rb b/lib/lti/substitutions_helper.rb index c207830c3839d..d752692808ef5 100644 --- a/lib/lti/substitutions_helper.rb +++ b/lib/lti/substitutions_helper.rb @@ -191,7 +191,7 @@ def current_lis_roles def concluded_course_enrollments @concluded_course_enrollments ||= - @context.is_a?(Course) && @user ? @user.enrollments.concluded.where(course_id: @context.id).shard(@context.shard) : [] + (@context.is_a?(Course) && @user) ? @user.enrollments.concluded.where(course_id: @context.id).shard(@context.shard) : [] end def concluded_lis_roles @@ -204,13 +204,13 @@ def granted_permissions(permissions_to_check) def current_canvas_roles roles = (course_enrollments + account_enrollments).map(&:role).map(&:name).uniq - roles = roles.map { |role| role == "AccountAdmin" ? "Account Admin" : role } # to maintain backwards compatibility + roles = roles.map { |role| (role == "AccountAdmin") ? "Account Admin" : role } # to maintain backwards compatibility roles.join(",") end def current_canvas_roles_lis_v2(version = "lis2") roles = (course_enrollments + account_enrollments).map(&:class).uniq - role_map = version == "lti1_3" ? LIS_V2_LTI_ADVANTAGE_ROLE_MAP : LIS_V2_ROLE_MAP + role_map = (version == "lti1_3") ? LIS_V2_LTI_ADVANTAGE_ROLE_MAP : LIS_V2_ROLE_MAP roles.map { |r| role_map[r] }.join(",") end @@ -218,7 +218,7 @@ def enrollment_state enrollments = @user ? @context.enrollments.where(user_id: @user.id).preload(:enrollment_state) : [] return "" if enrollments.empty? - enrollments.any? { |membership| membership.state_based_on_date == :active } ? LtiOutbound::LTIUser::ACTIVE_STATE : LtiOutbound::LTIUser::INACTIVE_STATE + (enrollments.any? { |membership| membership.state_based_on_date == :active }) ? LtiOutbound::LTIUser::ACTIVE_STATE : LtiOutbound::LTIUser::INACTIVE_STATE end def previous_lti_context_ids diff --git a/lib/messageable_user.rb b/lib/messageable_user.rb index 6c98f51465250..4d0b5f28797ea 100644 --- a/lib/messageable_user.rb +++ b/lib/messageable_user.rb @@ -167,7 +167,7 @@ def common_contexts_on_current_shard(common_contexts) sharded_ids.each do |id| # a context id of 0 indicates admin visibility without an actual shared # context; don't "globalize" it - global_id = id == 0 ? id : Shard.global_id_for(id) + global_id = (id == 0) ? id : Shard.global_id_for(id) id = global_id unless Shard.current == target_shard local_common_contexts[id] = common_contexts[global_id] end diff --git a/lib/microsoft_sync/syncer_steps.rb b/lib/microsoft_sync/syncer_steps.rb index 4046e1a1375a7..838abc548a89d 100644 --- a/lib/microsoft_sync/syncer_steps.rb +++ b/lib/microsoft_sync/syncer_steps.rb @@ -126,7 +126,7 @@ def retry_object_for_error(e, **extra_args) def step_initial(job_type, _job_state_data) StateMachineJob::NextStep.new( - job_type.to_s == "partial" ? :step_partial_sync : :step_full_sync_prerequisites + (job_type.to_s == "partial") ? :step_partial_sync : :step_full_sync_prerequisites ) end diff --git a/lib/model_cache.rb b/lib/model_cache.rb index 51ff1cff41f8e..09703ce6a773f 100644 --- a/lib/model_cache.rb +++ b/lib/model_cache.rb @@ -129,7 +129,7 @@ def self.make_cacheable(klass, method, options = {}) expected_args = options[:key_method] ? 0 : 1 maybe_reset = "cache[#{key_value}] = #{orig_method} if args.size > #{expected_args}" - klass.send(options[:type] == :instance ? :class_eval : :instance_eval, <<~RUBY, __FILE__, __LINE__ + 1) + klass.send((options[:type] == :instance) ? :class_eval : :instance_eval, <<~RUBY, __FILE__, __LINE__ + 1) def #{method}(*args) if cache = ModelCache[#{options[:cache_name].inspect}] and cache = cache[#{options[:key_lookup].inspect}] #{maybe_reset} diff --git a/lib/outcomes/csv_importer.rb b/lib/outcomes/csv_importer.rb index c47cd14265edd..cd45bb23e6d48 100644 --- a/lib/outcomes/csv_importer.rb +++ b/lib/outcomes/csv_importer.rb @@ -118,7 +118,7 @@ def test_header_i18n has_bom = header.start_with?((+"\xEF\xBB\xBF").force_encoding("ASCII-8BIT")) @file.rewind @file.read(3) if has_bom - header.count(";") > header.count(",") ? ";" : "," + (header.count(";") > header.count(",")) ? ";" : "," end def file_line_count diff --git a/lib/outcomes/outcome_friendly_description_resolver.rb b/lib/outcomes/outcome_friendly_description_resolver.rb index 540e701092fb9..88bd291434ed3 100644 --- a/lib/outcomes/outcome_friendly_description_resolver.rb +++ b/lib/outcomes/outcome_friendly_description_resolver.rb @@ -42,7 +42,7 @@ def resolve_friendly_descriptions(account, course, outcome_ids) friendly_descriptions = OutcomeFriendlyDescription.active.where( learning_outcome_id: outcome_ids ).where(context_queries(account, course)).to_a.sort_by do |friendly_description| - friendly_description.context_type == "Course" ? 0 : account_order.index(friendly_description.context_id) + 1 + (friendly_description.context_type == "Course") ? 0 : account_order.index(friendly_description.context_id) + 1 end friendly_descriptions.uniq(&:learning_outcome_id) end diff --git a/lib/planner_api_helper.rb b/lib/planner_api_helper.rb index 14841f99b9c19..7a2cf660331c0 100644 --- a/lib/planner_api_helper.rb +++ b/lib/planner_api_helper.rb @@ -89,6 +89,6 @@ def mark_doneable_tag(item) req[:id] == tag.id && req[:type] == "must_mark_done" end end - doneable_tags.length == 1 ? doneable_tags.first : nil + (doneable_tags.length == 1) ? doneable_tags.first : nil end end diff --git a/lib/progress_runner.rb b/lib/progress_runner.rb index cbb5ee319a095..a89ba67979273 100644 --- a/lib/progress_runner.rb +++ b/lib/progress_runner.rb @@ -112,7 +112,7 @@ def finish_update @errors.each do |message, elements| @progress.message += "\n" + @error_message.call(message, elements) end - @completed_count > 0 ? @progress.complete! : @progress.fail! + (@completed_count > 0) ? @progress.complete! : @progress.fail! @progress.save end end diff --git a/lib/simple_stats.rb b/lib/simple_stats.rb index c826d424022cb..32f702aa6ee4e 100644 --- a/lib/simple_stats.rb +++ b/lib/simple_stats.rb @@ -21,7 +21,7 @@ module SimpleStats def variance(items, type = :population) return 0 if items.size < 2 - divisor = type == :population ? items.length : items.length - 1 + divisor = (type == :population) ? items.length : items.length - 1 mean = items.sum / items.length.to_f sum = items.sum { |item| (item - mean)**2 } (sum / divisor).to_f diff --git a/lib/simple_tags.rb b/lib/simple_tags.rb index 91c26515ca889..b7d9f53cef482 100644 --- a/lib/simple_tags.rb +++ b/lib/simple_tags.rb @@ -43,7 +43,7 @@ def tagged(*tags) if conditions.empty? none else - where(conditions.join(options[:mode] == :or ? " OR " : " AND ")) + where(conditions.join((options[:mode] == :or) ? " OR " : " AND ")) end end diff --git a/lib/sis/csv/course_importer.rb b/lib/sis/csv/course_importer.rb index 978257f2bd7ed..c0869d22b5e5e 100644 --- a/lib/sis/csv/course_importer.rb +++ b/lib/sis/csv/course_importer.rb @@ -35,8 +35,8 @@ def process(csv, index = nil, count = nil) messages = [] count = SIS::CourseImporter.new(@root_account, importer_opts).process(messages) do |importer| csv_rows(csv, index, count) do |row| - start_date = (row.key? "start_date") ? nil : "not_present" - end_date = (row.key? "end_date") ? nil : "not_present" + start_date = row.key?("start_date") ? nil : "not_present" + end_date = row.key?("end_date") ? nil : "not_present" begin start_date = Time.zone.parse(row["start_date"]) if row["start_date"].present? end_date = Time.zone.parse(row["end_date"]) if row["end_date"].present? @@ -56,7 +56,7 @@ def process(csv, index = nil, count = nil) end errors = [] messages.each do |message| - errors << ((message.is_a? SisBatchError) ? message : SisBatch.build_error(csv, message, sis_batch: @batch)) + errors << (message.is_a?(SisBatchError) ? message : SisBatch.build_error(csv, message, sis_batch: @batch)) end SisBatch.bulk_insert_sis_errors(errors) count diff --git a/lib/sis/csv/enrollment_importer.rb b/lib/sis/csv/enrollment_importer.rb index 8b30597122043..9483d99f11fa1 100644 --- a/lib/sis/csv/enrollment_importer.rb +++ b/lib/sis/csv/enrollment_importer.rb @@ -47,7 +47,7 @@ def process(csv, index = nil, count = nil) def persist_errors(csv, messages) errors = messages.map do |message| - (message.is_a? SisBatchError) ? message : SisBatch.build_error(csv, message, sis_batch: @batch) + message.is_a?(SisBatchError) ? message : SisBatch.build_error(csv, message, sis_batch: @batch) end SisBatch.bulk_insert_sis_errors(errors) end diff --git a/lib/sis/enrollment_importer.rb b/lib/sis/enrollment_importer.rb index 4fd2569000e22..4b77987ebf1cb 100644 --- a/lib/sis/enrollment_importer.rb +++ b/lib/sis/enrollment_importer.rb @@ -254,7 +254,7 @@ def process_batch end if %w[StudentEnrollment ObserverEnrollment].include?(type) && MasterCourses::MasterTemplate.is_master_course?(@course) - message = "#{type == "StudentEnrollment" ? "Student" : "Observer"} enrollment for \"#{enrollment_info.user_id}\" not allowed in blueprint course \"#{@course.sis_course_id}\"" + message = "#{(type == "StudentEnrollment") ? "Student" : "Observer"} enrollment for \"#{enrollment_info.user_id}\" not allowed in blueprint course \"#{@course.sis_course_id}\"" @messages << SisBatch.build_error(enrollment_info.csv, message, sis_batch: @batch, row: enrollment_info.lineno, row_info: enrollment_info.row_info) next end diff --git a/lib/sis/group_importer.rb b/lib/sis/group_importer.rb index 6a3e42d2d3f9f..da8052562a8f7 100644 --- a/lib/sis/group_importer.rb +++ b/lib/sis/group_importer.rb @@ -104,7 +104,7 @@ def add_group(group_id, group_category_id, account_id, course_id, name, status) group.name = name if name.present? && !group.stuck_sis_fields.include?(:name) group.context = context group.sis_batch_id = @batch.id - group.workflow_state = status == "deleted" ? "deleted" : "available" + group.workflow_state = (status == "deleted") ? "deleted" : "available" if group.save data = SisBatchRollBackData.build_data(sis_batch: @batch, context: group) diff --git a/lib/sis/user_importer.rb b/lib/sis/user_importer.rb index 1a7f5d8979f8b..db46529ec2139 100644 --- a/lib/sis/user_importer.rb +++ b/lib/sis/user_importer.rb @@ -237,7 +237,7 @@ def process_batch(login_only: false) end if user_row.declared_user_type.present? - pseudo.declared_user_type = user_row.declared_user_type == "" ? nil : user_row.declared_user_type + pseudo.declared_user_type = (user_row.declared_user_type == "") ? nil : user_row.declared_user_type end if status == "deleted" && !user.new_record? @@ -375,7 +375,7 @@ def process_batch(login_only: false) cc.pseudonym_id = pseudo.id cc.path = user_row.email cc.bounce_count = 0 if cc.path_changed? - cc.workflow_state = status == "deleted" ? "retired" : "active" + cc.workflow_state = (status == "deleted") ? "retired" : "active" newly_active = cc.path_changed? || (cc.active? && cc.workflow_state_changed?) if cc.changed? if cc.valid? && cc.save_without_broadcasting diff --git a/lib/submission_search.rb b/lib/submission_search.rb index afaebd24d40fc..d17d9a51caecf 100644 --- a/lib/submission_search.rb +++ b/lib/submission_search.rb @@ -103,7 +103,7 @@ def add_order_bys(search_scope) order_bys = Array(@options[:order_by]) order_bys.each do |order_field_direction| field = order_field_direction[:field] - direction = order_field_direction[:direction] == "descending" ? "DESC NULLS LAST" : "ASC" + direction = (order_field_direction[:direction] == "descending") ? "DESC NULLS LAST" : "ASC" search_scope = case field when "username" diff --git a/lib/user_list.rb b/lib/user_list.rb index 16496092df8f2..ef6faef08204a 100644 --- a/lib/user_list.rb +++ b/lib/user_list.rb @@ -271,10 +271,10 @@ def resolve number = sms[:address].gsub(/[^\d\w]/, "") sms[:address] = "(#{number[0, 3]}) #{number[3, 3]}-#{number[6, 4]}" end - sms_account_ids = @search_method == :closed ? all_account_ids : [@root_account] + sms_account_ids = (@search_method == :closed) ? all_account_ids : [@root_account] unless smses.empty? Shard.partition_by_shard(sms_account_ids) do |account_ids| - sms_scope = @search_method == :closed ? Pseudonym.where(account_id: account_ids) : Pseudonym + sms_scope = (@search_method == :closed) ? Pseudonym.where(account_id: account_ids) : Pseudonym sms_scope.active .select("path AS address, users.name AS name, communication_channels.user_id AS user_id") .joins(user: :communication_channels) @@ -309,12 +309,12 @@ def resolve address.delete :id # Only allow addresses that we found a user, or that we can implicitly create the user if address[:user_id].present? - (@addresses.find { |a| a[:user_id] == address[:user_id] && a[:shard] == address[:shard] } ? @duplicate_addresses : @addresses) << address + ((@addresses.find { |a| a[:user_id] == address[:user_id] && a[:shard] == address[:shard] }) ? @duplicate_addresses : @addresses) << address elsif address[:type] == :email && @search_method == :open - (@addresses.find { |a| a[:address].casecmp?(address[:address]) } ? @duplicate_addresses : @addresses) << address + ((@addresses.find { |a| a[:address].casecmp?(address[:address]) }) ? @duplicate_addresses : @addresses) << address elsif @search_method == :preferred && (address[:details] == :non_unique || address[:type] == :email) address.delete :user_id - (@addresses.find { |a| a[:address].casecmp?(address[:address]) } ? @duplicate_addresses : @addresses) << address + ((@addresses.find { |a| a[:address].casecmp?(address[:address]) }) ? @duplicate_addresses : @addresses) << address else @errors << { address: address[:address], type: address[:type], details: (address[:details] || :not_found) } end diff --git a/lib/user_search.rb b/lib/user_search.rb index 76191929fa89a..2f55e06947558 100644 --- a/lib/user_search.rb +++ b/lib/user_search.rb @@ -82,7 +82,7 @@ def order_scope(users_scope, context, options = {}) when "last_login" users_scope.select("users.*").order(Arel.sql("last_login#{order}")) when "username" - users_scope.select("users.*").order_by_sortable_name(direction: options[:order] == "desc" ? :descending : :ascending) + users_scope.select("users.*").order_by_sortable_name(direction: (options[:order] == "desc") ? :descending : :ascending) when "email" users_scope = users_scope.select("users.*, (SELECT path FROM #{CommunicationChannel.quoted_table_name} WHERE communication_channels.user_id = users.id AND @@ -93,7 +93,7 @@ def order_scope(users_scope, context, options = {}) AS email") users_scope.order(Arel.sql("email#{order}")) when "sis_id", "integration_id" - column = options[:sort] == "sis_id" ? "sis_user_id" : "integration_id" + column = (options[:sort] == "sis_id") ? "sis_user_id" : "integration_id" users_scope = users_scope.select(User.send(:sanitize_sql, [ "users.*, (SELECT #{column} FROM #{Pseudonym.quoted_table_name} WHERE pseudonyms.user_id = users.id AND diff --git a/lib/utils/time_presenter.rb b/lib/utils/time_presenter.rb index ccb99c07ab985..31ea72354c5e7 100644 --- a/lib/utils/time_presenter.rb +++ b/lib/utils/time_presenter.rb @@ -54,7 +54,7 @@ def is_range?(range_time) end def format - time.min == 0 ? :tiny_on_the_hour : :tiny + (time.min == 0) ? :tiny_on_the_hour : :tiny end end end diff --git a/script/lint_commit_message b/script/lint_commit_message index a0af7366f55ea..f2b4407bbd1fe 100755 --- a/script/lint_commit_message +++ b/script/lint_commit_message @@ -101,7 +101,7 @@ end unless long_lines.empty? comment "warn", long_lines.first[1] + 3, "try to keep all lines under #{BODY_IDEAL_LINE_LENGTH} characters" + - (long_lines.size > 1 ? " (note that #{long_lines.size - 1} other long lines follow this one)" : ""), + ((long_lines.size > 1) ? " (note that #{long_lines.size - 1} other long lines follow this one)" : ""), link_to_guidelines: true end diff --git a/spec/apis/v1/discussion_topics_api_spec.rb b/spec/apis/v1/discussion_topics_api_spec.rb index 5dd52a0f70b2d..31887add42b8b 100644 --- a/spec/apis/v1/discussion_topics_api_spec.rb +++ b/spec/apis/v1/discussion_topics_api_spec.rb @@ -2656,7 +2656,7 @@ def call_mark_entry_unread(course, topic, entry) end def call_mark_all_as_read_state(new_state, opts = {}) - method = new_state == "read" ? :put : :delete + method = (new_state == "read") ? :put : :delete url = +"/api/v1/courses/#{@course.id}/discussion_topics/#{@topic.id}/read_all.json" expected_params = { controller: "discussion_topics_api", action: "mark_all_#{new_state}", format: "json", course_id: @course.id.to_s, topic_id: @topic.id.to_s } diff --git a/spec/controllers/course_paces_controller_spec.rb b/spec/controllers/course_paces_controller_spec.rb index 4ab71ece0f3f4..2d5b002e54f4e 100644 --- a/spec/controllers/course_paces_controller_spec.rb +++ b/spec/controllers/course_paces_controller_spec.rb @@ -126,8 +126,8 @@ expect(response).to be_successful expect(assigns[:js_bundles].flatten).to include(:course_paces) js_env = controller.js_env - expect(js_env[:BLACKOUT_DATES]).to eq((@course.blackout_dates).as_json(include_root: false)) - expect(js_env[:CALENDAR_EVENT_BLACKOUT_DATES]).to eq((@calendar_event_blackout_dates).as_json(include_root: false)) + expect(js_env[:BLACKOUT_DATES]).to eq(@course.blackout_dates.as_json(include_root: false)) + expect(js_env[:CALENDAR_EVENT_BLACKOUT_DATES]).to eq(@calendar_event_blackout_dates.as_json(include_root: false)) expect(js_env[:COURSE]).to match(hash_including({ id: @course.id, name: @course.name, diff --git a/spec/controllers/external_tools_controller_spec.rb b/spec/controllers/external_tools_controller_spec.rb index 15cd3a37a12b6..88c872be44ed1 100644 --- a/spec/controllers/external_tools_controller_spec.rb +++ b/spec/controllers/external_tools_controller_spec.rb @@ -1532,7 +1532,7 @@ include_context "lti_1_3_spec_helper" - let(:tool_id) { response.status == 200 ? JSON.parse(response.body)["id"] : -1 } + let(:tool_id) { (response.status == 200) ? JSON.parse(response.body)["id"] : -1 } let(:tool_configuration) { Lti::ToolConfiguration.create! settings: settings, developer_key: developer_key } let(:developer_key) { DeveloperKey.create!(account: account) } let_once(:user) { account_admin_user(account: account) } diff --git a/spec/controllers/lti/ims/names_and_roles_controller_spec.rb b/spec/controllers/lti/ims/names_and_roles_controller_spec.rb index e64f6ff72461e..18625003be5e0 100644 --- a/spec/controllers/lti/ims/names_and_roles_controller_spec.rb +++ b/spec/controllers/lti/ims/names_and_roles_controller_spec.rb @@ -1438,7 +1438,7 @@ def as_query_params(params_hash) end def page_count(total_items, page_size) - (total_items / page_size) + (total_items % page_size > 0 ? 1 : 0) + (total_items / page_size) + ((total_items % page_size > 0) ? 1 : 0) end def response_links diff --git a/spec/controllers/oauth2_provider_controller_spec.rb b/spec/controllers/oauth2_provider_controller_spec.rb index 05a34e84e61cd..393301a6ebeee 100644 --- a/spec/controllers/oauth2_provider_controller_spec.rb +++ b/spec/controllers/oauth2_provider_controller_spec.rb @@ -681,7 +681,7 @@ Canvas::Security::JwtValidator::REQUIRED_ASSERTIONS.each do |assertion| it "returns 400 when #{assertion} missing" do jwt.delete assertion.to_sym - expected = assertion == "sub" ? :unauthorized : :bad_request + expected = (assertion == "sub") ? :unauthorized : :bad_request expect(subject).to have_http_status expected end end diff --git a/spec/factories/message_factory.rb b/spec/factories/message_factory.rb index e0bee88bc4a69..8b6fda5da3450 100644 --- a/spec/factories/message_factory.rb +++ b/spec/factories/message_factory.rb @@ -39,7 +39,7 @@ def generate_message(notification_name, path_type, asset, options = {}) data = options[:data] || {} user ||= User.create!(name: "some user") - cc_path_type = path_type == :summary ? :email : path_type + cc_path_type = (path_type == :summary) ? :email : path_type @cc = user.communication_channels.of_type(cc_path_type.to_s).first @cc ||= user.communication_channels.create!(path_type: cc_path_type.to_s, path: "generate_message@example.com") diff --git a/spec/factories/pseudonym_factory.rb b/spec/factories/pseudonym_factory.rb index 3f2311b08963c..fa55b53ff1ec1 100644 --- a/spec/factories/pseudonym_factory.rb +++ b/spec/factories/pseudonym_factory.rb @@ -45,7 +45,7 @@ def valid_pseudonym_attributes def pseudonym(user, opts = {}) @spec_pseudonym_count ||= 0 - username = opts[:username] || (@spec_pseudonym_count > 0 ? "nobody+#{@spec_pseudonym_count}@example.com" : "nobody@example.com") + username = opts[:username] || ((@spec_pseudonym_count > 0) ? "nobody+#{@spec_pseudonym_count}@example.com" : "nobody@example.com") opts[:username] ||= username @spec_pseudonym_count += 1 if /nobody(\+\d+)?@example.com/.match?(username) password = opts[:password] || "asdfasdf" diff --git a/spec/factories/quiz_factory.rb b/spec/factories/quiz_factory.rb index 9208a544025d3..cf4250f818607 100644 --- a/spec/factories/quiz_factory.rb +++ b/spec/factories/quiz_factory.rb @@ -474,7 +474,7 @@ def course_quiz(active = false) end def question_data(reset = false, data = {}) - @qdc = reset || !@qdc ? 1 : @qdc + 1 + @qdc = (reset || !@qdc) ? 1 : @qdc + 1 { :name => "question #{@qdc}", :points_possible => 1, "question_type" => "multiple_choice_question", "answers" => [{ "answer_text" => "1", "answer_weight" => "100" }, { "answer_text" => "2" }, { "answer_text" => "3" }, { "answer_text" => "4" }] diff --git a/spec/lib/api/v1/outcome_spec.rb b/spec/lib/api/v1/outcome_spec.rb index c484b6d0ad102..c26d2c5949202 100644 --- a/spec/lib/api/v1/outcome_spec.rb +++ b/spec/lib/api/v1/outcome_spec.rb @@ -125,7 +125,7 @@ def new_outcome_link(creation_params = {}, course = @course) it "ignores the resolved_outcome_proficiency and resolved_calculation_method of the provided context" do opts[:context] = @course - check_outcome_json.call(lib.outcome_json(new_outcome(({ **outcome_params, context: @course })), nil, nil, opts)) + check_outcome_json.call(lib.outcome_json(new_outcome({ **outcome_params, context: @course }), nil, nil, opts)) end end end diff --git a/spec/lib/microsoft_sync/syncer_steps_spec.rb b/spec/lib/microsoft_sync/syncer_steps_spec.rb index 67915fda273ff..e4902e8d7edd5 100644 --- a/spec/lib/microsoft_sync/syncer_steps_spec.rb +++ b/spec/lib/microsoft_sync/syncer_steps_spec.rb @@ -198,7 +198,7 @@ def new_http_error(code, headers = {}) MicrosoftSync::SyncerSteps::MaxMemberEnrollmentsReached end end - let(:max_default) { owners_or_members == "owners" ? 100 : 25_000 } + let(:max_default) { (owners_or_members == "owners") ? 100 : 25_000 } let(:err_msg) do "Microsoft 365 allows a maximum of #{(max || max_default).to_s(:delimited)} " \ "#{owners_or_members} in a team." diff --git a/spec/lib/stats_spec.rb b/spec/lib/stats_spec.rb index aed75c0e5393e..75f63918a1e88 100644 --- a/spec/lib/stats_spec.rb +++ b/spec/lib/stats_spec.rb @@ -39,7 +39,7 @@ def check_stats_with_matchers(c, empty, size, max, min, sum, mean, var, stddev, def check_stats(c, size, max, min, sum, mean, var, histogram) check_stats_with_matchers c, - (size > 0 ? be_falsey : be_truthy), + ((size > 0) ? be_falsey : be_truthy), eql(size), eql(max), eql(min), diff --git a/spec/manual_seeding/large_gradebook_seeds.rb b/spec/manual_seeding/large_gradebook_seeds.rb index 1ddab5fd89914..afe1d48689e3d 100644 --- a/spec/manual_seeding/large_gradebook_seeds.rb +++ b/spec/manual_seeding/large_gradebook_seeds.rb @@ -117,10 +117,10 @@ def self.enroll_students(users: [], course:, section:, type: "student") exit end opts.parse(ARGV) -student_count = generate_for == :speedgrader ? 50 : 400 -assignment_count = generate_for == :speedgrader ? 50 : 200 +student_count = (generate_for == :speedgrader) ? 50 : 400 +assignment_count = (generate_for == :speedgrader) ? 50 : 200 -puts generate_for == :speedgrader ? "Speedgrader".yellow : "Gradebook".yellow +puts((generate_for == :speedgrader) ? "Speedgrader".yellow : "Gradebook".yellow) puts "Student Count = #{student_count}".red puts "Assignment Count = #{assignment_count}".red diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index b978788114609..31dbe9009f9f5 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -731,7 +731,7 @@ def account_with_admin_and_restricted_user(account, restricted_role) hash.each do |k, v| v[:account].update_attribute(:settings, { no_enrollments_can_create_courses: false }) - admin, user = account_with_admin_and_restricted_user(v[:account], (k == :site_admin ? @sa_role : @root_role)) + admin, user = account_with_admin_and_restricted_user(v[:account], ((k == :site_admin) ? @sa_role : @root_role)) hash[k][:admin] = admin hash[k][:user] = user end @@ -779,8 +779,8 @@ def account_with_admin_and_restricted_user(account, restricted_role) next unless k == :site_admin || k == :root account = v[:account] - expect(account.check_policy(hash[:sub][:admin])).to match_array(k == :site_admin ? [:read_global_outcomes] : %i[read_outcomes read_terms launch_external_tool]) - expect(account.check_policy(hash[:sub][:user])).to match_array(k == :site_admin ? [:read_global_outcomes] : %i[read_outcomes read_terms launch_external_tool]) + expect(account.check_policy(hash[:sub][:admin])).to match_array((k == :site_admin) ? [:read_global_outcomes] : %i[read_outcomes read_terms launch_external_tool]) + expect(account.check_policy(hash[:sub][:user])).to match_array((k == :site_admin) ? [:read_global_outcomes] : %i[read_outcomes read_terms launch_external_tool]) end hash.each do |k, v| next if k == :site_admin || k == :root @@ -794,7 +794,7 @@ def account_with_admin_and_restricted_user(account, restricted_role) some_access = [:read_reports] + limited_access hash.each do |k, v| account = v[:account] - account.role_overrides.create!(permission: "read_reports", role: (k == :site_admin ? @sa_role : @root_role), enabled: true) + account.role_overrides.create!(permission: "read_reports", role: ((k == :site_admin) ? @sa_role : @root_role), enabled: true) account.role_overrides.create!(permission: "reset_any_mfa", role: @sa_role, enabled: true) # clear caches account.tap do |a| @@ -810,7 +810,7 @@ def account_with_admin_and_restricted_user(account, restricted_role) admin_privileges += [:read_global_outcomes] if k == :site_admin admin_privileges += [:manage_privacy_settings] if k == :root user_array = some_access + [:reset_any_mfa] + - (k == :site_admin ? [:read_global_outcomes] : []) + ((k == :site_admin) ? [:read_global_outcomes] : []) expect(account.check_policy(hash[:site_admin][:admin]) - conditional_access).to match_array admin_privileges expect(account.check_policy(hash[:site_admin][:user])).to match_array user_array end @@ -831,8 +831,8 @@ def account_with_admin_and_restricted_user(account, restricted_role) next unless k == :site_admin || k == :root account = v[:account] - expect(account.check_policy(hash[:sub][:admin])).to match_array(k == :site_admin ? [:read_global_outcomes] : %i[read_outcomes read_terms launch_external_tool]) - expect(account.check_policy(hash[:sub][:user])).to match_array(k == :site_admin ? [:read_global_outcomes] : %i[read_outcomes read_terms launch_external_tool]) + expect(account.check_policy(hash[:sub][:admin])).to match_array((k == :site_admin) ? [:read_global_outcomes] : %i[read_outcomes read_terms launch_external_tool]) + expect(account.check_policy(hash[:sub][:user])).to match_array((k == :site_admin) ? [:read_global_outcomes] : %i[read_outcomes read_terms launch_external_tool]) end hash.each do |k, v| next if k == :site_admin || k == :root diff --git a/spec/models/course_pace_spec.rb b/spec/models/course_pace_spec.rb index 0d332e2332d80..dd33e85056ca0 100644 --- a/spec/models/course_pace_spec.rb +++ b/spec/models/course_pace_spec.rb @@ -195,7 +195,7 @@ context "publish" do def fancy_midnight_rounded_to_last_second(date) - (CanvasTime.fancy_midnight(date.to_datetime).to_time).in_time_zone("UTC") + CanvasTime.fancy_midnight(date.to_datetime).to_time.in_time_zone("UTC") end before :once do @@ -862,7 +862,7 @@ def fancy_midnight_rounded_to_last_second(date) it "creates a course in a subaccount with its own calendar events and counts all the account calendar events" do allow(InstStatsd::Statsd).to receive(:count) - @subaccount1 = Account.find((@course.root_account.id)).sub_accounts.create! + @subaccount1 = Account.find(@course.root_account.id).sub_accounts.create! @subaccount1.enable_feature!(:course_paces) @course1 = course_factory(account: @subaccount1, active_all: true) @course1.enable_course_paces = true diff --git a/spec/models/folder_spec.rb b/spec/models/folder_spec.rb index 007d1deded890..addcadab69ca3 100644 --- a/spec/models/folder_spec.rb +++ b/spec/models/folder_spec.rb @@ -201,7 +201,7 @@ @course.folders.create!(name: "locked 3", lock_at: 1.day.ago, unlock_at: 1.day.from_now) ] expect(@course.folders.map(&:id).sort).to eq (not_locked + locked).map(&:id).sort - expect(@course.folders.not_locked.map(&:id).sort).to eq (not_locked).map(&:id).sort + expect(@course.folders.not_locked.map(&:id).sort).to eq not_locked.map(&:id).sort end it "does not create multiple root folders for a course" do diff --git a/spec/models/learning_outcome_spec.rb b/spec/models/learning_outcome_spec.rb index 6085820ca4a2a..013c137c6d2cc 100644 --- a/spec/models/learning_outcome_spec.rb +++ b/spec/models/learning_outcome_spec.rb @@ -1314,7 +1314,7 @@ def add_or_get_rubric(outcome) context: account, title: "outcome_#{i}", calculation_method: "highest", - workflow_state: i == 0 ? "deleted" : "active" + workflow_state: (i == 0) ? "deleted" : "active" ) end outcome_ids = account.created_learning_outcomes.pluck(:id) diff --git a/spec/models/quizzes/quiz_statistics/item_analysis/common.rb b/spec/models/quizzes/quiz_statistics/item_analysis/common.rb index f41cf46c514c1..0924f19be1b11 100644 --- a/spec/models/quizzes/quiz_statistics/item_analysis/common.rb +++ b/spec/models/quizzes/quiz_statistics/item_analysis/common.rb @@ -90,7 +90,7 @@ def simple_quiz_with_submissions(answer_key, *submissions) true_false = answer == "T" || answer == "F" type = true_false ? "true_false_question" : "multiple_choice_question" answers = (true_false ? ["T", "F"] : "A".."D").each_with_index.map do |a, j| - { answer_text: a, answer_weight: (a == answer ? 100 : 0), id: ((4 * i) + j) } + { answer_text: a, answer_weight: ((a == answer) ? 100 : 0), id: ((4 * i) + j) } end { question_data: { name: "question #{i + 1}", points_possible: points, question_type: type, answers: answers } } @@ -117,7 +117,7 @@ def simple_quiz_with_shuffled_answers(answer_key, *submissions) true_false = answer == "T" || answer == "F" type = true_false ? "true_false_question" : "multiple_choice_question" answers = (true_false ? ["T", "F"] : "A".."D").each_with_index.map do |a, j| - { answer_text: a, answer_weight: (a == answer ? 100 : 0), id: ((4 * i) + j) } + { answer_text: a, answer_weight: ((a == answer) ? 100 : 0), id: ((4 * i) + j) } end { question_data: { name: "question #{i + 1}", points_possible: points, question_type: type, answers: answers } } end diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index af8635cea40f9..441bc65226caf 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -329,9 +329,9 @@ def get_base_type(hash, name) } ["adding", "deleting"].each do |mode| roles_to_test.each do |perm_role| - role_key_to_test = mode == "adding" ? :addable_by_user : :deleteable_by_user - opposite_role_key_to_test = mode == "adding" ? :deleteable_by_user : :addable_by_user - permission_key = mode == "adding" ? "add_#{perm_role}_to_course".to_sym : "remove_#{perm_role}_from_course" + role_key_to_test = (mode == "adding") ? :addable_by_user : :deleteable_by_user + opposite_role_key_to_test = (mode == "adding") ? :deleteable_by_user : :addable_by_user + permission_key = (mode == "adding") ? "add_#{perm_role}_to_course".to_sym : "remove_#{perm_role}_from_course" it "when #{mode} a(n) #{perm_role}" do @course.account.role_overrides.create!(role: @role, enabled: true, permission: permission_key) diff --git a/spec/models/sis_batch_spec.rb b/spec/models/sis_batch_spec.rb index 9c8ed3673f82d..561289fc2fc20 100644 --- a/spec/models/sis_batch_spec.rb +++ b/spec/models/sis_batch_spec.rb @@ -240,7 +240,7 @@ def process_csv_data(data, opts = {}) # a boolean. allow_any_instance_of(SIS::CSV::ImportRefactored).to receive(:should_stop_import?) do v = response_values.shift - v == :raise ? raise("PC_LOAD_LETTER") : v + (v == :raise) ? raise("PC_LOAD_LETTER") : v end end diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index 68c60e95d46be..3626e34c7fa7b 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -2609,12 +2609,12 @@ OriginalityReport.create!(attachment: attachment, submission: submission, workflow_state: preferred_state, - originality_score: preferred_state == "scored" ? 1 : nil) + originality_score: (preferred_state == "scored") ? 1 : nil) end let(:other_report) do OriginalityReport.create!(attachment: attachment, submission: submission, workflow_state: other_state, - originality_score: other_state == "scored" ? 2 : nil) + originality_score: (other_state == "scored") ? 2 : nil) end before do @@ -3013,14 +3013,14 @@ let(:preferred_report) do OriginalityReport.create!(attachment: attachment, submission: submission, - originality_score: preferred_state == "scored" ? 1 : nil, + originality_score: (preferred_state == "scored") ? 1 : nil, workflow_state: preferred_state, originality_report_url: preferred_url) end let(:other_report) do OriginalityReport.create!(attachment: attachment, submission: submission, - originality_score: other_state == "scored" ? 2 : nil, + originality_score: (other_state == "scored") ? 2 : nil, workflow_state: other_state, originality_report_url: other_url) end diff --git a/spec/requests/pace_contexts_spec.rb b/spec/requests/pace_contexts_spec.rb index b666fbbdc4253..7122e81715e9f 100644 --- a/spec/requests/pace_contexts_spec.rb +++ b/spec/requests/pace_contexts_spec.rb @@ -113,7 +113,7 @@ json = JSON.parse(response.body) course.course_sections.each do |section| context_json = json["pace_contexts"].detect { |pc| pc["item_id"] == section.id } - expected_pace_type = section.course_paces.count > 0 ? "Section" : "Course" + expected_pace_type = (section.course_paces.count > 0) ? "Section" : "Course" expect(context_json["applied_pace"]["type"]).to eq expected_pace_type end end diff --git a/spec/selenium/admin/account_admin_developer_keys_rewrite_spec.rb b/spec/selenium/admin/account_admin_developer_keys_rewrite_spec.rb index abd6b7ee2ff93..a4f3efc811978 100644 --- a/spec/selenium/admin/account_admin_developer_keys_rewrite_spec.rb +++ b/spec/selenium/admin/account_admin_developer_keys_rewrite_spec.rb @@ -274,11 +274,11 @@ before do stub_const("ApiScopeMapper", Class.new do def self.lookup_resource(controller, _action) - controller == :assignment_groups_api ? :assignment_groups : controller + (controller == :assignment_groups_api) ? :assignment_groups : controller end def self.name_for_resource(resource) - resource == :assignment_groups ? "Assignment Groups" : resource.to_s + (resource == :assignment_groups) ? "Assignment Groups" : resource.to_s end end) diff --git a/spec/selenium/admin/admin_sub_accounts_spec.rb b/spec/selenium/admin/admin_sub_accounts_spec.rb index 4aa7fc76a0eab..79e36aef72047 100644 --- a/spec/selenium/admin/admin_sub_accounts_spec.rb +++ b/spec/selenium/admin/admin_sub_accounts_spec.rb @@ -29,7 +29,7 @@ def create_sub_account(name = "sub account", number_to_create = 1, parent_accoun sub_account = Account.create(name: name + " #{i}", parent_account: parent_account) created_sub_accounts.push(sub_account) end - created_sub_accounts.count == 1 ? created_sub_accounts[0] : created_sub_accounts + (created_sub_accounts.count == 1) ? created_sub_accounts[0] : created_sub_accounts end def click_account_action_link(account_id, action_link_css) diff --git a/spec/selenium/admin/pages/permissions_page.rb b/spec/selenium/admin/pages/permissions_page.rb index 7858c84f632f2..9de16b4bbfe8e 100644 --- a/spec/selenium/admin/pages/permissions_page.rb +++ b/spec/selenium/admin/pages/permissions_page.rb @@ -173,7 +173,7 @@ def expand_manage_wiki # ---------------------- Actions ---------------------- def choose_tab(tab_name) name = tab_name.to_s.downcase - tab = name == "account" ? account_roles_tab : course_roles_tab + tab = (name == "account") ? account_roles_tab : course_roles_tab tab.click end diff --git a/spec/selenium/announcements/announcements_teacher_spec.rb b/spec/selenium/announcements/announcements_teacher_spec.rb index 5c26d487a0000..ac2d9aa771a5c 100644 --- a/spec/selenium/announcements/announcements_teacher_spec.rb +++ b/spec/selenium/announcements/announcements_teacher_spec.rb @@ -133,7 +133,7 @@ end it "adds an attachment to a graded topic", priority: "1" do - what_to_create == DiscussionTopic ? @course.discussion_topics.create!(title: "graded attachment topic", user: @user) : announcement_model(title: "graded attachment topic", user: @user) + (what_to_create == DiscussionTopic) ? @course.discussion_topics.create!(title: "graded attachment topic", user: @user) : announcement_model(title: "graded attachment topic", user: @user) if what_to_create == DiscussionTopic what_to_create.last.update(assignment: @course.assignments.create!(name: "graded topic assignment")) end @@ -146,7 +146,7 @@ it "edits a topic", priority: "1" do edit_name = "edited discussion name" - topic = what_to_create == DiscussionTopic ? @course.discussion_topics.create!(title: @topic_title, user: @user) : announcement_model(title: @topic_title, user: @user) + topic = (what_to_create == DiscussionTopic) ? @course.discussion_topics.create!(title: @topic_title, user: @user) : announcement_model(title: @topic_title, user: @user) get "#{url}/#{topic.id}" expect_new_page_load { f(".edit-btn").click } diff --git a/spec/selenium/course_paces/pages/coursepaces_common_page.rb b/spec/selenium/course_paces/pages/coursepaces_common_page.rb index 6997de20e4bb0..7caa66e401d34 100644 --- a/spec/selenium/course_paces/pages/coursepaces_common_page.rb +++ b/spec/selenium/course_paces/pages/coursepaces_common_page.rb @@ -146,7 +146,7 @@ def format_course_pacing_date(date) def date_of_next(day) date = Date.parse(day) - delta = date > Date.today ? 0 : 7 + delta = (date > Date.today) ? 0 : 7 date + delta end diff --git a/spec/selenium/dashboard/pages/k5_schedule_tab_page.rb b/spec/selenium/dashboard/pages/k5_schedule_tab_page.rb index 7043b24f91290..80baf2a7e3e08 100644 --- a/spec/selenium/dashboard/pages/k5_schedule_tab_page.rb +++ b/spec/selenium/dashboard/pages/k5_schedule_tab_page.rb @@ -105,7 +105,7 @@ def assignment_link(missing_assignment_element, course_id, assignment_id) def beginning_of_week_date date_block = ff(week_date_selector) - date_block[0].text == "Today" ? date_block[1].text : date_block[0].text + (date_block[0].text == "Today") ? date_block[1].text : date_block[0].text end def calendar_event_modal @@ -261,10 +261,10 @@ def update_todo_title(old_todo_title, new_todo_title) #------------------------Helper Methods------------------------# def beginning_weekday_calculation(current_date) - (current_date.beginning_of_week(:sunday)).strftime("%B %-d") + current_date.beginning_of_week(:sunday).strftime("%B %-d") end def ending_weekday_calculation(current_date) - (current_date.end_of_week(:sunday)).strftime("%B %-d") + current_date.end_of_week(:sunday).strftime("%B %-d") end end diff --git a/spec/selenium/files/new_files_folders_spec.rb b/spec/selenium/files/new_files_folders_spec.rb index a8d8c60a40dd2..23d190e8c56ee 100644 --- a/spec/selenium/files/new_files_folders_spec.rb +++ b/spec/selenium/files/new_files_folders_spec.rb @@ -162,7 +162,7 @@ f(".ef-name-col > a.ef-name-col__link").click wait_for_ajaximations 1.upto(15) do |number_of_folders| - folder_regex = number_of_folders > 1 ? Regexp.new("New Folder\\s#{number_of_folders}") : "New Folder" + folder_regex = (number_of_folders > 1) ? Regexp.new("New Folder\\s#{number_of_folders}") : "New Folder" create_new_folder expect(all_files_folders.count).to eq number_of_folders expect(all_files_folders.last.text).to match folder_regex diff --git a/spec/selenium/grades/grading_standards/grading_standards_spec.rb b/spec/selenium/grades/grading_standards/grading_standards_spec.rb index 717f37e0c4c0c..10ff11734e361 100644 --- a/spec/selenium/grades/grading_standards/grading_standards_spec.rb +++ b/spec/selenium/grades/grading_standards/grading_standards_spec.rb @@ -121,7 +121,7 @@ expect(rows.length).to eq @standard.data.length rows.each_with_index do |r, idx| expect(r.find_element(:css, ".name").text).to eq @standard.data[idx].first - expect(r.find_element(:css, ".value").text).to eq(idx == 0 ? "100" : "< #{round_if_whole(@standard.data[idx - 1].last * 100)}") + expect(r.find_element(:css, ".value").text).to eq((idx == 0) ? "100" : "< #{round_if_whole(@standard.data[idx - 1].last * 100)}") expect(r.find_element(:css, ".next_value").text).to eq round_if_whole(@standard.data[idx].last * 100).to_s end dialog.find_element(:css, "#grading_standard_brief_#{@standard.id} .select_grading_standard_link").click diff --git a/spec/selenium/grades/speedgrader/speedgrader_quiz_submissions_spec.rb b/spec/selenium/grades/speedgrader/speedgrader_quiz_submissions_spec.rb index 593a144e81431..57308a5e17d74 100644 --- a/spec/selenium/grades/speedgrader/speedgrader_quiz_submissions_spec.rb +++ b/spec/selenium/grades/speedgrader/speedgrader_quiz_submissions_spec.rb @@ -32,7 +32,7 @@ student_in_course 2.times do |i| qs = @quiz.generate_submission(@student) - opts = i == 0 ? { finished_at: (Time.zone.today - 7) + 30.minutes } : {} + opts = (i == 0) ? { finished_at: (Time.zone.today - 7) + 30.minutes } : {} Quizzes::SubmissionGrader.new(qs).grade_submission(opts) end end diff --git a/spec/selenium/grades/student_grades_page/gradebook_student_spec.rb b/spec/selenium/grades/student_grades_page/gradebook_student_spec.rb index 1913092cf86d9..989bf1d5b8699 100644 --- a/spec/selenium/grades/student_grades_page/gradebook_student_spec.rb +++ b/spec/selenium/grades/student_grades_page/gradebook_student_spec.rb @@ -46,7 +46,7 @@ ] shared_examples "Student Gradebook View" do |role| - it "for #{role == "observer" ? "an Observer" : "a Student"}", priority: "1" do + it "for #{(role == "observer") ? "an Observer" : "a Student"}", priority: "1" do course_with_student_logged_in({ course_name: "Course A" }) course1 = @course student = @user diff --git a/spec/selenium/helpers/announcements_common.rb b/spec/selenium/helpers/announcements_common.rb index 94843c4f62766..9a4e31d3aed3b 100644 --- a/spec/selenium/helpers/announcements_common.rb +++ b/spec/selenium/helpers/announcements_common.rb @@ -65,9 +65,9 @@ def update_attributes_and_validate(attribute, update_value, search_term = update def refresh_and_filter(filter_type, filter, expected_text, expected_results = 1) refresh_page # in order to get the new topic information expect(ff(".toggleSelected")).to have_size(what_to_create.count) - filter_type == :css ? fj(filter).click : replace_content(f("#searchTerm"), filter) + (filter_type == :css) ? fj(filter).click : replace_content(f("#searchTerm"), filter) expect(ff(".ic-announcement-row").count).to eq expected_results - expected_results > 1 ? ff(".ic-announcement-row").each { |topic| expect(topic).to include_text(expected_text) } : (expect(f(".discussionTopicIndexList .discussion-topic")).to include_text(expected_text)) + (expected_results > 1) ? ff(".ic-announcement-row").each { |topic| expect(topic).to include_text(expected_text) } : (expect(f(".discussionTopicIndexList .discussion-topic")).to include_text(expected_text)) end def add_attachment_and_validate diff --git a/spec/selenium/helpers/calendar2_common.rb b/spec/selenium/helpers/calendar2_common.rb index 03bfb185904fe..3b463e8aeebda 100644 --- a/spec/selenium/helpers/calendar2_common.rb +++ b/spec/selenium/helpers/calendar2_common.rb @@ -275,7 +275,7 @@ def test_timed_calendar_event_in_tz(time_zone, start_time = "6:30 AM", end_time @date = @user.time_zone.now.beginning_of_day new_date = @date new_date = - new_date.to_date.mday == "15" ? new_date.change({ day: 20 }) : new_date.change({ day: 15 }) + (new_date.to_date.mday == "15") ? new_date.change({ day: 20 }) : new_date.change({ day: 15 }) create_timed_calendar_event(new_date, start_time, end_time) event_title_on_calendar.click expect( @@ -302,7 +302,7 @@ def test_timed_calendar_event_in_tz_more_options( @date = @user.time_zone.now.beginning_of_day new_date = @date new_date = - new_date.to_date.mday == "15" ? new_date.change({ day: 20 }) : new_date.change({ day: 15 }) + (new_date.to_date.mday == "15") ? new_date.change({ day: 20 }) : new_date.change({ day: 15 }) input_timed_calendar_event_fields(new_date, start_time, end_time) expect_new_page_load { edit_calendar_event_form_more_options.click } expect(more_options_date_field.property("value")).to eq( diff --git a/spec/selenium/helpers/discussions_common.rb b/spec/selenium/helpers/discussions_common.rb index 399d33074bdc4..55b80a4f3125b 100644 --- a/spec/selenium/helpers/discussions_common.rb +++ b/spec/selenium/helpers/discussions_common.rb @@ -213,7 +213,7 @@ def click_publish_icon(topic) end def confirm(state) - checkbox_state = state == :on ? "true" : nil + checkbox_state = (state == :on) ? "true" : nil get url wait_for_ajaximations diff --git a/spec/selenium/helpers/legacy_announcements_common.rb b/spec/selenium/helpers/legacy_announcements_common.rb index 35d9f5985ce3f..87a3d9ee6605e 100644 --- a/spec/selenium/helpers/legacy_announcements_common.rb +++ b/spec/selenium/helpers/legacy_announcements_common.rb @@ -65,9 +65,9 @@ def update_attributes_and_validate(attribute, update_value, search_term = update def refresh_and_filter(filter_type, filter, expected_text, expected_results = 1) refresh_page # in order to get the new topic information expect(ff(".toggleSelected")).to have_size(what_to_create.count) - filter_type == :css ? fj(filter).click : replace_content(f("#searchTerm"), filter) + (filter_type == :css) ? fj(filter).click : replace_content(f("#searchTerm"), filter) expect(ff(".discussionTopicIndexList .discussion-topic").count).to eq expected_results - expected_results > 1 ? ff(".discussionTopicIndexList .discussion-topic").each { |topic| expect(topic).to include_text(expected_text) } : (expect(f(".discussionTopicIndexList .discussion-topic")).to include_text(expected_text)) + (expected_results > 1) ? ff(".discussionTopicIndexList .discussion-topic").each { |topic| expect(topic).to include_text(expected_text) } : (expect(f(".discussionTopicIndexList .discussion-topic")).to include_text(expected_text)) end def add_attachment_and_validate diff --git a/spec/selenium/helpers/manage_groups_common.rb b/spec/selenium/helpers/manage_groups_common.rb index d1a923a41c80a..2c6a175d803f9 100644 --- a/spec/selenium/helpers/manage_groups_common.rb +++ b/spec/selenium/helpers/manage_groups_common.rb @@ -97,8 +97,8 @@ def add_groups_in_category(category, i = 3) end def simulate_group_drag(user_id, from_group_id, to_group_id) - from_group = (from_group_id == "blank" ? ".group_blank:visible" : "#group_#{from_group_id}") - to_group = (to_group_id == "blank" ? ".group_blank:visible" : "#group_#{to_group_id}") + from_group = ((from_group_id == "blank") ? ".group_blank:visible" : "#group_#{from_group_id}") + to_group = ((to_group_id == "blank") ? ".group_blank:visible" : "#group_#{to_group_id}") driver.execute_script(<<~JS) window.contextGroups.moveToGroup( $('#{from_group} .user_id_#{user_id}'), @@ -108,7 +108,7 @@ def simulate_group_drag(user_id, from_group_id, to_group_id) end def expand_group(group_id) - group_selector = (group_id == "unassigned" ? ".unassigned-students" : ".group[data-id=\"#{group_id}\"]") + group_selector = ((group_id == "unassigned") ? ".unassigned-students" : ".group[data-id=\"#{group_id}\"]") return if group_selector == ".unassigned-students" || f(group_selector).attribute(:class).include?("group-expanded") fj("#{group_selector} .toggle-group").click diff --git a/spec/selenium/helpers/outcome_common.rb b/spec/selenium/helpers/outcome_common.rb index 6b8f3111210b1..68dc1dba6f2ff 100644 --- a/spec/selenium/helpers/outcome_common.rb +++ b/spec/selenium/helpers/outcome_common.rb @@ -219,7 +219,7 @@ def should_create_a_learning_outcome_nested def should_edit_a_learning_outcome_and_delete_a_rating edited_title = "edit outcome" - @context = who_to_login == "teacher" ? @course : account + @context = (who_to_login == "teacher") ? @course : account outcome_model get outcome_url @@ -262,7 +262,7 @@ def should_edit_a_learning_outcome_and_delete_a_rating end def should_delete_a_learning_outcome - @context = who_to_login == "teacher" ? @course : account + @context = (who_to_login == "teacher") ? @course : account outcome_model get outcome_url fj(".outcomes-sidebar .outcome-level:first li").click @@ -403,7 +403,7 @@ def should_create_an_outcome_group_nested def should_edit_an_outcome_group edited_title = "edited group" - @context = who_to_login == "teacher" ? @course : account + @context = (who_to_login == "teacher") ? @course : account outcome_group_model get outcome_url @@ -428,7 +428,7 @@ def should_edit_an_outcome_group end def should_delete_an_outcome_group - @context = who_to_login == "teacher" ? @course : account + @context = (who_to_login == "teacher") ? @course : account outcome_group_model get outcome_url fj(".outcomes-sidebar .outcome-level:first li.outcome-group").click diff --git a/spec/selenium/helpers/theme_editor_common.rb b/spec/selenium/helpers/theme_editor_common.rb index 6859431d483cd..6404261ac6618 100644 --- a/spec/selenium/helpers/theme_editor_common.rb +++ b/spec/selenium/helpers/theme_editor_common.rb @@ -152,7 +152,7 @@ def all_watermarks def all_colors(array, color = "random") array.each do |x| - x.send_keys(color == "random" ? random_hex_color : color) + x.send_keys((color == "random") ? random_hex_color : color) end end diff --git a/spec/selenium/master_courses/blueprint_associations_spec.rb b/spec/selenium/master_courses/blueprint_associations_spec.rb index 8f5cf92f07c7f..f89b77c9e5d5a 100644 --- a/spec/selenium/master_courses/blueprint_associations_spec.rb +++ b/spec/selenium/master_courses/blueprint_associations_spec.rb @@ -44,7 +44,7 @@ def create_sub_account(name = "sub account", number_to_create = 1, parent_accoun sub_account = Account.create(name: name + " #{i}", parent_account: parent_account) created_sub_accounts.push(sub_account) end - created_sub_accounts.count == 1 ? created_sub_accounts[0] : created_sub_accounts + (created_sub_accounts.count == 1) ? created_sub_accounts[0] : created_sub_accounts end before do diff --git a/spec/selenium/outcomes/outcome_spec.rb b/spec/selenium/outcomes/outcome_spec.rb index efae90b195c9f..dedcc25329ed0 100644 --- a/spec/selenium/outcomes/outcome_spec.rb +++ b/spec/selenium/outcomes/outcome_spec.rb @@ -173,7 +173,7 @@ def save_without_error(value = 4, title = "New Outcome") context "actions" do it "does not render an HTML-escaped title in outcome directory while editing", priority: "2" do title = "escape & me <<->> if you dare" - @context = who_to_login == "teacher" ? @course : account + @context = (who_to_login == "teacher") ? @course : account outcome_model get outcome_url wait_for_ajaximations diff --git a/spec/selenium/outcomes/outcome_teacher_spec.rb b/spec/selenium/outcomes/outcome_teacher_spec.rb index 3a6a5022073be..7046beec69e9b 100644 --- a/spec/selenium/outcomes/outcome_teacher_spec.rb +++ b/spec/selenium/outcomes/outcome_teacher_spec.rb @@ -167,7 +167,7 @@ def goto_account_default_outcomes context "moving outcomes tree" do before do course_with_teacher_logged_in - @context = who_to_login == "teacher" ? @course : account + @context = (who_to_login == "teacher") ? @course : account end it "alerts user if attempting to move with no directory selected" do diff --git a/spec/selenium/test_setup/common_helper_methods/custom_selenium_actions.rb b/spec/selenium/test_setup/common_helper_methods/custom_selenium_actions.rb index 51a2ab72b8d0c..29f2d9fba2b7c 100644 --- a/spec/selenium/test_setup/common_helper_methods/custom_selenium_actions.rb +++ b/spec/selenium/test_setup/common_helper_methods/custom_selenium_actions.rb @@ -513,7 +513,7 @@ def replace_content(el, value, options = {}) # This is a known issue and hasn't been solved yet. https://bugs.chromium.org/p/chromedriver/issues/detail?id=30 if SeleniumDriverSetup.saucelabs_test_run? el.click - el.send_keys [(driver.browser == :safari ? :command : :control), "a"] + el.send_keys [((driver.browser == :safari) ? :command : :control), "a"] el.send_keys(value) else driver.execute_script("arguments[0].select();", el) @@ -673,7 +673,7 @@ def dismiss_flash_messages end def dismiss_flash_messages_if_present - unless (find_all_with_jquery(flash_message_selector).length) == 0 + unless find_all_with_jquery(flash_message_selector).empty? find_all_with_jquery(flash_message_selector).each(&:click) end end diff --git a/spec/selenium/test_setup/common_helper_methods/state_poller.rb b/spec/selenium/test_setup/common_helper_methods/state_poller.rb index 65225f1613536..6ebedd68d3400 100644 --- a/spec/selenium/test_setup/common_helper_methods/state_poller.rb +++ b/spec/selenium/test_setup/common_helper_methods/state_poller.rb @@ -55,7 +55,7 @@ def rerun_timeout_multiplier # Next wait time is calculated using exponential growth function and capped at predefined level def next_wait(wait) - wait < WAIT_STEP_CAP ? [wait * WAIT_STEP_GROWTH, WAIT_STEP_CAP].min : wait + (wait < WAIT_STEP_CAP) ? [wait * WAIT_STEP_GROWTH, WAIT_STEP_CAP].min : wait end def f3(float) diff --git a/spec/shared_examples/redo_submission.rb b/spec/shared_examples/redo_submission.rb index 51072a8992b22..97cc771979e11 100644 --- a/spec/shared_examples/redo_submission.rb +++ b/spec/shared_examples/redo_submission.rb @@ -28,7 +28,7 @@ it "does not allow on assignments without due date" do @assignment = @course.assignments.create!(title: "some assignment", submission_types: "online_url,online_upload") @submission = @assignment.submit_homework(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id }.merge(@resource_pair) user_session(@teacher) put :redo_submission, params: @params @@ -38,7 +38,7 @@ it "does not allow from users without the right permissions" do @assignment = @course.assignments.create!(title: "some assignment", submission_types: "online_url,online_upload", due_at: 3.days.from_now) @submission = @assignment.submit_homework(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id }.merge(@resource_pair) user_session(@student) put :redo_submission, params: @params @@ -48,7 +48,7 @@ it "allows on assignments with due date" do @assignment = @course.assignments.create!(title: "some assignment", submission_types: "online_url,online_upload", due_at: 3.days.from_now) @submission = @assignment.submit_homework(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id }.merge(@resource_pair) user_session(@teacher) put :redo_submission, params: @params @@ -64,7 +64,7 @@ lock_at: 3.days.from_now ) @submission = @assignment.submit_homework(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id }.merge(@resource_pair) user_session(@teacher) put :redo_submission, params: @params @@ -80,7 +80,7 @@ lock_at: 3.days.from_now ) @submission = @assignment.submit_homework(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id }.merge(@resource_pair) user_session(@student) put :redo_submission, params: @params @@ -95,7 +95,7 @@ lock_at: 3.days.ago ) @submission = @assignment.submit_homework(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { submission_id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id }.merge(@resource_pair) user_session(@teacher) put :redo_submission, params: @params diff --git a/spec/shared_examples/update_submission.rb b/spec/shared_examples/update_submission.rb index 807f494de6ded..78b11c312f15c 100644 --- a/spec/shared_examples/update_submission.rb +++ b/spec/shared_examples/update_submission.rb @@ -24,7 +24,7 @@ course_with_student(active_all: true) @assignment = @course.assignments.create!(title: "some assignment", submission_types: "online_url,online_upload") @submission = @assignment.submit_homework(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { comment: "some comment" } }.merge(@resource_pair) put :update, params: @params assert_unauthorized @@ -36,7 +36,7 @@ @course.enroll_user(@user2) @assignment = @course.assignments.create!(title: "some assignment", submission_types: "online_url,online_upload") @submission = @assignment.submit_homework(@user2) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user2.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user2.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { comment: "some comment" } }.merge(@resource_pair) put :update, params: @params assert_unauthorized @@ -55,7 +55,7 @@ it "allows updating homework to add comments" do submission = assignment.submit_homework(student) - resource_pair = controller == :anonymous_submissions ? { anonymous_id: submission.anonymous_id } : { id: student.id } + resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: submission.anonymous_id } : { id: student.id } params = { course_id: course.id, assignment_id: assignment.id, submission: { comment: "some comment" } }.merge(resource_pair) user_session(student) put :update, params: params @@ -68,7 +68,7 @@ it "teacher adding a comment posts the submission when assignment posts automatically" do assignment.ensure_post_policy(post_manually: false) submission = assignment.submit_homework(student) - resource_pair = controller == :anonymous_submissions ? { anonymous_id: submission.anonymous_id } : { id: student.id } + resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: submission.anonymous_id } : { id: student.id } params = { course_id: course.id, assignment_id: assignment.id, submission: { comment: "some comment" } }.merge(resource_pair) user_session(teacher) put :update, params: params @@ -78,7 +78,7 @@ it "teacher adding a comment does not post the submission when assignment posts manually" do assignment.ensure_post_policy(post_manually: true) submission = assignment.submit_homework(student) - resource_pair = controller == :anonymous_submissions ? { anonymous_id: submission.anonymous_id } : { id: student.id } + resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: submission.anonymous_id } : { id: student.id } params = { course_id: course.id, assignment_id: assignment.id, submission: { comment: "some comment" } }.merge(resource_pair) user_session(teacher) put :update, params: params @@ -88,7 +88,7 @@ it "teacher adding a comment to an unposted submission is hidden" do assignment.ensure_post_policy(post_manually: true) submission = assignment.submit_homework(student) - resource_pair = controller == :anonymous_submissions ? { anonymous_id: submission.anonymous_id } : { id: student.id } + resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: submission.anonymous_id } : { id: student.id } params = { course_id: course.id, assignment_id: assignment.id, submission: { comment: "some comment" } }.merge(resource_pair) user_session(teacher) put :update, params: params @@ -98,7 +98,7 @@ it "teacher adding a comment to a posted submission is not hidden" do assignment.ensure_post_policy(post_manually: false) submission = assignment.submit_homework(student) - resource_pair = controller == :anonymous_submissions ? { anonymous_id: submission.anonymous_id } : { id: student.id } + resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: submission.anonymous_id } : { id: student.id } params = { course_id: course.id, assignment_id: assignment.id, submission: { comment: "some comment" } }.merge(resource_pair) user_session(teacher) put :update, params: params @@ -109,7 +109,7 @@ describe "quiz submissions" do let_once(:assignment) { course.assignments.create!(title: "quiz", submission_types: "online_quiz") } let_once(:course) { Course.create! } - let_once(:resource_pair) { controller == :anonymous_submissions ? { anonymous_id: submission.anonymous_id } : { id: student.id } } + let_once(:resource_pair) { (controller == :anonymous_submissions) ? { anonymous_id: submission.anonymous_id } : { id: student.id } } let_once(:student) { course.enroll_student(User.create!, enrollment_state: :active).user } let_once(:submission) { assignment.submissions.find_by(user: student) } let_once(:teacher) { course.enroll_teacher(User.create!, enrollment_state: :active).user } @@ -230,7 +230,7 @@ @submission = @assignment.submit_homework(@user) site_admin_user user_session(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { comment: "some comment" } }.merge(@resource_pair) put :update, params: @params expect(response).to be_redirect @@ -248,7 +248,7 @@ @assignment.save! site_admin_user user_session(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { comment: "some comment" } }.merge(@resource_pair) put :update, params: @params expect(response).to be_redirect @@ -273,7 +273,7 @@ @group.users << @u1 @group.users << @user @submission = @u1.submissions.find_by!(assignment: @assignment) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @u1.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @u1.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { comment: "some comment", group_comment: "1" } }.merge(@resource_pair) put :update, params: @params subs = @assignment.submissions @@ -290,7 +290,7 @@ @submission = @assignment.submit_homework(@user) data1 = fixture_file_upload("docs/doc.doc", "application/msword", true) data2 = fixture_file_upload("docs/txt.txt", "text/plain", true) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, @@ -316,7 +316,7 @@ @assignment = @course.assignments.create!(title: "some assignment", submission_types: "online_url,online_upload") @submission = @assignment.submit_homework(@user) data = fixture_file_upload("docs/txt.txt", "text/plain", true) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, @@ -336,7 +336,7 @@ @submission = @student.submissions.find_by!(assignment: assignment) user_session(@teacher) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } @test_params = { course_id: @course.id, assignment_id: assignment.id, @@ -380,7 +380,7 @@ it "renders json with scores for teachers" do user_session(@teacher) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { student_entered_score: "2" } }.merge(@resource_pair) put :update, params: @params, format: :json expect(body["id"]).to eq @submission.id @@ -392,7 +392,7 @@ it "renders json with scores for students" do user_session(@student) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { student_entered_score: "2" } }.merge(@resource_pair) put :update, params: @params, format: :json expect(body["id"]).to eq @submission.id @@ -404,7 +404,7 @@ it "renders json with scores for teachers for unposted submissions" do @assignment.ensure_post_policy(post_manually: true) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { student_entered_score: "2" } }.merge(@resource_pair) put :update, params: @params, format: :json expect(body["id"]).to eq @submission.id @@ -417,7 +417,7 @@ it "renders json without scores for students for unposted submissions" do user_session(@student) @assignment.ensure_post_policy(post_manually: true) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { student_entered_score: "2" } }.merge(@resource_pair) put :update, params: @params, format: :json expect(body["id"]).to eq @submission.id @@ -443,7 +443,7 @@ it "does not return submission user_id when user is a peer reviewer" do user_session(@peer_reviewer) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { student_entered_score: "2" } }.merge(@resource_pair) put :update, params: @params, format: :json expect(body).not_to have_key "user_id" @@ -451,7 +451,7 @@ it "returns submission user_id when user is a teacher" do user_session(@teacher) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { student_entered_score: "2" } }.merge(@resource_pair) put :update, params: @params, format: :json expect(body).to have_key "user_id" @@ -459,7 +459,7 @@ it "returns submission user_id when user owns the submission" do user_session(@student) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @student.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { student_entered_score: "2" } }.merge(@resource_pair) put :update, params: @params, format: :json expect(body).to have_key "user_id" @@ -582,7 +582,7 @@ @assignment = @course.assignments.create!(title: "some assignment", submission_types: "online_url,online_upload") @submission = @assignment.submit_homework(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { student_entered_score: "2" } }.merge(@resource_pair) put :update, params: @params, format: :json expect(@submission.reload.student_entered_score).to eq 2.0 @@ -593,7 +593,7 @@ @assignment = @course.assignments.create!(title: "some assignment", submission_types: "online_url,online_upload") @submission = @assignment.submit_homework(@user) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { student_entered_score: "2.0000000020" } }.merge(@resource_pair) put :update, params: @params, format: :json expect(@submission.reload.student_entered_score).to eq 2.0 @@ -606,7 +606,7 @@ quiz_submission = quiz.generate_submission(@user).complete! quiz_submission.update_column(:workflow_state, :pending_review) @submission = @student.submissions.find_by!(assignment: assignment) - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: assignment.id, submission: { student_entered_score: "2" } }.merge(@resource_pair) put :update, params: @params, format: :json expect(quiz_submission.submission.reload).not_to be_pending_review @@ -621,7 +621,7 @@ end it "creates a provisional comment" do - @resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + @resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, submission: { comment: "provisional!", provisional: true } }.merge(@resource_pair) user_session(@teacher) put :update, params: @params, format: :json @@ -638,7 +638,7 @@ before(:once) do @assignment.update!(final_grader: @teacher) @submission.find_or_create_provisional_grade!(@teacher) - resource_pair = controller == :anonymous_submissions ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } + resource_pair = (controller == :anonymous_submissions) ? { anonymous_id: @submission.anonymous_id } : { id: @user.id } @params = { course_id: @course.id, assignment_id: @assignment.id, @@ -705,7 +705,7 @@ let(:submission) { @student.submissions.find_by!(assignment: @assignment) } let(:submission_params) { { comment: "hi", provisional: true, final: true } } - let(:resource_pair) { controller == :anonymous_submissions ? { anonymous_id: submission.anonymous_id } : { id: @student.id } } + let(:resource_pair) { (controller == :anonymous_submissions) ? { anonymous_id: submission.anonymous_id } : { id: @student.id } } let(:request_params) do { course_id: @course.id, assignment_id: @assignment.id, submission: submission_params }.merge(resource_pair) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e3a36412bd534..a4dc09e533978 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -251,7 +251,7 @@ def test_db_name def switch_role!(env) if readonly_user_exists? && readonly_user_can_read? - ActiveRecord::Base.connection.execute(env == :secondary ? "SET ROLE canvas_readonly_user" : "RESET ROLE") + ActiveRecord::Base.connection.execute((env == :secondary) ? "SET ROLE canvas_readonly_user" : "RESET ROLE") else puts "The database #{test_db_name} is not setup with a secondary/readonly_user to fix run the following." puts "psql -c 'ALTER USER #{datbase_username} CREATEDB CREATEROLE' -d #{test_db_name}" diff --git a/spec/support/spec_time_limit.rb b/spec/support/spec_time_limit.rb index b4a783ed34abf..24492229d3929 100644 --- a/spec/support/spec_time_limit.rb +++ b/spec/support/spec_time_limit.rb @@ -88,8 +88,8 @@ def commit_modifies_spec?(example) def commit_files @commit_files ||= - (`git diff-tree --no-commit-id --name-only -r HEAD | grep -E '_spec\.rb$'` - ).split("\n") + `git diff-tree --no-commit-id --name-only -r HEAD | grep -E '_spec\.rb$'` + .split("\n") end end end