Skip to content

Commit

Permalink
Revert "RuboCop: update to 1.22.0"
Browse files Browse the repository at this point in the history
This reverts commit 3fdd418.

Reason for revert: Jenkins broke

Change-Id: I981c14d5db293289c40576bd425c25d1933c1935
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274304
Tested-by: Service Cloud Jenkins <[email protected]>
QA-Review: Aaron Ogata <[email protected]>
Product-Review: Aaron Ogata <[email protected]>
Reviewed-by: Kyle Rosenbaum <[email protected]>
  • Loading branch information
aogata-inst committed Sep 30, 2021
1 parent 3fdd418 commit eb44849
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Gemfile.d/rubocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
gem 'gergich', '2.0.0', require: false
gem 'mime-types-data', '3.2021.0901', require: false

gem 'rubocop', '1.22.0', require: false
gem 'rubocop', '1.21.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"
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.d/rubocop.rb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ GEM
rainbow (3.0.0)
regexp_parser (1.8.2)
rexml (3.2.5)
rubocop (1.22.0)
rubocop (1.21.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.12.0, < 2.0)
rubocop-ast (>= 1.9.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.12.0)
Expand Down Expand Up @@ -88,7 +88,7 @@ DEPENDENCIES
parallel (= 1.21.0)
rainbow (= 3.0.0)
regexp_parser (= 1.8.2)
rubocop (= 1.22.0)
rubocop (= 1.21.0)
rubocop-ast (= 1.12.0)
rubocop-canvas!
rubocop-performance (= 1.11.5)
Expand Down
12 changes: 6 additions & 6 deletions app/models/attachments/garbage_collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ def initialize(older_than: ContentExport.expire_days.days.ago, dry_run: false)
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
Expand All @@ -206,20 +206,20 @@ def initialize(older_than: ContentMigration.expire_days.days.ago, dry_run: false
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
Expand Down
8 changes: 4 additions & 4 deletions app/models/learning_outcome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,14 @@ def clear_total_outcomes_cache
.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?
Expand Down
12 changes: 6 additions & 6 deletions app/models/rubric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,28 +97,28 @@ def self.aligned_to_outcomes
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ def simple_outcome_scope
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')
Expand Down
54 changes: 27 additions & 27 deletions gems/plugins/account_reports/lib/account_reports/outcome_reports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def student_assignment_outcome_map_scope

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",
Expand Down Expand Up @@ -222,32 +222,32 @@ def outcome_results_scope
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')")
Expand Down
4 changes: 2 additions & 2 deletions lib/data_fixup/add_post_policies_to_assignments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def self.set_submission_posted_at_dates(start_at, end_at)
.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
ELSE
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

Expand Down
2 changes: 2 additions & 0 deletions lib/gradebook_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def parse!
@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]

Expand All @@ -243,6 +244,7 @@ def parse!

no_change || !submission['gradeable']
end
# rubocop:enable Lint/AssignmentInCondition
end

custom_column_ids_to_skip_on_import = []
Expand Down
4 changes: 2 additions & 2 deletions lib/messageable_user/calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -837,13 +837,13 @@ def uncached_messageable_groups
.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' })
Expand Down

0 comments on commit eb44849

Please sign in to comment.