This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit 6a4ee9aa authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Allow simple ivar ||= form. Update accordingly

parent b34a96120039
# rubocop:disable Cop/ModuleWithInstanceVariables
module BoardsResponses
def authorize_read_list
authorize_action_for!(board.parent, :read_list)
......@@ -24,10 +23,12 @@ def authorize_action_for!(resource, ability)
return render_403 unless can?(current_user, ability, resource)
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def respond_with_boards
respond_with(@boards)
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def respond_with_board
respond_with(@board)
end
......
# rubocop:disable Cop/ModuleWithInstanceVariables
module CreatesCommit
extend ActiveSupport::Concern
# rubocop:disable Cop/ModuleWithInstanceVariables
def create_commit(service, success_path:, failure_path:, failure_view: nil, success_notice: nil)
if can?(current_user, :push_code, @project)
@project_to_commit_into = @project
......@@ -78,6 +78,7 @@ def final_success_path(success_path)
end
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def new_merge_request_path
project_new_merge_request_path(
@project_to_commit_into,
......@@ -94,6 +95,7 @@ def existing_merge_request_path
project_merge_request_path(@project, @merge_request)
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def merge_request_exists?
return @merge_request if defined?(@merge_request)
......@@ -101,10 +103,12 @@ def merge_request_exists?
.find_by(source_project_id: @project_to_commit_into, source_branch: @branch_name, target_branch: @start_branch)
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def different_project?
@project_to_commit_into != @project
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def create_merge_request?
# Even if the field is set, if we're checking the same branch
# as the target branch in the same project,
......
module CycleAnalyticsParams
extend ActiveSupport::Concern
# rubocop:disable Cop/ModuleWithInstanceVariables
def options(params)
@options ||= { from: start_date(params), current_user: current_user }
end
......
# rubocop:disable Cop/ModuleWithInstanceVariables
module IssuableActions
extend ActiveSupport::Concern
......@@ -8,6 +7,7 @@ module IssuableActions
before_action :authorize_admin_issuable!, only: :bulk_update
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def destroy
issuable.destroy
destroy_method = "destroy_#{issuable.class.name.underscore}".to_sym
......@@ -36,6 +36,7 @@ def bulk_update
private
# rubocop:disable Cop/ModuleWithInstanceVariables
def render_conflict_response
respond_to do |format|
format.html do
......@@ -53,6 +54,7 @@ def render_conflict_response
end
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def labels
@labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute
end
......@@ -63,6 +65,7 @@ def authorize_destroy_issuable!
end
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def authorize_admin_issuable!
unless can?(current_user, :"admin_#{resource_name}", @project)
return access_denied!
......
# rubocop:disable Cop/ModuleWithInstanceVariables
module IssuableCollections
extend ActiveSupport::Concern
include SortingHelper
......@@ -11,6 +10,7 @@ module IssuableCollections
private
# rubocop:disable Cop/ModuleWithInstanceVariables
def set_issues_index
@collection_type = "Issue"
@issues = issues_collection
......@@ -85,6 +85,7 @@ def issuable_finder_for(finder_class)
finder_class.new(current_user, filter_params)
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def filter_params
set_sort_order_from_cookie
set_default_state
......
# rubocop:disable Cop/ModuleWithInstanceVariables
module IssuesAction
extend ActiveSupport::Concern
include IssuableCollections
# rubocop:disable Cop/ModuleWithInstanceVariables
def issues
@label = issues_finder.labels.first
......
......@@ -90,7 +90,6 @@ def build_can_download_code?
has_authentication_ability?(:build_download_code) && can?(user, :build_download_code, project)
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def storage_project
@storage_project ||= begin
result = project
......@@ -104,7 +103,6 @@ def storage_project
end
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def objects
@objects ||= (params[:objects] || []).to_a
end
......
......@@ -76,7 +76,6 @@ def members_page_url
end
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def source_type
@source_type ||= membershipable.class.to_s.humanize(capitalize: false)
end
......
# rubocop:disable Cop/ModuleWithInstanceVariables
module MergeRequestsAction
extend ActiveSupport::Concern
include IssuableCollections
# rubocop:disable Cop/ModuleWithInstanceVariables
def merge_requests
@label = merge_requests_finder.labels.first
......
......@@ -13,8 +13,7 @@ def prepare_scopes
end
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def load_scopes
@scopes = Doorkeeper.configuration.scopes
@scopes ||= Doorkeeper.configuration.scopes
end
end
......@@ -17,7 +17,6 @@ def client_ip_whitelisted?
ip_whitelist.any? { |e| e.include?(Gitlab::RequestContext.client_ip) }
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def ip_whitelist
@ip_whitelist ||= Settings.monitoring.ip_whitelist.map(&IPAddr.method(:new))
end
......
......@@ -17,7 +17,6 @@ def columns
super.reject { |column| ignored_columns.include?(column.name) }
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def ignored_columns
@ignored_columns ||= Set.new
end
......
......@@ -5,7 +5,6 @@
#
# Used by Issue, Note, MergeRequest, and Commit.
#
# # rubocop:disable Cop/ModuleWithInstanceVariables
module Mentionable
extend ActiveSupport::Concern
......@@ -44,6 +43,7 @@ def local_reference
self
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def all_references(current_user = nil, extractor: nil)
@extractors ||= {}
......
......@@ -12,7 +12,6 @@ def base_class_name
#
# noteable.class # => MergeRequest
# noteable.human_class_name # => "merge request"
# rubocop:disable Cop/ModuleWithInstanceVariables
def human_class_name
@human_class_name ||= base_class_name.titleize.downcase
end
......@@ -35,7 +34,6 @@ def discussion_notes
delegate :find_discussion, to: :discussion_notes
# rubocop:disable Cop/ModuleWithInstanceVariables
def discussions
@discussions ||= discussion_notes
.inc_relations_for_view
......@@ -70,7 +68,6 @@ def discussions_to_be_resolved?
discussions_resolvable? && !discussions_resolved?
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def discussions_to_be_resolved
@discussions_to_be_resolved ||= resolvable_discussions.select(&:to_be_resolved?)
end
......
......@@ -55,17 +55,18 @@ def participant(attr)
# This method processes attributes of objects in breadth-first order.
#
# Returns an Array of User instances.
# rubocop:disable Cop/ModuleWithInstanceVariables
def participants(current_user = nil)
@participants ||= Hash.new do |hash, user|
hash[user] = raw_participants(user)
end
@participants[current_user]
all_participants[current_user]
end
private
def all_participants
@all_participants ||= Hash.new do |hash, user|
hash[user] = raw_participants(user)
end
end
def raw_participants(current_user = nil)
current_user ||= author
ext = Gitlab::ReferenceExtractor.new(project, current_user)
......
......@@ -55,7 +55,6 @@ def matching(ref_name, protected_refs: nil)
private
# rubocop:disable Cop/ModuleWithInstanceVariables
def ref_matcher
@ref_matcher ||= ProtectedRefMatcher.new(self)
end
......
# rubocop:disable Cop/ModuleWithInstanceVariables
module RelativePositioning
extend ActiveSupport::Concern
......@@ -45,6 +44,7 @@ def next_relative_position
next_pos
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def move_between(before, after)
return move_after(before) unless after
return move_before(after) unless before
......@@ -59,6 +59,7 @@ def move_between(before, after)
self.relative_position = position_between(before.relative_position, after.relative_position)
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def move_after(before = self)
pos_before = before.relative_position
pos_after = before.next_relative_position
......@@ -74,6 +75,7 @@ def move_after(before = self)
self.relative_position = position_between(pos_before, pos_after)
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def move_before(after = self)
pos_after = after.relative_position
pos_before = after.prev_relative_position
......@@ -133,6 +135,7 @@ def position_between(pos_before, pos_after)
end
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def save_positionable_neighbours
return unless @positionable_neighbours
......
# rubocop:disable Cop/ModuleWithInstanceVariables
module ResolvableDiscussion
extend ActiveSupport::Concern
......@@ -31,12 +30,14 @@ module ResolvableDiscussion
allow_nil: true
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def resolvable?
return @resolvable if @resolvable.present?
@resolvable = potentially_resolvable? && notes.any?(&:resolvable?)
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def resolved?
return @resolved if @resolved.present?
......@@ -47,12 +48,14 @@ def first_note
@first_note ||= notes.first
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def first_note_to_resolve
return unless resolvable?
@first_note_to_resolve ||= notes.find(&:to_be_resolved?)
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def last_resolved_note
return unless resolved?
......@@ -89,6 +92,7 @@ def unresolve!
private
# rubocop:disable Cop/ModuleWithInstanceVariables
def update
# Do not select `Note.resolvable`, so that system notes remain in the collection
notes_relation = Note.where(id: notes.map(&:id))
......
# Store object full path in separate table for easy lookup and uniq validation
# Object must have name and path db fields and respond to parent and parent_changed? methods.
# rubocop:disable Cop/ModuleWithInstanceVariables
module Routable
extend ActiveSupport::Concern
......@@ -87,6 +86,7 @@ def where_full_path_in(paths)
end
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def full_name
if route && route.name.present?
@full_name ||= route.name
......@@ -107,6 +107,7 @@ def full_path
RequestStore[full_path_key] ||= uncached_full_path
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def expires_full_path_cache
RequestStore.delete(full_path_key) if RequestStore.active?
@full_path = nil
......@@ -122,6 +123,7 @@ def build_full_path
private
# rubocop:disable Cop/ModuleWithInstanceVariables
def uncached_full_path
if route && route.path.present?
@full_path ||= route.path
......@@ -157,6 +159,7 @@ def update_route
route.save
end
# rubocop:disable Cop/ModuleWithInstanceVariables
def prepare_route
route || build_route(source: self)
route.path = build_full_path
......
......@@ -49,7 +49,6 @@ def prepare_for_destroy
private
# rubocop:disable Cop/ModuleWithInstanceVariables
def old_repository_storage_paths
@old_repository_storage_paths ||= repository_storage_paths
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment