Commit 40c8a21c authored by Shubham Kumar's avatar Shubham Kumar Committed by Rémy Coutable

Resolves rubocop offense Style/RedundantAssignment

parent 6853eeb8
...@@ -864,11 +864,6 @@ Style/RaiseArgs: ...@@ -864,11 +864,6 @@ Style/RaiseArgs:
Enabled: false Enabled: false
EnforcedStyle: exploded EnforcedStyle: exploded
# Offense count: 73
# Cop supports --auto-correct.
Style/RedundantAssignment:
Enabled: false
# Offense count: 2 # Offense count: 2
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/RedundantBegin: Style/RedundantBegin:
......
...@@ -13,8 +13,7 @@ class AwardEmojisFinder ...@@ -13,8 +13,7 @@ class AwardEmojisFinder
def execute def execute
awards = awardable.award_emoji awards = awardable.award_emoji
awards = by_name(awards) awards = by_name(awards)
awards = by_awarded_by(awards) by_awarded_by(awards)
awards
end end
private private
......
...@@ -11,8 +11,7 @@ class BranchesFinder < GitRefsFinder ...@@ -11,8 +11,7 @@ class BranchesFinder < GitRefsFinder
else else
branches = repository.branches_sorted_by(sort) branches = repository.branches_sorted_by(sort)
branches = by_search(branches) branches = by_search(branches)
branches = by_names(branches) by_names(branches)
branches
end end
end end
......
...@@ -35,8 +35,7 @@ module Ci ...@@ -35,8 +35,7 @@ module Ci
return Ci::DailyBuildGroupReportResult.none unless query_allowed? return Ci::DailyBuildGroupReportResult.none unless query_allowed?
collection = Ci::DailyBuildGroupReportResult.by_projects(params[:project]) collection = Ci::DailyBuildGroupReportResult.by_projects(params[:project])
collection = filter_report_results(collection) filter_report_results(collection)
collection
end end
private private
...@@ -51,8 +50,7 @@ module Ci ...@@ -51,8 +50,7 @@ module Ci
collection = by_dates(collection) collection = by_dates(collection)
collection = sort(collection) collection = sort(collection)
collection = limit_by(collection) limit_by(collection)
collection
end end
def by_coverage(items) def by_coverage(items)
......
...@@ -11,8 +11,7 @@ module Ci ...@@ -11,8 +11,7 @@ module Ci
def execute def execute
variables = resource.variables variables = resource.variables
variables = by_key(variables) variables = by_key(variables)
variables = by_environment_scope(variables) by_environment_scope(variables)
variables
end end
private private
......
...@@ -11,9 +11,7 @@ class ContextCommitsFinder ...@@ -11,9 +11,7 @@ class ContextCommitsFinder
def execute def execute
commits = init_collection commits = init_collection
commits = filter_existing_commits(commits) filter_existing_commits(commits)
commits
end end
private private
...@@ -21,19 +19,15 @@ class ContextCommitsFinder ...@@ -21,19 +19,15 @@ class ContextCommitsFinder
attr_reader :project, :merge_request, :search, :limit, :offset attr_reader :project, :merge_request, :search, :limit, :offset
def init_collection def init_collection
commits = if search.present?
if search.present? search_commits
search_commits else
else project.repository.commits(merge_request.target_branch, { limit: limit, offset: offset })
project.repository.commits(merge_request.target_branch, { limit: limit, offset: offset }) end
end
commits
end end
def filter_existing_commits(commits) def filter_existing_commits(commits)
commits.select! { |commit| already_included_ids.exclude?(commit.id) } commits.select! { |commit| already_included_ids.exclude?(commit.id) }
commits commits
end end
......
...@@ -33,9 +33,7 @@ class DeploymentsFinder ...@@ -33,9 +33,7 @@ class DeploymentsFinder
items = by_environment(items) items = by_environment(items)
items = by_status(items) items = by_status(items)
items = preload_associations(items) items = preload_associations(items)
items = sort(items) sort(items)
items
end end
private private
......
...@@ -15,9 +15,7 @@ class EnvironmentsFinder ...@@ -15,9 +15,7 @@ class EnvironmentsFinder
environments = by_search(environments) environments = by_search(environments)
# Raises InvalidStatesError if params[:states] contains invalid states. # Raises InvalidStatesError if params[:states] contains invalid states.
environments = by_states(environments) by_states(environments)
environments
end end
private private
......
...@@ -48,8 +48,7 @@ class GroupProjectsFinder < ProjectsFinder ...@@ -48,8 +48,7 @@ class GroupProjectsFinder < ProjectsFinder
def filter_projects(collection) def filter_projects(collection)
projects = super projects = super
projects = by_feature_availability(projects) by_feature_availability(projects)
projects
end end
def limit(collection) def limit(collection)
......
...@@ -119,9 +119,7 @@ class IssuableFinder ...@@ -119,9 +119,7 @@ class IssuableFinder
# https://www.postgresql.org/docs/current/static/queries-with.html # https://www.postgresql.org/docs/current/static/queries-with.html
items = by_search(items) items = by_search(items)
items = sort(items) sort(items)
items
end end
def filter_items(items) def filter_items(items)
......
...@@ -81,8 +81,7 @@ class IssuesFinder < IssuableFinder ...@@ -81,8 +81,7 @@ class IssuesFinder < IssuableFinder
issues = super issues = super
issues = by_due_date(issues) issues = by_due_date(issues)
issues = by_confidential(issues) issues = by_confidential(issues)
issues = by_issue_types(issues) by_issue_types(issues)
issues
end end
def by_confidential(items) def by_confidential(items)
......
...@@ -14,9 +14,7 @@ class MergeRequest::MetricsFinder ...@@ -14,9 +14,7 @@ class MergeRequest::MetricsFinder
items = init_collection items = init_collection
items = by_target_project(items) items = by_target_project(items)
items = by_merged_after(items) items = by_merged_after(items)
items = by_merged_before(items) by_merged_before(items)
items
end end
private private
......
...@@ -39,8 +39,7 @@ module Namespaces ...@@ -39,8 +39,7 @@ module Namespaces
def filter_projects(collection) def filter_projects(collection)
collection = by_ids(collection) collection = by_ids(collection)
collection = by_similarity(collection) by_similarity(collection)
collection
end end
def by_ids(items) def by_ids(items)
......
...@@ -8,8 +8,7 @@ module Packages ...@@ -8,8 +8,7 @@ module Packages
def package_files def package_files
files = super files = super
files = by_conan_file_type(files) files = by_conan_file_type(files)
files = by_conan_package_reference(files) by_conan_package_reference(files)
files
end end
def by_conan_file_type(files) def by_conan_file_type(files)
......
...@@ -11,8 +11,7 @@ module Packages ...@@ -11,8 +11,7 @@ module Packages
collection = relation.with_container(container) collection = relation.with_container(container)
collection = by_codename(collection) collection = by_codename(collection)
collection = by_suite(collection) collection = by_suite(collection)
collection = by_codename_or_suite(collection) by_codename_or_suite(collection)
collection
end end
private private
......
...@@ -32,8 +32,7 @@ module Packages ...@@ -32,8 +32,7 @@ module Packages
packages = filter_with_version(packages) packages = filter_with_version(packages)
packages = filter_by_package_type(packages) packages = filter_by_package_type(packages)
packages = filter_by_package_name(packages) packages = filter_by_package_name(packages)
packages = filter_by_status(packages) filter_by_status(packages)
packages
end end
def group_projects_visible_to_current_user def group_projects_visible_to_current_user
......
...@@ -21,9 +21,7 @@ class Packages::PackageFileFinder ...@@ -21,9 +21,7 @@ class Packages::PackageFileFinder
def package_files def package_files
files = package.package_files files = package.package_files
files = by_file_name(files) by_file_name(files)
files
end end
def by_file_name(files) def by_file_name(files)
......
...@@ -22,8 +22,7 @@ module Packages ...@@ -22,8 +22,7 @@ module Packages
packages = filter_by_package_type(packages) packages = filter_by_package_type(packages)
packages = filter_by_package_name(packages) packages = filter_by_package_name(packages)
packages = filter_by_status(packages) packages = filter_by_status(packages)
packages = order_packages(packages) order_packages(packages)
packages
end end
private private
......
...@@ -26,9 +26,7 @@ class PendingTodosFinder ...@@ -26,9 +26,7 @@ class PendingTodosFinder
todos = by_project(todos) todos = by_project(todos)
todos = by_target_id(todos) todos = by_target_id(todos)
todos = by_target_type(todos) todos = by_target_type(todos)
todos = by_commit_id(todos) by_commit_id(todos)
todos
end end
def by_project(todos) def by_project(todos)
......
...@@ -12,9 +12,7 @@ module Projects ...@@ -12,9 +12,7 @@ module Projects
def execute def execute
export_jobs = project.export_jobs export_jobs = project.export_jobs
export_jobs = by_status(export_jobs) by_status(export_jobs)
export_jobs
end end
private private
......
...@@ -30,9 +30,7 @@ module Projects ...@@ -30,9 +30,7 @@ module Projects
relation = by_environment(relation) relation = by_environment(relation)
relation = by_metric(relation) relation = by_metric(relation)
relation = by_id(relation) relation = by_id(relation)
relation = ordered(relation) ordered(relation)
relation
end end
private private
......
...@@ -83,8 +83,7 @@ class ProjectsFinder < UnionFinder ...@@ -83,8 +83,7 @@ class ProjectsFinder < UnionFinder
collection = by_deleted_status(collection) collection = by_deleted_status(collection)
collection = by_last_activity_after(collection) collection = by_last_activity_after(collection)
collection = by_last_activity_before(collection) collection = by_last_activity_before(collection)
collection = by_repository_storage(collection) by_repository_storage(collection)
collection
end end
def collection_with_user def collection_with_user
......
...@@ -36,9 +36,7 @@ class PrometheusMetricsFinder ...@@ -36,9 +36,7 @@ class PrometheusMetricsFinder
metrics = by_common(metrics) metrics = by_common(metrics)
metrics = by_ordered(metrics) metrics = by_ordered(metrics)
metrics = by_identifier(metrics) metrics = by_identifier(metrics)
metrics = by_id(metrics) by_id(metrics)
metrics
end end
private private
......
...@@ -20,9 +20,7 @@ class ProtectedBranchesFinder ...@@ -20,9 +20,7 @@ class ProtectedBranchesFinder
def execute def execute
protected_branches = project.limited_protected_branches(LIMIT) protected_branches = project.limited_protected_branches(LIMIT)
protected_branches = by_name(protected_branches) by_name(protected_branches)
protected_branches
end end
private private
......
...@@ -20,8 +20,7 @@ class ReleasesFinder ...@@ -20,8 +20,7 @@ class ReleasesFinder
releases = get_releases releases = get_releases
releases = by_tag(releases) releases = by_tag(releases)
releases = releases.preloaded if preload releases = releases.preloaded if preload
releases = order_releases(releases) order_releases(releases)
releases
end end
private private
......
...@@ -7,7 +7,6 @@ class TagsFinder < GitRefsFinder ...@@ -7,7 +7,6 @@ class TagsFinder < GitRefsFinder
def execute def execute
tags = repository.tags_sorted_by(sort) tags = repository.tags_sorted_by(sort)
tags = by_search(tags) by_search(tags)
tags
end end
end end
...@@ -15,9 +15,7 @@ class UsersStarProjectsFinder ...@@ -15,9 +15,7 @@ class UsersStarProjectsFinder
stars = UsersStarProject.all stars = UsersStarProject.all
stars = by_project(stars) stars = by_project(stars)
stars = by_search(stars) stars = by_search(stars)
stars = filter_visible_profiles(stars) filter_visible_profiles(stars)
stars
end end
private private
......
...@@ -165,7 +165,7 @@ module ApplicationHelper ...@@ -165,7 +165,7 @@ module ApplicationHelper
css_classes = [short_format ? 'js-short-timeago' : 'js-timeago'] css_classes = [short_format ? 'js-short-timeago' : 'js-timeago']
css_classes << html_class unless html_class.blank? css_classes << html_class unless html_class.blank?
element = content_tag :time, l(time, format: "%b %d, %Y"), content_tag :time, l(time, format: "%b %d, %Y"),
class: css_classes.join(' '), class: css_classes.join(' '),
title: l(time.to_time.in_time_zone, format: :timeago_tooltip), title: l(time.to_time.in_time_zone, format: :timeago_tooltip),
datetime: time.to_time.getutc.iso8601, datetime: time.to_time.getutc.iso8601,
...@@ -174,8 +174,6 @@ module ApplicationHelper ...@@ -174,8 +174,6 @@ module ApplicationHelper
placement: placement, placement: placement,
container: 'body' container: 'body'
} }
element
end end
def edited_time_ago_with_tooltip(object, placement: 'top', html_class: 'time_ago', exclude_author: false) def edited_time_ago_with_tooltip(object, placement: 'top', html_class: 'time_ago', exclude_author: false)
......
...@@ -4,8 +4,7 @@ module GitHelper ...@@ -4,8 +4,7 @@ module GitHelper
def strip_signature(text) def strip_signature(text)
text = text.gsub(/-----BEGIN PGP SIGNATURE-----(.*)-----END PGP SIGNATURE-----/m, "") text = text.gsub(/-----BEGIN PGP SIGNATURE-----(.*)-----END PGP SIGNATURE-----/m, "")
text = text.gsub(/-----BEGIN PGP MESSAGE-----(.*)-----END PGP MESSAGE-----/m, "") text = text.gsub(/-----BEGIN PGP MESSAGE-----(.*)-----END PGP MESSAGE-----/m, "")
text = text.gsub(/-----BEGIN SIGNED MESSAGE-----(.*)-----END SIGNED MESSAGE-----/m, "") text.gsub(/-----BEGIN SIGNED MESSAGE-----(.*)-----END SIGNED MESSAGE-----/m, "")
text
end end
def short_sha(text) def short_sha(text)
......
...@@ -21,8 +21,7 @@ module Ci ...@@ -21,8 +21,7 @@ module Ci
deps = model_class.where(pipeline_id: processable.pipeline_id).latest deps = model_class.where(pipeline_id: processable.pipeline_id).latest
deps = from_previous_stages(deps) deps = from_previous_stages(deps)
deps = from_needs(deps) deps = from_needs(deps)
deps = from_dependencies(deps) from_dependencies(deps)
deps
end end
# Dependencies from the same parent-pipeline hierarchy excluding # Dependencies from the same parent-pipeline hierarchy excluding
......
...@@ -49,11 +49,9 @@ module MergeRequests ...@@ -49,11 +49,9 @@ module MergeRequests
def duplicates def duplicates
existing_oids = merge_request.merge_request_context_commits.map { |commit| commit.sha.to_s } existing_oids = merge_request.merge_request_context_commits.map { |commit| commit.sha.to_s }
duplicate_oids = existing_oids.select do |existing_oid| existing_oids.select do |existing_oid|
commit_ids.select { |commit_id| existing_oid.start_with?(commit_id) }.count > 0 commit_ids.select { |commit_id| existing_oid.start_with?(commit_id) }.count > 0
end end
duplicate_oids
end end
def build_context_commit_rows(merge_request_id, commits) def build_context_commit_rows(merge_request_id, commits)
......
...@@ -25,9 +25,7 @@ module ResourceEvents ...@@ -25,9 +25,7 @@ module ResourceEvents
def apply_common_filters(events) def apply_common_filters(events)
events = apply_last_fetched_at(events) events = apply_last_fetched_at(events)
events = apply_fetch_until(events) apply_fetch_until(events)
events
end end
def apply_last_fetched_at(events) def apply_last_fetched_at(events)
......
...@@ -147,8 +147,7 @@ class IrkerWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -147,8 +147,7 @@ class IrkerWorker # rubocop:disable Scalability/IdempotentWorker
def files_count(commit) def files_count(commit)
diff_size = commit.raw_deltas.size diff_size = commit.raw_deltas.size
files = "#{diff_size} file".pluralize(diff_size) "#{diff_size} file".pluralize(diff_size)
files
end end
def colorize_sha(sha) def colorize_sha(sha)
......
---
title: Resolves offenses Style/RedundantAssignment
merge_request: 58013
author: Shubham Kumar (@imskr)
type: fixed
...@@ -17,9 +17,8 @@ module HangoutsChat ...@@ -17,9 +17,8 @@ module HangoutsChat
headers: { 'Content-Type' => 'application/json' }, headers: { 'Content-Type' => 'application/json' },
parse: nil # disables automatic response parsing parse: nil # disables automatic response parsing
) )
net_http_response = httparty_response.response httparty_response.response
# The rest of the integration expects a Net::HTTP response # The rest of the integration expects a Net::HTTP response
net_http_response
end end
end end
......
...@@ -22,7 +22,7 @@ module EE ...@@ -22,7 +22,7 @@ module EE
end end
def merge_request_params_attributes def merge_request_params_attributes
attrs = super.push( super.push(
{ blocking_merge_request_references: [] }, { blocking_merge_request_references: [] },
:update_blocking_merge_request_refs, :update_blocking_merge_request_refs,
:remove_hidden_blocking_merge_requests, :remove_hidden_blocking_merge_requests,
...@@ -32,8 +32,6 @@ module EE ...@@ -32,8 +32,6 @@ module EE
:approver_ids, :approver_ids,
:reset_approval_rules_to_defaults :reset_approval_rules_to_defaults
) )
attrs
end end
def approval_rule_attributes def approval_rule_attributes
......
...@@ -54,7 +54,7 @@ module Registrations ...@@ -54,7 +54,7 @@ module Registrations
end end
def create_learn_gitlab_project def create_learn_gitlab_project
learn_gitlab_project = File.open(learn_gitlab_template_path) do |archive| File.open(learn_gitlab_template_path) do |archive|
::Projects::GitlabProjectsImportService.new( ::Projects::GitlabProjectsImportService.new(
current_user, current_user,
namespace_id: @project.namespace_id, namespace_id: @project.namespace_id,
...@@ -62,8 +62,6 @@ module Registrations ...@@ -62,8 +62,6 @@ module Registrations
name: learn_gitlab_project_name name: learn_gitlab_project_name
).execute ).execute
end end
learn_gitlab_project
end end
def authorize_create_project! def authorize_create_project!
......
...@@ -9,8 +9,7 @@ class DastScannerProfilesFinder ...@@ -9,8 +9,7 @@ class DastScannerProfilesFinder
relation = DastScannerProfile.all relation = DastScannerProfile.all
relation = by_id(relation) relation = by_id(relation)
relation = by_project(relation) relation = by_project(relation)
relation = by_name(relation) by_name(relation)
relation
end end
private private
......
...@@ -9,8 +9,7 @@ class DastSiteProfilesFinder ...@@ -9,8 +9,7 @@ class DastSiteProfilesFinder
relation = DastSiteProfile.with_dast_site_and_validation relation = DastSiteProfile.with_dast_site_and_validation
relation = by_id(relation) relation = by_id(relation)
relation = by_project(relation) relation = by_project(relation)
relation = by_name(relation) by_name(relation)
relation
end end
private private
......
...@@ -20,8 +20,7 @@ module EE ...@@ -20,8 +20,7 @@ module EE
return ::Ci::DailyBuildGroupReportResult.none unless query_allowed? return ::Ci::DailyBuildGroupReportResult.none unless query_allowed?
collection = ::Ci::DailyBuildGroupReportResult.by_group(params[:group]) collection = ::Ci::DailyBuildGroupReportResult.by_group(params[:group])
collection = filter_report_results(collection) filter_report_results(collection)
collection
end end
private private
...@@ -29,8 +28,7 @@ module EE ...@@ -29,8 +28,7 @@ module EE
override :filter_report_results override :filter_report_results
def filter_report_results(collection) def filter_report_results(collection)
collection = super(collection) collection = super(collection)
collection = by_activity_per_group(collection) by_activity_per_group(collection)
collection
end end
def by_activity_per_group(items) def by_activity_per_group(items)
......
...@@ -14,8 +14,7 @@ module EE ...@@ -14,8 +14,7 @@ module EE
override :filter_projects override :filter_projects
def filter_projects(collection) def filter_projects(collection)
collection = super(collection) collection = super(collection)
collection = by_security_reports_presence(collection) by_security_reports_presence(collection)
collection
end end
def by_security_reports_presence(collection) def by_security_reports_presence(collection)
......
...@@ -9,9 +9,7 @@ module EE ...@@ -9,9 +9,7 @@ module EE
def filter_items(items) def filter_items(items)
items = super(items) items = super(items)
items = by_approvers(items) items = by_approvers(items)
items = by_merge_commit_sha(items) by_merge_commit_sha(items)
items
end end
# Filter by merge requests approval list that contains specified user directly or as part of group membership # Filter by merge requests approval list that contains specified user directly or as part of group membership
......
...@@ -21,8 +21,7 @@ module EE ...@@ -21,8 +21,7 @@ module EE
collection = super(collection) collection = super(collection)
collection = with_vulnerabilities(collection) collection = with_vulnerabilities(collection)
collection = with_code_coverage(collection) collection = with_code_coverage(collection)
collection = by_storage(collection) by_storage(collection)
collection
end end
def by_storage(items) def by_storage(items)
......
...@@ -17,8 +17,7 @@ module EE ...@@ -17,8 +17,7 @@ module EE
def filter_projects(collection) def filter_projects(collection)
collection = super(collection) collection = super(collection)
collection = by_plans(collection) collection = by_plans(collection)
collection = by_aimed_for_deletion(collection) by_aimed_for_deletion(collection)
collection
end end
def by_plans(collection) def by_plans(collection)
......
...@@ -13,9 +13,7 @@ module IncidentManagement ...@@ -13,9 +13,7 @@ module IncidentManagement
return IncidentManagement::OncallRotation.none unless schedule && allowed? return IncidentManagement::OncallRotation.none unless schedule && allowed?
collection = schedule.rotations collection = schedule.rotations
collection = by_id(collection) by_id(collection)
collection
end end
private private
......
...@@ -12,9 +12,7 @@ module IncidentManagement ...@@ -12,9 +12,7 @@ module IncidentManagement
return IncidentManagement::OncallSchedule.none unless allowed? return IncidentManagement::OncallSchedule.none unless allowed?
collection = project.incident_management_oncall_schedules collection = project.incident_management_oncall_schedules
collection = by_iid(collection) by_iid(collection)
collection
end end
private private
......
...@@ -37,8 +37,7 @@ module StatusPage ...@@ -37,8 +37,7 @@ module StatusPage
notes = init_collection notes = init_collection
notes = only_user(notes) notes = only_user(notes)
notes = to_publish(notes) notes = to_publish(notes)
notes = chronological(notes) chronological(notes)
notes
end end
def init_collection def init_collection
......
...@@ -20,14 +20,12 @@ module EE ...@@ -20,14 +20,12 @@ module EE
end end
def maintenance_mode_message def maintenance_mode_message
html = tag.div do tag.div do
tag.p(class: 'gl-mb-3') do tag.p(class: 'gl-mb-3') do
concat(sprite_icon('information-o', css_class: 'gl-icon gl-mr-3')) concat(sprite_icon('information-o', css_class: 'gl-icon gl-mr-3'))
concat(custom_maintenance_mode_message) concat(custom_maintenance_mode_message)
end end
end end
html
end end
def geo_secondary_read_only_message def geo_secondary_read_only_message
......
...@@ -30,9 +30,7 @@ module EE ...@@ -30,9 +30,7 @@ module EE
border_width = small ? '1px' : '2px' border_width = small ? '1px' : '2px'
html = %(<span class="#{wrapper_classes.join(' ')}" style="--label-inset-border: inset 0 0 0 #{border_width} #{label.color}; color: #{label.color}">#{label_html}</span>).html_safe %(<span class="#{wrapper_classes.join(' ')}" style="--label-inset-border: inset 0 0 0 #{border_width} #{label.color}; color: #{label.color}">#{label_html}</span>).html_safe
html
end end
def label_tooltip_title(label) def label_tooltip_title(label)
......
...@@ -14,9 +14,7 @@ module Dashboard ...@@ -14,9 +14,7 @@ module Dashboard
return Project.none unless License.feature_available?(feature) return Project.none unless License.feature_available?(feature)
project_ids = available_project_ids(project_ids) unless include_unavailable project_ids = available_project_ids(project_ids) unless include_unavailable
projects = find_projects(project_ids) find_projects(project_ids)
projects
end end
private private
......
...@@ -23,8 +23,7 @@ module Security ...@@ -23,8 +23,7 @@ module Security
collection = init_collection collection = init_collection
collection = filter_by_package_manager(collection) collection = filter_by_package_manager(collection)
collection = filter_by_vulnerable(collection) collection = filter_by_vulnerable(collection)
collection = sort(collection) sort(collection)
collection
end end
private private
......
...@@ -106,7 +106,7 @@ module Gitlab ...@@ -106,7 +106,7 @@ module Gitlab
raise WriteInsideReadOnlyTransactionError, 'A write query is performed inside a read-only transaction' raise WriteInsideReadOnlyTransactionError, 'A write query is performed inside a read-only transaction'
end end
result = @load_balancer.read_write do |connection| @load_balancer.read_write do |connection|
# Sticking has to be enabled before calling the method. Not doing so # Sticking has to be enabled before calling the method. Not doing so
# could lead to methods called in a block still being performed on a # could lead to methods called in a block still being performed on a
# secondary instead of on a primary (when necessary). # secondary instead of on a primary (when necessary).
...@@ -114,8 +114,6 @@ module Gitlab ...@@ -114,8 +114,6 @@ module Gitlab
connection.send(name, *args, &block) connection.send(name, *args, &block)
end end
result
end end
private private
......
...@@ -13,9 +13,7 @@ RSpec.describe BackfillOperationsFeatureFlagsIid do ...@@ -13,9 +13,7 @@ RSpec.describe BackfillOperationsFeatureFlagsIid do
def setup def setup
namespace = namespaces.create!(name: 'foo', path: 'foo') namespace = namespaces.create!(name: 'foo', path: 'foo')
project = projects.create!(namespace_id: namespace.id) projects.create!(namespace_id: namespace.id)
project
end end
it 'backfills the iid for a flag' do it 'backfills the iid for a flag' do
......
...@@ -19,9 +19,7 @@ RSpec.describe FeatureFlagIssues::DestroyService do ...@@ -19,9 +19,7 @@ RSpec.describe FeatureFlagIssues::DestroyService do
def setup def setup
feature_flag = create(:operations_feature_flag, project: project) feature_flag = create(:operations_feature_flag, project: project)
issue = create(:issue, project: project) issue = create(:issue, project: project)
feature_flag_issue = create(:feature_flag_issue, feature_flag: feature_flag, issue: issue) create(:feature_flag_issue, feature_flag: feature_flag, issue: issue)
feature_flag_issue
end end
describe '#execute' do describe '#execute' do
......
...@@ -52,9 +52,7 @@ module API ...@@ -52,9 +52,7 @@ module API
groups = groups.where.not(id: params[:skip_groups]) if params[:skip_groups].present? groups = groups.where.not(id: params[:skip_groups]) if params[:skip_groups].present?
order_options = { params[:order_by] => params[:sort] } order_options = { params[:order_by] => params[:sort] }
order_options["id"] ||= "asc" order_options["id"] ||= "asc"
groups = groups.reorder(order_options) groups.reorder(order_options)
groups
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -209,10 +209,8 @@ module API ...@@ -209,10 +209,8 @@ module API
end end
def find_personal_access_token def find_personal_access_token
personal_access_token = find_personal_access_token_from_conan_jwt || find_personal_access_token_from_conan_jwt ||
find_personal_access_token_from_http_basic_auth find_personal_access_token_from_http_basic_auth
personal_access_token
end end
def find_user_from_job_token def find_user_from_job_token
......
...@@ -113,9 +113,7 @@ module ErrorTracking ...@@ -113,9 +113,7 @@ module ErrorTracking
uri = URI(url) uri = URI(url)
uri.path.squeeze!('/') uri.path.squeeze!('/')
# Remove trailing slash # Remove trailing slash
uri = uri.to_s.delete_suffix('/') uri.to_s.delete_suffix('/')
uri
end end
def map_to_errors(issues) def map_to_errors(issues)
......
...@@ -96,9 +96,7 @@ module Gitlab ...@@ -96,9 +96,7 @@ module Gitlab
initial_config = Config::External::Processor.new(initial_config, @context).perform initial_config = Config::External::Processor.new(initial_config, @context).perform
initial_config = Config::Extendable.new(initial_config).to_hash initial_config = Config::Extendable.new(initial_config).to_hash
initial_config = Config::Yaml::Tags::Resolver.new(initial_config).to_hash initial_config = Config::Yaml::Tags::Resolver.new(initial_config).to_hash
initial_config = Config::EdgeStagesInjector.new(initial_config).to_hash Config::EdgeStagesInjector.new(initial_config).to_hash
initial_config
end end
def find_sha(project) def find_sha(project)
......
...@@ -25,8 +25,7 @@ module Gitlab ...@@ -25,8 +25,7 @@ module Gitlab
return unless value return unless value
encrypted_token = Base64.decode64(value) encrypted_token = Base64.decode64(value)
decrypted_token = Encryptor.decrypt(AES256_GCM_OPTIONS.merge(value: encrypted_token, iv: nonce)) Encryptor.decrypt(AES256_GCM_OPTIONS.merge(value: encrypted_token, iv: nonce))
decrypted_token
end end
end end
end end
...@@ -12,7 +12,7 @@ module Gitlab ...@@ -12,7 +12,7 @@ module Gitlab
author_url = build_author_url(build.commit, commit) author_url = build_author_url(build.commit, commit)
data = { {
object_kind: 'build', object_kind: 'build',
ref: build.ref, ref: build.ref,
...@@ -67,8 +67,6 @@ module Gitlab ...@@ -67,8 +67,6 @@ module Gitlab
environment: build_environment(build) environment: build_environment(build)
} }
data
end end
private private
......
...@@ -199,8 +199,7 @@ module Gitlab ...@@ -199,8 +199,7 @@ module Gitlab
def linkify_issues(str) def linkify_issues(str)
str = str.gsub(/([Ii]ssue) ([0-9]+)/, '\1 #\2') str = str.gsub(/([Ii]ssue) ([0-9]+)/, '\1 #\2')
str = str.gsub(/([Cc]ase) ([0-9]+)/, '\1 #\2') str.gsub(/([Cc]ase) ([0-9]+)/, '\1 #\2')
str
end end
def escape_for_markdown(str) def escape_for_markdown(str)
...@@ -208,8 +207,7 @@ module Gitlab ...@@ -208,8 +207,7 @@ module Gitlab
str = str.gsub(/^-/, "\\-") str = str.gsub(/^-/, "\\-")
str = str.gsub("`", "\\~") str = str.gsub("`", "\\~")
str = str.delete("\r") str = str.delete("\r")
str = str.gsub("\n", " \n") str.gsub("\n", " \n")
str
end end
def format_content(raw_content) def format_content(raw_content)
......
...@@ -127,10 +127,9 @@ module Gitlab ...@@ -127,10 +127,9 @@ module Gitlab
end end
def decorate! def decorate!
collection = each_with_index do |element, i| each_with_index do |element, i|
@array[i] = yield(element) @array[i] = yield(element)
end end
collection
end end
alias_method :to_ary, :to_a alias_method :to_ary, :to_a
......
...@@ -30,15 +30,13 @@ module Gitlab ...@@ -30,15 +30,13 @@ module Gitlab
# ex: " OR (relative_position = 23 AND id > 500)" # ex: " OR (relative_position = 23 AND id > 500)"
def second_attribute_condition def second_attribute_condition
condition = <<~SQL <<~SQL
OR ( OR (
#{table_condition(order_list.first, values.first, '=').to_sql} #{table_condition(order_list.first, values.first, '=').to_sql}
AND AND
#{table_condition(order_list[1], values[1], operators[1]).to_sql} #{table_condition(order_list[1], values[1], operators[1]).to_sql}
) )
SQL SQL
condition
end end
# ex: " OR (relative_position IS NULL)" # ex: " OR (relative_position IS NULL)"
......
...@@ -14,15 +14,13 @@ module Gitlab ...@@ -14,15 +14,13 @@ module Gitlab
# ex: "(relative_position IS NULL AND id > 500)" # ex: "(relative_position IS NULL AND id > 500)"
def first_attribute_condition def first_attribute_condition
condition = <<~SQL <<~SQL
( (
#{table_condition(order_list.first, nil, 'is_null').to_sql} #{table_condition(order_list.first, nil, 'is_null').to_sql}
AND AND
#{table_condition(order_list[1], values[1], operators[1]).to_sql} #{table_condition(order_list[1], values[1], operators[1]).to_sql}
) )
SQL SQL
condition
end end
# ex: " OR (relative_position IS NOT NULL)" # ex: " OR (relative_position IS NOT NULL)"
......
...@@ -224,11 +224,9 @@ module Gitlab ...@@ -224,11 +224,9 @@ module Gitlab
frag_path = frag_path.gsub(DOTS_RE) do |dots| frag_path = frag_path.gsub(DOTS_RE) do |dots|
rel_dir(dots.split('/').count) rel_dir(dots.split('/').count)
end end
frag_path = frag_path.gsub(IMPLICIT_ROOT) do frag_path.gsub(IMPLICIT_ROOT) do
(Rails.root / 'app').to_s + '/' (Rails.root / 'app').to_s + '/'
end end
frag_path
end end
def rel_dir(n_steps_up) def rel_dir(n_steps_up)
......
...@@ -104,9 +104,7 @@ module Gitlab ...@@ -104,9 +104,7 @@ module Gitlab
def format_query(metric) def format_query(metric)
expression = remove_new_lines(metric[:expr]) expression = remove_new_lines(metric[:expr])
expression = replace_variables(expression) expression = replace_variables(expression)
expression = replace_global_variables(expression, metric) replace_global_variables(expression, metric)
expression
end end
# Accomodates instance-defined Grafana variables. # Accomodates instance-defined Grafana variables.
...@@ -135,9 +133,7 @@ module Gitlab ...@@ -135,9 +133,7 @@ module Gitlab
def replace_global_variables(expression, metric) def replace_global_variables(expression, metric)
expression = expression.gsub('$__interval', metric[:interval]) if metric[:interval] expression = expression.gsub('$__interval', metric[:interval]) if metric[:interval]
expression = expression.gsub('$__from', query_params[:from]) expression = expression.gsub('$__from', query_params[:from])
expression = expression.gsub('$__to', query_params[:to]) expression.gsub('$__to', query_params[:to])
expression
end end
# Removes new lines from expression. # Removes new lines from expression.
......
...@@ -26,16 +26,13 @@ module Gitlab ...@@ -26,16 +26,13 @@ module Gitlab
# Repeated dashes are invalid (OpenShift limitation) # Repeated dashes are invalid (OpenShift limitation)
slugified.squeeze!('-') slugified.squeeze!('-')
slugified = if slugified.size > 24 || slugified != name
if slugified.size > 24 || slugified != name # Maximum length: 24 characters (OpenShift limitation)
# Maximum length: 24 characters (OpenShift limitation) shorten_and_add_suffix(slugified)
shorten_and_add_suffix(slugified) else
else # Cannot end with a dash (Kubernetes label limitation)
# Cannot end with a dash (Kubernetes label limitation) slugified.chomp('-')
slugified.chomp('-') end
end
slugified
end end
private private
......
...@@ -53,12 +53,10 @@ module QA ...@@ -53,12 +53,10 @@ module QA
end end
def run_saml_idp_service(group_name) def run_saml_idp_service(group_name)
service = Service::DockerRun::SamlIdp.new(Runtime::Scenario.gitlab_address, group_name).tap do |runner| Service::DockerRun::SamlIdp.new(Runtime::Scenario.gitlab_address, group_name).tap do |runner|
runner.pull runner.pull
runner.register! runner.register!
end end
service
end end
def remove_saml_idp_service(saml_idp_service) def remove_saml_idp_service(saml_idp_service)
......
...@@ -43,7 +43,7 @@ module GitalyTest ...@@ -43,7 +43,7 @@ module GitalyTest
end end
def env def env
env_hash = { {
'HOME' => File.expand_path('tmp/tests'), 'HOME' => File.expand_path('tmp/tests'),
'GEM_PATH' => Gem.path.join(':'), 'GEM_PATH' => Gem.path.join(':'),
'BUNDLE_APP_CONFIG' => File.join(gemfile_dir, '.bundle'), 'BUNDLE_APP_CONFIG' => File.join(gemfile_dir, '.bundle'),
...@@ -54,8 +54,6 @@ module GitalyTest ...@@ -54,8 +54,6 @@ module GitalyTest
# Git hooks can't run during tests as the internal API is not running. # Git hooks can't run during tests as the internal API is not running.
'GITALY_TESTING_NO_GIT_HOOKS' => "1" 'GITALY_TESTING_NO_GIT_HOOKS' => "1"
} }
env_hash
end end
# rubocop:disable GitlabSecurity/SystemCommandInjection # rubocop:disable GitlabSecurity/SystemCommandInjection
......
...@@ -2016,9 +2016,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers do ...@@ -2016,9 +2016,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
def setup def setup
namespace = namespaces.create!(name: 'foo', path: 'foo') namespace = namespaces.create!(name: 'foo', path: 'foo')
project = projects.create!(namespace_id: namespace.id) projects.create!(namespace_id: namespace.id)
project
end end
it 'generates iids properly for models created after the migration' do it 'generates iids properly for models created after the migration' do
......
...@@ -10,9 +10,7 @@ RSpec.describe BackfillOperationsFeatureFlagsActive do ...@@ -10,9 +10,7 @@ RSpec.describe BackfillOperationsFeatureFlagsActive do
def setup def setup
namespace = namespaces.create!(name: 'foo', path: 'foo') namespace = namespaces.create!(name: 'foo', path: 'foo')
project = projects.create!(namespace_id: namespace.id) projects.create!(namespace_id: namespace.id)
project
end end
it 'executes successfully when there are no flags in the table' do it 'executes successfully when there are no flags in the table' do
......
...@@ -10,9 +10,7 @@ RSpec.describe BackfillOperationsFeatureFlagsIid do ...@@ -10,9 +10,7 @@ RSpec.describe BackfillOperationsFeatureFlagsIid do
def setup def setup
namespace = namespaces.create!(name: 'foo', path: 'foo') namespace = namespaces.create!(name: 'foo', path: 'foo')
project = projects.create!(namespace_id: namespace.id) projects.create!(namespace_id: namespace.id)
project
end end
it 'migrates successfully when there are no flags in the database' do it 'migrates successfully when there are no flags in the database' do
......
...@@ -10,9 +10,7 @@ RSpec.describe DeleteInternalIdsWhereFeatureFlagsUsage do ...@@ -10,9 +10,7 @@ RSpec.describe DeleteInternalIdsWhereFeatureFlagsUsage do
def setup def setup
namespace = namespaces.create!(name: 'foo', path: 'foo') namespace = namespaces.create!(name: 'foo', path: 'foo')
project = projects.create!(namespace_id: namespace.id) projects.create!(namespace_id: namespace.id)
project
end end
it 'deletes feature flag rows from the internal_ids table' do it 'deletes feature flag rows from the internal_ids table' do
......
...@@ -12,9 +12,7 @@ RSpec.describe MigrateOpsFeatureFlagsScopesTargetUserIds do ...@@ -12,9 +12,7 @@ RSpec.describe MigrateOpsFeatureFlagsScopesTargetUserIds do
def setup def setup
namespace = namespaces.create!(name: 'foo', path: 'foo') namespace = namespaces.create!(name: 'foo', path: 'foo')
project = projects.create!(namespace_id: namespace.id) project = projects.create!(namespace_id: namespace.id)
flag = flags.create!(project_id: project.id, active: true, name: 'test_flag') flags.create!(project_id: project.id, active: true, name: 'test_flag')
flag
end end
it 'migrates successfully when there are no scopes in the database' do it 'migrates successfully when there are no scopes in the database' do
......
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