diff --git a/app/controllers/assignments_api_controller.rb b/app/controllers/assignments_api_controller.rb index 78b3e060b5e..772f0e6e49c 100644 --- a/app/controllers/assignments_api_controller.rb +++ b/app/controllers/assignments_api_controller.rb @@ -877,8 +877,7 @@ class AssignmentsApiController < ApplicationController ActiveRecord::Associations::Preloader.new.preload(assignments, :score_statistic) end - hashes = [] - hashes = assignments.map do |assignment| + assignments.map do |assignment| visibility_array = assignment_visibilities[assignment.id] if assignment_visibilities submission = submissions[assignment.id] needs_grading_course_proxy = @context.grants_right?(user, session, :manage_grades) ? @@ -897,7 +896,6 @@ class AssignmentsApiController < ApplicationController include_can_edit: include_params.include?('can_edit'), include_score_statistics: include_params.include?('score_statistics')) end - hashes end end diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb index fdd47623d53..d96f1e0759a 100644 --- a/app/controllers/assignments_controller.rb +++ b/app/controllers/assignments_controller.rb @@ -530,7 +530,6 @@ class AssignmentsController < ApplicationController def syllabus rce_js_env add_crumb @context.elementary_enabled? ? t("Important Info") : t('#crumbs.syllabus', "Syllabus") - active_tab = "Syllabus" @course_home_sub_navigation_tools = ContextExternalTool.all_tools_for(@context, placements: :course_home_sub_navigation, diff --git a/app/controllers/calendar_events_api_controller.rb b/app/controllers/calendar_events_api_controller.rb index f669ef50ccc..a5d6b7001ba 100644 --- a/app/controllers/calendar_events_api_controller.rb +++ b/app/controllers/calendar_events_api_controller.rb @@ -506,7 +506,6 @@ class CalendarEventsApiController < ApplicationController # Create duplicates if necessary events = [] dup_options = get_duplicate_params(params[:calendar_event]) - title = dup_options[:title] if dup_options[:count] > 0 events += create_event_and_duplicates(dup_options) else diff --git a/app/controllers/context_modules_controller.rb b/app/controllers/context_modules_controller.rb index 4e9119ad0e3..f407f5b3d8f 100644 --- a/app/controllers/context_modules_controller.rb +++ b/app/controllers/context_modules_controller.rb @@ -51,7 +51,7 @@ class ContextModulesController < ApplicationController collection_cache_key(@modules), Time.zone, Digest::MD5.hexdigest([visible_assignments, @section_visibility].join("/"))] cache_key = cache_key_items.join('/') cache_key = add_menu_tools_to_cache_key(cache_key) - cache_key = add_mastery_paths_to_cache_key(cache_key, @context, @current_user) + add_mastery_paths_to_cache_key(cache_key, @context, @current_user) end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 9eb85ff7966..2f0c4fc72bd 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1529,8 +1529,6 @@ class CoursesController < ApplicationController end def update_user_engine_choice(course, selection_obj) - old_selection = course.settings[:engine_selected][:user_id] - new_settings = {} new_selections = {} new_selections[:user_id] = { newquizzes_engine_selected: selection_obj[:newquizzes_engine_selected], @@ -1866,9 +1864,8 @@ class CoursesController < ApplicationController if session[:accepted_enrollment_uuid].present? && (enrollment = @context.enrollments.where(uuid: session[:accepted_enrollment_uuid]).first) - success = false if enrollment.invited? - success = enrollment.accept! + enrollment.accept! flash[:notice] = t('notices.invitation_accepted', "Invitation accepted! Welcome to %{course}!", :course => @context.name) end diff --git a/app/controllers/discussion_topics_api_controller.rb b/app/controllers/discussion_topics_api_controller.rb index fd11183f1c3..a9796db2220 100644 --- a/app/controllers/discussion_topics_api_controller.rb +++ b/app/controllers/discussion_topics_api_controller.rb @@ -163,7 +163,6 @@ class DiscussionTopicsApiController < ApplicationController ) include_enrollment_state = params[:include_enrollment_state] && (@context.is_a?(Course) || @context.is_a?(Group)) && @context.grants_right?(@current_user, session, :read_as_admin) - enrollments = nil if include_enrollment_state || include_context_card_info enrollment_context = @context.is_a?(Course) ? @context : @context.context all_enrollments = enrollment_context.enrollments.where(:user_id => participants).to_a diff --git a/app/controllers/discussion_topics_controller.rb b/app/controllers/discussion_topics_controller.rb index 097cc833a44..dbc2073617f 100644 --- a/app/controllers/discussion_topics_controller.rb +++ b/app/controllers/discussion_topics_controller.rb @@ -438,7 +438,6 @@ class DiscussionTopicsController < ApplicationController add_body_class 'hide-content-while-scripts-not-loaded' @page_title = join_title(t('#titles.discussions', "Discussions"), @context.name) - feed_code = @context_enrollment.try(:feed_code) || (@context.available? && @context.feed_code) content_for_head helpers.auto_discovery_link_tag(:atom, feeds_forum_format_path(@context.feed_code, :atom), { :title => t(:course_discussions_atom_feed_title, "Course Discussions Atom Feed") }) js_bundle :discussion_topics_index diff --git a/app/controllers/eportfolio_categories_controller.rb b/app/controllers/eportfolio_categories_controller.rb index 230a6325ea9..d1dc9423854 100644 --- a/app/controllers/eportfolio_categories_controller.rb +++ b/app/controllers/eportfolio_categories_controller.rb @@ -31,7 +31,6 @@ class EportfolioCategoriesController < ApplicationController def create if authorized_action(@portfolio, @current_user, :update) - category_names = @portfolio.eportfolio_categories.map { |c| c.name } @category = @portfolio.eportfolio_categories.build(eportfolio_category_params) respond_to do |format| if @category.save diff --git a/app/controllers/eportfolio_entries_controller.rb b/app/controllers/eportfolio_entries_controller.rb index f76d9a12fea..0b7f6d6e1c8 100644 --- a/app/controllers/eportfolio_entries_controller.rb +++ b/app/controllers/eportfolio_entries_controller.rb @@ -32,7 +32,6 @@ class EportfolioEntriesController < ApplicationController if authorized_action(@portfolio, @current_user, :update) @category = @portfolio.eportfolio_categories.find(params[:eportfolio_entry].delete(:eportfolio_category_id)) - page_names = @category.eportfolio_entries.map { |c| c.name } @page = @portfolio.eportfolio_entries.build(eportfolio_entry_params) @page.eportfolio_category = @category @page.parse_content(params) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 8a90f12cec0..472beb38ffe 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -498,7 +498,6 @@ class FilesController < ApplicationController def show GuardRail.activate(:secondary) do - original_params = params.dup params[:id] ||= params[:file_id] get_context # note that the /files/XXX URL implicitly uses the current user as the diff --git a/app/controllers/lti/concerns/oembed.rb b/app/controllers/lti/concerns/oembed.rb index b2d204fee01..842fb918f5a 100644 --- a/app/controllers/lti/concerns/oembed.rb +++ b/app/controllers/lti/concerns/oembed.rb @@ -111,7 +111,7 @@ module Lti::Concerns params.require(:oembed_token), associated_tool.shared_secret ) - rescue JSON::JWS::VerificationFailed, JSON::JWS::UnexpectedAlgorithm => error + rescue JSON::JWS::VerificationFailed, JSON::JWS::UnexpectedAlgorithm raise OembedAuthorizationError.new 'Error validating oembed_token signature' end end diff --git a/app/controllers/observer_alert_thresholds_api_controller.rb b/app/controllers/observer_alert_thresholds_api_controller.rb index 0a240794699..79fa4759a21 100644 --- a/app/controllers/observer_alert_thresholds_api_controller.rb +++ b/app/controllers/observer_alert_thresholds_api_controller.rb @@ -52,7 +52,7 @@ class ObserverAlertThresholdsApiController < ApplicationController return render json: { errors: ['user_id is invalid'] }, status: :bad_request end - threshold = ObserverAlertThreshold.where(observer: @current_user, student: attrs[:user_id], alert_type: attrs[:alert_type]).take + threshold = ObserverAlertThreshold.where(observer: @current_user, student: user, alert_type: attrs[:alert_type]).take if threshold # update if duplicate threshold.update(threshold: attrs[:threshold], workflow_state: 'active') diff --git a/app/controllers/outcome_groups_controller.rb b/app/controllers/outcome_groups_controller.rb index efc400a12c9..c49331112ab 100644 --- a/app/controllers/outcome_groups_controller.rb +++ b/app/controllers/outcome_groups_controller.rb @@ -40,12 +40,9 @@ class OutcomeGroupsController < ApplicationController if authorized_action(@context, @current_user, :manage_outcomes) data = JSON.parse(params[:file].read).with_indifferent_access rescue nil if data && data[:category] && data[:title] && data[:description] && data[:outcomes] - params = {} - group = @context.learning_outcome_groups.create(params) + group = @context.learning_outcome_groups.create data[:outcomes].each do |outcome_hash| - params = {} - outcome_hash = outcome_hash.with_indifferent_access - group.learning_outcomes.create(params) + group.learning_outcomes.create end render :json => group.as_json(:include => :learning_outcomes), :as_text => true diff --git a/app/controllers/outcomes_academic_benchmark_import_api_controller.rb b/app/controllers/outcomes_academic_benchmark_import_api_controller.rb index fe6a2e9a112..cb9f9e3c1d4 100644 --- a/app/controllers/outcomes_academic_benchmark_import_api_controller.rb +++ b/app/controllers/outcomes_academic_benchmark_import_api_controller.rb @@ -60,7 +60,7 @@ class OutcomesAcademicBenchmarkImportApiController < ApplicationController cmj = content_migration_json(cm, @current_user, session) cmj[:migration_issues] = migration_issues_json(cm_issues, cm, @current_user, session) render json: cmj - rescue ActiveRecord::RecordNotFound => e + rescue ActiveRecord::RecordNotFound render json: { error: "no content migration matching id #{params[:migration_id]}" } end end diff --git a/app/controllers/quizzes/quizzes_controller.rb b/app/controllers/quizzes/quizzes_controller.rb index a23cfcaa356..7c60512b160 100644 --- a/app/controllers/quizzes/quizzes_controller.rb +++ b/app/controllers/quizzes/quizzes_controller.rb @@ -315,7 +315,6 @@ class Quizzes::QuizzesController < ApplicationController @quiz.due_at = params[:due_at] if params[:due_at] @quiz.assignment_group_id = params[:assignment_group_id] if params[:assignment_group_id] - student_ids = @context.student_ids @banks_hash = get_banks(@quiz) if (@has_student_submissions = @quiz.has_student_submissions?) @@ -437,7 +436,6 @@ class Quizzes::QuizzesController < ApplicationController end def update - n = Time.now.to_f if authorized_action(@quiz, @current_user, :update) quiz_params = get_quiz_params params[:quiz] ||= {} diff --git a/app/controllers/release_notes_controller.rb b/app/controllers/release_notes_controller.rb index 52793c0da54..388426f976e 100644 --- a/app/controllers/release_notes_controller.rb +++ b/app/controllers/release_notes_controller.rb @@ -131,7 +131,7 @@ class ReleaseNotesController < ApplicationController end end - notes = all_notes.sort_by { |note| note.show_ats[release_note_env] }.reverse!.first(latest_limit) + all_notes.sort_by { |note| note.show_ats[release_note_env] }.reverse!.first(latest_limit) end def last_seen_release_note diff --git a/app/controllers/rubrics_controller.rb b/app/controllers/rubrics_controller.rb index 558445d0280..e00c860ebe5 100644 --- a/app/controllers/rubrics_controller.rb +++ b/app/controllers/rubrics_controller.rb @@ -50,7 +50,7 @@ class RubricsController < ApplicationController permission = @context.is_a?(User) ? :manage : [:manage_rubrics, :read_rubrics] return unless authorized_action(@context, @current_user, permission) - if (id = params[:id]) =~ Api::ID_REGEX + if params[:id].match?(Api::ID_REGEX) js_env :ROOT_OUTCOME_GROUP => get_root_outcome, :PERMISSIONS => { manage_rubrics: @context.grants_right?(@current_user, session, :manage_rubrics) diff --git a/app/controllers/usage_rights_controller.rb b/app/controllers/usage_rights_controller.rb index 7cd51c2aa0d..2f9c2291e52 100644 --- a/app/controllers/usage_rights_controller.rb +++ b/app/controllers/usage_rights_controller.rb @@ -157,15 +157,15 @@ class UsageRightsController < ApplicationController # recursively enumerate file ids under a folder def enumerate_contents(folder) - ids = folder.active_sub_folders.inject([]) { |file_ids, folder| file_ids += enumerate_contents(folder) } - ids += folder.active_file_attachments.pluck(:id) + ids = folder.active_sub_folders.flat_map { |sub_folder| enumerate_contents(sub_folder) } + ids + folder.active_file_attachments.pluck(:id) end # assign the given usage rights to params[:file_ids] / params[:folder_ids] def assign_usage_rights(usage_rights) folder_ids = Array(params[:folder_ids]).map(&:to_i) folders = @context.folders.active.where(id: folder_ids).to_a - file_ids = folders.inject([]) { |file_ids, folder| file_ids += enumerate_contents(folder) } + file_ids = folders.flat_map { |folder| enumerate_contents(folder) } file_ids += @context.attachments.not_deleted.where(id: Array(params[:file_ids]).map(&:to_i)).pluck(:id) update_attrs = { usage_rights_id: usage_rights&.id } update_attrs.merge!(locked: false) if usage_rights.present? && value_to_boolean(params[:publish]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2c914ae190c..866bfe9336b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -107,22 +107,20 @@ module ApplicationHelper name = name.sub(/context/, context_name) opts.unshift context.id opts.push({}) unless opts[-1].is_a?(Hash) - ajax = - begin - opts[-1].delete :ajax - rescue StandardError - nil - end + begin + opts[-1].delete :ajax + rescue + nil + end opts[-1][:only_path] = true unless opts[-1][:only_path] == false res = self.send name, *opts elsif opts[0].is_a? Hash opts = opts[0] - ajax = - begin - opts[0].delete :ajax - rescue StandardError - nil - end + begin + opts[0].delete :ajax + rescue + nil + end opts[:only_path] = true opts["#{context_name}_id"] = context.id res = self.url_for opts diff --git a/app/helpers/avatar_helper.rb b/app/helpers/avatar_helper.rb index 75fd7d61f21..b70941e3fe0 100644 --- a/app/helpers/avatar_helper.rb +++ b/app/helpers/avatar_helper.rb @@ -31,7 +31,7 @@ module AvatarHelper avatar_settings = (@domain_root_account && @domain_root_account.settings[:avatars]) || 'enabled' user_id = Shard.global_id_for(user_id) user_shard = Shard.shard_for(user_id) - image_url, alt_tag = user_shard.activate do + user_shard.activate do Rails.cache.fetch(Cacher.inline_avatar_cache_key(user_id, avatar_settings)) do if !user && user_id.to_i > 0 user ||= User.find(user_id) diff --git a/app/helpers/broken_link_helper.rb b/app/helpers/broken_link_helper.rb index 29f2b172af1..67586531b08 100644 --- a/app/helpers/broken_link_helper.rb +++ b/app/helpers/broken_link_helper.rb @@ -55,7 +55,7 @@ module BrokenLinkHelper course_validator = CourseLinkValidator.new(course) course_validator.check_object_status(url, object: link_obj) || response_code_type - rescue => e + rescue :missing_item end diff --git a/app/helpers/calendar_conferences_helper.rb b/app/helpers/calendar_conferences_helper.rb index 280908307a9..5336e153804 100644 --- a/app/helpers/calendar_conferences_helper.rb +++ b/app/helpers/calendar_conferences_helper.rb @@ -34,7 +34,7 @@ module CalendarConferencesHelper end end elsif conference_params[:title].present? - conference = context.web_conferences.build(valid_params).tap do |conf| + context.web_conferences.build(valid_params).tap do |conf| conf.user = @current_user conf.settings[:default_return_url] = named_context_url(context, :context_url, :include_host => true) end diff --git a/app/helpers/quizzes_helper.rb b/app/helpers/quizzes_helper.rb index e2845af5f4e..ef2f90798a7 100644 --- a/app/helpers/quizzes_helper.rb +++ b/app/helpers/quizzes_helper.rb @@ -663,7 +663,7 @@ module QuizzesHelper end titles = titles.map { |title| h(title) } - title = "title=\"#{titles.join(' ')}\"".html_safe if titles.length > 0 + "title=\"#{titles.join(' ')}\"".html_safe if titles.length > 0 # rubocop:disable Rails/OutputSafety end def matching_answer_title(item_text, did_select_answer, selected_answer_text, is_correct_answer, correct_answer_text, show_correct_answers) @@ -688,7 +688,7 @@ module QuizzesHelper end titles = titles.map { |title| h(title) } - title = "title=\"#{titles.join(' ')}\"".html_safe if titles.length > 0 + "title=\"#{titles.join(' ')}\"".html_safe if titles.length > 0 # rubocop:disable Rails/OutputSafety end def show_correct_answers? diff --git a/app/models/announcement.rb b/app/models/announcement.rb index 9ea8f408403..814c352fddf 100644 --- a/app/models/announcement.rb +++ b/app/models/announcement.rb @@ -49,7 +49,7 @@ class Announcement < DiscussionTopic } def validate_draft_state_change - old_draft_state, new_draft_state = self.changes['workflow_state'] + _old_draft_state, new_draft_state = self.changes['workflow_state'] self.errors.add :workflow_state, I18n.t('#announcements.error_draft_state', "This topic cannot be set to draft state because it is an announcement.") if new_draft_state == 'unpublished' end diff --git a/app/models/assessment_question_bank.rb b/app/models/assessment_question_bank.rb index 7dd3eea807b..69f69205558 100644 --- a/app/models/assessment_question_bank.rb +++ b/app/models/assessment_question_bank.rb @@ -142,8 +142,7 @@ class AssessmentQuestionBank < ActiveRecord::Base def bookmark_for(user, do_bookmark = true) if do_bookmark - question_bank_user = self.assessment_question_bank_users.where(user_id: user).first - question_bank_user ||= self.assessment_question_bank_users.create(:user => user) + assessment_question_bank_users.where(user: user).first_or_create! else AssessmentQuestionBankUser.where(:user_id => user, :assessment_question_bank_id => self).delete_all end diff --git a/app/models/asset_user_access.rb b/app/models/asset_user_access.rb index bdf46b0b984..46d4ebc3a39 100644 --- a/app/models/asset_user_access.rb +++ b/app/models/asset_user_access.rb @@ -179,7 +179,7 @@ class AssetUserAccess < ActiveRecord::Base unless @asset return nil unless asset_code - asset_code, general = self.asset_code.split(":").reverse + asset_code, = self.asset_code.split(":").reverse @asset = Context.find_asset_by_asset_string(asset_code, context) @asset ||= (match = asset_code.match(/enrollment_(\d+)/)) && Enrollment.where(:id => match[1]).first end @@ -284,9 +284,8 @@ class AssetUserAccess < ActiveRecord::Base end def self.infer_asset(code) - asset_code, general = code.split(":").reverse - asset = Context.find_asset_by_asset_string(asset_code) - asset + asset_code, = code.split(":").reverse + Context.find_asset_by_asset_string(asset_code) end # For Quizzes, we want the view score not to include the participation score diff --git a/app/models/asset_user_access_log.rb b/app/models/asset_user_access_log.rb index 32e715bdff8..ecf83014b33 100644 --- a/app/models/asset_user_access_log.rb +++ b/app/models/asset_user_access_log.rb @@ -295,9 +295,6 @@ class AssetUserAccessLog log_batch_size = mb_settings[:log_batch_size] max_compaction_time = mb_settings[:max_compaction_time] receive_timeout = mb_settings[:receive_timeout] - # semaphore to flip if we manage to advance to the "head" - # of the topic within this compaction run. - caught_up = false early_exit = false # use to signal as soon as we've decided to bail on compaction. positive_runtime_budget = true # set to false when budget runtime exceed allocation @@ -859,7 +856,7 @@ class AssetUserAccessLog "(#{row["aua_id"]}, #{row["view_count"]}, '#{max_updated_at}')" end.join(", ") - update_query = <<~SQL + <<~SQL.squish UPDATE #{AssetUserAccess.quoted_table_name} AS aua SET view_score = COALESCE(aua.view_score, 0) + log_segment.view_count, updated_at = GREATEST(aua.updated_at, TO_TIMESTAMP(log_segment.max_updated_at, 'YYYY-MM-DD HH24:MI:SS.US')), diff --git a/app/models/attachment.rb b/app/models/attachment.rb index c673849fe98..c520078425b 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -1016,7 +1016,7 @@ class Attachment < ActiveRecord::Base def thumbnail_for_size(geometry) if self.class.allows_thumbnails_of_size?(geometry) to_use = thumbnails.loaded? ? thumbnails.detect { |t| t.thumbnail == geometry } : thumbnails.where(thumbnail: geometry).first - to_use ||= create_dynamic_thumbnail(geometry) + to_use || create_dynamic_thumbnail(geometry) end end @@ -1922,7 +1922,6 @@ class Attachment < ActiveRecord::Base return filename if attempts <= 1 && block.call(filename) - new_name = filename addition = attempts || 1 dir = File.dirname(filename) dir = dir == "." ? "" : "#{dir}/" diff --git a/app/models/bookmark_service.rb b/app/models/bookmark_service.rb index 7b99e2fb5ba..ce8385042c9 100644 --- a/app/models/bookmark_service.rb +++ b/app/models/bookmark_service.rb @@ -36,7 +36,7 @@ class BookmarkService < UserService elsif self.service == 'diigo' Diigo::Connection.diigo_post_bookmark(self, url, title, description, tags) end - rescue => e + rescue # Should probably save the data to try again if it fails... at least one more try end end diff --git a/app/models/content_migration.rb b/app/models/content_migration.rb index 8c580f429eb..cab117ad064 100644 --- a/app/models/content_migration.rb +++ b/app/models/content_migration.rb @@ -998,13 +998,13 @@ class ContentMigration < ActiveRecord::Base def imported_migration_items_for_insert_type import_type = migration_settings[:insert_into_module_type] - imported_items = if import_type.present? - class_name = self.class.import_class_name(import_type) - imported_migration_items_hash[class_name] ||= {} - imported_migration_items_hash[class_name].values - else - imported_migration_items - end + if import_type.present? + class_name = self.class.import_class_name(import_type) + imported_migration_items_hash[class_name] ||= {} + imported_migration_items_hash[class_name].values + else + imported_migration_items + end end def self.import_class_name(import_type) diff --git a/app/models/context.rb b/app/models/context.rb index 665a4465783..f05fda9a635 100644 --- a/app/models/context.rb +++ b/app/models/context.rb @@ -293,7 +293,7 @@ module Context object = context.try(params[:controller].sub(/^.+\//, ''))&.find_by(id: params[:id]) end object - rescue => e + rescue nil end diff --git a/app/models/context_external_tool.rb b/app/models/context_external_tool.rb index 46864105434..eec5909e9f6 100644 --- a/app/models/context_external_tool.rb +++ b/app/models/context_external_tool.rb @@ -333,7 +333,7 @@ class ContextExternalTool < ActiveRecord::Base return if self.vendor_help_link.blank? begin - value, uri = CanvasHttp.validate_url(self.vendor_help_link) + _value, uri = CanvasHttp.validate_url(self.vendor_help_link) self.vendor_help_link = uri.to_s rescue URI::Error, ArgumentError self.vendor_help_link = nil @@ -947,7 +947,7 @@ class ContextExternalTool < ActiveRecord::Base if !context.is_a?(Account) && context.respond_to?(:context_external_tools) tools += context.context_external_tools.having_setting(type.to_s) end - tools += ContextExternalTool.having_setting(type.to_s).where(context_type: 'Account', context_id: context.account_chain_ids) + tools + ContextExternalTool.having_setting(type.to_s).where(context_type: 'Account', context_id: context.account_chain_ids) end def self.serialization_excludes; [:shared_secret, :settings]; end diff --git a/app/models/context_module.rb b/app/models/context_module.rb index c1250ca64db..7a3bb58728e 100644 --- a/app/models/context_module.rb +++ b/app/models/context_module.rb @@ -317,7 +317,6 @@ class ContextModule < ActiveRecord::Base end def update_downstreams(original_position = nil) - original_position ||= self.position || 0 positions = ContextModule.module_positions(self.context).to_a.sort_by { |a| a[1] } downstream_ids = positions.select { |a| a[1] > (self.position || 0) }.map { |a| a[0] } downstreams = downstream_ids.empty? ? [] : self.context.context_modules.not_deleted.where(id: downstream_ids) @@ -788,7 +787,6 @@ class ContextModule < ActiveRecord::Base end def update_for(user, action, tag, points = nil) - retry_count = 0 return nil unless self.context.grants_right?(user, :participate_as_student) return nil unless (progression = self.evaluate_for(user)) return nil if progression.locked? diff --git a/app/models/context_module_progressions/finder.rb b/app/models/context_module_progressions/finder.rb index 2e8a2d29635..c4c5fa0ad9c 100644 --- a/app/models/context_module_progressions/finder.rb +++ b/app/models/context_module_progressions/finder.rb @@ -43,7 +43,7 @@ module ContextModuleProgressions GuardRail.activate(:primary) do ContextModuleProgression.unique_constraint_retry do |retry_count| progression = mod.context_module_progressions.where(user_id: user).first if retry_count > 0 - progression ||= mod.context_module_progressions.create!(user: user) + progression || mod.context_module_progressions.create!(user: user) end end end diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 5a24da6a57a..4c0f5b481db 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -434,6 +434,7 @@ class Conversation < ActiveRecord::Base def context_name name = context.try(:name) name ||= Context.find_by_asset_string(context_tags.first).try(:name) if context_tags.first + name end def context_code diff --git a/app/models/conversation_batch.rb b/app/models/conversation_batch.rb index dd4689ac74c..85da955dde4 100644 --- a/app/models/conversation_batch.rb +++ b/app/models/conversation_batch.rb @@ -70,7 +70,7 @@ class ConversationBatch < ActiveRecord::Base update_attribute :workflow_state, 'sent' end - rescue StandardError => e + rescue self.workflow_state = 'error' save! end diff --git a/app/models/course_section.rb b/app/models/course_section.rb index 491a6aa2602..7b28bd95de9 100644 --- a/app/models/course_section.rb +++ b/app/models/course_section.rb @@ -244,7 +244,6 @@ class CourseSection < ActiveRecord::Base # This is messy, and I hate it. # The SIS import actually gives us three names for a section # and I don't know which one is best, or which one to show. - name_had_changed = name_changed? # Here's the current plan: # - otherwise, just use name # - use the method display_name to consolidate this logic diff --git a/app/models/crocodoc_document.rb b/app/models/crocodoc_document.rb index e66a41d362a..51198787ed9 100644 --- a/app/models/crocodoc_document.rb +++ b/app/models/crocodoc_document.rb @@ -206,7 +206,6 @@ class CrocodocDocument < ActiveRecord::Base bulk_updates = {} error_uuids = [] statuses.each do |status| - uuid, state = status['uuid'], status['status'] bulk_updates[status['status']] ||= [] bulk_updates[status['status']] << status['uuid'] if status['status'] == 'ERROR' diff --git a/app/models/enrollment.rb b/app/models/enrollment.rb index 034c045499b..117418657f4 100644 --- a/app/models/enrollment.rb +++ b/app/models/enrollment.rb @@ -1329,7 +1329,7 @@ class Enrollment < ActiveRecord::Base def self.cached_temporary_invitations(email) if Enrollment.cross_shard_invitations? Shard.birth.activate do - invitations = Rails.cache.fetch([email, 'all_invited_enrollments2'].cache_key) do + Rails.cache.fetch([email, 'all_invited_enrollments2'].cache_key) do Shard.with_each_shard(CommunicationChannel.associated_shards(email)) do Enrollment.invited.for_email(email).to_a end diff --git a/app/models/exporters/exporter_helper.rb b/app/models/exporters/exporter_helper.rb index 6a9b7d1814a..66d4305cf18 100644 --- a/app/models/exporters/exporter_helper.rb +++ b/app/models/exporters/exporter_helper.rb @@ -31,7 +31,7 @@ module Exporters begin handle = attachment.open(:need_local_file => true) zipfile.get_output_stream(filename) { |zos| Zip::IOExtras.copy_stream(zos, handle) } - rescue => e + rescue return false ensure handle.close if handle diff --git a/app/models/external_feed.rb b/app/models/external_feed.rb index 794eec16f21..54e4b09964b 100644 --- a/app/models/external_feed.rb +++ b/app/models/external_feed.rb @@ -50,7 +50,7 @@ class ExternalFeed < ActiveRecord::Base def display_name(short = true) short_url = (self.url || "").split("/")[0, 3].join("/") - res = self.title || (short ? t(:short_feed_title, "%{short_url} feed", :short_url => short_url) : self.url) + self.title || (short ? t(:short_feed_title, "%{short_url} feed", :short_url => short_url) : self.url) end def header_match=(str) diff --git a/app/models/folder.rb b/app/models/folder.rb index 4ad2ade8b34..d8bcc9d393b 100644 --- a/app/models/folder.rb +++ b/app/models/folder.rb @@ -166,7 +166,6 @@ class Folder < ActiveRecord::Base t :default_folder_name, 'New Folder' self.name = 'New Folder' if self.name.blank? self.name = self.name.strip.gsub(/\//, "_") - folder = self @update_sub_folders = false self.parent_folder_id = nil if !self.parent_folder || self.parent_folder.context != self.context || self.parent_folder_id == self.id self.context = self.parent_folder.context if self.parent_folder diff --git a/app/models/group.rb b/app/models/group.rb index 2c28efe938b..2dfdc5953f6 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -322,6 +322,7 @@ class Group < ActiveRecord::Base def full_name res = before_label(self.name) + " " res += (self.context.course_code rescue self.context.name) if self.context + res end def to_atom diff --git a/app/models/importers/assignment_importer.rb b/app/models/importers/assignment_importer.rb index 8bfec6d30a6..826781b445f 100644 --- a/app/models/importers/assignment_importer.rb +++ b/app/models/importers/assignment_importer.rb @@ -28,7 +28,6 @@ module Importers def self.process_migration(data, migration) assignments = data['assignments'] ? data['assignments'] : [] - to_import = migration.to_import 'assignments' create_assignments(assignments, migration) diff --git a/app/models/importers/context_external_tool_importer.rb b/app/models/importers/context_external_tool_importer.rb index 28a5dd07280..1dcced23d0d 100644 --- a/app/models/importers/context_external_tool_importer.rb +++ b/app/models/importers/context_external_tool_importer.rb @@ -28,7 +28,7 @@ module Importers tools.each do |tool| if migration.import_object?("context_external_tools", tool['migration_id']) || migration.import_object?("external_tools", tool['migration_id']) begin - item = import_from_migration(tool, migration.context, migration) + import_from_migration(tool, migration.context, migration) rescue migration.add_import_warning(t('#migration.external_tool_type', "External Tool"), tool[:title], $!) end diff --git a/app/models/importers/course_content_importer.rb b/app/models/importers/course_content_importer.rb index f2f23fad9a1..24a269e3a9e 100644 --- a/app/models/importers/course_content_importer.rb +++ b/app/models/importers/course_content_importer.rb @@ -86,7 +86,6 @@ module Importers end def self.import_content(course, data, params, migration) - params ||= { :copy => {} } logger.debug "starting import" Importers.disable_live_events! do @@ -532,7 +531,6 @@ module Importers Time.use_zone time_zone do time = ActiveSupport::TimeWithZone.new(time.utc, Time.zone) old_date = time.to_date - new_date = old_date.clone old_start_date = options[:old_start_date] old_end_date = options[:old_end_date] new_start_date = options[:new_start_date] diff --git a/app/models/importers/quiz_importer.rb b/app/models/importers/quiz_importer.rb index 734a60d38e7..d87d09a8d1d 100644 --- a/app/models/importers/quiz_importer.rb +++ b/app/models/importers/quiz_importer.rb @@ -192,8 +192,6 @@ module Importers item.hide_correct_answers_at = Canvas::Migration::MigratorHelper.get_utc_time_from_timestamp(hash[:hide_correct_answers_at]) if master_migration || hash[:hide_correct_answers_at] item.scoring_policy = hash[:which_attempt_to_keep] if master_migration || hash[:which_attempt_to_keep] - missing_links = [] - unless migration.quizzes_next_migration? # The description is mapped to "instructions" in NQ item.description = migration.convert_html(hash[:description], :quiz, hash[:migration_id], :description) end diff --git a/app/models/importers/wiki_page_importer.rb b/app/models/importers/wiki_page_importer.rb index 0031774d30f..799bd715597 100644 --- a/app/models/importers/wiki_page_importer.rb +++ b/app/models/importers/wiki_page_importer.rb @@ -74,7 +74,6 @@ module Importers item ||= context.wiki_pages.temp_record(:wiki => context.wiki) item.mark_as_importing!(migration) - new_record = item.new_record? # force the url to be the same as the url_name given, since there are # likely other resources in the import that link to that url if hash[:url_name].present? diff --git a/app/models/incoming_mail/message_handler.rb b/app/models/incoming_mail/message_handler.rb index 317d086c4a0..2563799a06d 100644 --- a/app/models/incoming_mail/message_handler.rb +++ b/app/models/incoming_mail/message_handler.rb @@ -97,7 +97,7 @@ module IncomingMail # Can't use our usual mechanisms, so just try to send it once now begin Mailer.deliver(Mailer.create_message(outgoing_message)) - rescue => e + rescue # TODO: put some kind of error logging here? end end diff --git a/app/models/master_courses/restrictor.rb b/app/models/master_courses/restrictor.rb index ffc9b67600c..a70f4374213 100644 --- a/app/models/master_courses/restrictor.rb +++ b/app/models/master_courses/restrictor.rb @@ -88,7 +88,6 @@ module MasterCourses::Restrictor def check_for_restricted_column_changes return true if @importing_migration || !is_child_content? || !self.check_restrictions? - restrictions = nil locked_columns = [] self.class.base_class.restricted_column_settings.each do |type, columns| changed_columns = (self.changes.keys & columns) @@ -168,7 +167,6 @@ module MasterCourses::Restrictor child_tag = @importing_migration.master_course_subscription.content_tag_for(self) # find or create it return unless child_tag && child_tag.downstream_changes.present? - restrictions = nil columns_to_restore = [] self.class.base_class.restricted_column_settings.each do |type, columns| changed_columns = (child_tag.downstream_changes & columns) # should unlink all changes if _any_ in the category has been changed diff --git a/app/models/message.rb b/app/models/message.rb index b09c4e1fb33..42eaf69ebbd 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -53,7 +53,7 @@ class Message < ActiveRecord::Base def deliver message.deliver - rescue QueuedNotFound => e + rescue QueuedNotFound raise Delayed::RetriableError, "Message does not (yet?) exist" end @@ -663,7 +663,6 @@ class Message < ActiveRecord::Base self.url = @message_content_link || nil else # Message doesn't exist so we flag the message as an error - main_link = eval(Erubi::Engine.new(self.notification.main_link || "").src) self.subject = eval(Erubi::Engine.new(subject).src) self.body = eval(Erubi::Engine.new(body).src) self.transmission_errors = "couldn't find #{Canvas::MessageHelper.find_message_path(filename)}" @@ -1125,7 +1124,6 @@ class Message < ActiveRecord::Base @exception = e error_string = "Exception: #{e.class}: #{e.message}\n\t#{e.backtrace.join("\n\t")}" logger.error error_string - transmission_errors = error_string cancel raise e end diff --git a/app/models/page_view/pv4_client.rb b/app/models/page_view/pv4_client.rb index fdd2fd2c5ab..0f906d01588 100644 --- a/app/models/page_view/pv4_client.rb +++ b/app/models/page_view/pv4_client.rb @@ -63,7 +63,7 @@ class PageView PageView.from_attributes(pv) end - rescue Net::ReadTimeout => e + rescue Net::ReadTimeout raise Pv4Timeout, "failed to load page view history due to service timeout" end diff --git a/app/models/pseudonym.rb b/app/models/pseudonym.rb index 8c62bd5e4c5..81f944aa84b 100644 --- a/app/models/pseudonym.rb +++ b/app/models/pseudonym.rb @@ -580,7 +580,7 @@ class Pseudonym < ActiveRecord::Base pseudonyms = [] begin pseudonyms = find_all_by_arbitrary_credentials(credentials, account_ids, remote_ip) - rescue ImpossibleCredentialsError => e + rescue ImpossibleCredentialsError Rails.logger.info("Impossible pseudonym credentials: #{credentials[:unique_id]}, invalidating session") return :impossible_credentials end diff --git a/app/models/quizzes/log_auditing/snapshot_scraper.rb b/app/models/quizzes/log_auditing/snapshot_scraper.rb index 6d1e9bdb906..b7b39e77971 100644 --- a/app/models/quizzes/log_auditing/snapshot_scraper.rb +++ b/app/models/quizzes/log_auditing/snapshot_scraper.rb @@ -71,7 +71,6 @@ module Quizzes::LogAuditing private def optimize(events) - answered_event_type = Quizzes::QuizSubmissionEvent::EVT_QUESTION_ANSWERED optimizer = Quizzes::LogAuditing::QuestionAnsweredEventOptimizer.new quiz_submission_events = events.group_by(&:quiz_submission_id) diff --git a/app/models/quizzes/outstanding_quiz_submission_manager.rb b/app/models/quizzes/outstanding_quiz_submission_manager.rb index e6537cc0366..d006255f41f 100644 --- a/app/models/quizzes/outstanding_quiz_submission_manager.rb +++ b/app/models/quizzes/outstanding_quiz_submission_manager.rb @@ -54,10 +54,7 @@ module Quizzes end def find_by_quiz - # Find these in batches, so as to reduce the memory load - outstanding_qs = [] - outstanding_qs = Quizzes::QuizSubmission.where("quiz_id = ?", @quiz.id).preload(:user).needs_grading - outstanding_qs + Quizzes::QuizSubmission.where(quiz_id: @quiz).preload(:user).needs_grading end end end diff --git a/app/models/quizzes/quiz_question/answer_serializers/matching.rb b/app/models/quizzes/quiz_question/answer_serializers/matching.rb index 39254d9abb0..8e273497aec 100644 --- a/app/models/quizzes/quiz_question/answer_serializers/matching.rb +++ b/app/models/quizzes/quiz_question/answer_serializers/matching.rb @@ -47,8 +47,6 @@ module Quizzes::QuizQuestion::AnswerSerializers end pairings.each_with_index do |entry, index| - answer_id, match_id = nil, nil - unless entry.is_a?(Hash) || entry.is_a?(ActionController::Parameters) return rc.reject :invalid_type, "answer[#{index}]", Hash end diff --git a/app/models/quizzes/quiz_question_builder.rb b/app/models/quizzes/quiz_question_builder.rb index 2dac89eec7a..b94117ab636 100644 --- a/app/models/quizzes/quiz_question_builder.rb +++ b/app/models/quizzes/quiz_question_builder.rb @@ -114,7 +114,7 @@ class Quizzes::QuizQuestionBuilder # just a question else - questions = [descriptor] + [descriptor] end questions.each do |question| diff --git a/app/models/quizzes/quiz_statistics/student_analysis.rb b/app/models/quizzes/quiz_statistics/student_analysis.rb index a4b8a61d03a..a0fe038a906 100644 --- a/app/models/quizzes/quiz_statistics/student_analysis.rb +++ b/app/models/quizzes/quiz_statistics/student_analysis.rb @@ -338,9 +338,8 @@ class Quizzes::QuizStatistics::StudentAnalysis < Quizzes::QuizStatistics::Report logged_out = logged_out.where(user_id: user_ids) end - all_submissions = [] - all_submissions = prep_submissions scope - all_submissions += prep_submissions logged_out + all_submissions = prep_submissions(scope) + all_submissions + prep_submissions(logged_out) end end diff --git a/app/models/role_override.rb b/app/models/role_override.rb index dc66a5b378a..f661ba55777 100644 --- a/app/models/role_override.rb +++ b/app/models/role_override.rb @@ -1623,7 +1623,7 @@ class RoleOverride < ActiveRecord::Base end def self.css_class_for(context, permission, role, role_context = :role_account) - generated_permission = self.permission_for(context, permission, role, role_context = :role_account) + generated_permission = self.permission_for(context, permission, role, :role_account) css = [] if generated_permission[:readonly] diff --git a/app/models/rubric.rb b/app/models/rubric.rb index 1c9c28b3030..1ea515a0e6f 100644 --- a/app/models/rubric.rb +++ b/app/models/rubric.rb @@ -406,7 +406,7 @@ class Rubric < ActiveRecord::Base end def update_assessments_for_new_criteria(new_criteria) - criteria = self.data + data end # undo innocuous changes introduced by migrations which break `will_change_with_update?` diff --git a/app/models/rubric_assessment.rb b/app/models/rubric_assessment.rb index 0aad0718c28..016f0c97f1b 100644 --- a/app/models/rubric_assessment.rb +++ b/app/models/rubric_assessment.rb @@ -288,7 +288,7 @@ class RubricAssessment < ActiveRecord::Base def related_group_submissions_and_assessments if active_rubric_association? && self.rubric_association.association_object.is_a?(Assignment) && !self.artifact.is_a?(ModeratedGrading::ProvisionalGrade) && !self.rubric_association.association_object.grade_group_students_individually students = self.rubric_association.association_object.group_students(self.user).last - submissions = students.map do |student| + students.map do |student| submission = self.rubric_association.association_object.find_asset_for_assessment(self.rubric_association, student).first { submission: submission, rubric_assessments: submission.rubric_assessments diff --git a/app/models/submission.rb b/app/models/submission.rb index 30dc5361d41..101bd2c19cf 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -2287,12 +2287,7 @@ class Submission < ActiveRecord::Base res.workflow_state = 'assigned' if res.new_record? just_created = res.new_record? res.send_reminder! # this method also saves the assessment_request - case obj - when User - user = obj - when Submission - obj.assign_assessment(res) if just_created - end + obj.assign_assessment(res) if obj.is_a?(Submission) && just_created res end @@ -2372,7 +2367,6 @@ class Submission < ActiveRecord::Base end def to_atom(opts = {}) - prefix = self.assignment.context_prefix || "" author_name = self.assignment.present? && self.assignment.context.present? ? self.assignment.context.name : t('atom_no_author', "No Author") Atom::Entry.new do |entry| entry.title = "#{self&.user.name} -- #{self&.assignment.title}#{', ' + self.assignment.context.name if opts[:include_context]}" diff --git a/app/models/submission_comment.rb b/app/models/submission_comment.rb index 61af81c7b5a..80478809c3c 100644 --- a/app/models/submission_comment.rb +++ b/app/models/submission_comment.rb @@ -357,7 +357,7 @@ class SubmissionComment < ActiveRecord::Base return Attachment.none unless attachment_ids.present? ids = parse_attachment_ids - attachments = submission.assignment.attachments.where(id: ids) + submission.assignment.attachments.where(id: ids) end def self.preload_attachments(comments) diff --git a/app/models/web_conference.rb b/app/models/web_conference.rb index ec2b459a1a4..a94f3f95109 100644 --- a/app/models/web_conference.rb +++ b/app/models/web_conference.rb @@ -405,7 +405,7 @@ class WebConference < ActiveRecord::Base close end @conference_active - rescue Errno::ECONNREFUSED => ex + rescue Errno::ECONNREFUSED # Account credentials changed, server unreachable/down, bad stuff happened. @conference_active = false @conference_active diff --git a/app/serializers/quizzes/quiz_serializer.rb b/app/serializers/quizzes/quiz_serializer.rb index b3b782cd485..b1d122d86cc 100644 --- a/app/serializers/quizzes/quiz_serializer.rb +++ b/app/serializers/quizzes/quiz_serializer.rb @@ -278,7 +278,7 @@ module Quizzes hash = super # legacy v1 api unless accepts_jsonapi? - links = hash.delete('links') + hash.delete('links') # id = hash['assignment_group'] # hash['assignment_group_id'] = quiz.assignment_group.try(:id) else diff --git a/config/initializers/active_record.rb b/config/initializers/active_record.rb index c6ee01f64b8..52d1062154d 100644 --- a/config/initializers/active_record.rb +++ b/config/initializers/active_record.rb @@ -450,8 +450,6 @@ class ActiveRecord::Base num_days = options[:num_days] || 20 min_date = (options[:min_date] || max_date.advance(:days => -(num_days - 1))).midnight - offset = max_date.utc_offset - expression = "((#{column} || '-00')::TIMESTAMPTZ AT TIME ZONE '#{Time.zone.tzinfo.name}')::DATE" result = where("#{column} >= ? AND #{column} < ?", diff --git a/config/initializers/active_support.rb b/config/initializers/active_support.rb index 2f528a52001..e0ceb0048ae 100644 --- a/config/initializers/active_support.rb +++ b/config/initializers/active_support.rb @@ -53,8 +53,8 @@ module ActiveSupport::Cache if @value && Rails.env.test? begin super - rescue TypeError => e - return + rescue TypeError + nil end else super diff --git a/doc/api/fulldoc/html/setup.rb b/doc/api/fulldoc/html/setup.rb index 36ea3a31ca8..d09fcc39449 100644 --- a/doc/api/fulldoc/html/setup.rb +++ b/doc/api/fulldoc/html/setup.rb @@ -76,12 +76,12 @@ module YARD::Templates::Helpers::BaseHelper raise __errmsg end - topic, controller = *lookup_topic(appendix.namespace.to_s) + topic, _controller = *lookup_topic(appendix.namespace.to_s) if topic html_file = "#{topicize topic.first}.html" bookmark = "#{appendix.name.to_s.gsub(' ', '+')}-appendix" - ret = link_url("#{html_file}##{bookmark}", appendix.title) + link_url("#{html_file}##{bookmark}", appendix.title) else raise __errmsg end @@ -145,7 +145,7 @@ module YARD::Templates::Helpers::HtmlHelper raise __errmsg end - topic, controller = *lookup_topic(appendix.namespace.to_s) + topic, _controller = *lookup_topic(appendix.namespace.to_s) unless topic raise __errmsg @@ -202,7 +202,6 @@ end def generate_swagger_json api_resources = [] - model_resources = [] options[:resources].each do |name, controllers| view = ControllerListView.new(name, controllers) api_resources << view.swagger_reference diff --git a/gems/adheres_to_policy/lib/adheres_to_policy/instance_methods.rb b/gems/adheres_to_policy/lib/adheres_to_policy/instance_methods.rb index c5372f9bb86..77342cde70d 100644 --- a/gems/adheres_to_policy/lib/adheres_to_policy/instance_methods.rb +++ b/gems/adheres_to_policy/lib/adheres_to_policy/instance_methods.rb @@ -242,7 +242,7 @@ module AdheresToPolicy # Check the cache for the sought_right. If it exists in the cache its # state (true or false) will be returned. Otherwise we calculate the # state and cache it. - value, how_it_got_it = Cache.fetch( + value, _how_it_got_it = Cache.fetch( permission_cache_key_for(user, session, sought_right), use_rails_cache: use_rails_cache ) do @@ -252,7 +252,6 @@ module AdheresToPolicy # Loop through all the conditions until we find the first one that # grants us the sought_right. conditions.any? do |condition| - condition_applies = false start_time = Time.now condition_applies = condition.applies?(self, user, session) elapsed_time = Time.now - start_time diff --git a/gems/attachment_fu/lib/attachment_fu.rb b/gems/attachment_fu/lib/attachment_fu.rb index 2315d361695..545aac20fc3 100644 --- a/gems/attachment_fu/lib/attachment_fu.rb +++ b/gems/attachment_fu/lib/attachment_fu.rb @@ -380,7 +380,8 @@ module AttachmentFu # :nodoc: digest.update(line) read_bytes = true end - rescue => e + rescue + nil ensure io.close if file_from_path end diff --git a/gems/attachment_fu/lib/attachment_fu/backends/s3_backend.rb b/gems/attachment_fu/lib/attachment_fu/backends/s3_backend.rb index 01457a0bc20..c4e58cca846 100644 --- a/gems/attachment_fu/lib/attachment_fu/backends/s3_backend.rb +++ b/gems/attachment_fu/lib/attachment_fu/backends/s3_backend.rb @@ -298,8 +298,8 @@ module AttachmentFu # :nodoc: # it looks like they're not always working for some reason begin bucket.object(old_full_filename).move_to(full_filename, :acl => attachment_options[:s3_access]) - rescue => e - filename = @old_filename + rescue + nil end @old_filename = nil diff --git a/gems/bookmarked_collection/lib/bookmarked_collection/concat_collection.rb b/gems/bookmarked_collection/lib/bookmarked_collection/concat_collection.rb index 67bc191ca7f..3e6db365354 100644 --- a/gems/bookmarked_collection/lib/bookmarked_collection/concat_collection.rb +++ b/gems/bookmarked_collection/lib/bookmarked_collection/concat_collection.rb @@ -22,7 +22,7 @@ class BookmarkedCollection::ConcatCollection < BookmarkedCollection::CompositeCo def validate(bookmark) return false unless super - bookmark, index = decompose_bookmark(bookmark) + _bookmark, index = decompose_bookmark(bookmark) return false if index.nil? return true diff --git a/gems/canvas_http/spec/canvas_http_spec.rb b/gems/canvas_http/spec/canvas_http_spec.rb index 609b8b9185b..866df830991 100644 --- a/gems/canvas_http/spec/canvas_http_spec.rb +++ b/gems/canvas_http/spec/canvas_http_spec.rb @@ -202,7 +202,6 @@ describe "CanvasHttp" do end it "checks host before running" do - res = nil stub_request(:get, "http://www.example.com/a/b") .to_return(body: "Hello", headers: { 'Content-Length' => 5 }) expect(CanvasHttp).to receive(:insecure_host?).with("www.example.com").and_return(true) diff --git a/gems/event_stream/lib/event_stream/index_strategy/active_record.rb b/gems/event_stream/lib/event_stream/index_strategy/active_record.rb index f75f12a7781..cec78886b88 100644 --- a/gems/event_stream/lib/event_stream/index_strategy/active_record.rb +++ b/gems/event_stream/lib/event_stream/index_strategy/active_record.rb @@ -48,7 +48,7 @@ module EventStream::IndexStrategy index_scope = index_scope.where("created_at <= ?", options[:newest]) if options[:newest].present? index_scope = index_scope.select(:id, :created_at) if options[:just_ids] == true event_bookmarker = EventStream::IndexStrategy::ActiveRecord::Bookmarker.new(ar_type) - bookmarked_collection = BookmarkedCollection.build(event_bookmarker) do |pager| + BookmarkedCollection.build(event_bookmarker) do |pager| records = pager_to_records(index_scope, pager) pager.replace(records) pager.has_more! if records.next_page diff --git a/gems/event_stream/spec/event_stream/index_strategy/active_record_spec.rb b/gems/event_stream/spec/event_stream/index_strategy/active_record_spec.rb index 75714c97da4..ef5c051e573 100644 --- a/gems/event_stream/spec/event_stream/index_strategy/active_record_spec.rb +++ b/gems/event_stream/spec/event_stream/index_strategy/active_record_spec.rb @@ -62,7 +62,6 @@ describe EventStream::IndexStrategy::ActiveRecord do describe "scope assembly" do before :each do - query_options = {} stream = double('stream', :record_type => EventStream::Record, :active_record_type => fake_record_type) diff --git a/gems/html_text_helper/lib/html_text_helper.rb b/gems/html_text_helper/lib/html_text_helper.rb index 89bc3188df9..a59ede29d80 100644 --- a/gems/html_text_helper/lib/html_text_helper.rb +++ b/gems/html_text_helper/lib/html_text_helper.rb @@ -297,10 +297,7 @@ module HtmlTextHelper end processed_lines << quote_clump(quote_block) if !quote_block.empty? message = processed_lines.join("\n") - if opts[:url] - url = add_notification_to_link(opts[:url], opts[:notification_id]) if opts[:notification_id] - links.unshift opts[:url] - end + links.unshift opts[:url] if opts[:url] links.unshift message.html_safe end diff --git a/gems/i18n_tasks/lib/tasks/i18n.rake b/gems/i18n_tasks/lib/tasks/i18n.rake index 8a959640a93..6d388628dce 100755 --- a/gems/i18n_tasks/lib/tasks/i18n.rake +++ b/gems/i18n_tasks/lib/tasks/i18n.rake @@ -301,7 +301,6 @@ namespace :i18n do puts "Exported en.yml, current translations unmodified (check git log for last change)" else `git commit -a -m"generated en.yml for translation"` - remote_branch = `git remote-ref`.strip.sub(%r{\Aremotes/[^/]+/(.*)\z}, '\\1') local = current_branch || 'master' `remote=$(git config branch."#{local}".remote); \ remote_ref=$(git config branch."#{local}".merge); \ diff --git a/gems/incoming_mail_processor/spec/incoming_mail_processor/imap_mailbox_spec.rb b/gems/incoming_mail_processor/spec/incoming_mail_processor/imap_mailbox_spec.rb index fc6aa2bfb8d..d1e10217f09 100644 --- a/gems/incoming_mail_processor/spec/incoming_mail_processor/imap_mailbox_spec.rb +++ b/gems/incoming_mail_processor/spec/incoming_mail_processor/imap_mailbox_spec.rb @@ -223,7 +223,7 @@ describe IncomingMailProcessor::ImapMailbox do exception_propegated = false begin @mailbox.disconnect - rescue SyntaxError => e + rescue SyntaxError exception_propegated = true end expect(exception_propegated).to be_truthy diff --git a/gems/plugins/qti_exporter/spec_canvas/lib/qti/qti_2_1_zip_spec.rb b/gems/plugins/qti_exporter/spec_canvas/lib/qti/qti_2_1_zip_spec.rb index b5808b8d7b5..482e737a1dd 100644 --- a/gems/plugins/qti_exporter/spec_canvas/lib/qti/qti_2_1_zip_spec.rb +++ b/gems/plugins/qti_exporter/spec_canvas/lib/qti/qti_2_1_zip_spec.rb @@ -23,7 +23,6 @@ if Qti.migration_executable before(:once) do archive_file_path = File.join(BASE_FIXTURE_DIR, 'qti', 'qti_2_1.zip') unzipped_file_path = create_temp_dir! - create_temp_dir! exporter = Qti::Converter.new(:export_archive_path => archive_file_path, :base_download_dir => unzipped_file_path) exporter.export @course_data = exporter.course.with_indifferent_access diff --git a/gems/request_context/spec/request_context/session_spec.rb b/gems/request_context/spec/request_context/session_spec.rb index 300b2166409..96553a9183b 100644 --- a/gems/request_context/spec/request_context/session_spec.rb +++ b/gems/request_context/spec/request_context/session_spec.rb @@ -32,7 +32,7 @@ describe "RequestContext::Session" do end Rails.application = app_class.new env = { 'rack.session.options' => { id: 'abc' } } - _, headers, _ = RequestContext::Session.new(->(env) { + RequestContext::Session.new(->(_env) { [200, {}, []] }).call(env) expect(env['action_dispatch.cookies']['log_session_id']).to eq 'abc' diff --git a/lib/api/html/url_proxy.rb b/lib/api/html/url_proxy.rb index ab82d52d747..f0a60fe2e5e 100644 --- a/lib/api/html/url_proxy.rb +++ b/lib/api/html/url_proxy.rb @@ -153,7 +153,7 @@ module Api element[att] = val end end - rescue URI::Error => e + rescue URI::Error # leave it as is end end diff --git a/lib/api/v1/post_grades_status.rb b/lib/api/v1/post_grades_status.rb index b2a84fed8c9..eaa5a35ff3b 100644 --- a/lib/api/v1/post_grades_status.rb +++ b/lib/api/v1/post_grades_status.rb @@ -22,6 +22,6 @@ module Api::V1::PostGradesStatus include Api::V1::Json def post_grades_status_json(course_or_section) - res = course_or_section.sis_post_grades_statuses.last.as_json(:only => %w(id course_id course_section_id status message grades_posted_at)) + course_or_section.sis_post_grades_statuses.last.as_json(:only => %w(id course_id course_section_id status message grades_posted_at)) end end diff --git a/lib/brand_config_regenerator.rb b/lib/brand_config_regenerator.rb index b5ba9fb870c..3fc2e2e0974 100644 --- a/lib/brand_config_regenerator.rb +++ b/lib/brand_config_regenerator.rb @@ -101,7 +101,6 @@ class BrandConfigRegenerator new_config = config.clone_with_new_parent(new_parent_md5) new_config.save_unless_dup! - account = thing.is_a?(SharedBrandConfig) ? thing.account : thing job_type = thing.is_a?(SharedBrandConfig) ? :sync_to_s3_and_save_to_shared_brand_config! : :sync_to_s3_and_save_to_account! new_config.send(job_type, @progress, thing) diff --git a/lib/canvas.rb b/lib/canvas.rb index b38b9a0f58e..0794d7adc35 100644 --- a/lib/canvas.rb +++ b/lib/canvas.rb @@ -230,7 +230,7 @@ module Canvas begin Timeout.timeout(timeout, &block) - rescue Timeout::Error => e + rescue Timeout::Error error_ttl = timeout_protection_error_ttl(service_name) redis.incrby(redis_key, 1) redis.expire(redis_key, error_ttl) diff --git a/lib/canvas/dynamo_db/dev_utils.rb b/lib/canvas/dynamo_db/dev_utils.rb index e8841e688f0..0c52d8a30d7 100644 --- a/lib/canvas/dynamo_db/dev_utils.rb +++ b/lib/canvas/dynamo_db/dev_utils.rb @@ -42,7 +42,7 @@ module Canvas dynamodb = canvas_ddb.client local_table_name = canvas_ddb.prefixed_table_name(table_name) exists = begin - result = dynamodb.describe_table(table_name: local_table_name) + dynamodb.describe_table(table_name: local_table_name) true rescue Aws::DynamoDB::Errors::ResourceNotFoundException false diff --git a/lib/canvas/migration/worker/zip_file_worker.rb b/lib/canvas/migration/worker/zip_file_worker.rb index 04bc178be92..eb6c3eaf0d0 100644 --- a/lib/canvas/migration/worker/zip_file_worker.rb +++ b/lib/canvas/migration/worker/zip_file_worker.rb @@ -62,7 +62,6 @@ class Canvas::Migration::Worker::ZipFileWorker < Canvas::Migration::Worker::Base ) zipfile.close - zipfile = nil cm.workflow_state = :imported cm.save diff --git a/lib/canvas/plugins/ticketing_system/custom_error.rb b/lib/canvas/plugins/ticketing_system/custom_error.rb index 6f631a30486..57d3a3d8ec2 100644 --- a/lib/canvas/plugins/ticketing_system/custom_error.rb +++ b/lib/canvas/plugins/ticketing_system/custom_error.rb @@ -108,7 +108,7 @@ module Canvas::Plugins::TicketingSystem become_user_uri.query = (Hash[*(become_user_uri.query || '') .split('&').map { |part| part.split('=') }.flatten]) .merge({ 'become_user_id' => user_id }).to_query - rescue URI::Error => e + rescue URI::Error become_user_uri = "unable to parse uri: #{url}" end become_user_uri.to_s diff --git a/lib/cc/cc_helper.rb b/lib/cc/cc_helper.rb index f5ff1fdbb5b..b8cbf7db846 100644 --- a/lib/cc/cc_helper.rb +++ b/lib/cc/cc_helper.rb @@ -283,7 +283,7 @@ module CC @rewriter.set_handler('items') do |match| item = ContentTag.find(match.obj_id) migration_id = @key_generator.create_key(item) - new_url = "#{COURSE_TOKEN}/modules/#{match.type}/#{migration_id}#{match.query}" + "#{COURSE_TOKEN}/modules/#{match.type}/#{migration_id}#{match.query}" end @rewriter.set_default_handler do |match| new_url = match.url @@ -347,24 +347,24 @@ module CC media_id = anchor['id'].gsub(/^media_comment_/, '') obj = MediaObject.active.by_media_id(media_id).first - if obj && (migration_id = @key_generator.create_key(obj)) - @used_media_objects << obj - info = CCHelper.media_object_info(obj, course: @course, flavor: media_object_flavor) - @media_object_infos[obj.id] = info - anchor['href'] = File.join(WEB_CONTENT_TOKEN, info[:path]) - end + next unless obj && @key_generator.create_key(obj) + + @used_media_objects << obj + info = CCHelper.media_object_info(obj, course: @course, flavor: media_object_flavor) + @media_object_infos[obj.id] = info + anchor['href'] = File.join(WEB_CONTENT_TOKEN, info[:path]) end # process new RCE media iframes too doc.css('iframe[data-media-id]').each do |iframe| media_id = iframe['data-media-id'] obj = MediaObject.active.by_media_id(media_id).take - if obj && (migration_id = @key_generator.create_key(obj)) - @used_media_objects << obj - info = CCHelper.media_object_info(obj, course: @course, flavor: media_object_flavor) - @media_object_infos[obj.id] = info - iframe['src'] = File.join(WEB_CONTENT_TOKEN, info[:path]) - end + next unless obj && @key_generator.create_key(obj) + + @used_media_objects << obj + info = CCHelper.media_object_info(obj, course: @course, flavor: media_object_flavor) + @media_object_infos[obj.id] = info + iframe['src'] = File.join(WEB_CONTENT_TOKEN, info[:path]) end # prepend the Canvas domain to remaining absolute paths that are missing the host @@ -380,7 +380,7 @@ module CC if !url.host && url_str[0] == '/'[0] element[attribute] = "#{@url_prefix}#{url_str}" end - rescue URI::Error => e + rescue URI::Error # leave it as is end end @@ -432,7 +432,7 @@ module CC Rack::Utils.parse_query(uri.query).each do |k, v| qs << "canvas_qs_#{Rack::Utils.escape(k)}=#{Rack::Utils.escape(v)}" end - rescue URI::Error => e + rescue URI::Error # if we can't parse the url, we can't preserve canvas query params end return nil if qs.blank? diff --git a/lib/cc/exporter/epub/converters/files_converter.rb b/lib/cc/exporter/epub/converters/files_converter.rb index 69d7a07a688..d1bf47730fb 100644 --- a/lib/cc/exporter/epub/converters/files_converter.rb +++ b/lib/cc/exporter/epub/converters/files_converter.rb @@ -33,7 +33,7 @@ module CC::Exporter::Epub::Converters return flv_path unless mp4_url.present? # Maybe a weird exception to catch, but that's what ends up being thrown # if we pass a media_id that doesn't have a corresponding set of assets. - rescue NoMethodError => e + rescue NoMethodError return flv_path end diff --git a/lib/cc/importer/canvas/converter.rb b/lib/cc/importer/canvas/converter.rb index ba70d8729a1..d5641b8a4e0 100644 --- a/lib/cc/importer/canvas/converter.rb +++ b/lib/cc/importer/canvas/converter.rb @@ -42,8 +42,7 @@ module CC::Importer::Canvas end # exports the package into the intermediary json - def export(to_export = SCRAPE_ALL_HASH) - to_export = SCRAPE_ALL_HASH.merge to_export if to_export + def export(_to_export = SCRAPE_ALL_HASH) unzip_archive set_progress(5) diff --git a/lib/cc/importer/standard/assignment_converter.rb b/lib/cc/importer/standard/assignment_converter.rb index 7f24d63e0dd..564474c7706 100644 --- a/lib/cc/importer/standard/assignment_converter.rb +++ b/lib/cc/importer/standard/assignment_converter.rb @@ -83,7 +83,7 @@ module CC::Importer::Standard def parse_canvas_assignment_data(meta_doc, html_doc = nil, assignment = {}) if html_doc - title, body = get_html_title_and_body(html_doc) + _title, body = get_html_title_and_body(html_doc) assignment['description'] = body end diff --git a/lib/copy_authorized_links.rb b/lib/copy_authorized_links.rb index 3d7668bc85b..ac8cd5572fb 100644 --- a/lib/copy_authorized_links.rb +++ b/lib/copy_authorized_links.rb @@ -58,7 +58,6 @@ module CopyAuthorizedLinks end def copy_authorized_links_to_context - block = self.class.copy_authorized_links_block rescue nil columns = (self.class.copy_authorized_links_columns || []).compact columns.each do |column| if column == :custom @@ -68,8 +67,6 @@ module CopyAuthorizedLinks else html = self.read_attribute(column) rescue nil if html && !html.empty? - context, inferred_user = self.instance_eval(&block) if block - user = @copy_authorized_links_override_user || inferred_user self.write_attribute(column, html) if html && !html.empty? end end diff --git a/lib/course_link_validator.rb b/lib/course_link_validator.rb index bc029cf0493..cd26af2fc62 100644 --- a/lib/course_link_validator.rb +++ b/lib/course_link_validator.rb @@ -278,7 +278,7 @@ class CourseLinkValidator return :unpublished_item if object.workflow_state == 'unpublished' end nil - rescue => e + rescue :missing_item end diff --git a/lib/custom_validations.rb b/lib/custom_validations.rb index 66be8db998d..87494189e2f 100644 --- a/lib/custom_validations.rb +++ b/lib/custom_validations.rb @@ -23,7 +23,7 @@ module CustomValidations def validates_as_url(*fields, allowed_schemes: %w{http https}) validates_each(fields, :allow_nil => true) do |record, attr, value| begin - value, uri = CanvasHttp.validate_url(value, allowed_schemes: allowed_schemes) + value, = CanvasHttp.validate_url(value, allowed_schemes: allowed_schemes) record.send("#{attr}=", value) rescue CanvasHttp::Error, URI::Error, ArgumentError diff --git a/lib/data_fixup/create_lti_links_for_legacy_lti_tool_settings.rb b/lib/data_fixup/create_lti_links_for_legacy_lti_tool_settings.rb index ee9c0d1d2cd..9651a37ad54 100644 --- a/lib/data_fixup/create_lti_links_for_legacy_lti_tool_settings.rb +++ b/lib/data_fixup/create_lti_links_for_legacy_lti_tool_settings.rb @@ -25,14 +25,14 @@ module DataFixup::CreateLtiLinksForLegacyLtiToolSettings .where.not(resource_link_id: nil).find_each do |tool_setting| Lti::Link.transaction do originality_report = OriginalityReport.find_by(link_id: tool_setting.resource_link_id) - link = Lti::Link.create_with({ - product_code: tool_setting.product_code, - vendor_code: tool_setting.vendor_code, - resource_type_code: tool_setting.resource_type_code, - custom_parameters: tool_setting.custom_parameters, - resource_url: tool_setting.resource_url, - linkable: originality_report - }).find_or_create_by!(resource_link_id: tool_setting.resource_link_id) + Lti::Link.create_with({ + product_code: tool_setting.product_code, + vendor_code: tool_setting.vendor_code, + resource_type_code: tool_setting.resource_type_code, + custom_parameters: tool_setting.custom_parameters, + resource_url: tool_setting.resource_url, + linkable: originality_report + }).find_or_create_by!(resource_link_id: tool_setting.resource_link_id) end end end diff --git a/lib/data_fixup/reinsert_assessment_question_file_verifiers.rb b/lib/data_fixup/reinsert_assessment_question_file_verifiers.rb index cb89df36042..84b26e27852 100644 --- a/lib/data_fixup/reinsert_assessment_question_file_verifiers.rb +++ b/lib/data_fixup/reinsert_assessment_question_file_verifiers.rb @@ -27,7 +27,6 @@ module DataFixup::ReinsertAssessmentQuestionFileVerifiers if links.any? att_id_map = Hash[links.map { |l| [l, l.match(/\/assessment_questions\/\d+\/files\/(\d+)/)[1].to_i] }] uuid_map = Hash[Attachment.where(:id => att_id_map.values, :context_type => "AssessmentQuestion").pluck(:id, :uuid)] - new_data = data links.each do |link| uuid = uuid_map[att_id_map[link]] next unless uuid # just in case somehow the attachment disappeared diff --git a/lib/grade_calculator.rb b/lib/grade_calculator.rb index 8dbe2ebb04a..6e46f62da6e 100644 --- a/lib/grade_calculator.rb +++ b/lib/grade_calculator.rb @@ -870,7 +870,7 @@ class GradeCalculator max_total = (submissions + cant_drop).map { |s| s[:total] }.max kept = keep_highest(submissions, cant_drop, n_highest, max_total) - kept = keep_lowest(kept, cant_drop, n_lowest, max_total) + keep_lowest(kept, cant_drop, n_lowest, max_total) end def keep_highest(submissions, cant_drop, keep, max_total) diff --git a/lib/gradebook_importer.rb b/lib/gradebook_importer.rb index b4aeb123918..e7aa454d10a 100644 --- a/lib/gradebook_importer.rb +++ b/lib/gradebook_importer.rb @@ -642,7 +642,8 @@ class GradebookImporter # If the number of fields generated by this separator is consistent for all lines, # we should be able to assume it's a valid delimiter for this file field_counts[separator] = field_count_by_row.first if field_count_by_row.uniq.size == 1 - rescue CSV::MalformedCSVError => e + rescue CSV::MalformedCSVError + nil end end diff --git a/lib/inst_fs.rb b/lib/inst_fs.rb index 64a8ba75d09..07fc8e3084c 100644 --- a/lib/inst_fs.rb +++ b/lib/inst_fs.rb @@ -334,7 +334,7 @@ module InstFS # floor_to rounds `number` down to a multiple of the chosen step. def floor_to(number, step) - whole, remainder = number.divmod(step) + whole, = number.divmod(step) whole * step end diff --git a/lib/message_dispatcher.rb b/lib/message_dispatcher.rb index 92cd9a026aa..024bc87768d 100644 --- a/lib/message_dispatcher.rb +++ b/lib/message_dispatcher.rb @@ -80,12 +80,10 @@ class MessageDispatcher < Delayed::PerformableMethod raise ActiveRecord::RecordNotFound unless messages.length == queued.length end messages.each do |message| - begin - message.deliver - rescue Exception, Timeout::Error => e - # this delivery failed, we'll have to make an individual job to retry - self.dispatch(message) - end + message.deliver + rescue + # this delivery failed, we'll have to make an individual job to retry + self.dispatch(message) end end end diff --git a/lib/microsoft_sync/graph_service.rb b/lib/microsoft_sync/graph_service.rb index fdd11bf0336..554fe6f770c 100644 --- a/lib/microsoft_sync/graph_service.rb +++ b/lib/microsoft_sync/graph_service.rb @@ -114,8 +114,6 @@ module MicrosoftSync group_remove_user_requests(group_id, owners, 'owners') quota = [reqs.count, reqs.count] - expected_error = nil - ignored_request_ids = run_batch( 'group_remove_users', reqs, diff --git a/lib/plannable.rb b/lib/plannable.rb index 823a8f12a43..a0402c61c75 100644 --- a/lib/plannable.rb +++ b/lib/plannable.rb @@ -123,7 +123,7 @@ module Plannable rel_hash = nil end end - rel_array.reduce(object) { |val, key| val = val.send(key) } + rel_array.reduce(object) { |val, key| val.send(key) } end # Grabs the value to use for the bookmark & comparison diff --git a/lib/sis/course_importer.rb b/lib/sis/course_importer.rb index 0d8cb67fa7c..4b87dabc597 100644 --- a/lib/sis/course_importer.rb +++ b/lib/sis/course_importer.rb @@ -222,9 +222,9 @@ module SIS templated_course.save_without_broadcasting! Auditors::Course.record_updated(templated_course, @batch_user, changes, source: :sis, sis_batch_id: @batch_id) else - msg = "A (templated) course did not pass validation " - msg += "(" + "course: #{course_id} / #{short_name}, error: " + - msg += templated_course.errors.full_messages.join(",") + ")" + msg = "A (templated) course did not pass validation " \ + "(course: #{course_id} / #{short_name}, error: " \ + "#{templated_course.errors.full_messages.join(',')})" raise ImportError, msg end end @@ -236,9 +236,9 @@ module SIS data = SisBatchRollBackData.build_data(sis_batch: @batch, context: course) @roll_back_data << data if data else - msg = "A course did not pass validation " - msg += "(" + "course: #{course_id} / #{short_name}, error: " + - msg += course.errors.full_messages.join(",") + ")" + msg = "A course did not pass validation " \ + "(course: #{course_id} / #{short_name}, error: " \ + "#{course.errors.full_messages.join(',')})" raise ImportError, msg end @course_ids_to_update_associations.add(course.id) if update_account_associations diff --git a/lib/sis/csv/import_refactored.rb b/lib/sis/csv/import_refactored.rb index e7d16009234..d5a9e1f3883 100644 --- a/lib/sis/csv/import_refactored.rb +++ b/lib/sis/csv/import_refactored.rb @@ -266,7 +266,7 @@ module SIS parallel_importer.complete(rows_processed: count) # just update progress on completion - the parallel jobs should be short enough update_progress unless skip_progress - rescue ::CSV::MalformedCSVError => csv_err + rescue ::CSV::MalformedCSVError # sometimes the file we get from s3 is incomplete. # it would be really hard to get a true malformed csv error because # we parse the file in order to count the rows for splitting it up in the first place, diff --git a/lib/submission_list.rb b/lib/submission_list.rb index f3497bc843c..e5cbce8d730 100644 --- a/lib/submission_list.rb +++ b/lib/submission_list.rb @@ -172,7 +172,6 @@ class SubmissionList # Returns an array of assignments with an array of submission open structs. def assignments_for_grader_and_day(grader, day) - start = Time.now hsh = submission_entries.find_all { |e| e[:grader] == grader and e[:graded_on] == day }.inject({}) do |h, submission| assignment = submission[:assignment_name] h[assignment] ||= OpenObject.new( diff --git a/lib/turnitin.rb b/lib/turnitin.rb index bf3c638246d..5e84956687c 100644 --- a/lib/turnitin.rb +++ b/lib/turnitin.rb @@ -80,7 +80,7 @@ module Turnitin elsif item.respond_to?(:turnitin_id) "#{item.turnitin_asset_string}@null.instructure.example.com" end - email ||= "#{item.asset_string}@null.instructure.example.com" + email || "#{item.asset_string}@null.instructure.example.com" end TurnitinUser = Struct.new(:asset_string, :first_name, :last_name, :name) @@ -211,7 +211,6 @@ module Turnitin end def generateReport(submission, asset_string) - user = submission.user assignment = submission.assignment course = assignment.context object_id = submission.turnitin_data[asset_string][:object_id] rescue nil @@ -228,7 +227,6 @@ module Turnitin end def submissionReportUrl(submission, asset_string) - user = submission.user assignment = submission.assignment course = assignment.context object_id = submission.turnitin_data[asset_string][:object_id] rescue nil @@ -357,8 +355,8 @@ module Turnitin req = Net::HTTP::Post.new(@endpoint, headers) con.read_timeout = 30 begin - res = con.request(req, query) - rescue => e + con.request(req, query) + rescue Rails.logger.error("Turnitin API error for account_id #{@account_id}: POSTING FAILED") Rails.logger.error(params.to_json) end diff --git a/lib/unzip_attachment.rb b/lib/unzip_attachment.rb index 4d17ab1e6ac..5026323e038 100644 --- a/lib/unzip_attachment.rb +++ b/lib/unzip_attachment.rb @@ -101,7 +101,7 @@ class UnzipAttachment folder_path_array = path_elements_for(@context_files_folder.full_name) entry_path_array = path_elements_for(entry.name) - filename = entry_path_array.pop + entry_path_array.pop folder_path_array += entry_path_array folder_name = folder_path_array.join('/') @@ -197,7 +197,7 @@ class UnzipAttachment # Creates a title-ized name from a path. # So, display_name(/tmp/foo/bar_baz) generates 'Bar baz' def display_name(path) - display_name = File.split(path).last + File.split(path).last end # Finds the folder in the database, creating the path if necessary @@ -230,7 +230,6 @@ class UnzipAttachment @folders = nil if reset return @folders if @folders - root_folders = Folder.root_folders(self.context) @folders = OpenStruct.new(:root_directory => self.context_files_folder) end end diff --git a/lib/vericite.rb b/lib/vericite.rb index 0e754936ed2..c1f011bd7c3 100644 --- a/lib/vericite.rb +++ b/lib/vericite.rb @@ -62,7 +62,7 @@ module VeriCite email = if item.is_a?(User) item.email end - email ||= "#{item.asset_string}@null.instructure.example.com" + email || "#{item.asset_string}@null.instructure.example.com" end def self.default_assignment_vericite_settings @@ -234,7 +234,7 @@ module VeriCite assignment_data.assignment_due_date = assignment.due_at.to_time.utc.to_i * 1000 end assignment_data.assignment_grade = assignment.points_possible != nil ? assignment.points_possible : -1 - data, status_code, headers = vericite_client.assignments_context_id_assignment_id_post(context_id, assignment_id, consumer, consumer_secret, assignment_data) + _data, status_code, _headers = vericite_client.assignments_context_id_assignment_id_post(context_id, assignment_id, consumer, consumer_secret, assignment_data) # check status code response[:return_code] = status_code if !is_response_success?(response) @@ -266,7 +266,7 @@ module VeriCite external_content_data.upload_content_length = args[:psize] report_meta_data.external_content_data = external_content_data # @return [Array] - data, status_code, headers = vericite_client.reports_submit_request_context_id_assignment_id_user_id_post(context_id, assignment_id, user_id, consumer, consumer_secret, report_meta_data) + data, status_code, _headers = vericite_client.reports_submit_request_context_id_assignment_id_user_id_post(context_id, assignment_id, user_id, consumer, consumer_secret, report_meta_data) # check status code response[:return_code] = status_code if !is_response_success?(response) @@ -341,7 +341,7 @@ module VeriCite token_user_role = 'Instructor' end # @return [Array] - data, status_code, headers = vericite_client.reports_urls_context_id_get(context_id, assignment_id_filter, consumer, consumer_secret, token_user, token_user_role, { user_id_filter => user_id, external_content_id_filter => args[:oid] }) + data, status_code, _headers = vericite_client.reports_urls_context_id_get(context_id, assignment_id_filter, consumer, consumer_secret, token_user, token_user_role, { user_id_filter => user_id, external_content_id_filter => args[:oid] }) # check status code response[:return_code] = status_code if !is_response_success?(response)