Skip to content

Commit

Permalink
RuboCop: Style/RedundantSelf
Browse files Browse the repository at this point in the history
[skip-stages=Flakey]

auto-corrected

Change-Id: I5f26ad1f8210a74c2198b514235d5134dcd0dae1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279070
Reviewed-by: Jacob Burroughs <[email protected]>
QA-Review: Cody Cutrer <[email protected]>
Product-Review: Cody Cutrer <[email protected]>
Migration-Review: Cody Cutrer <[email protected]>
Tested-by: Service Cloud Jenkins <[email protected]>
  • Loading branch information
ccutrer committed Nov 20, 2021
1 parent 4287654 commit ff99d18
Show file tree
Hide file tree
Showing 410 changed files with 5,567 additions and 5,593 deletions.
4 changes: 2 additions & 2 deletions .rubocop.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ Style/RedundantRegexpEscape:
Severity: error
Style/RedundantReturn:
Severity: error
Style/RedundantSelf:
Severity: error
Style/RedundantSelfAssignment:
Severity: error
Style/RedundantSelfAssignmentBranch:
Expand Down Expand Up @@ -485,8 +487,6 @@ Style/NumericLiterals: # TODO: autocorrect
Enabled: false
Style/ParallelAssignment: # TODO: autocorrect (with probable exceptions)
Enabled: false
Style/RedundantSelf: # TODO: autocorrect
Enabled: false
Style/RescueModifier: # TODO
Severity: warning
AutoCorrect: false
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,11 @@ def named_context_url(context, name, *opts)
# rubocop:enable Style/RescueModifier
opts[-1][:only_path] = true unless name.end_with?("_path")
end
self.send name, *opts
send name, *opts
end

def self.promote_view_path(path)
self.view_paths = self.view_paths.to_ary.reject { |p| p.to_s == path }
self.view_paths = view_paths.to_ary.reject { |p| p.to_s == path }
prepend_view_path(path)
end

Expand Down Expand Up @@ -976,7 +976,7 @@ def get_context(include_deleted: false)
end
@context_membership = @context_enrollment
check_for_readonly_enrollment_state
elsif params[:account_id] || (self.is_a?(AccountsController) && (params[:account_id] = params[:id]))
elsif params[:account_id] || (is_a?(AccountsController) && (params[:account_id] = params[:id]))
@context = api_find(Account.active, params[:account_id])
params[:context_id] = @context.id
params[:context_type] = "Account"
Expand All @@ -989,13 +989,13 @@ def get_context(include_deleted: false)
params[:context_type] = "Group"
@context_enrollment = @context.group_memberships.where(user_id: @current_user).first if @context && @current_user
@context_membership = @context_enrollment
elsif params[:user_id] || (self.is_a?(UsersController) && (params[:user_id] = params[:id]))
elsif params[:user_id] || (is_a?(UsersController) && (params[:user_id] = params[:id]))
scope = include_deleted ? User : User.active
@context = api_find(scope, params[:user_id])
params[:context_id] = params[:user_id]
params[:context_type] = "User"
@context_membership = @context if @context == @current_user
elsif params[:course_section_id] || (self.is_a?(SectionsController) && (params[:course_section_id] = params[:id]))
elsif params[:course_section_id] || (is_a?(SectionsController) && (params[:course_section_id] = params[:id]))
params[:context_id] = params[:course_section_id]
params[:context_type] = "CourseSection"
@context = api_find(CourseSection, params[:course_section_id])
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ def edit
hash[:CONTEXT_ACTION_SOURCE] = :assignments
hash[:DUE_DATE_REQUIRED_FOR_ACCOUNT] = AssignmentUtil.due_date_required_for_account?(@context)
hash[:MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT] = AssignmentUtil.name_length_required_for_account?(@context)
hash[:MAX_NAME_LENGTH] = self.try(:context).try(:account).try(:sis_assignment_name_length_input).try(:[], :value).to_i
hash[:MAX_NAME_LENGTH] = try(:context).try(:account).try(:sis_assignment_name_length_input).try(:[], :value).to_i

selected_tool = @assignment.tool_settings_tool
hash[:SELECTED_CONFIG_TOOL_ID] = selected_tool ? selected_tool.id : nil
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/context_modules_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def index

if includes.include?('items')
if @context.user_has_been_observer?(@student || @current_user)
opts[:observed_student_ids] = ObserverEnrollment.observed_student_ids(self.context, (@student || @current_user))
opts[:observed_student_ids] = ObserverEnrollment.observed_student_ids(context, (@student || @current_user))
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/gradebooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def show_learning_mastery
private :show_learning_mastery

