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