Skip to content

Commit 7901bee

Browse files
committed
Style/SlicingWithRange
Ruby 2.6 introduced endless ranges. This commit updates all ranges that ended at -1 to instead by endless. This issue was identified by the Rubocop Style/SlicingWithRange cop.
1 parent 7e42621 commit 7901bee

File tree

29 files changed

+39
-39
lines changed

29 files changed

+39
-39
lines changed

lib/puppet/functions/getvar.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_from_navigation(scope, navigation, default_value = nil, &block)
6969
matches = navigation.match(/^((::)?(\w+::)*\w+)(.*)\z/)
7070
navigation = matches[4]
7171
if navigation[0] == '.'
72-
navigation = navigation[1..-1]
72+
navigation = navigation[1..]
7373
else
7474
unless navigation.empty?
7575
raise ArgumentError, _("First character after var name in get string must be a '.' - got %{char}") % { char: navigation[0] }

lib/puppet/module_tool/errors/shared.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ def initialize(options)
106106
@requested_module = options[:requested_module]
107107
@requested_version = options[:requested_version]
108108
@conditions = options[:conditions]
109-
@source = options[:source][1..-1]
109+
@source = options[:source][1..]
110110

111111
super _("'%{module_name}' (%{version}) requested; Invalid dependency cycle") % { module_name: @requested_module, version: v(@requested_version) }
112112
end
113113

114114
def multiline
115115
dependency_list = []
116116
dependency_list << _("You specified '%{name}' (%{version})") % { name: @source.first[:name], version: v(@requested_version) }
117-
dependency_list += @source[1..-1].map do |m|
117+
dependency_list += @source[1..].map do |m|
118118
# TRANSLATORS This message repeats as separate lines as a list under the heading "You specified '%{name}' (%{version})\n"
119119
_("This depends on '%{name}' (%{version})") % { name: m[:name], version: v(m[:version]) }
120120
end

lib/puppet/network/http/api/indirected_routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def call(request, response)
5757

5858
def uri2indirection(http_method, uri, params)
5959
# the first field is always nil because of the leading slash,
60-
indirection_type, version, indirection_name, key = uri.split("/", 5)[1..-1]
60+
indirection_type, version, indirection_name, key = uri.split("/", 5)[1..]
6161
url_prefix = "/#{indirection_type}/#{version}"
6262
environment = params.delete(:environment)
6363

lib/puppet/network/http/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def to_url(path)
266266

267267
def normalize_path(path)
268268
if path[0] == '/'
269-
path[1..-1]
269+
path[1..]
270270
else
271271
path
272272
end

lib/puppet/parser/functions/sprintf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
This statement produces a notice of `value is : 42`."
4646
) do |args|
4747
fmt = args[0]
48-
args = args[1..-1]
48+
args = args[1..]
4949
begin
5050
return sprintf(fmt, *args)
5151
rescue KeyError => e

lib/puppet/parser/scope.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ def lookupvar(name, options = EMPTY_HASH)
496496
# If name has '::' in it, it is resolved as a qualified variable
497497
unless (idx = name.index('::')).nil?
498498
# Always drop leading '::' if present as that is how the values are keyed.
499-
return lookup_qualified_variable(idx == 0 ? name[2..-1] : name, options)
499+
return lookup_qualified_variable(idx == 0 ? name[2..] : name, options)
500500
end
501501

502502
# At this point, search is for a non qualified (simple) name
@@ -609,7 +609,7 @@ def lookup_qualified_variable(fqn, options)
609609
# not found - search inherited scope for class
610610
leaf_index = fqn.rindex('::')
611611
unless leaf_index.nil?
612-
leaf_name = fqn[(leaf_index + 2)..-1]
612+
leaf_name = fqn[(leaf_index + 2)..]
613613
class_name = fqn[0, leaf_index]
614614
begin
615615
qs = qualified_scope(class_name)
@@ -898,9 +898,9 @@ def to_s
898898
# check module paths first since they may be in the environment (i.e. they are longer)
899899
module_path = environment.full_modulepath.detect { |m_path| path.start_with?(m_path) }
900900
if module_path
901-
path = "<module>" + path[module_path.length..-1]
901+
path = "<module>" + path[module_path.length..]
902902
elsif env_path && path && path.start_with?(env_path)
903-
path = "<env>" + path[env_path.length..-1]
903+
path = "<env>" + path[env_path.length..]
904904
end
905905
# Make the output appear as "Scope(path, line)"
906906
"Scope(#{[path, detail[1]].join(', ')})"

lib/puppet/pops/evaluator/access_operator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ def access_PClassType(o, scope, keys)
703703

704704
name = c.downcase
705705
# Remove leading '::' since all references are global, and 3x runtime does the wrong thing
706-
name = name[2..-1] if name[0, 2] == NS
706+
name = name[2..] if name[0, 2] == NS
707707

708708
fail(Issues::ILLEGAL_NAME, @semantic.keys[i], { :name => c }) unless name =~ Patterns::NAME
709709

lib/puppet/pops/evaluator/closure.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def combine_values_with_parameters(scope, args)
266266
given_argument = args[index]
267267
if param_captures
268268
# get excess arguments
269-
value = args[(parameter_count - 1)..-1]
269+
value = args[(parameter_count - 1)..]
270270
# If the input was a single nil, or undef, and there is a default, use the default
271271
# This supports :undef in case it was used in a 3x data structure and it is passed as an arg
272272
#

lib/puppet/pops/evaluator/deferred_resolver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def resolve_future(f)
161161
mapped_arguments = map_arguments(f.arguments)
162162
# if name starts with $ then this is a call to dig
163163
if func_name[0] == DOLLAR
164-
var_name = func_name[1..-1]
164+
var_name = func_name[1..]
165165
func_name = DIG
166166
mapped_arguments.insert(0, @scope[var_name])
167167
end

lib/puppet/pops/evaluator/epp_evaluator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def self.evaluate(parser, func_name, scope, use_global_scope_only, parse_result,
8686
filtered_args = {}
8787
template_args.each_pair do |k, v|
8888
if k =~ /::/
89-
k = k[2..-1] if k.start_with?('::')
89+
k = k[2..] if k.start_with?('::')
9090
scope[k] = v
9191
else
9292
filtered_args[k] = v

0 commit comments

Comments
 (0)