def post_grades_ltis
@post_grades_ltis ||= self.external_tools.map { |tool| external_tool_detail(tool) }
@post_grades_ltis ||= external_tools.map { |tool| external_tool_detail(tool) }
end

def external_tool_detail(tool)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/lti/concerns/sessionless_launches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def assignment_launch_link(assignment, session_token)

def course_or_account_launch_link(context, tool, session_token, launch_url)
context_type = context.class.to_s.downcase
self.send(
send(
"#{context_type}_external_tool_url",
context.id,
id: tool.id,
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/media_objects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def update_media_object
)
end

self.extend TextHelper
extend TextHelper
@media_object.user_entered_title =
CanvasTextHelper.truncate_text(params[:user_entered_title], max_length: 255)
@media_object.save!
Expand All @@ -198,7 +198,7 @@ def create_media_object

if authorized_action(@context, @current_user, :read)
if params[:id] && params[:type] && @context.respond_to?(:media_objects)
self.extend TextHelper
extend TextHelper

# The MediaObject will be created on the current shard,
# not the @context's shard.
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/outcome_results_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def linked_include_collections
linked = {}
includes = Api.value_to_array(params[:include])
includes.uniq.each do |include_name|
linked[include_name] = self.send(include_method_name(include_name))
linked[include_name] = send(include_method_name(include_name))
end
linked
end
Expand Down Expand Up @@ -520,7 +520,7 @@ def verify_include_parameter
when 'users'
reject! "can't include users unless aggregate is not set" if params[:aggregate].present?
else
reject! "invalid include: #{include_name}" unless self.respond_to? include_method_name(include_name), :include_private
reject! "invalid include: #{include_name}" unless respond_to? include_method_name(include_name), :include_private
end
end
true
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/release_notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def include_langs?

# For specs only
def clear_ivars
self.instance_variables.each do |ivar|
self.instance_variable_set(ivar, nil)
instance_variables.each do |ivar|
instance_variable_set(ivar, nil)
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/user_notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def create
# We want notes to be an html field, but we're only using a plaintext box for now. That's why we're
# doing the trip to html now, instead of on the way out. This should be removed once the user notes
# entry form is replaced with the rich text editor.
self.extend TextHelper
extend TextHelper
user_note_params[:note] = format_message(user_note_params[:note]).first if user_note_params[:note]
user_note_params[:root_account_id] = @domain_root_account.id
@user_note = user.user_notes.new(user_note_params)
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/graphql_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module GraphQLHelpers
# will get a standard canvas id
def self.relay_or_legacy_id_prepare_func(expected_type)
proc do |relay_or_legacy_id|
self.parse_relay_or_legacy_id(relay_or_legacy_id, expected_type)
parse_relay_or_legacy_id(relay_or_legacy_id, expected_type)
rescue InvalidIDError => e
GraphQL::ExecutionError.new(e.message)
end
Expand All @@ -35,7 +35,7 @@ def self.relay_or_legacy_id_prepare_func(expected_type)
def self.relay_or_legacy_ids_prepare_func(expected_type)
proc do |relay_or_legacy_ids|
relay_or_legacy_ids.map do |relay_or_legacy_id|
self.parse_relay_or_legacy_id(relay_or_legacy_id, expected_type)
parse_relay_or_legacy_id(relay_or_legacy_id, expected_type)
end
rescue InvalidIDError => e
GraphQL::ExecutionError.new(e.message)
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/graphql_postgres_timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class << self
end

def self.wrap(query)
if self.do_not_wrap
if do_not_wrap
yield
else
ActiveRecord::Base.transaction do
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/add_conversation_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def resolve(input:)
message_ids: input[:included_messages],
body: input[:body],
attachment_ids: input[:attachment_ids],
domain_root_account_id: self.context[:domain_root_account].id,
domain_root_account_id: context[:domain_root_account].id,
media_comment_id: input[:media_comment_id],
media_comment_type: input[:media_comment_type],
user_note: input[:user_note]
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/mutations/update_assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def resolve(input:)
module_ids = prepare_module_ids!(input_hash)

# make sure to do other required updates
self.send(other_update_on_assignment) if other_update_on_assignment
send(other_update_on_assignment) if other_update_on_assignment

# ensure the assignment is part of all required modules
ensure_modules(module_ids) if module_ids
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/communication_channel_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CommunicationChannelType < ApplicationObjectType
argument :context_type, NotificationPreferencesContextType, required: false
end
def notification_policies(context_type: nil)
NotificationPolicy.find_all_for(self.object, context_type: context_type)
NotificationPolicy.find_all_for(object, context_type: context_type)
end

field :notification_policy_overrides, [NotificationPolicyType], null: true do
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def context_url(context, *opts)
nil
end
opts[-1][:only_path] = true unless opts[-1][:only_path] == false
res = self.send name, *opts
res = send name, *opts
elsif opts[0].is_a? Hash
opts = opts[0]
begin
Expand All @@ -121,7 +121,7 @@ def context_url(context, *opts)
end
opts[:only_path] = true
opts["#{context_name}_id"] = context.id
res = self.url_for opts
res = url_for opts
else
res = context_name.to_s + opts.to_json.to_s
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/attachment_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def doc_preview_attributes(attachment, attrs = {})
attrs[:mimetype] = attachment.mimetype
context_name = url_helper_context_from_object(attachment.context)
url_helper = "#{context_name}_file_inline_view_url"
if self.respond_to?(url_helper)
attrs[:attachment_view_inline_ping_url] = self.send(url_helper, attachment.context, attachment.id, { :verifier => params[:verifier] })
if respond_to?(url_helper)
attrs[:attachment_view_inline_ping_url] = send(url_helper, attachment.context, attachment.id, { :verifier => params[:verifier] })
end
if attachment.pending_upload? || attachment.processing?
attrs[:attachment_preview_processing] = true
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/datadog_rum_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def enabled?
end

def randomly_include?
self.random <= sample_rate
random <= sample_rate
end

def sample_rate
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/search_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def validate(bookmark)
end

def self.wrap(collection)
BookmarkedCollection.build(self.new(collection)) do |pager|
BookmarkedCollection.build(new(collection)) do |pager|
page_start = pager.current_bookmark ? pager.current_bookmark + 1 : 0
page_end = page_start + pager.per_page
pager.replace collection[page_start, page_end]
Expand Down
4 changes: 2 additions & 2 deletions app/middleware/request_throttle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def get_up_front_cost_for_path(path)
self.class.up_front_cost_by_path_regex.each do |regex, cost|
return cost if regex&.match?(path)
end
self.up_front_cost # otherwise use the default
up_front_cost # otherwise use the default
end

# This method does an initial increment by the up_front_cost, loading the
Expand Down Expand Up @@ -347,7 +347,7 @@ def increment(amount, reserve_cost = 0, current_time = Time.now)
end

current_time = current_time.to_f
Rails.logger.debug("request throttling increment: #{([amount, reserve_cost, current_time] + self.as_json.to_a).to_json}")
Rails.logger.debug("request throttling increment: #{([amount, reserve_cost, current_time] + as_json.to_a).to_json}")
redis = self.redis
count, last_touched = LeakyBucket.lua.run(:increment_bucket, [cache_key], [amount + reserve_cost, current_time, outflow, maximum], redis)
self.count = count.to_f
Expand Down
8 changes: 4 additions & 4 deletions app/models/access_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def self.authenticate(token_string, token_key = :crypted_token)
# hash the user supplied token with all of our known keys
# attempt to find a token that matches one of the hashes
hashed_tokens = all_hashed_tokens(token_string)
token = self.not_deleted.where(token_key => hashed_tokens).first
token = not_deleted.where(token_key => hashed_tokens).first
if token && token.send(token_key) != hashed_tokens.first
# we found the token but, its hashed using an old key. save the updated hash
token.send("#{token_key}=", hashed_tokens.first)
Expand All @@ -90,7 +90,7 @@ def self.authenticate(token_string, token_key = :crypted_token)
end

def self.authenticate_refresh_token(token_string)
self.authenticate(token_string, :crypted_refresh_token)
authenticate(token_string, :crypted_refresh_token)
end

def self.hashed_token(token)
Expand Down Expand Up @@ -136,7 +136,7 @@ def record_last_used_threshold
def used!
if !last_used_at || last_used_at < record_last_used_threshold.seconds.ago
self.last_used_at = Time.now.utc
self.save
save
end
end

Expand All @@ -159,7 +159,7 @@ def clear_full_token!
end

def generate_token(overwrite = false)
if overwrite || !self.crypted_token
if overwrite || !crypted_token
self.token = CanvasSlug.generate(nil, TOKEN_SIZE)

self.expires_at = Time.now.utc + 1.hour if developer_key&.auto_expire_tokens
Expand Down
Loading

0 comments on commit ff99d18

Please sign in to comment.