Commit 06571e03 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'pl-rubocop-todo-parallel-assignment' into 'master'

Resolves rubocop offense Style/ParallelAssignment

See merge request gitlab-org/gitlab!57999
parents 7f333beb b62ce98c
......@@ -845,11 +845,6 @@ Style/Next:
Style/NumericLiteralPrefix:
Enabled: false
# Offense count: 140
# Cop supports --auto-correct.
Style/ParallelAssignment:
Enabled: false
# Offense count: 2698
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
......
......@@ -308,7 +308,8 @@ class Clusters::ClustersController < Clusters::BaseController
def proxy_variable_substitution_service
@empty_service ||= Class.new(BaseService) do
def initialize(proxyable, params)
@proxyable, @params = proxyable, params
@proxyable = proxyable
@params = params
end
def execute
......
......@@ -63,7 +63,8 @@ class Projects::CommitsController < Projects::ApplicationController
def set_commits
render_404 unless @path.empty? || request.format == :atom || @repository.blob_at(@commit.id, @path) || @repository.tree(@commit.id, @path).entries.present?
@limit, @offset = (params[:limit] || 40).to_i, (params[:offset] || 0).to_i
@limit = (params[:limit] || 40).to_i
@offset = (params[:offset] || 0).to_i
search = params[:search]
author = params[:author]
......
......@@ -3,7 +3,8 @@
module Ci
class VariablesFinder
def initialize(resource, params)
@resource, @params = resource, params
@resource = resource
@params = params
raise ArgumentError, 'Please provide params[:key]' if params[:key].blank?
end
......
......@@ -4,7 +4,9 @@ class EnvironmentsByDeploymentsFinder
attr_reader :project, :current_user, :params
def initialize(project, current_user, params = {})
@project, @current_user, @params = project, current_user, params
@project = project
@current_user = current_user
@params = params
end
# rubocop: disable CodeReuse/ActiveRecord
......
......@@ -6,7 +6,9 @@ class EnvironmentsFinder
InvalidStatesError = Class.new(StandardError)
def initialize(project, current_user, params = {})
@project, @current_user, @params = project, current_user, params
@project = project
@current_user = current_user
@params = params
end
def execute
......
......@@ -4,7 +4,8 @@ module Metrics
module Dashboards
class AnnotationsFinder
def initialize(dashboard:, params:)
@dashboard, @params = dashboard, params
@dashboard = dashboard
@params = params
end
def execute
......
......@@ -3,7 +3,9 @@
module Metrics
class UsersStarredDashboardsFinder
def initialize(user:, project:, params: {})
@user, @project, @params = user, project, params
@user = user
@project = project
@params = params
end
def execute
......
......@@ -4,7 +4,8 @@ module Packages
module Debian
class DistributionsFinder
def initialize(container, params = {})
@container, @params = container, params
@container = container
@params = params
end
def execute
......
......@@ -18,7 +18,8 @@ module SubmoduleHelper
end
if url =~ %r{([^/:]+)/([^/]+(?:\.git)?)\Z}
namespace, project = Regexp.last_match(1), Regexp.last_match(2)
namespace = Regexp.last_match(1)
project = Regexp.last_match(2)
gitlab_hosts = [Gitlab.config.gitlab.url,
Gitlab.config.gitlab_shell.ssh_path_prefix]
......
......@@ -58,7 +58,8 @@ class Ability
def allowed?(user, action, subject = :global, opts = {})
if subject.is_a?(Hash)
opts, subject = subject, :global
opts = subject
subject = :global
end
policy = policy_for(user, subject)
......
......@@ -438,11 +438,14 @@ module ApplicationSettingImplementation
def parse_addr_and_port(str)
case str
when /\A\[(?<address> .* )\]:(?<port> \d+ )\z/x # string like "[::1]:80"
address, port = $~[:address], $~[:port]
address = $~[:address]
port = $~[:port]
when /\A(?<address> [^:]+ ):(?<port> \d+ )\z/x # string like "127.0.0.1:80"
address, port = $~[:address], $~[:port]
address = $~[:address]
port = $~[:port]
else # string with no port number
address, port = str, nil
address = str
port = nil
end
[address, port&.to_i]
......
......@@ -62,7 +62,8 @@ class Commit
collection.sort do |a, b|
operands = [a, b].tap { |o| o.reverse! if sort == 'desc' }
attr1, attr2 = operands.first.public_send(order_by), operands.second.public_send(order_by) # rubocop:disable GitlabSecurity/PublicSend
attr1 = operands.first.public_send(order_by) # rubocop:disable GitlabSecurity/PublicSend
attr2 = operands.second.public_send(order_by) # rubocop:disable GitlabSecurity/PublicSend
# use case insensitive comparison for string values
order_by.in?(%w[email name]) ? attr1.casecmp(attr2) : attr1 <=> attr2
......
......@@ -30,7 +30,8 @@ module Taskable
end
def self.get_updated_tasks(old_content:, new_content:)
old_tasks, new_tasks = get_tasks(old_content), get_tasks(new_content)
old_tasks = get_tasks(old_content)
new_tasks = get_tasks(new_content)
new_tasks.select.with_index do |new_task, i|
old_task = old_tasks[i]
......
......@@ -29,7 +29,9 @@ module DesignManagement
# - design [DesignManagement::Design]: the design that was changed
# - action [Symbol]: the action that gitaly performed
def initialize(design, action, content = nil)
@design, @action, @content = design, action, content
@design = design
@action = action
@content = content
validate!
end
......
......@@ -18,7 +18,8 @@ module DesignManagement
validate :design_and_version_have_issue_id
def initialize(design: nil, version: nil)
@design, @version = design, version
@design = design
@version = version
end
# The ID, needed by GraphQL types and as part of the Lazy-fetch
......
......@@ -14,7 +14,9 @@ module DesignManagement
attr_reader :sha, :issue_id, :actions
def initialize(sha, issue_id, actions)
@sha, @issue_id, @actions = sha, issue_id, actions
@sha = sha
@issue_id = issue_id
@actions = actions
end
def message
......
......@@ -6,7 +6,8 @@ class ExternalIssue
attr_reader :project
def initialize(issue_identifier, project)
@issue_identifier, @project = issue_identifier, project
@issue_identifier = issue_identifier
@project = project
end
def to_s
......
......@@ -291,7 +291,9 @@ class Member < ApplicationRecord
private
def parse_users_list(source, list)
emails, user_ids, users = [], [], []
emails = []
user_ids = []
users = []
existing_members = {}
list.each do |item|
......
......@@ -13,7 +13,9 @@ module Preloaders
attr_reader :labels, :user, :project
def initialize(labels, user, project = nil)
@labels, @user, @project = labels, user, project
@labels = labels
@user = user
@project = project
end
def preload_all
......
......@@ -3,7 +3,9 @@
module ApplicationSettings
class BaseService < ::BaseService
def initialize(application_setting, user, params = {})
@application_setting, @current_user, @params = application_setting, user, params.dup
@application_setting = application_setting
@current_user = user
@params = params.dup
end
end
end
......@@ -7,6 +7,8 @@ class BaseContainerService
attr_reader :container, :current_user, :params
def initialize(container:, current_user: nil, params: {})
@container, @current_user, @params = container, current_user, params.dup
@container = container
@current_user = current_user
@params = params.dup
end
end
......@@ -15,7 +15,9 @@ class BaseService
attr_accessor :project, :current_user, :params
def initialize(project, user = nil, params = {})
@project, @current_user, @params = project, user, params.dup
@project = project
@current_user = user
@params = params.dup
end
delegate :repository, to: :project
......
......@@ -6,7 +6,9 @@ module Boards
attr_accessor :parent, :current_user, :params
def initialize(parent, user, params = {})
@parent, @current_user, @params = parent, user, params.dup
@parent = parent
@current_user = user
@params = params.dup
end
end
end
......
......@@ -96,7 +96,8 @@ module Ci
# rubocop: enable Metrics/ParameterLists
def execute!(*args, &block)
source, params = args[0], Hash(args[1])
source = args[0]
params = Hash(args[1])
execute(source, **params, &block).tap do |pipeline|
unless pipeline.persisted?
......
......@@ -5,7 +5,8 @@ module Clusters
attr_reader :current_user, :params
def initialize(user = nil, params = {})
@current_user, @params = user, params.dup
@current_user = user
@params = params.dup
end
def execute(access_token: nil)
......
......@@ -5,7 +5,8 @@ module Clusters
attr_reader :current_user, :params
def initialize(user = nil, params = {})
@current_user, @params = user, params.dup
@current_user = user
@params = params.dup
@response = {}
end
......
......@@ -5,7 +5,8 @@ module Clusters
attr_reader :current_user, :params
def initialize(user = nil, params = {})
@current_user, @params = user, params.dup
@current_user = user
@params = params.dup
end
def execute(cluster)
......
......@@ -5,7 +5,9 @@ module DraftNotes
attr_accessor :merge_request, :current_user, :params
def initialize(merge_request, current_user, params = nil)
@merge_request, @current_user, @params = merge_request, current_user, params.dup
@merge_request = merge_request
@current_user = current_user
@params = params.dup
end
def merge_request_activity_counter
......
......@@ -8,7 +8,9 @@ module Git
attr_reader :wiki
def initialize(wiki, current_user, params)
@wiki, @current_user, @params = wiki, current_user, params.dup
@wiki = wiki
@current_user = current_user
@params = params.dup
end
def execute
......
......@@ -9,7 +9,9 @@ module Git
# @param [Hash] change - must have keys `:oldrev` and `:newrev`
# @param [Gitlab::Git::RawDiffChange] raw_change
def initialize(wiki, change, raw_change)
@wiki, @raw_change, @change = wiki, raw_change, change
@wiki = wiki
@raw_change = raw_change
@change = change
end
def page
......
......@@ -5,7 +5,9 @@ module Groups
attr_accessor :group, :current_user, :params
def initialize(group, user, params = {})
@group, @current_user, @params = group, user, params.dup
@group = group
@current_user = user
@params = params.dup
end
private
......
......@@ -3,7 +3,8 @@
module Groups
class CreateService < Groups::BaseService
def initialize(user, params = {})
@current_user, @params = user, params.dup
@current_user = user
@params = params.dup
@chat_team = @params.delete(:create_chat_team)
end
......
......@@ -5,7 +5,8 @@ module Groups
attr_reader :group_path, :visibility_level
def initialize(user, params)
@current_user, @params = user, params.dup
@current_user = user
@params = params.dup
@group_path = @params.delete(:group_path)
@visibility_level = @params.delete(:visibility_level) ||
Gitlab::CurrentSettings.current_application_settings.default_group_visibility
......
......@@ -7,7 +7,9 @@ module Issuable
attr_accessor :parent, :current_user, :params
def initialize(parent, user = nil, params = {})
@parent, @current_user, @params = parent, user, params.dup
@parent = parent
@current_user = user
@params = params.dup
end
def execute(type)
......
......@@ -7,7 +7,9 @@ module IssuableLinks
attr_reader :issuable, :current_user, :params
def initialize(issuable, user, params)
@issuable, @current_user, @params = issuable, user, params.dup
@issuable = issuable
@current_user = user
@params = params.dup
end
def execute
......
......@@ -7,7 +7,8 @@ module IssuableLinks
attr_reader :issuable, :current_user
def initialize(issuable, user)
@issuable, @current_user = issuable, user
@issuable = issuable
@current_user = user
end
def execute
......
......@@ -5,7 +5,9 @@ module JiraConnectSubscriptions
attr_accessor :jira_connect_installation, :current_user, :params
def initialize(jira_connect_installation, user = nil, params = {})
@jira_connect_installation, @current_user, @params = jira_connect_installation, user, params.dup
@jira_connect_installation = jira_connect_installation
@current_user = user
@params = params.dup
end
end
end
......@@ -5,7 +5,8 @@ module Keys
attr_accessor :user, :params
def initialize(user, params = {})
@user, @params = user, params
@user = user
@params = params
@ip_address = @params.delete(:ip_address)
end
......
......@@ -5,7 +5,8 @@ module Keys
attr_accessor :current_user
def initialize(current_user, params = {})
@current_user, @params = current_user, params
@current_user = current_user
@params = params
@ip_address = @params.delete(:ip_address)
@user = params.delete(:user) || current_user
end
......
......@@ -3,7 +3,8 @@
module Mattermost
class CreateTeamService < ::BaseService
def initialize(group, current_user)
@group, @current_user = group, current_user
@group = group
@current_user = current_user
end
def execute
......
......@@ -13,7 +13,8 @@ module Metrics
:create
def initialize(user, params)
@user, @params = user, params
@user = user
@params = params
end
def execute
......
......@@ -11,7 +11,8 @@ module Metrics
:delete
def initialize(user, annotation)
@user, @annotation = user, annotation
@user = user
@annotation = annotation
end
def execute
......
......@@ -122,7 +122,8 @@ module Metrics
# Identifies the uid of the dashboard based on url format
class GrafanaUidParser
def initialize(grafana_url, project)
@grafana_url, @project = grafana_url, project
@grafana_url = grafana_url
@project = project
end
def parse
......@@ -145,7 +146,8 @@ module Metrics
# If no panel is specified, defaults to the first valid panel.
class DatasourceNameParser
def initialize(grafana_url, grafana_dashboard)
@grafana_url, @grafana_dashboard = grafana_url, grafana_dashboard
@grafana_url = grafana_url
@grafana_dashboard = grafana_dashboard
end
def parse
......
......@@ -22,7 +22,9 @@ module Metrics
].freeze
def initialize(project, panel_yaml, environment)
@project, @panel_yaml, @environment = project, panel_yaml, environment
@project = project
@panel_yaml = panel_yaml
@environment = environment
end
def execute
......
......@@ -11,7 +11,9 @@ module Metrics
:create
def initialize(user, project, dashboard_path)
@user, @project, @dashboard_path = user, project, dashboard_path
@user = user
@project = project
@dashboard_path = dashboard_path
end
def execute
......
......@@ -5,7 +5,9 @@ module Metrics
module UsersStarredDashboards
class DeleteService < ::BaseService
def initialize(user, project, dashboard_path = nil)
@user, @project, @dashboard_path = user, project, dashboard_path
@user = user
@project = project
@dashboard_path = dashboard_path
end
def execute
......
......@@ -6,7 +6,9 @@ module Milestones
attr_accessor :parent, :current_user, :params
def initialize(parent, user, params = {})
@parent, @current_user, @params = parent, user, params.dup
@parent = parent
@current_user = user
@params = params.dup
super
end
end
......
......@@ -5,7 +5,9 @@ module Milestones
attr_accessor :project, :current_user, :params
def initialize(project, user, params = {})
@project, @current_user, @params = project, user, params.dup
@project = project
@current_user = user
@params = params.dup
end
def execute
......
......@@ -6,7 +6,9 @@ module NotificationRecipients
attr_reader :merge_request, :current_user, :reviewer
def initialize(merge_request, current_user, reviewer)
@merge_request, @current_user, @reviewer = merge_request, current_user, reviewer
@merge_request = merge_request
@current_user = current_user
@reviewer = reviewer
end
def target
......
......@@ -6,7 +6,8 @@ module Packages
InvalidJson = Class.new(StandardError)
def initialize(project, target)
@project, @target = project, target
@project = project
@target = target
end
def execute
......
......@@ -4,7 +4,8 @@ module Packages
module Composer
class VersionParserService
def initialize(tag_name: nil, branch_name: nil)
@tag_name, @branch_name = tag_name, branch_name
@tag_name = tag_name
@branch_name = branch_name
end
def execute
......
......@@ -4,7 +4,8 @@ module Packages
module Debian
class CreateDistributionService
def initialize(container, user, params)
@container, @params = container, params
@container = container
@params = params
@params[:creator] = user
@components = params.delete(:components) || ['main']
......
......@@ -4,7 +4,8 @@ module Packages
module Debian
class UpdateDistributionService
def initialize(distribution, params)
@distribution, @params = distribution, params
@distribution = distribution
@params = params
@components = params.delete(:components)
......
......@@ -33,7 +33,8 @@ module Packages
#
# The first upload has to create the proper package (the one with the version set).
if params[:file_name] == Packages::Maven::Metadata.filename && !params[:path]&.ends_with?(SNAPSHOT_TERM)
package_name, version = params[:path], nil
package_name = params[:path]
version = nil
else
package_name, _, version = params[:path].rpartition('/')
end
......
......@@ -71,7 +71,8 @@ class Projects::BranchesByModeService
# And increase it whenever we go to the next page
previous_offset = params[:offset].to_i
previous_path, next_path = nil, nil
previous_path = nil
next_path = nil
return [branches, previous_path, next_path] if branches.blank?
......
......@@ -7,7 +7,8 @@ module Projects
attr_reader :template_name
def initialize(user, params)
@current_user, @params = user, params.to_h.dup
@current_user = user
@params = params.to_h.dup
@template_name = @params.delete(:template_name).presence
end
......
......@@ -5,11 +5,12 @@ module Projects
include ValidatesClassificationLabel
def initialize(user, params)
@current_user, @params = user, params.dup
@skip_wiki = @params.delete(:skip_wiki)
@current_user = user
@params = params.dup
@skip_wiki = @params.delete(:skip_wiki)
@initialize_with_readme = Gitlab::Utils.to_boolean(@params.delete(:initialize_with_readme))
@import_data = @params.delete(:import_data)
@relations_block = @params.delete(:relations_block)
@import_data = @params.delete(:import_data)
@relations_block = @params.delete(:relations_block)
end
def execute
......
......@@ -7,7 +7,8 @@ module Projects
].freeze
def initialize(project, url)
@project, @url = project, url
@project = project
@url = url
end
def execute
......
......@@ -11,7 +11,9 @@ module Projects
attr_reader :current_user, :params
def initialize(user, import_params, override_params = nil)
@current_user, @params, @override_params = user, import_params.dup, override_params
@current_user = user
@params = import_params.dup
@override_params = override_params
end
def execute
......
......@@ -23,7 +23,8 @@ module Projects
attr_reader :build
def initialize(project, build)
@project, @build = project, build
@project = project
@build = build
end
def execute
......
......@@ -41,7 +41,8 @@ module Prometheus
# }
# })
def initialize(environment, params = {})
@environment, @params = environment, params.deep_dup
@environment = environment
@params = params.deep_dup
end
# @return - params [Hash<Symbol,Any>] Returns a Hash containing a params key which is
......
......@@ -8,7 +8,9 @@ module Releases
attr_accessor :project, :current_user, :params
def initialize(project, user = nil, params = {})
@project, @current_user, @params = project, user, params.dup
@project = project
@current_user = user
@params = params.dup
end
def tag_name
......
......@@ -5,7 +5,8 @@ module ResourceEvents
attr_reader :resource, :user
def initialize(resource, user)
@resource, @user = resource, user
@resource = resource
@user = user
end
def execute(added_labels: [], removed_labels: [])
......
......@@ -5,7 +5,8 @@ module ResourceEvents
attr_reader :resource, :user
def initialize(user:, resource:)
@user, @resource = user, resource
@user = user
@resource = resource
end
def execute(params)
......
......@@ -9,7 +9,8 @@ module Search
attr_accessor :current_user, :params
def initialize(user, params)
@current_user, @params = user, params.dup
@current_user = user
@params = params.dup
end
def execute
......
......@@ -9,7 +9,9 @@ module Search
attr_accessor :project, :current_user, :params
def initialize(project, user, params)
@project, @current_user, @params = project, user, params.dup
@project = project
@current_user = user
@params = params.dup
end
def execute
......
......@@ -9,9 +9,11 @@ class TaskListToggleService
attr_reader :updated_markdown, :updated_markdown_html
def initialize(markdown, markdown_html, line_source:, line_number:, toggle_as_checked:)
@markdown, @markdown_html = markdown, markdown_html
@line_source, @line_number = line_source, line_number
@toggle_as_checked = toggle_as_checked
@markdown = markdown
@markdown_html = markdown_html
@line_source = line_source
@line_number = line_number
@toggle_as_checked = toggle_as_checked
@updated_markdown, @updated_markdown_html = nil
end
......
......@@ -7,7 +7,8 @@ module TwoFactor
attr_reader :current_user, :params, :user
def initialize(current_user, params = {})
@current_user, @params = current_user, params
@current_user = current_user
@params = params
@user = params.delete(:user)
end
end
......
......@@ -5,7 +5,10 @@ class UploadService
attr_accessor :override_max_attachment_size
def initialize(model, file, uploader_class = FileUploader, **uploader_context)
@model, @file, @uploader_class, @uploader_context = model, file, uploader_class, uploader_context
@model = model
@file = file
@uploader_class = uploader_class
@uploader_context = uploader_context
end
def execute
......
......@@ -4,7 +4,8 @@ class UserAgentDetailService
attr_accessor :spammable, :request
def initialize(spammable, request)
@spammable, @request = spammable, request
@spammable = spammable
@request = request
end
def create
......
......@@ -3,7 +3,8 @@
module Users
class RespondToTermsService
def initialize(user, term)
@user, @term = user, term
@user = user
@term = term
end
# rubocop: disable CodeReuse/ActiveRecord
......
......@@ -7,7 +7,8 @@ module Users
attr_reader :current_user, :target_user, :params
def initialize(current_user, params)
@current_user, @params = current_user, params.dup
@current_user = current_user
@params = params.dup
@target_user = params.delete(:user) || current_user
end
......
- note_count = @issuable_meta_data[issuable.id].user_notes_count
- issue_votes = @issuable_meta_data[issuable.id]
- upvotes, downvotes = issue_votes.upvotes, issue_votes.downvotes
- upvotes = issue_votes.upvotes
- downvotes = issue_votes.downvotes
- issuable_path = issuable_path(issuable, anchor: 'notes')
- issuable_mr = @issuable_meta_data[issuable.id].merge_requests_count
......
......@@ -16,7 +16,8 @@ module ObjectStorage
attr_accessor :error
def initialize(upload, error = nil)
@upload, @error = upload, error
@upload = upload
@error = error
end
def success?
......
---
title: Resolves offenses Style/ParallelAssignment
merge_request: 57999
author: Shubham Kumar (@imskr)
type: fixed
......@@ -8,7 +8,9 @@ module Admin
LEASE_KEY = 'admin/email_service'
def initialize(recipients, subject, body)
@recipients, @subject, @body = recipients, subject, body
@recipients = recipients
@subject = subject
@body = body
end
def execute
......
......@@ -7,7 +7,9 @@ module Epics
attr_reader :group, :parent_epic, :child_epic
def initialize(group, current_user, params = {})
@group, @current_user, @params = group, current_user, params
@group = group
@current_user = current_user
@params = params
end
private
......
......@@ -8,7 +8,9 @@ module Iterations
attr_accessor :group, :current_user, :params
def initialize(group, user, params = {})
@group, @current_user, @params = group, user, params.dup
@group = group
@current_user = user
@params = params.dup
end
def execute
......
......@@ -6,7 +6,9 @@ module Iterations
include Gitlab::Allowable
def initialize(iteration_cadence, user, params = {})
@iteration_cadence, @current_user, @params = iteration_cadence, user, params.dup
@iteration_cadence = iteration_cadence
@current_user = user
@params = params.dup
end
def execute
......
......@@ -8,7 +8,9 @@ module Iterations
attr_accessor :parent, :current_user, :params
def initialize(parent, user, params = {})
@parent, @current_user, @params = parent, user, params.dup
@parent = parent
@current_user = user
@params = params.dup
end
def execute
......
......@@ -9,7 +9,9 @@ module Iterations
attr_accessor :parent, :current_user, :params
def initialize(parent, user, params = {})
@parent, @current_user, @params = parent, user, params.dup
@parent = parent
@current_user = user
@params = params.dup
end
def execute(iteration)
......
......@@ -5,7 +5,8 @@ module Licenses
include Gitlab::Allowable
def initialize(license, user)
@license, @user = license, user
@license = license
@user = user
end
def execute
......
......@@ -70,7 +70,8 @@ module Security
def sort_findings!
@findings.sort! do |a, b|
a_severity, b_severity = a.severity, b.severity
a_severity = a.severity
b_severity = b.severity
if a_severity == b_severity
a.compare_key <=> b.compare_key
......@@ -99,7 +100,8 @@ module Security
return unless reports_sortable?
@source_reports.sort! do |a, b|
a_scanner_id, b_scanner_id = a.scanners.values[0].external_id, b.scanners.values[0].external_id
a_scanner_id = a.scanners.values[0].external_id
b_scanner_id = b.scanners.values[0].external_id
a_scanner_id = "unknown" if ANALYZER_ORDER[a_scanner_id].nil?
b_scanner_id = "unknown" if ANALYZER_ORDER[b_scanner_id].nil?
......
......@@ -5,7 +5,10 @@ module VulnerabilityFeedback
include Gitlab::Utils::StrongMemoize
def initialize(project, user, vulnerability_feedback, revert_vulnerability_state: true)
@project, @current_user, @vulnerability_feedback, @revert_vulnerability_state = project, user, vulnerability_feedback, revert_vulnerability_state
@project = project
@current_user = user
@vulnerability_feedback = vulnerability_feedback
@revert_vulnerability_state = revert_vulnerability_state
end
def execute
......
......@@ -10,7 +10,9 @@ class RepositoryPushAuditEventWorker # rubocop:disable Scalability/IdempotentWor
user = User.find(user_id)
changes.map! do |change|
before, after, ref = change['before'], change['after'], change['ref']
before = change['before']
after = change['after']
ref = change['ref']
service = EE::AuditEvents::RepositoryPushAuditEventService
.new(user, project, ref, before, after)
......
......@@ -6,7 +6,8 @@ module Elastic
attr_reader :class_name, :record_id
def initialize(class_name, record_id)
@class_name, @record_id = class_name, record_id
@class_name = class_name
@record_id = record_id
end
def message
......
......@@ -6,7 +6,9 @@ module Gitlab
include ::Gitlab::Utils::StrongMemoize
def initialize(project, ref, paths)
@project, @ref, @paths = project, ref, Array(paths)
@project = project
@ref = ref
@paths = Array(paths)
end
def entries
......
......@@ -62,7 +62,8 @@ RSpec.describe 'EE > Projects > Licenses > Maintainer views policies', :js do
end
def label_for(dependency)
name, version = dependency['name'], dependency['version']
name = dependency['name']
version = dependency['version']
version ? "#{name} (#{version})" : name
end
......
......@@ -18,7 +18,8 @@ module Banzai
def references_in(text, pattern = Label.reference_pattern)
labels = {}
unescaped_html = unescape_html_entities(text).gsub(pattern) do |match|
namespace, project = $~[:namespace], $~[:project]
namespace = $~[:namespace]
project = $~[:project]
project_path = full_project_path(namespace, project)
label = find_label_cached(project_path, $~[:label_id], $~[:label_name])
......
......@@ -5,7 +5,8 @@ module ContainerRegistry
attr_reader :tag, :blob, :data
def initialize(tag, blob)
@tag, @blob = tag, blob
@tag = tag
@blob = blob
@data = Gitlab::Json.parse(blob.data)
end
......
......@@ -10,7 +10,8 @@ module ContainerRegistry
delegate :revision, :short_revision, to: :config_blob, allow_nil: true
def initialize(repository, name)
@repository, @name = repository, name
@repository = repository
@name = name
end
def valid?
......
......@@ -5,7 +5,8 @@ module DeclarativePolicy
PREFERRED_SCOPE_KEY = :"DeclarativePolicy.preferred_scope"
def with_preferred_scope(scope)
Thread.current[PREFERRED_SCOPE_KEY], old_scope = scope, Thread.current[PREFERRED_SCOPE_KEY]
old_scope = Thread.current[PREFERRED_SCOPE_KEY]
Thread.current[PREFERRED_SCOPE_KEY] = scope
yield
ensure
Thread.current[PREFERRED_SCOPE_KEY] = old_scope
......
......@@ -11,7 +11,8 @@ class FileSizeValidator < ActiveModel::EachValidator
if range = (options.delete(:in) || options.delete(:within))
raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range)
options[:minimum], options[:maximum] = range.begin, range.end
options[:minimum] = range.begin
options[:maximum] = range.end
options[:maximum] -= 1 if range.exclude_end?
end
......
......@@ -46,7 +46,8 @@ module Gitlab
def initialize(namespace, queue_id)
raise ArgumentError if namespace.empty? || queue_id.empty?
@namespace, @queue_id = namespace, queue_id
@namespace = namespace
@queue_id = queue_id
end
##
......
......@@ -69,7 +69,9 @@ module Gitlab
def load_from_project
return unless commit
self.sha, self.status, self.ref = commit.sha, commit.status, project.default_branch
self.sha = commit.sha
self.status = commit.status
self.ref = project.default_branch
end
# We only cache the status for the HEAD commit of a project
......
......@@ -17,7 +17,9 @@ module Gitlab
attr_reader :stream, :path, :full_version
def initialize(stream, path, **opts)
@stream, @path, @opts = stream, path, opts
@stream = stream
@path = path
@opts = opts
@full_version = read_version
end
......
......@@ -5,7 +5,9 @@ module Gitlab
attr_accessor :email, :name, :commits, :additions, :deletions
def initialize
@commits, @additions, @deletions = 0, 0, 0
@commits = 0
@additions = 0
@deletions = 0
end
end
end
......@@ -13,8 +13,11 @@ module Gitlab
attr_accessor :index, :type, :old_pos, :new_pos
def initialize(text, type, index, old_pos, new_pos, parent_file: nil, line_code: nil, rich_text: nil)
@text, @type, @index = text, type, index
@old_pos, @new_pos = old_pos, new_pos
@text = text
@type = type
@index = index
@old_pos = old_pos
@new_pos = new_pos
@parent_file = parent_file
@rich_text = rich_text
......
......@@ -29,9 +29,8 @@ module Gitlab
lines_above, lines_below = nil
if lang_param && suggestion_params = fetch_suggestion_params(lang_param)
lines_above, lines_below =
suggestion_params[:above],
suggestion_params[:below]
lines_above = suggestion_params[:above]
lines_below = suggestion_params[:below]
end
Gitlab::Diff::Suggestion.new(node.text,
......
......@@ -10,7 +10,8 @@ module Gitlab
:load_type
def initialize(user, label)
@user, @label = user, label
@user = user
@label = label
end
def loaded?
......
......@@ -6,7 +6,8 @@ module Gitlab
VALIDITY_TIME = 6.hours
def initialize(user, label)
@user, @label = user, label
@user = user
@label = label
end
def load
......
......@@ -13,7 +13,8 @@ module Gitlab
}.freeze
def initialize(user, label)
@user, @label = user, label
@user = user
@label = label
end
def request_access
......
......@@ -30,8 +30,10 @@ module Gitlab
end
def process_raw_blame(output)
lines, final = [], []
info, commits = {}, {}
lines = []
final = []
info = {}
commits = {}
# process the output
output.split("\n").each do |line|
......
......@@ -6,7 +6,8 @@ module Gitlab
include Gitlab::Utils::StrongMemoize
def initialize(repository, refs)
@repository, @refs = repository, refs
@repository = repository
@refs = refs
end
# Returns the SHA of the first common ancestor
......
......@@ -7,7 +7,10 @@ module Gitlab
include Gitlab::Git::WrapsGitalyErrors
def initialize(user, repository, branch, patch_collection)
@user, @repository, @branch, @patches = user, repository, branch, patch_collection
@user = user
@repository = repository
@branch = branch
@patches = patch_collection
end
def commit
......
......@@ -5,7 +5,8 @@ module Gitlab
module Loaders
class BatchLfsOidLoader
def initialize(repository, blob_id)
@repository, @blob_id = repository, blob_id
@repository = repository
@blob_id = blob_id
end
def find
......
......@@ -7,7 +7,8 @@ module Gitlab
attr_reader :model_class, :model_id
def initialize(model_class, model_id)
@model_class, @model_id = model_class, model_id
@model_class = model_class
@model_id = model_id
end
# rubocop: disable CodeReuse/ActiveRecord
......
......@@ -9,7 +9,8 @@ module Gitlab
attr_reader :model_class, :full_path
def initialize(model_class, full_path)
@model_class, @full_path = model_class, full_path
@model_class = model_class
@full_path = full_path
end
def find
......
......@@ -13,7 +13,11 @@ module Gitlab
# @param [Symbol] before_or_after indicates whether we want
# items :before the cursor or :after the cursor
def initialize(arel_table, order_list, values, operators, before_or_after)
@arel_table, @order_list, @values, @operators, @before_or_after = arel_table, order_list, values, operators, before_or_after
@arel_table = arel_table
@order_list = order_list
@values = values
@operators = operators
@before_or_after = before_or_after
@before_or_after = :after unless [:after, :before].include?(@before_or_after)
end
......
......@@ -6,7 +6,10 @@ module Gitlab
module Keyset
class QueryBuilder
def initialize(arel_table, order_list, decoded_cursor, before_or_after)
@arel_table, @order_list, @decoded_cursor, @before_or_after = arel_table, order_list, decoded_cursor, before_or_after
@arel_table = arel_table
@order_list = order_list
@decoded_cursor = decoded_cursor
@before_or_after = before_or_after
if order_list.empty?
raise ArgumentError.new('No ordering scopes have been supplied')
......
......@@ -4,7 +4,8 @@ module Gitlab
module Issues
class Importer
def initialize(project, after = nil)
@project, @after = project, after
@project = project
@after = after
end
def execute
......
......@@ -4,7 +4,8 @@ module Gitlab
module Issues
class TaskImporter
def initialize(project, task)
@project, @task = project, task
@project = project
@task = task
end
def execute
......
......@@ -4,7 +4,8 @@ module Gitlab
module PhabricatorImport
class UserFinder
def initialize(project, phids)
@project, @phids = project, phids
@project = project
@phids = phids
@loaded_phids = Set.new
end
......
......@@ -5,7 +5,11 @@ module Gitlab
attr_reader :title, :name, :description, :preview, :logo
def initialize(name, title, description, preview, logo = 'illustrations/gitlab_logo.svg')
@name, @title, @description, @preview, @logo = name, title, description, preview, logo
@name = name
@title = title
@description = description
@preview = preview
@logo = logo
end
def file
......
......@@ -4,7 +4,8 @@ module Gitlab
module RelativePositioning
class ClosedRange < RelativePositioning::Range
def initialize(lhs, rhs)
@lhs, @rhs = lhs, rhs
@lhs = lhs
@rhs = rhs
raise IllegalRange, 'Either lhs or rhs is missing' unless lhs && rhs
raise IllegalRange, 'lhs and rhs cannot be the same object' if lhs == rhs
end
......
......@@ -6,7 +6,8 @@ module Gitlab
attr_reader :start_pos, :end_pos
def initialize(start_pos, end_pos)
@start_pos, @end_pos = start_pos, end_pos
@start_pos = start_pos
@end_pos = end_pos
end
def ==(other)
......
......@@ -36,7 +36,9 @@ module Gitlab
attr_accessor :project, :current_user, :params, :chat_name
def initialize(project, chat_name, params = {})
@project, @current_user, @params = project, chat_name.user, params.dup
@project = project
@current_user = chat_name.user
@params = params.dup
@chat_name = chat_name
end
......
......@@ -221,7 +221,8 @@ namespace :gitlab do
result_file = args[:result_file] || raise("Please specify result_file argument")
raise "File exists already, won't overwrite: #{result_file}" if File.exist?(result_file)
verbose_was, ActiveRecord::Migration.verbose = ActiveRecord::Migration.verbose, true
verbose_was = ActiveRecord::Migration.verbose
ActiveRecord::Migration.verbose = true
ctx = ActiveRecord::Base.connection.migration_context
existing_versions = ctx.get_all_versions.to_set
......
......@@ -9,7 +9,8 @@ RSpec.describe FinderWithGroupHierarchy do
include Gitlab::Utils::StrongMemoize
def initialize(current_user, params = {})
@current_user, @params = current_user, params
@current_user = current_user
@params = params
end
def execute(skip_authorization: false)
......
......@@ -246,7 +246,8 @@ RSpec.describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :
subject.track_rename('namespace', 'path/to/namespace', 'path/to/renamed')
old_path, new_path = [nil, nil]
old_path = nil
new_path = nil
Gitlab::Redis::SharedState.with do |redis|
rename_info = redis.lpop(key)
old_path, new_path = Gitlab::Json.parse(rename_info)
......
......@@ -302,7 +302,8 @@ RSpec.describe Gitlab::Diff::LinesUnfolder do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
old_pos = expected_diff_lines[i][0]
new_pos = expected_diff_lines[i][1]
unless line.type == 'match'
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
......@@ -396,7 +397,8 @@ RSpec.describe Gitlab::Diff::LinesUnfolder do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
old_pos = expected_diff_lines[i][0]
new_pos = expected_diff_lines[i][1]
unless line.type == 'match'
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
......@@ -490,7 +492,8 @@ RSpec.describe Gitlab::Diff::LinesUnfolder do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
old_pos = expected_diff_lines[i][0]
new_pos = expected_diff_lines[i][1]
unless line.type == 'match'
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
......@@ -581,7 +584,8 @@ RSpec.describe Gitlab::Diff::LinesUnfolder do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
old_pos = expected_diff_lines[i][0]
new_pos = expected_diff_lines[i][1]
unless line.type == 'match'
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
......@@ -691,7 +695,8 @@ RSpec.describe Gitlab::Diff::LinesUnfolder do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
old_pos = expected_diff_lines[i][0]
new_pos = expected_diff_lines[i][1]
unless line.type == 'match'
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
......@@ -783,7 +788,8 @@ RSpec.describe Gitlab::Diff::LinesUnfolder do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
old_pos = expected_diff_lines[i][0]
new_pos = expected_diff_lines[i][1]
unless line.type == 'match'
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
......
......@@ -56,7 +56,8 @@ RSpec.describe Gitlab::Diff::SuggestionsParser do
end
it 'parsed suggestion has correct data' do
from_line, to_line = position.new_line, position.new_line
from_line = position.new_line
to_line = position.new_line
expect(subject.first.to_hash).to include(from_content: blob_lines_data(from_line, to_line),
to_content: " foo\n bar\n",
......
......@@ -7,7 +7,8 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Extension, :clean_gitlab_redis_cach
include CacheMarkdownField
def initialize(title: nil, description: nil)
@title, @description = title, description
@title = title
@description = description
end
attr_reader :title, :description
......
......@@ -13,8 +13,10 @@ RSpec.describe Gitlab::Utils::LazyAttributes do
def initialize
@number = -> { 1 }
@reader_1, @reader_2 = 'reader_1', -> { 'reader_2' }
@incorrect_type, @accessor_2 = -> { :incorrect_type }, -> { 'accessor_2' }
@reader_1 = 'reader_1'
@reader_2 = -> { 'reader_2' }
@incorrect_type = -> { :incorrect_type }
@accessor_2 = -> { 'accessor_2' }
end
end
end
......
......@@ -17,9 +17,13 @@ RSpec.describe CacheMarkdownField, :clean_gitlab_redis_cache do
include CacheMarkdownField
def initialize(args = {})
@title, @description, @cached_markdown_version = args[:title], args[:description], args[:cached_markdown_version]
@title_html, @description_html = args[:title_html], args[:description_html]
@author, @project = args[:author], args[:project]
@title = args[:title]
@description = args[:description]
@cached_markdown_version = args[:cached_markdown_version]
@title_html = args[:title_html]
@description_html = args[:description_html]
@author = args[:author]
@project = args[:project]
@parent_user = args[:parent_user]
end
......
......@@ -1103,7 +1103,8 @@ RSpec.describe Repository do
describe '#create_ref' do
it 'redirects the call to write_ref' do
ref, ref_path = '1', '2'
ref = '1'
ref_path = '2'
expect(repository.raw_repository).to receive(:write_ref).with(ref_path, ref)
......
......@@ -307,7 +307,10 @@ module GraphqlHelpers
def query_graphql_field(name, attributes = {}, fields = nil, type = nil)
type ||= name.to_s.classify
attributes, fields = [nil, attributes] if fields.nil? && !attributes.is_a?(Hash)
if fields.nil? && !attributes.is_a?(Hash)
fields = attributes
attributes = nil
end
field = field_with_params(name, attributes)
......
......@@ -27,7 +27,8 @@ module Spec
# Encodes an openssh-mpi-encoded integer.
def encode_mpi(n) # rubocop:disable Naming/UncommunicativeMethodParamName
chars, n = [], n.to_i
chars = []
n = n.to_i
chars << (n & 0xff) && n >>= 8 while n != 0
chars << 0 if chars.empty? || chars.last >= 0x80
chars.reverse.pack('C*')
......
......@@ -13,7 +13,9 @@ RSpec.describe X509CertificateCredentialsValidator do
attr_accessor :certificate, :private_key, :passphrase
def initialize(certificate, private_key, passphrase = nil)
@certificate, @private_key, @passphrase = certificate, private_key, passphrase
@certificate = certificate
@private_key = private_key
@passphrase = passphrase
end
end
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