RuboCop: Style/NegatedUnless, Style/NegatedWhile

auto-corrected

Change-Id: I382bbd776e89244784652751a7efb642827d0209
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278762
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2021-11-18 09:12:24 -07:00
parent fb1ec2e450
commit d6cc861d50
12 changed files with 16 additions and 12 deletions

View File

@ -226,6 +226,10 @@ Style/MutableConstant:
Severity: error
Style/NegatedIf:
Severity: error
Style/NegatedUnless:
Severity: error
Style/NegatedWhile:
Severity: error
Style/NumericPredicate:
Enabled: false # `> 0` can be easier to read than `.positive?`
Style/OrAssignment:

View File

@ -777,7 +777,7 @@ class Attachment < ActiveRecord::Base
valid_name = false
self.shard.activate do
iter_count = 1
while !valid_name
until valid_name
existing_names = self.folder.active_file_attachments.where.not(id: self.id).pluck(:display_name)
new_name = opts[:name] || self.display_name
self.display_name = Attachment.make_unique_filename(new_name, existing_names, iter_count)

View File

@ -74,7 +74,7 @@ class KalturaMediaFileHandler
Rails.logger.debug "waiting for bulk upload id: #{bulk_upload_id}"
started_at = Time.now
timeout = Setting.get('media_bulk_upload_timeout', 30.minutes.to_s).to_i
while !res[:ready]
until res[:ready]
if Time.now > started_at + timeout
refresh_later(res[:id], attachments, root_account_id)
break

View File

@ -165,7 +165,7 @@ class Quizzes::QuizSubmission < ActiveRecord::Base
end
def temporary_data
raise "Cannot view temporary data for completed quiz" unless !self.completed?
raise "Cannot view temporary data for completed quiz" if self.completed?
raise "Cannot view temporary data for completed quiz" if graded?
(self.submission_data || {}).with_indifferent_access

View File

@ -23,7 +23,7 @@ load_cache_config = -> do
searched = Set.new
clusters_to_search = Switchman::DatabaseServer.all.map(&:id)
while !clusters_to_search.empty?
until clusters_to_search.empty?
cluster = clusters_to_search.shift
next if searched.include?(cluster)

View File

@ -30,7 +30,7 @@ module AttachmentFu # :nodoc:
# Yields a block containing an MiniMagick Image for the given binary data.
def with_image(file)
begin
binary_data = file.is_a?(MiniMagick::Image) ? file : MiniMagick::Image.open(file) unless !Object.const_defined?(:MiniMagick)
binary_data = file.is_a?(MiniMagick::Image) ? file : MiniMagick::Image.open(file) if Object.const_defined?(:MiniMagick)
rescue
# Log the failure to load the image.
logger.debug("Exception working with image: #{$!}")

View File

@ -552,7 +552,7 @@ module AccountReports::ReportHelper
def read_csv_in_chunks(filename, chunk_size = 1000)
CSV.open(filename) do |csv|
rows = []
while !(row = csv.readline).nil?
until (row = csv.readline).nil?
rows << row
if rows.size == chunk_size
yield rows

View File

@ -46,7 +46,7 @@ module ActiveSupport::Cache::SafeRedisRaceCondition
lock_key = "lock:#{key}"
unless entry
while !entry
until entry
unless (lock_nonce = lock(lock_key, options))
# someone else is already generating it; wait for them
sleep 0.1

View File

@ -130,7 +130,7 @@ module SIS
return unless any_left_to_process?
enrollment_info = nil
while !@enrollment_batch.empty?
until @enrollment_batch.empty?
enrollment_info = @enrollment_batch.shift
@last_section = @section if @section

View File

@ -124,7 +124,7 @@ namespace :db do
unless user
require 'highline/import'
while !Rails.env.test? do
until Rails.env.test? do
if telemetry_enabled?
print "\e[33mInput fields will be hidden to ensure that entered data will not be sent to the telemetry service.\nWe do not recommend using sensitive data for development environments.\e[0m\n"

View File

@ -188,8 +188,8 @@ module TextHelper
end
# remove everything else
while !current.is_a?(Nokogiri::HTML::Document)
while !current.next.nil?
until current.is_a?(Nokogiri::HTML::Document)
until current.next.nil?
current.next.remove
end
current = current.parent

View File

@ -383,7 +383,7 @@ module VeriCite
end
def response_error_hash(response)
return {} unless !is_response_success?(response)
return {} if is_response_success?(response)
{
error_code: response[:return_code],