Skip to content
Snippets Groups Projects
Commit 1050ef73 authored by Igor Drozdov's avatar Igor Drozdov :two: Committed by Peter Leitzen
Browse files

Fix Style/SlicingWithRange offences

parent fddd1c97
No related branches found
No related tags found
1 merge request!76661Fix Style/SlicingWithRange offences
Showing
with 20 additions and 25 deletions
......@@ -827,11 +827,6 @@ Style/RescueModifier:
Style/SingleArgumentDig:
Enabled: false
# Offense count: 45
# Cop supports --auto-correct.
Style/SlicingWithRange:
Enabled: false
# Offense count: 63
# Configuration parameters: AllowModifier.
Style/SoleNestedConditional:
......
......@@ -99,7 +99,7 @@ def preview
@content = params[:content]
@blob.load_all_data!
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::Highlight.new(diff_lines, repository: @repository).highlight
......
......@@ -283,7 +283,7 @@ def diff_file_path_text(diff_file, max: 60)
return path unless path.size > max && max > 3
"...#{path[-(max - 3)..-1]}"
"...#{path[-(max - 3)..]}"
end
def code_navigation_path(diffs)
......
......@@ -11,7 +11,7 @@ def self.decrypt_token(token)
# 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
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)
else
......
......@@ -204,7 +204,7 @@ def lineage(top: nil, bottom: nil, hierarchy_order: nil)
end
if bottom
skope = skope.where(id: bottom.traversal_ids[0..-1])
skope = skope.where(id: bottom.traversal_ids)
end
# The original `with_depth` attribute in ObjectHierarchy increments as you
......
......@@ -37,7 +37,7 @@ def serverless_domain_cluster_uuid
'a1',
serverless_domain_cluster.uuid[2..-3],
'f2',
serverless_domain_cluster.uuid[-2..-1]
serverless_domain_cluster.uuid[-2..]
].join
end
end
......
......@@ -338,7 +338,7 @@ def process_title(title)
current_dirname = File.dirname(title)
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 == '.'
end
......
......@@ -38,7 +38,7 @@ def cohorts
{
registration_month: registration_month,
activity_months: activity_months[1..-1],
activity_months: activity_months[1..],
total: activity_months.first[:total],
inactive: inactive
}
......
......@@ -9,7 +9,7 @@ class LfsObjectUploader < GitlabUploader
alias_method :upload, :model
def filename
model.oid[4..-1]
model.oid[4..]
end
def store_dir
......
......@@ -108,7 +108,7 @@ def to_html
"<span class=\"error\">#{I18n.t('template loop detected', :tree => debug_tree)}</span>"
else
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_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 @@ def get_sidekiq_job_id
index = context_data.index('JID-')
return unless index
context_data[index + 4..-1]
context_data[index + 4..]
end
end
end
......
......@@ -56,7 +56,7 @@
it 'only updates merge_request documents missing visibility_level', :aggregate_failures do
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)]
expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).with(*expected).once
......
......@@ -51,7 +51,7 @@
it 'only updates issue documents missing upvotes', :aggregate_failures do
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)]
expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).with(*expected).once
......
......@@ -53,7 +53,7 @@
it 'only updates documents missing a field', :aggregate_failures do
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)]
expect(::Elastic::ProcessInitialBookkeepingService).to receive(:track!).with(*expected).once.and_call_original
......
......@@ -39,7 +39,7 @@ def call
code[:class] = INLINE_CLASSES
code[STYLE_ATTRIBUTE] = 'inline'
closing.content = closing.content[1..-1]
closing.content = closing.content[1..]
opening.content = opening.content[0..-2]
end
end
......
......@@ -174,7 +174,7 @@ def request_path
def build_relative_path(path, request_path)
return request_path if path.empty?
return path unless request_path
return path[1..-1] if path.start_with?('/')
return path[1..] if path.start_with?('/')
parts = request_path.split('/')
......
......@@ -113,7 +113,7 @@ def extract_raw_ref(id)
best_match = valid_refs.max_by(&:length)
# 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
def use_first_path_segment?(ref)
......
......@@ -51,7 +51,7 @@ def encode_as_utf8(obj)
end
def body
content = @commit[:message][first_line.size..-1]
content = @commit[:message][first_line.size..]
content.strip! if content
"<pre>#{content}</pre>" unless content.empty?
end
......
......@@ -48,10 +48,10 @@ def without_executed_command_line(output)
# follows it will produce a nil. For example:
#
# "\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.
if (converted = output.split("\n")[1..-1])
if (converted = output.split("\n")[1..])
converted.join("\n")
else
''
......
......@@ -51,7 +51,7 @@ def clone_as_blank
def replace_with!(other)
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment