Skip to content
Snippets Groups Projects
Verified Commit 01d8c1f6 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
Browse files

Whitelist none method from ActiveRecord::Querying

parent fc892db6
No related branches found
No related tags found
No related merge requests found
Showing with 0 additions and 31 deletions
Loading
Loading
@@ -72,7 +72,6 @@ module Autocomplete
author_id.present? && current_user
end
 
# rubocop: disable CodeReuse/ActiveRecord
def find_users
if project
project.authorized_users.union_with_user(author_id)
Loading
Loading
@@ -84,6 +83,5 @@ module Autocomplete
User.none
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
Loading
Loading
@@ -16,7 +16,6 @@ module FinderWithCrossProjectAccess
end
 
override :execute
# rubocop: disable CodeReuse/ActiveRecord
def execute(*args)
check = Gitlab::CrossProjectAccess.find_check(self)
original = super
Loading
Loading
@@ -30,7 +29,6 @@ module FinderWithCrossProjectAccess
original
end
end
# rubocop: enable CodeReuse/ActiveRecord
 
# We can skip the cross project check for finding indivitual records.
# this would be handled by the `can?(:read_*, result)` call in `FinderMethods`
Loading
Loading
Loading
Loading
@@ -131,7 +131,6 @@ class GroupDescendantsFinder
.with_selects_for_list(archived: params[:archived])
end
 
# rubocop: disable CodeReuse/ActiveRecord
def subgroups
return Group.none unless Group.supports_nested_groups?
 
Loading
Loading
@@ -145,7 +144,6 @@ class GroupDescendantsFinder
 
groups.with_selects_for_list(archived: params[:archived]).order_by(sort)
end
# rubocop: enable CodeReuse/ActiveRecord
 
# rubocop: disable CodeReuse/Finder
def direct_child_projects
Loading
Loading
Loading
Loading
@@ -40,7 +40,6 @@ class GroupsFinder < UnionFinder
 
attr_reader :current_user, :params
 
# rubocop: disable CodeReuse/ActiveRecord
def all_groups
return [owned_groups] if params[:owned]
return [groups_with_min_access_level] if min_access_level?
Loading
Loading
@@ -52,7 +51,6 @@ class GroupsFinder < UnionFinder
groups << Group.none if groups.empty?
groups
end
# rubocop: enable CodeReuse/ActiveRecord
 
def groups_for_ancestors
current_user.authorized_groups
Loading
Loading
@@ -82,11 +80,9 @@ class GroupsFinder < UnionFinder
end
# rubocop: enable CodeReuse/ActiveRecord
 
# rubocop: disable CodeReuse/ActiveRecord
def owned_groups
current_user&.owned_groups || Group.none
end
# rubocop: enable CodeReuse/ActiveRecord
 
def include_public_groups?
current_user.nil? || all_available?
Loading
Loading
Loading
Loading
@@ -196,7 +196,6 @@ class IssuableFinder
milestones? && params[:milestone_title] == Milestone::None.title
end
 
# rubocop: disable CodeReuse/ActiveRecord
def milestones
return @milestones if defined?(@milestones)
 
Loading
Loading
@@ -217,7 +216,6 @@ class IssuableFinder
Milestone.none
end
end
# rubocop: enable CodeReuse/ActiveRecord
 
def labels?
params[:label_name].present?
Loading
Loading
@@ -227,7 +225,6 @@ class IssuableFinder
labels? && params[:label_name].include?(Label::None.title)
end
 
# rubocop: disable CodeReuse/ActiveRecord
def labels
return @labels if defined?(@labels)
 
Loading
Loading
@@ -238,7 +235,6 @@ class IssuableFinder
Label.none
end
end
# rubocop: enable CodeReuse/ActiveRecord
 
def assignee_id?
params[:assignee_id].present?
Loading
Loading
Loading
Loading
@@ -135,7 +135,6 @@ class IssuesFinder < IssuableFinder
current_user.blank?
end
 
# rubocop: disable CodeReuse/ActiveRecord
def by_assignee(items)
if filter_by_no_assignee?
items.unassigned
Loading
Loading
@@ -149,5 +148,4 @@ class IssuesFinder < IssuableFinder
items
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
Loading
Loading
@@ -12,7 +12,6 @@ class LabelsFinder < UnionFinder
@params = params
end
 
# rubocop: disable CodeReuse/ActiveRecord
def execute(skip_authorization: false)
@skip_authorization = skip_authorization
items = find_union(label_ids, Label) || Label.none
Loading
Loading
@@ -21,7 +20,6 @@ class LabelsFinder < UnionFinder
items = by_search(items)
sort(items)
end
# rubocop: enable CodeReuse/ActiveRecord
 
private
 
Loading
Loading
Loading
Loading
@@ -20,7 +20,6 @@ class MilestonesFinder
@params = params
end
 
# rubocop: disable CodeReuse/ActiveRecord
def execute
return Milestone.none if project_ids.empty? && group_ids.empty?
 
Loading
Loading
@@ -31,7 +30,6 @@ class MilestonesFinder
 
order(items)
end
# rubocop: enable CodeReuse/ActiveRecord
 
private
 
Loading
Loading
Loading
Loading
@@ -12,7 +12,6 @@ class PipelinesFinder
@params = params
end
 
# rubocop: disable CodeReuse/ActiveRecord
def execute
unless Ability.allowed?(current_user, :read_pipeline, project)
return Ci::Pipeline.none
Loading
Loading
@@ -28,7 +27,6 @@ class PipelinesFinder
items = by_yaml_errors(items)
sort_items(items)
end
# rubocop: enable CodeReuse/ActiveRecord
 
private
 
Loading
Loading
Loading
Loading
@@ -88,7 +88,6 @@ class ProjectsFinder < UnionFinder
# rubocop: enable CodeReuse/ActiveRecord
 
# Builds a collection for an anonymous user.
# rubocop: disable CodeReuse/ActiveRecord
def collection_without_user
if private_only? || owned_projects? || min_access_level?
Project.none
Loading
Loading
@@ -96,7 +95,6 @@ class ProjectsFinder < UnionFinder
Project.public_to_user
end
end
# rubocop: enable CodeReuse/ActiveRecord
 
def owned_projects?
params[:owned].present?
Loading
Loading
Loading
Loading
@@ -43,7 +43,6 @@ class SnippetsFinder < UnionFinder
end
end
 
# rubocop: disable CodeReuse/ActiveRecord
def authorized_snippets_from_project
if can?(current_user, :read_project_snippet, project)
if project.team.member?(current_user)
Loading
Loading
@@ -55,7 +54,6 @@ class SnippetsFinder < UnionFinder
Snippet.none
end
end
# rubocop: enable CodeReuse/ActiveRecord
 
# rubocop: disable CodeReuse/ActiveRecord
def authorized_snippets
Loading
Loading
Loading
Loading
@@ -11,13 +11,11 @@ module Search
@group = group
end
 
# rubocop: disable CodeReuse/ActiveRecord
def projects
return Project.none unless group
return @projects if defined? @projects
 
@projects = super.inside_path(group.full_path)
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
Loading
Loading
@@ -14,13 +14,11 @@ module Gitlab
@text = text
end
 
# rubocop: disable CodeReuse/ActiveRecord
def users
return User.none unless @text.present?
 
@users ||= User.from_union(union_relations)
end
# rubocop: enable CodeReuse/ActiveRecord
 
def usernames
matches[:usernames]
Loading
Loading
Loading
Loading
@@ -49,7 +49,6 @@ module RuboCop
limit: true,
lock: false,
many?: false,
none: false,
offset: true,
order: true,
pluck: true,
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