Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-09-18 20:25:23 +0300
committerLin Jen-Shin <godfat@godfat.org>2017-09-18 20:29:32 +0300
commit6a4ee9aa7140862075cafae1ddebd133eec52b5b (patch)
tree9890bb5c906a0d6e207149ae5fe1df84d213fa7c /app/models
parent9ae92b8caa6c11d8860f86b7d6378062215d1b72 (diff)
Allow simple ivar ||= form. Update accordingly
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/ignorable_column.rb1
-rw-r--r--app/models/concerns/mentionable.rb2
-rw-r--r--app/models/concerns/noteable.rb3
-rw-r--r--app/models/concerns/participable.rb13
-rw-r--r--app/models/concerns/protected_ref.rb1
-rw-r--r--app/models/concerns/relative_positioning.rb5
-rw-r--r--app/models/concerns/resolvable_discussion.rb6
-rw-r--r--app/models/concerns/routable.rb5
-rw-r--r--app/models/concerns/storage/legacy_namespace.rb1
-rw-r--r--app/models/concerns/strip_attribute.rb1
-rw-r--r--app/models/concerns/taskable.rb2
-rw-r--r--app/models/concerns/time_trackable.rb4
12 files changed, 25 insertions, 19 deletions
diff --git a/app/models/concerns/ignorable_column.rb b/app/models/concerns/ignorable_column.rb
index 3a3afbcd366..eb9f3423e48 100644
--- a/app/models/concerns/ignorable_column.rb
+++ b/app/models/concerns/ignorable_column.rb
@@ -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
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index b2dca51f5de..7644f2ea95f 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -5,7 +5,6 @@
#
# Used by Issue, Note, MergeRequest, and Commit.
#
-# # rubocop:disable Cop/ModuleWithInstanceVariables
module Mentionable
extend ActiveSupport::Concern
@@ -44,6 +43,7 @@ module Mentionable
self
end
+ # rubocop:disable Cop/ModuleWithInstanceVariables
def all_references(current_user = nil, extractor: nil)
@extractors ||= {}
diff --git a/app/models/concerns/noteable.rb b/app/models/concerns/noteable.rb
index 143f4a12bba..9d81a19cbb9 100644
--- a/app/models/concerns/noteable.rb
+++ b/app/models/concerns/noteable.rb
@@ -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
@@ -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
@@ -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
diff --git a/app/models/concerns/participable.rb b/app/models/concerns/participable.rb
index e971b2aafdd..e48bc0be410 100644
--- a/app/models/concerns/participable.rb
+++ b/app/models/concerns/participable.rb
@@ -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)
diff --git a/app/models/concerns/protected_ref.rb b/app/models/concerns/protected_ref.rb
index cd3889c1385..454374121f3 100644
--- a/app/models/concerns/protected_ref.rb
+++ b/app/models/concerns/protected_ref.rb
@@ -55,7 +55,6 @@ module ProtectedRef
private
- # rubocop:disable Cop/ModuleWithInstanceVariables
def ref_matcher
@ref_matcher ||= ProtectedRefMatcher.new(self)
end
diff --git a/app/models/concerns/relative_positioning.rb b/app/models/concerns/relative_positioning.rb
index 951dd925292..9a7b9cd12b0 100644
--- a/app/models/concerns/relative_positioning.rb
+++ b/app/models/concerns/relative_positioning.rb
@@ -1,4 +1,3 @@
-# rubocop:disable Cop/ModuleWithInstanceVariables
module RelativePositioning
extend ActiveSupport::Concern
@@ -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
@@ -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
@@ -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
@@ -133,6 +135,7 @@ module RelativePositioning
end
end
+ # rubocop:disable Cop/ModuleWithInstanceVariables
def save_positionable_neighbours
return unless @positionable_neighbours
diff --git a/app/models/concerns/resolvable_discussion.rb b/app/models/concerns/resolvable_discussion.rb
index 09bb2823ab9..56ba4a9a4d0 100644
--- a/app/models/concerns/resolvable_discussion.rb
+++ b/app/models/concerns/resolvable_discussion.rb
@@ -1,4 +1,3 @@
-# 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 @@ 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?
@@ -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))
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb
index a68f9188e80..80a8f63514f 100644
--- a/app/models/concerns/routable.rb
+++ b/app/models/concerns/routable.rb
@@ -1,6 +1,5 @@
# 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 @@ module Routable
end
end
+ # rubocop:disable Cop/ModuleWithInstanceVariables
def full_name
if route && route.name.present?
@full_name ||= route.name
@@ -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
@@ -122,6 +123,7 @@ module Routable
private
+ # rubocop:disable Cop/ModuleWithInstanceVariables
def uncached_full_path
if route && route.path.present?
@full_path ||= route.path
@@ -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
diff --git a/app/models/concerns/storage/legacy_namespace.rb b/app/models/concerns/storage/legacy_namespace.rb
index 3823653b386..5ab5c80a2f5 100644
--- a/app/models/concerns/storage/legacy_namespace.rb
+++ b/app/models/concerns/storage/legacy_namespace.rb
@@ -49,7 +49,6 @@ module Storage
private
- # rubocop:disable Cop/ModuleWithInstanceVariables
def old_repository_storage_paths
@old_repository_storage_paths ||= repository_storage_paths
end
diff --git a/app/models/concerns/strip_attribute.rb b/app/models/concerns/strip_attribute.rb
index 5189f736991..8806ebe897a 100644
--- a/app/models/concerns/strip_attribute.rb
+++ b/app/models/concerns/strip_attribute.rb
@@ -17,7 +17,6 @@ module StripAttribute
strip_attrs.concat(attrs)
end
- # rubocop:disable Cop/ModuleWithInstanceVariables
def strip_attrs
@strip_attrs ||= []
end
diff --git a/app/models/concerns/taskable.rb b/app/models/concerns/taskable.rb
index 298f7b61047..a73de49b9bb 100644
--- a/app/models/concerns/taskable.rb
+++ b/app/models/concerns/taskable.rb
@@ -6,7 +6,6 @@ require 'task_list/filter'
# bugs".
#
# Used by MergeRequest and Issue
-# rubocop:disable Cop/ModuleWithInstanceVariables
module Taskable
COMPLETED = 'completed'.freeze
INCOMPLETE = 'incomplete'.freeze
@@ -37,6 +36,7 @@ module Taskable
end
# Called by `TaskList::Summary`
+ # rubocop:disable Cop/ModuleWithInstanceVariables
def task_list_items
return [] if description.blank?
diff --git a/app/models/concerns/time_trackable.rb b/app/models/concerns/time_trackable.rb
index 75f7c81fa4e..995fa98efac 100644
--- a/app/models/concerns/time_trackable.rb
+++ b/app/models/concerns/time_trackable.rb
@@ -4,7 +4,6 @@
#
# Used by Issue and MergeRequest.
#
-# rubocop:disable Cop/ModuleWithInstanceVariables
module TimeTrackable
extend ActiveSupport::Concern
@@ -21,6 +20,7 @@ module TimeTrackable
has_many :timelogs, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
end
+ # rubocop:disable Cop/ModuleWithInstanceVariables
def spend_time(options)
@time_spent = options[:duration]
@time_spent_user = options[:user]
@@ -50,6 +50,7 @@ module TimeTrackable
private
+ # rubocop:disable Cop/ModuleWithInstanceVariables
def reset_spent_time
timelogs.new(time_spent: total_time_spent * -1, user: @time_spent_user)
end
@@ -58,6 +59,7 @@ module TimeTrackable
timelogs.new(time_spent: time_spent, user: @time_spent_user)
end
+ # rubocop:disable Cop/ModuleWithInstanceVariables
def check_negative_time_spent
return if time_spent.nil? || time_spent == :reset