RuboCop: update to 1.22.0
* Layout/DotPosition now handles heredocs (auto-correct, including cascading layout fixes) * Lint/AssignmentInCondition now ignores assignments-in-blocks-in conditions, so can remove explicit disabling Change-Id: I476c0d54cf6d38fc3b009d7057f7e6082465240d Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274756 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
a61047237d
commit
3fdd418bc0
|
@ -31,7 +31,7 @@ group :test do
|
|||
gem 'gergich', '2.0.0', require: false
|
||||
gem 'mime-types-data', '3.2021.0901', require: false
|
||||
|
||||
gem 'rubocop', '1.21.0', require: false
|
||||
gem 'rubocop', '1.22.0', require: false
|
||||
gem 'rubocop-ast', '1.12.0', require: false
|
||||
gem 'unicode-display_width', '2.1.0', require: false
|
||||
gem 'rubocop-canvas', require: false, path: "#{'../' if dedicated_gemfile}gems/rubocop-canvas"
|
||||
|
|
|
@ -45,13 +45,13 @@ GEM
|
|||
rainbow (3.0.0)
|
||||
regexp_parser (1.8.2)
|
||||
rexml (3.2.5)
|
||||
rubocop (1.21.0)
|
||||
rubocop (1.22.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.0.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml
|
||||
rubocop-ast (>= 1.9.1, < 2.0)
|
||||
rubocop-ast (>= 1.12.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.12.0)
|
||||
|
@ -88,7 +88,7 @@ DEPENDENCIES
|
|||
parallel (= 1.21.0)
|
||||
rainbow (= 3.0.0)
|
||||
regexp_parser (= 1.8.2)
|
||||
rubocop (= 1.21.0)
|
||||
rubocop (= 1.22.0)
|
||||
rubocop-ast (= 1.12.0)
|
||||
rubocop-canvas!
|
||||
rubocop-performance (= 1.11.5)
|
||||
|
|
|
@ -181,12 +181,12 @@ class Attachments::GarbageCollector
|
|||
def delete_rows
|
||||
raise "Cannot delete rows in dry_run mode" if dry_run
|
||||
|
||||
null_scope = ContentExport.joins(<<~SQL).
|
||||
null_scope = ContentExport.joins(<<~SQL)
|
||||
INNER JOIN #{Attachment.quoted_table_name}
|
||||
ON attachments.context_type = 'ContentExport'
|
||||
AND content_exports.attachment_id = attachments.id
|
||||
SQL
|
||||
where(attachments: { workflow_state: 'deleted', file_state: 'deleted' })
|
||||
.where(attachments: { workflow_state: 'deleted', file_state: 'deleted' })
|
||||
while null_scope.limit(1000).update_all(attachment_id: nil) > 0; end
|
||||
super
|
||||
end
|
||||
|
@ -206,20 +206,20 @@ class Attachments::GarbageCollector
|
|||
def delete_rows
|
||||
raise "Cannot delete rows in dry_run mode" if dry_run
|
||||
|
||||
ce_null_scope = ContentExport.joins(<<~SQL).
|
||||
ce_null_scope = ContentExport.joins(<<~SQL)
|
||||
INNER JOIN #{Attachment.quoted_table_name}
|
||||
ON attachments.context_type = 'ContentExport'
|
||||
AND content_exports.attachment_id = attachments.id
|
||||
SQL
|
||||
where(attachments: { workflow_state: 'deleted', file_state: 'deleted' })
|
||||
.where(attachments: { workflow_state: 'deleted', file_state: 'deleted' })
|
||||
while ce_null_scope.limit(1000).update_all(attachment_id: nil) > 0; end
|
||||
|
||||
cm_null_scope = ContentMigration.joins(<<~SQL).
|
||||
cm_null_scope = ContentMigration.joins(<<~SQL)
|
||||
INNER JOIN #{Attachment.quoted_table_name}
|
||||
ON attachments.context_type IN ('ContentMigration', 'ContentExport')
|
||||
AND content_migrations.attachment_id = attachments.id
|
||||
SQL
|
||||
where(attachments: { workflow_state: 'deleted', file_state: 'deleted' })
|
||||
.where(attachments: { workflow_state: 'deleted', file_state: 'deleted' })
|
||||
while cm_null_scope.limit(1000).update_all(attachment_id: nil) > 0; end
|
||||
|
||||
super
|
||||
|
|
|
@ -466,14 +466,14 @@ class LearningOutcome < ActiveRecord::Base
|
|||
.active
|
||||
.distinct
|
||||
.where(content_id: id)
|
||||
.select(<<-SQL).
|
||||
.select(<<-SQL)
|
||||
root_account_id,
|
||||
(CASE WHEN context_type='LearningOutcomeGroup' THEN NULL ELSE context_type END) context_type,
|
||||
(CASE WHEN context_type='LearningOutcomeGroup' THEN NULL ELSE context_id END) context_id
|
||||
SQL
|
||||
map do |ct|
|
||||
Outcomes::LearningOutcomeGroupChildren.new(ct.context).clear_total_outcomes_cache
|
||||
end
|
||||
.map do |ct|
|
||||
Outcomes::LearningOutcomeGroupChildren.new(ct.context).clear_total_outcomes_cache
|
||||
end
|
||||
end
|
||||
|
||||
def improved_outcomes_management?
|
||||
|
|
|
@ -97,28 +97,28 @@ class Rubric < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.with_at_most_one_association
|
||||
joins(<<~JOINS).
|
||||
joins(<<~JOINS)
|
||||
LEFT JOIN #{RubricAssociation.quoted_table_name} associations_for_count
|
||||
ON rubrics.id = associations_for_count.rubric_id
|
||||
AND associations_for_count.purpose = 'grading'
|
||||
AND associations_for_count.workflow_state = 'active'
|
||||
JOINS
|
||||
group('rubrics.id')
|
||||
.having('COUNT(rubrics.id) < 2')
|
||||
.group('rubrics.id')
|
||||
.having('COUNT(rubrics.id) < 2')
|
||||
end
|
||||
|
||||
def self.unassessed
|
||||
joins(<<~JOINS).
|
||||
joins(<<~JOINS)
|
||||
LEFT JOIN #{RubricAssociation.quoted_table_name} associations_for_unassessed
|
||||
ON rubrics.id = associations_for_unassessed.rubric_id
|
||||
AND associations_for_unassessed.purpose = 'grading'
|
||||
AND associations_for_unassessed.workflow_state = 'active'
|
||||
JOINS
|
||||
joins(<<~JOINS).
|
||||
.joins(<<~JOINS)
|
||||
LEFT JOIN #{RubricAssessment.quoted_table_name} assessments_for_unassessed
|
||||
ON associations_for_unassessed.id = assessments_for_unassessed.rubric_association_id
|
||||
JOINS
|
||||
where(assessments_for_unassessed: { id: nil })
|
||||
.where(assessments_for_unassessed: { id: nil })
|
||||
end
|
||||
|
||||
def default_values
|
||||
|
|
|
@ -113,11 +113,11 @@ module AccountReports
|
|||
end
|
||||
|
||||
def outcome_scope
|
||||
simple_outcome_scope.joins(<<~SQL).
|
||||
simple_outcome_scope.joins(<<~SQL)
|
||||
JOIN #{LearningOutcomeGroup.quoted_table_name} learning_outcome_groups
|
||||
ON learning_outcome_groups.id = content_tags.associated_asset_id
|
||||
SQL
|
||||
where("learning_outcomes.workflow_state <> 'deleted'")
|
||||
.where("learning_outcomes.workflow_state <> 'deleted'")
|
||||
.order('learning_outcomes.id')
|
||||
.group('learning_outcomes.id')
|
||||
.group('content_tags.content_id')
|
||||
|
|
|
@ -187,7 +187,7 @@ module AccountReports
|
|||
|
||||
def outcome_results_scope
|
||||
students = account.learning_outcome_links.active
|
||||
.select(<<~SELECT).
|
||||
.select(<<~SELECT)
|
||||
distinct on (#{outcome_order}, p.id, s.id, r.id, qr.id, q.id, a.id, subs.id, qs.id, aq.id)
|
||||
u.sortable_name AS "student name",
|
||||
p.user_id AS "student id",
|
||||
|
@ -222,32 +222,32 @@ module AccountReports
|
|||
acct.id AS "account id",
|
||||
acct.name AS "account name"
|
||||
SELECT
|
||||
joins(<<~JOINS).
|
||||
INNER JOIN #{LearningOutcome.quoted_table_name} ON content_tags.content_id = learning_outcomes.id
|
||||
AND content_tags.content_type = 'LearningOutcome'
|
||||
INNER JOIN #{LearningOutcomeResult.quoted_table_name} r ON r.learning_outcome_id = learning_outcomes.id
|
||||
INNER JOIN #{ContentTag.quoted_table_name} ct ON r.content_tag_id = ct.id
|
||||
INNER JOIN #{User.quoted_table_name} u ON u.id = r.user_id
|
||||
INNER JOIN #{Pseudonym.quoted_table_name} p on p.user_id = r.user_id
|
||||
INNER JOIN #{Course.quoted_table_name} c ON r.context_id = c.id
|
||||
INNER JOIN #{Account.quoted_table_name} acct ON acct.id = c.account_id
|
||||
INNER JOIN #{Enrollment.quoted_table_name} e ON e.type = 'StudentEnrollment' and e.root_account_id = #{account.root_account.id}
|
||||
AND e.user_id = p.user_id AND e.course_id = c.id
|
||||
#{@include_deleted ? '' : "AND e.workflow_state <> 'deleted'"}
|
||||
INNER JOIN #{CourseSection.quoted_table_name} s ON e.course_section_id = s.id
|
||||
LEFT OUTER JOIN #{LearningOutcomeQuestionResult.quoted_table_name} qr on qr.learning_outcome_result_id = r.id
|
||||
LEFT OUTER JOIN #{Quizzes::Quiz.quoted_table_name} q ON q.id = r.association_id
|
||||
AND r.association_type IN ('Quiz', 'Quizzes::Quiz')
|
||||
LEFT OUTER JOIN #{Assignment.quoted_table_name} a ON (a.id = ct.content_id
|
||||
AND ct.content_type = 'Assignment') OR a.id = q.assignment_id
|
||||
LEFT OUTER JOIN #{Submission.quoted_table_name} subs ON subs.assignment_id = a.id
|
||||
AND subs.user_id = u.id AND subs.workflow_state <> 'deleted' AND subs.workflow_state <> 'unsubmitted'
|
||||
LEFT OUTER JOIN #{Quizzes::QuizSubmission.quoted_table_name} qs ON r.artifact_id = qs.id
|
||||
AND r.artifact_type IN ('QuizSubmission', 'Quizzes::QuizSubmission')
|
||||
LEFT OUTER JOIN #{AssessmentQuestion.quoted_table_name} aq ON aq.id = qr.associated_asset_id
|
||||
AND qr.associated_asset_type = 'AssessmentQuestion'
|
||||
JOINS
|
||||
where("ct.workflow_state <> 'deleted' AND r.workflow_state <> 'deleted' AND r.artifact_type <> 'Submission'")
|
||||
.joins(<<~JOINS)
|
||||
INNER JOIN #{LearningOutcome.quoted_table_name} ON content_tags.content_id = learning_outcomes.id
|
||||
AND content_tags.content_type = 'LearningOutcome'
|
||||
INNER JOIN #{LearningOutcomeResult.quoted_table_name} r ON r.learning_outcome_id = learning_outcomes.id
|
||||
INNER JOIN #{ContentTag.quoted_table_name} ct ON r.content_tag_id = ct.id
|
||||
INNER JOIN #{User.quoted_table_name} u ON u.id = r.user_id
|
||||
INNER JOIN #{Pseudonym.quoted_table_name} p on p.user_id = r.user_id
|
||||
INNER JOIN #{Course.quoted_table_name} c ON r.context_id = c.id
|
||||
INNER JOIN #{Account.quoted_table_name} acct ON acct.id = c.account_id
|
||||
INNER JOIN #{Enrollment.quoted_table_name} e ON e.type = 'StudentEnrollment' and e.root_account_id = #{account.root_account.id}
|
||||
AND e.user_id = p.user_id AND e.course_id = c.id
|
||||
#{@include_deleted ? '' : "AND e.workflow_state <> 'deleted'"}
|
||||
INNER JOIN #{CourseSection.quoted_table_name} s ON e.course_section_id = s.id
|
||||
LEFT OUTER JOIN #{LearningOutcomeQuestionResult.quoted_table_name} qr on qr.learning_outcome_result_id = r.id
|
||||
LEFT OUTER JOIN #{Quizzes::Quiz.quoted_table_name} q ON q.id = r.association_id
|
||||
AND r.association_type IN ('Quiz', 'Quizzes::Quiz')
|
||||
LEFT OUTER JOIN #{Assignment.quoted_table_name} a ON (a.id = ct.content_id
|
||||
AND ct.content_type = 'Assignment') OR a.id = q.assignment_id
|
||||
LEFT OUTER JOIN #{Submission.quoted_table_name} subs ON subs.assignment_id = a.id
|
||||
AND subs.user_id = u.id AND subs.workflow_state <> 'deleted' AND subs.workflow_state <> 'unsubmitted'
|
||||
LEFT OUTER JOIN #{Quizzes::QuizSubmission.quoted_table_name} qs ON r.artifact_id = qs.id
|
||||
AND r.artifact_type IN ('QuizSubmission', 'Quizzes::QuizSubmission')
|
||||
LEFT OUTER JOIN #{AssessmentQuestion.quoted_table_name} aq ON aq.id = qr.associated_asset_id
|
||||
AND qr.associated_asset_type = 'AssessmentQuestion'
|
||||
JOINS
|
||||
.where("ct.workflow_state <> 'deleted' AND r.workflow_state <> 'deleted' AND r.artifact_type <> 'Submission'")
|
||||
|
||||
unless @include_deleted
|
||||
students = students.where("p.workflow_state<>'deleted' AND c.workflow_state IN ('available', 'completed')")
|
||||
|
|
|
@ -28,7 +28,7 @@ module DataFixup::AddPostPoliciesToAssignments
|
|||
.find_ids_in_batches do |submission_ids|
|
||||
Submission.joins(:assignment)
|
||||
.where(id: submission_ids)
|
||||
.where(<<~SQL).
|
||||
.where(<<~SQL)
|
||||
CASE assignments.muted
|
||||
WHEN TRUE
|
||||
THEN posted_at IS NOT NULL
|
||||
|
@ -36,7 +36,7 @@ module DataFixup::AddPostPoliciesToAssignments
|
|||
graded_at IS NOT NULL AND posted_at IS NULL OR graded_at IS NULL AND posted_at IS NOT NULL OR posted_at<>graded_at
|
||||
END
|
||||
SQL
|
||||
update_all("posted_at = (CASE assignments.muted WHEN TRUE THEN NULL ELSE graded_at END), updated_at = NOW()")
|
||||
.update_all("posted_at = (CASE assignments.muted WHEN TRUE THEN NULL ELSE graded_at END), updated_at = NOW()")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -231,7 +231,6 @@ class GradebookImporter
|
|||
@assignments.each_with_index do |assignment, idx|
|
||||
next if assignment.changed? && !readonly_assignment?(assignment)
|
||||
|
||||
# rubocop:disable Lint/AssignmentInCondition https://github.com/rubocop/rubocop/issues/10136
|
||||
indexes_to_delete << idx if readonly_assignment?(assignment) || @students.all? do |student|
|
||||
submission = @gradebook_importer_assignments[student.id][idx]
|
||||
|
||||
|
@ -244,7 +243,6 @@ class GradebookImporter
|
|||
|
||||
no_change || !submission['gradeable']
|
||||
end
|
||||
# rubocop:enable Lint/AssignmentInCondition
|
||||
end
|
||||
|
||||
custom_column_ids_to_skip_on_import = []
|
||||
|
|
|
@ -837,13 +837,13 @@ class MessageableUser
|
|||
.select("group_memberships.group_id AS group_id")
|
||||
.distinct
|
||||
.joins(:user, :group)
|
||||
.joins(<<~SQL).
|
||||
.joins(<<~SQL)
|
||||
INNER JOIN #{Enrollment.quoted_table_name} ON
|
||||
enrollments.user_id=users.id AND
|
||||
enrollments.course_id=groups.context_id
|
||||
INNER JOIN #{Course.quoted_table_name} ON courses.id=enrollments.course_id
|
||||
SQL
|
||||
where(:workflow_state => 'accepted')
|
||||
.where(:workflow_state => 'accepted')
|
||||
.where("groups.workflow_state<>'deleted'")
|
||||
.where(MessageableUser::AVAILABLE_CONDITIONS)
|
||||
.where(:groups => { :context_type => 'Course' })
|
||||
|
|
Loading…
Reference in New Issue