Skip to content
Snippets Groups Projects
Commit 6a4ee9aa authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Allow simple ivar ||= form. Update accordingly

parent 9ae92b8c
No related branches found
No related tags found
No related merge requests found
Showing
with 37 additions and 29 deletions
# rubocop:disable Cop/ModuleWithInstanceVariables
module BoardsResponses
def authorize_read_list
authorize_action_for!(board.parent, :read_list)
Loading
Loading
@@ -24,10 +23,12 @@ module BoardsResponses
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
Loading
Loading
# 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
Loading
Loading
@@ -78,6 +78,7 @@ module CreatesCommit
end
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def new_merge_request_path
project_new_merge_request_path(
@project_to_commit_into,
Loading
Loading
@@ -94,6 +95,7 @@ module CreatesCommit
project_merge_request_path(@project, @merge_request)
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def merge_request_exists?
return @merge_request if defined?(@merge_request)
 
Loading
Loading
@@ -101,10 +103,12 @@ module CreatesCommit
.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,
Loading
Loading
module CycleAnalyticsParams
extend ActiveSupport::Concern
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def options(params)
@options ||= { from: start_date(params), current_user: current_user }
end
Loading
Loading
# rubocop:disable Cop/ModuleWithInstanceVariables
module IssuableActions
extend ActiveSupport::Concern
 
Loading
Loading
@@ -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
Loading
Loading
@@ -36,6 +36,7 @@ module IssuableActions
 
private
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def render_conflict_response
respond_to do |format|
format.html do
Loading
Loading
@@ -53,6 +54,7 @@ module IssuableActions
end
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def labels
@labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute
end
Loading
Loading
@@ -63,6 +65,7 @@ module IssuableActions
end
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def authorize_admin_issuable!
unless can?(current_user, :"admin_#{resource_name}", @project)
return access_denied!
Loading
Loading
# rubocop:disable Cop/ModuleWithInstanceVariables
module IssuableCollections
extend ActiveSupport::Concern
include SortingHelper
Loading
Loading
@@ -11,6 +10,7 @@ module IssuableCollections
 
private
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def set_issues_index
@collection_type = "Issue"
@issues = issues_collection
Loading
Loading
@@ -85,6 +85,7 @@ module IssuableCollections
finder_class.new(current_user, filter_params)
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def filter_params
set_sort_order_from_cookie
set_default_state
Loading
Loading
# rubocop:disable Cop/ModuleWithInstanceVariables
module IssuesAction
extend ActiveSupport::Concern
include IssuableCollections
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def issues
@label = issues_finder.labels.first
 
Loading
Loading
Loading
Loading
@@ -90,7 +90,6 @@ module LfsRequest
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
Loading
Loading
@@ -104,7 +103,6 @@ module LfsRequest
end
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def objects
@objects ||= (params[:objects] || []).to_a
end
Loading
Loading
Loading
Loading
@@ -76,7 +76,6 @@ module MembershipActions
end
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def source_type
@source_type ||= membershipable.class.to_s.humanize(capitalize: false)
end
Loading
Loading
# rubocop:disable Cop/ModuleWithInstanceVariables
module MergeRequestsAction
extend ActiveSupport::Concern
include IssuableCollections
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def merge_requests
@label = merge_requests_finder.labels.first
 
Loading
Loading
Loading
Loading
@@ -13,8 +13,7 @@ module OauthApplications
end
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def load_scopes
@scopes = Doorkeeper.configuration.scopes
@scopes ||= Doorkeeper.configuration.scopes
end
end
Loading
Loading
@@ -17,7 +17,6 @@ module RequiresWhitelistedMonitoringClient
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
Loading
Loading
Loading
Loading
@@ -17,7 +17,6 @@ module IgnorableColumn
super.reject { |column| ignored_columns.include?(column.name) }
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def ignored_columns
@ignored_columns ||= Set.new
end
Loading
Loading
Loading
Loading
@@ -5,7 +5,6 @@
#
# Used by Issue, Note, MergeRequest, and Commit.
#
# # rubocop:disable Cop/ModuleWithInstanceVariables
module Mentionable
extend ActiveSupport::Concern
 
Loading
Loading
@@ -44,6 +43,7 @@ module Mentionable
self
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def all_references(current_user = nil, extractor: nil)
@extractors ||= {}
 
Loading
Loading
Loading
Loading
@@ -12,7 +12,6 @@ module Noteable
#
# 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
Loading
Loading
@@ -35,7 +34,6 @@ module Noteable
 
delegate :find_discussion, to: :discussion_notes
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def discussions
@discussions ||= discussion_notes
.inc_relations_for_view
Loading
Loading
@@ -70,7 +68,6 @@ module Noteable
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
Loading
Loading
Loading
Loading
@@ -55,17 +55,18 @@ module Participable
# 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)
Loading
Loading
Loading
Loading
@@ -55,7 +55,6 @@ module ProtectedRef
 
private
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def ref_matcher
@ref_matcher ||= ProtectedRefMatcher.new(self)
end
Loading
Loading
# rubocop:disable Cop/ModuleWithInstanceVariables
module RelativePositioning
extend ActiveSupport::Concern
 
Loading
Loading
@@ -45,6 +44,7 @@ module RelativePositioning
next_pos
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def move_between(before, after)
return move_after(before) unless after
return move_before(after) unless before
Loading
Loading
@@ -59,6 +59,7 @@ module RelativePositioning
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
Loading
Loading
@@ -74,6 +75,7 @@ module RelativePositioning
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
Loading
Loading
@@ -133,6 +135,7 @@ module RelativePositioning
end
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def save_positionable_neighbours
return unless @positionable_neighbours
 
Loading
Loading
# rubocop:disable Cop/ModuleWithInstanceVariables
module ResolvableDiscussion
extend ActiveSupport::Concern
 
Loading
Loading
@@ -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?
 
Loading
Loading
@@ -47,12 +48,14 @@ module ResolvableDiscussion
@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?
 
Loading
Loading
@@ -89,6 +92,7 @@ module ResolvableDiscussion
 
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))
Loading
Loading
# 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
 
Loading
Loading
@@ -87,6 +86,7 @@ module Routable
end
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def full_name
if route && route.name.present?
@full_name ||= route.name
Loading
Loading
@@ -107,6 +107,7 @@ module Routable
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
Loading
Loading
@@ -122,6 +123,7 @@ module Routable
 
private
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def uncached_full_path
if route && route.path.present?
@full_path ||= route.path
Loading
Loading
@@ -157,6 +159,7 @@ module Routable
route.save
end
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def prepare_route
route || build_route(source: self)
route.path = build_full_path
Loading
Loading
Loading
Loading
@@ -49,7 +49,6 @@ module Storage
 
private
 
# rubocop:disable Cop/ModuleWithInstanceVariables
def old_repository_storage_paths
@old_repository_storage_paths ||= repository_storage_paths
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment