Commit 20c91b22 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'id-fix-slicing-with-range' into 'master'

Fix Style/SlicingWithRange offences

See merge request gitlab-org/gitlab!76661
parents 4727b151 1050ef73
...@@ -816,11 +816,6 @@ Style/RescueModifier: ...@@ -816,11 +816,6 @@ Style/RescueModifier:
Style/SingleArgumentDig: Style/SingleArgumentDig:
Enabled: false Enabled: false
# Offense count: 45
# Cop supports --auto-correct.
Style/SlicingWithRange:
Enabled: false
# Offense count: 63 # Offense count: 63
# Configuration parameters: AllowModifier. # Configuration parameters: AllowModifier.
Style/SoleNestedConditional: Style/SoleNestedConditional:
......
...@@ -99,7 +99,7 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -99,7 +99,7 @@ class Projects::BlobController < Projects::ApplicationController
@content = params[:content] @content = params[:content]
@blob.load_all_data! @blob.load_all_data!
diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true) diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true)
diff_lines = diffy.diff.scan(/.*\n/)[2..-1] diff_lines = diffy.diff.scan(/.*\n/)[2..]
diff_lines = Gitlab::Diff::Parser.new.parse(diff_lines).to_a diff_lines = Gitlab::Diff::Parser.new.parse(diff_lines).to_a
@diff_lines = Gitlab::Diff::Highlight.new(diff_lines, repository: @repository).highlight @diff_lines = Gitlab::Diff::Highlight.new(diff_lines, repository: @repository).highlight
......
...@@ -283,7 +283,7 @@ module DiffHelper ...@@ -283,7 +283,7 @@ module DiffHelper
return path unless path.size > max && max > 3 return path unless path.size > max && max > 3
"...#{path[-(max - 3)..-1]}" "...#{path[-(max - 3)..]}"
end end
def code_navigation_path(diffs) def code_navigation_path(diffs)
......
...@@ -11,7 +11,7 @@ module TokenAuthenticatableStrategies ...@@ -11,7 +11,7 @@ module TokenAuthenticatableStrategies
# The pattern of the token is "#{DYNAMIC_NONCE_IDENTIFIER}#{token}#{iv_of_12_characters}" # The pattern of the token is "#{DYNAMIC_NONCE_IDENTIFIER}#{token}#{iv_of_12_characters}"
if token.start_with?(DYNAMIC_NONCE_IDENTIFIER) && token.size > NONCE_SIZE + DYNAMIC_NONCE_IDENTIFIER.size if token.start_with?(DYNAMIC_NONCE_IDENTIFIER) && token.size > NONCE_SIZE + DYNAMIC_NONCE_IDENTIFIER.size
token_to_decrypt = token[1...-NONCE_SIZE] token_to_decrypt = token[1...-NONCE_SIZE]
iv = token[-NONCE_SIZE..-1] iv = token[-NONCE_SIZE..]
Gitlab::CryptoHelper.aes256_gcm_decrypt(token_to_decrypt, nonce: iv) Gitlab::CryptoHelper.aes256_gcm_decrypt(token_to_decrypt, nonce: iv)
else else
......
...@@ -204,7 +204,7 @@ module Namespaces ...@@ -204,7 +204,7 @@ module Namespaces
end end
if bottom if bottom
skope = skope.where(id: bottom.traversal_ids[0..-1]) skope = skope.where(id: bottom.traversal_ids)
end end
# The original `with_depth` attribute in ObjectHierarchy increments as you # The original `with_depth` attribute in ObjectHierarchy increments as you
......
...@@ -37,7 +37,7 @@ module Serverless ...@@ -37,7 +37,7 @@ module Serverless
'a1', 'a1',
serverless_domain_cluster.uuid[2..-3], serverless_domain_cluster.uuid[2..-3],
'f2', 'f2',
serverless_domain_cluster.uuid[-2..-1] serverless_domain_cluster.uuid[-2..]
].join ].join
end end
end end
......
...@@ -338,7 +338,7 @@ class WikiPage ...@@ -338,7 +338,7 @@ class WikiPage
current_dirname = File.dirname(title) current_dirname = File.dirname(title)
if persisted? if persisted?
return title[1..-1] if current_dirname == '/' return title[1..] if current_dirname == '/'
return File.join([directory.presence, title].compact) if current_dirname == '.' return File.join([directory.presence, title].compact) if current_dirname == '.'
end end
......
...@@ -38,7 +38,7 @@ class CohortsService ...@@ -38,7 +38,7 @@ class CohortsService
{ {
registration_month: registration_month, registration_month: registration_month,
activity_months: activity_months[1..-1], activity_months: activity_months[1..],
total: activity_months.first[:total], total: activity_months.first[:total],
inactive: inactive inactive: inactive
} }
......
...@@ -9,7 +9,7 @@ class LfsObjectUploader < GitlabUploader ...@@ -9,7 +9,7 @@ class LfsObjectUploader < GitlabUploader
alias_method :upload, :model alias_method :upload, :model
def filename def filename
model.oid[4..-1] model.oid[4..]
end end
def store_dir def store_dir
......
...@@ -108,7 +108,7 @@ module WikiCloth ...@@ -108,7 +108,7 @@ module WikiCloth
"<span class=\"error\">#{I18n.t('template loop detected', :tree => debug_tree)}</span>" "<span class=\"error\">#{I18n.t('template loop detected', :tree => debug_tree)}</span>"
else else
key = params[0].to_s.strip key = params[0].to_s.strip
key_options = params[1..-1].collect { |p| p.is_a?(Hash) ? { :name => p[:name].strip, :value => p[:value].strip } : p.strip } key_options = params[1..].collect { |p| p.is_a?(Hash) ? { :name => p[:name].strip, :value => p[:value].strip } : p.strip }
key_options ||= [] key_options ||= []
key_digest = Digest::MD5.hexdigest(key_options.to_a.sort {|x,y| (x.is_a?(Hash) ? x[:name] : x) <=> (y.is_a?(Hash) ? y[:name] : y) }.inspect) key_digest = Digest::MD5.hexdigest(key_options.to_a.sort {|x,y| (x.is_a?(Hash) ? x[:name] : x) <=> (y.is_a?(Hash) ? y[:name] : y) }.inspect)
......
...@@ -51,7 +51,7 @@ module Gitlab ...@@ -51,7 +51,7 @@ module Gitlab
index = context_data.index('JID-') index = context_data.index('JID-')
return unless index return unless index
context_data[index + 4..-1] context_data[index + 4..]
end end
end end
end end
......
...@@ -56,7 +56,7 @@ RSpec.describe AddNewDataToMergeRequestsDocuments, :elastic, :sidekiq_inline do ...@@ -56,7 +56,7 @@ RSpec.describe AddNewDataToMergeRequestsDocuments, :elastic, :sidekiq_inline do
it 'only updates merge_request documents missing visibility_level', :aggregate_failures do it 'only updates merge_request documents missing visibility_level', :aggregate_failures do
merge_request = merge_requests.first merge_request = merge_requests.first
add_visibility_level_for_merge_requests(merge_requests[1..-1]) add_visibility_level_for_merge_requests(merge_requests[1..])
expected = [Gitlab::Elastic::DocumentReference.new(MergeRequest, merge_request.id, merge_request.es_id, merge_request.es_parent)] expected = [Gitlab::Elastic::DocumentReference.new(MergeRequest, merge_request.id, merge_request.es_id, merge_request.es_parent)]
expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).with(*expected).once expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).with(*expected).once
......
...@@ -51,7 +51,7 @@ RSpec.describe AddUpvotesToIssues, :elastic, :sidekiq_inline do ...@@ -51,7 +51,7 @@ RSpec.describe AddUpvotesToIssues, :elastic, :sidekiq_inline do
it 'only updates issue documents missing upvotes', :aggregate_failures do it 'only updates issue documents missing upvotes', :aggregate_failures do
issue = issues.first issue = issues.first
add_upvotes_for_issues(issues[1..-1]) add_upvotes_for_issues(issues[1..])
expected = [Gitlab::Elastic::DocumentReference.new(Issue, issue.id, issue.es_id, issue.es_parent)] expected = [Gitlab::Elastic::DocumentReference.new(Issue, issue.id, issue.es_id, issue.es_parent)]
expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).with(*expected).once expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).with(*expected).once
......
...@@ -53,7 +53,7 @@ RSpec.shared_examples 'migration backfills a field' do ...@@ -53,7 +53,7 @@ RSpec.shared_examples 'migration backfills a field' do
it 'only updates documents missing a field', :aggregate_failures do it 'only updates documents missing a field', :aggregate_failures do
object = objects.first object = objects.first
add_field_for_objects(objects[1..-1]) add_field_for_objects(objects[1..])
expected = [Gitlab::Elastic::DocumentReference.new(klass, object.id, object.es_id, object.es_parent)] expected = [Gitlab::Elastic::DocumentReference.new(klass, object.id, object.es_id, object.es_parent)]
expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).with(*expected).once.and_call_original expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).with(*expected).once.and_call_original
......
...@@ -39,7 +39,7 @@ module Banzai ...@@ -39,7 +39,7 @@ module Banzai
code[:class] = INLINE_CLASSES code[:class] = INLINE_CLASSES
code[STYLE_ATTRIBUTE] = 'inline' code[STYLE_ATTRIBUTE] = 'inline'
closing.content = closing.content[1..-1] closing.content = closing.content[1..]
opening.content = opening.content[0..-2] opening.content = opening.content[0..-2]
end end
end end
......
...@@ -174,7 +174,7 @@ module Banzai ...@@ -174,7 +174,7 @@ module Banzai
def build_relative_path(path, request_path) def build_relative_path(path, request_path)
return request_path if path.empty? return request_path if path.empty?
return path unless request_path return path unless request_path
return path[1..-1] if path.start_with?('/') return path[1..] if path.start_with?('/')
parts = request_path.split('/') parts = request_path.split('/')
......
...@@ -113,7 +113,7 @@ module ExtractsRef ...@@ -113,7 +113,7 @@ module ExtractsRef
best_match = valid_refs.max_by(&:length) best_match = valid_refs.max_by(&:length)
# Partition the string into the ref and the path, ignoring the empty first value # Partition the string into the ref and the path, ignoring the empty first value
id.partition(best_match)[1..-1] id.partition(best_match)[1..]
end end
def use_first_path_segment?(ref) def use_first_path_segment?(ref)
......
...@@ -51,7 +51,7 @@ module Flowdock ...@@ -51,7 +51,7 @@ module Flowdock
end end
def body def body
content = @commit[:message][first_line.size..-1] content = @commit[:message][first_line.size..]
content.strip! if content content.strip! if content
"<pre>#{content}</pre>" unless content.empty? "<pre>#{content}</pre>" unless content.empty?
end end
......
...@@ -48,10 +48,10 @@ module Gitlab ...@@ -48,10 +48,10 @@ module Gitlab
# follows it will produce a nil. For example: # follows it will produce a nil. For example:
# #
# "\n".split("\n") # => [] # "\n".split("\n") # => []
# "\n".split("\n")[1..-1] # => nil # "\n".split("\n")[1..] # => nil
# #
# To work around this we only "join" if we're given an Array. # To work around this we only "join" if we're given an Array.
if (converted = output.split("\n")[1..-1]) if (converted = output.split("\n")[1..])
converted.join("\n") converted.join("\n")
else else
'' ''
......
...@@ -51,7 +51,7 @@ module Gitlab ...@@ -51,7 +51,7 @@ module Gitlab
def replace_with!(other) def replace_with!(other)
instance_variables.each do |ivar| instance_variables.each do |ivar|
instance_variable_set(ivar, other.public_send(ivar.to_s[1..-1])) # rubocop:disable GitlabSecurity/PublicSend instance_variable_set(ivar, other.public_send(ivar.to_s[1..])) # rubocop:disable GitlabSecurity/PublicSend
end end
end end
......
...@@ -36,7 +36,7 @@ module Gitlab ...@@ -36,7 +36,7 @@ module Gitlab
end end
def strip_diff_frontmatter(diff_content) def strip_diff_frontmatter(diff_content)
diff_content.scan(/.*\n/)[2..-1]&.join('') if diff_content.present? diff_content.scan(/.*\n/)[2..]&.join('') if diff_content.present?
end end
def blobs_with_transformed_diffs def blobs_with_transformed_diffs
......
...@@ -6,8 +6,8 @@ module Gitlab ...@@ -6,8 +6,8 @@ module Gitlab
attr_accessor :old_line, :new_line, :offset attr_accessor :old_line, :new_line, :offset
def initialize(old_line, new_line, offset: 0) def initialize(old_line, new_line, offset: 0)
@old_line = old_line[offset..-1] @old_line = old_line[offset..]
@new_line = new_line[offset..-1] @new_line = new_line[offset..]
@offset = offset @offset = offset
end end
......
...@@ -57,7 +57,7 @@ module Gitlab ...@@ -57,7 +57,7 @@ module Gitlab
def unfold_reference(reference, match, target_parent) def unfold_reference(reference, match, target_parent)
before = @text[0...match.begin(0)] before = @text[0...match.begin(0)]
after = @text[match.end(0)..-1] after = @text[match.end(0)..]
referable = find_referable(reference) referable = find_referable(reference)
return reference unless referable return reference unless referable
......
...@@ -48,7 +48,7 @@ module Gitlab ...@@ -48,7 +48,7 @@ module Gitlab
raw_keys.each_with_object({}) do |raw_key, grouped_subkeys| raw_keys.each_with_object({}) do |raw_key, grouped_subkeys|
primary_subkey_id = raw_key.primary_subkey.keyid primary_subkey_id = raw_key.primary_subkey.keyid
grouped_subkeys[primary_subkey_id] = raw_key.subkeys[1..-1].map do |s| grouped_subkeys[primary_subkey_id] = raw_key.subkeys[1..].map do |s|
{ keyid: s.keyid, fingerprint: s.fingerprint } { keyid: s.keyid, fingerprint: s.fingerprint }
end end
end end
......
...@@ -44,7 +44,7 @@ module Gitlab ...@@ -44,7 +44,7 @@ module Gitlab
next unless match next unless match
input = match.split(':')[1..-1].join input = match.split(':')[1..].join
next if input.empty? next if input.empty?
filter[:negated] = match.start_with?("-") filter[:negated] = match.start_with?("-")
......
...@@ -70,7 +70,7 @@ module Gitlab ...@@ -70,7 +70,7 @@ module Gitlab
next if total_duration <= MINIMUM_DURATION next if total_duration <= MINIMUM_DURATION
stats[1..-1].each_with_index do |data, index| stats[1..].each_with_index do |data, index|
next unless source_lines[index] next unless source_lines[index]
duration = microsec_to_millisec(data[0]) duration = microsec_to_millisec(data[0])
......
...@@ -99,7 +99,7 @@ module Gitlab ...@@ -99,7 +99,7 @@ module Gitlab
start = prev = positions[0] start = prev = positions[0]
range = MarkerRange.new(start, prev, mode: mode) range = MarkerRange.new(start, prev, mode: mode)
positions[1..-1].each do |pos| positions[1..].each do |pos|
if pos == prev + 1 if pos == prev + 1
range = MarkerRange.new(start, pos, mode: mode) range = MarkerRange.new(start, pos, mode: mode)
prev = pos prev = pos
......
...@@ -16,7 +16,7 @@ module Gitlab ...@@ -16,7 +16,7 @@ module Gitlab
# we remove the leading `//` and add `descendant-or-self::` # we remove the leading `//` and add `descendant-or-self::`
# in order to ensure we're searching from this node and all # in order to ensure we're searching from this node and all
# descendants. # descendants.
xpath.map { |t| "descendant-or-self::#{t[2..-1]}" }.join('|') xpath.map { |t| "descendant-or-self::#{t[2..]}" }.join('|')
end end
end end
end end
......
...@@ -184,7 +184,7 @@ class GroupSeeder ...@@ -184,7 +184,7 @@ class GroupSeeder
group = Group.find(group_id) group = Group.find(group_id)
@resource_count.times do |i| @resource_count.times do |i|
_, project_path = PROJECT_URL.split('/')[-2..-1] _, project_path = PROJECT_URL.split('/')[-2..]
project_path.gsub!('.git', '') project_path.gsub!('.git', '')
......
...@@ -46,7 +46,7 @@ module RuboCop ...@@ -46,7 +46,7 @@ module RuboCop
end end
def arguments(node) def arguments(node)
node.children[2..-1] node.children[2..]
end end
end end
end end
......
...@@ -46,7 +46,7 @@ module RuboCop ...@@ -46,7 +46,7 @@ module RuboCop
end end
def arguments(node) def arguments(node)
node.children[2..-1] node.children[2..]
end end
end end
end end
......
...@@ -128,7 +128,7 @@ RSpec.describe Projects::Serverless::FunctionsController do ...@@ -128,7 +128,7 @@ RSpec.describe Projects::Serverless::FunctionsController do
expect(json_response["functions"]).to all( expect(json_response["functions"]).to all(
include( include(
'url' => "https://#{function_name}-#{serverless_domain_cluster.uuid[0..1]}a1#{serverless_domain_cluster.uuid[2..-3]}f2#{serverless_domain_cluster.uuid[-2..-1]}#{"%x" % environment.id}-#{environment.slug}.#{serverless_domain_cluster.domain}" 'url' => "https://#{function_name}-#{serverless_domain_cluster.uuid[0..1]}a1#{serverless_domain_cluster.uuid[2..-3]}f2#{serverless_domain_cluster.uuid[-2..]}#{"%x" % environment.id}-#{environment.slug}.#{serverless_domain_cluster.domain}"
) )
) )
end end
...@@ -166,7 +166,7 @@ RSpec.describe Projects::Serverless::FunctionsController do ...@@ -166,7 +166,7 @@ RSpec.describe Projects::Serverless::FunctionsController do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include( expect(json_response).to include(
'url' => "https://#{function_name}-#{serverless_domain_cluster.uuid[0..1]}a1#{serverless_domain_cluster.uuid[2..-3]}f2#{serverless_domain_cluster.uuid[-2..-1]}#{"%x" % environment.id}-#{environment.slug}.#{serverless_domain_cluster.domain}" 'url' => "https://#{function_name}-#{serverless_domain_cluster.uuid[0..1]}a1#{serverless_domain_cluster.uuid[2..-3]}f2#{serverless_domain_cluster.uuid[-2..]}#{"%x" % environment.id}-#{environment.slug}.#{serverless_domain_cluster.domain}"
) )
end end
......
...@@ -20,7 +20,7 @@ RSpec.describe 'User views an open merge request' do ...@@ -20,7 +20,7 @@ RSpec.describe 'User views an open merge request' do
# Work around a weird Capybara behavior where calling `parent` on a node # Work around a weird Capybara behavior where calling `parent` on a node
# returns the whole document, not the node's actual parent element # returns the whole document, not the node's actual parent element
expect(find(:xpath, "#{node.path}/..").text).to eq(merge_request.description[2..-1]) expect(find(:xpath, "#{node.path}/..").text).to eq(merge_request.description[2..])
expect(page).to have_content(merge_request.title) expect(page).to have_content(merge_request.title)
end end
......
...@@ -80,7 +80,7 @@ RSpec.describe 'Issue prioritization' do ...@@ -80,7 +80,7 @@ RSpec.describe 'Issue prioritization' do
expect(issue_titles[0..1]).to contain_exactly('issue_5', 'issue_8') expect(issue_titles[0..1]).to contain_exactly('issue_5', 'issue_8')
expect(issue_titles[2..4]).to contain_exactly('issue_1', 'issue_3', 'issue_7') expect(issue_titles[2..4]).to contain_exactly('issue_1', 'issue_3', 'issue_7')
expect(issue_titles[5..-1]).to eq(%w(issue_2 issue_4 issue_6)) expect(issue_titles[5..]).to eq(%w(issue_2 issue_4 issue_6))
end end
end end
end end
...@@ -71,7 +71,7 @@ RSpec.describe Packages::Nuget::PackageFinder do ...@@ -71,7 +71,7 @@ RSpec.describe Packages::Nuget::PackageFinder do
end end
context 'with prefix wildcard' do context 'with prefix wildcard' do
let(:package_name) { "%#{package1.name[3..-1]}" } let(:package_name) { "%#{package1.name[3..]}" }
it { is_expected.to match_array([package1, package2]) } it { is_expected.to match_array([package1, package2]) }
end end
......
...@@ -43,10 +43,10 @@ RSpec.describe Gitlab::GitalyClient::ConflictFilesStitcher do ...@@ -43,10 +43,10 @@ RSpec.describe Gitlab::GitalyClient::ConflictFilesStitcher do
messages = [ messages = [
double(files: [double(header: header_1), double(header: nil, content: content_1[0..5])]), double(files: [double(header: header_1), double(header: nil, content: content_1[0..5])]),
double(files: [double(header: nil, content: content_1[6..-1])]), double(files: [double(header: nil, content: content_1[6..])]),
double(files: [double(header: header_2)]), double(files: [double(header: header_2)]),
double(files: [double(header: nil, content: content_2[0..5]), double(header: nil, content: content_2[6..10])]), double(files: [double(header: nil, content: content_2[0..5]), double(header: nil, content: content_2[6..10])]),
double(files: [double(header: nil, content: content_2[11..-1])]) double(files: [double(header: nil, content: content_2[11..])])
] ]
conflict_files = described_class.new(messages, target_repository.gitaly_repository).to_a conflict_files = described_class.new(messages, target_repository.gitaly_repository).to_a
......
...@@ -41,7 +41,7 @@ RSpec.describe Gitlab::GitalyClient::DiffStitcher do ...@@ -41,7 +41,7 @@ RSpec.describe Gitlab::GitalyClient::DiffStitcher do
msg_2.raw_patch_data = diff_2.patch[0..100] msg_2.raw_patch_data = diff_2.patch[0..100]
msg_2.end_of_patch = false msg_2.end_of_patch = false
msg_3 = OpenStruct.new(raw_patch_data: diff_2.patch[101..-1], end_of_patch: true) msg_3 = OpenStruct.new(raw_patch_data: diff_2.patch[101..], end_of_patch: true)
msg_4 = OpenStruct.new(diff_3.to_h.except(:patch)) msg_4 = OpenStruct.new(diff_3.to_h.except(:patch))
msg_4.raw_patch_data = diff_3.patch msg_4.raw_patch_data = diff_3.patch
......
...@@ -192,7 +192,7 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do ...@@ -192,7 +192,7 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
project: project, project: project,
commit_sha: commit_sha, commit_sha: commit_sha,
gpg_key: nil, gpg_key: nil,
gpg_key_primary_keyid: GpgHelpers::User3.subkey_fingerprints.last[24..-1], gpg_key_primary_keyid: GpgHelpers::User3.subkey_fingerprints.last[24..],
verification_status: 'unknown_key' verification_status: 'unknown_key'
end end
......
...@@ -98,7 +98,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do ...@@ -98,7 +98,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do
let(:nodes) { Project.all.order(Gitlab::Pagination::Keyset::Order.build([column_order_id_desc])) } let(:nodes) { Project.all.order(Gitlab::Pagination::Keyset::Order.build([column_order_id_desc])) }
it 'returns the correct nodes' do it 'returns the correct nodes' do
expect(subject.sliced_nodes).to contain_exactly(*projects[2..-1]) expect(subject.sliced_nodes).to contain_exactly(*projects[2..])
end end
end end
end end
...@@ -107,7 +107,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do ...@@ -107,7 +107,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do
let(:arguments) { { after: encoded_cursor(projects[1]) } } let(:arguments) { { after: encoded_cursor(projects[1]) } }
it 'only returns the project before the selected one' do it 'only returns the project before the selected one' do
expect(subject.sliced_nodes).to contain_exactly(*projects[2..-1]) expect(subject.sliced_nodes).to contain_exactly(*projects[2..])
end end
context 'when the sort order is descending' do context 'when the sort order is descending' do
......
...@@ -120,7 +120,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do ...@@ -120,7 +120,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do
let(:nodes) { Project.all.order(id: :desc) } let(:nodes) { Project.all.order(id: :desc) }
it 'returns the correct nodes' do it 'returns the correct nodes' do
expect(subject.sliced_nodes).to contain_exactly(*projects[2..-1]) expect(subject.sliced_nodes).to contain_exactly(*projects[2..])
end end
end end
end end
...@@ -129,7 +129,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do ...@@ -129,7 +129,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do
let(:arguments) { { after: encoded_cursor(projects[1]) } } let(:arguments) { { after: encoded_cursor(projects[1]) } }
it 'only returns the project before the selected one' do it 'only returns the project before the selected one' do
expect(subject.sliced_nodes).to contain_exactly(*projects[2..-1]) expect(subject.sliced_nodes).to contain_exactly(*projects[2..])
end end
context 'when the sort order is descending' do context 'when the sort order is descending' do
......
...@@ -40,7 +40,7 @@ RSpec.describe Gitlab::MultiCollectionPaginator do ...@@ -40,7 +40,7 @@ RSpec.describe Gitlab::MultiCollectionPaginator do
end end
it 'fils the last page with elements from the second collection' do it 'fils the last page with elements from the second collection' do
expected_collection = all_groups[-2..-1] expected_collection = all_groups[-2..]
expect(paginator.paginate(3)).to eq(expected_collection) expect(paginator.paginate(3)).to eq(expected_collection)
end end
......
...@@ -127,7 +127,7 @@ RSpec.describe Gitlab::Pagination::Keyset::Order do ...@@ -127,7 +127,7 @@ RSpec.describe Gitlab::Pagination::Keyset::Order do
end end
it do it do
expect(subject).to eq(expected.reverse[1..-1]) # removing one item because we used it to calculate cursor data for the "last" page in subject expect(subject).to eq(expected.reverse[1..]) # removing one item because we used it to calculate cursor data for the "last" page in subject
end end
end end
end end
......
...@@ -78,7 +78,7 @@ RSpec.describe Gitlab::RackAttack, :aggregate_failures do ...@@ -78,7 +78,7 @@ RSpec.describe Gitlab::RackAttack, :aggregate_failures do
it 'configures tracks and throttles with a selected set of dry-runs' do it 'configures tracks and throttles with a selected set of dry-runs' do
dry_run_throttles = throttles.each_key.first(2) dry_run_throttles = throttles.each_key.first(2)
regular_throttles = throttles.keys[2..-1] regular_throttles = throttles.keys[2..]
stub_env('GITLAB_THROTTLE_DRY_RUN', dry_run_throttles.join(',')) stub_env('GITLAB_THROTTLE_DRY_RUN', dry_run_throttles.join(','))
described_class.configure(fake_rack_attack) described_class.configure(fake_rack_attack)
......
...@@ -2506,7 +2506,7 @@ RSpec.describe Ci::Build do ...@@ -2506,7 +2506,7 @@ RSpec.describe Ci::Build do
it { is_expected.to start_with(project.web_url[0..6]) } it { is_expected.to start_with(project.web_url[0..6]) }
it { is_expected.to include(build.token) } it { is_expected.to include(build.token) }
it { is_expected.to include('gitlab-ci-token') } it { is_expected.to include('gitlab-ci-token') }
it { is_expected.to include(project.web_url[7..-1]) } it { is_expected.to include(project.web_url[7..]) }
end end
context 'when token is empty' do context 'when token is empty' do
......
...@@ -57,7 +57,7 @@ RSpec.describe SystemNotes::CommitService do ...@@ -57,7 +57,7 @@ RSpec.describe SystemNotes::CommitService do
end end
context 'with multiple existing commits' do context 'with multiple existing commits' do
let(:old_commits) { noteable.commits[3..-1] } let(:old_commits) { noteable.commits[3..] }
context 'with oldrev' do context 'with oldrev' do
let(:oldrev) { noteable.commits[2].id } let(:oldrev) { noteable.commits[2].id }
......
...@@ -138,7 +138,7 @@ module GpgHelpers ...@@ -138,7 +138,7 @@ module GpgHelpers
end end
def primary_keyid def primary_keyid
fingerprint[-16..-1] fingerprint[-16..]
end end
def fingerprint def fingerprint
...@@ -281,7 +281,7 @@ module GpgHelpers ...@@ -281,7 +281,7 @@ module GpgHelpers
end end
def primary_keyid2 def primary_keyid2
fingerprint2[-16..-1] fingerprint2[-16..]
end end
def fingerprint2 def fingerprint2
...@@ -374,7 +374,7 @@ module GpgHelpers ...@@ -374,7 +374,7 @@ module GpgHelpers
end end
def primary_keyid def primary_keyid
fingerprint[-16..-1] fingerprint[-16..]
end end
def fingerprint def fingerprint
...@@ -776,7 +776,7 @@ module GpgHelpers ...@@ -776,7 +776,7 @@ module GpgHelpers
end end
def primary_keyid def primary_keyid
fingerprint[-16..-1] fingerprint[-16..]
end end
def fingerprint def fingerprint
......
...@@ -23,7 +23,7 @@ module MemoryUsageHelper ...@@ -23,7 +23,7 @@ module MemoryUsageHelper
output, status = Gitlab::Popen.popen(%w(free -m)) output, status = Gitlab::Popen.popen(%w(free -m))
abort "`free -m` return code is #{status}: #{output}" unless status == 0 abort "`free -m` return code is #{status}: #{output}" unless status == 0
result = output.split("\n")[1].split(" ")[1..-1] result = output.split("\n")[1].split(" ")[1..]
attrs = %i(m_total m_used m_free m_shared m_buffers_cache m_available).freeze attrs = %i(m_total m_used m_free m_shared m_buffers_cache m_available).freeze
attrs.zip(result).to_h attrs.zip(result).to_h
......
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