Skip to content

Commit 96f711a

Browse files
committed
(PUP-11841) Fix Style/RedundantFreeze
Now that all strings are frozen, it's redundant to call String#freeze.
1 parent 3170daa commit 96f711a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+190
-190
lines changed

lib/hiera/scope.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ class Hiera
44
class Scope
55
extend Forwardable
66

7-
CALLING_CLASS = 'calling_class'.freeze
8-
CALLING_CLASS_PATH = 'calling_class_path'.freeze
9-
CALLING_MODULE = 'calling_module'.freeze
10-
MODULE_NAME = 'module_name'.freeze
7+
CALLING_CLASS = 'calling_class'
8+
CALLING_CLASS_PATH = 'calling_class_path'
9+
CALLING_MODULE = 'calling_module'
10+
MODULE_NAME = 'module_name'
1111

1212
CALLING_KEYS = [CALLING_CLASS, CALLING_CLASS_PATH, CALLING_MODULE].freeze
13-
EMPTY_STRING = ''.freeze
13+
EMPTY_STRING = ''
1414

1515
attr_reader :real
1616

lib/puppet/application/lookup.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class Puppet::Application::Lookup < Puppet::Application
88

99
RUN_HELP = _("Run 'puppet lookup --help' for more details").freeze
10-
DEEP_MERGE_OPTIONS = '--knock-out-prefix, --sort-merged-arrays, and --merge-hash-arrays'.freeze
10+
DEEP_MERGE_OPTIONS = '--knock-out-prefix, --sort-merged-arrays, and --merge-hash-arrays'
1111
TRUSTED_INFORMATION_FACTS = ["hostname", "domain", "fqdn", "clientcert"].freeze
1212

1313
run_mode :server

lib/puppet/context/trusted_information.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ def self.deep_freeze(object)
110110

111111
def to_h
112112
{
113-
'authenticated'.freeze => authenticated,
114-
'certname'.freeze => certname,
115-
'extensions'.freeze => extensions,
116-
'hostname'.freeze => hostname,
117-
'domain'.freeze => domain,
118-
'external'.freeze => external,
113+
'authenticated' => authenticated,
114+
'certname' => certname,
115+
'extensions' => extensions,
116+
'hostname' => hostname,
117+
'domain' => domain,
118+
'external' => external,
119119
}.freeze
120120
end
121121
end

lib/puppet/face/help.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ def all_application_summaries()
191191
end
192192
end
193193

194-
COMMON = 'Common:'.freeze
195-
SPECIALIZED = 'Specialized:'.freeze
196-
BLANK = "\n".freeze
194+
COMMON = 'Common:'
195+
SPECIALIZED = 'Specialized:'
196+
BLANK = "\n"
197197
def available_application_names_special_sort()
198198
full_list = Puppet::Application.available_application_names
199199
a_list = full_list & %w{apply agent config help lookup module resource}

lib/puppet/file_system/path_pattern.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Puppet::FileSystem
66
class PathPattern
77
class InvalidPattern < Puppet::Error; end
88

9-
DOTDOT = '..'.freeze
9+
DOTDOT = '..'
1010
ABSOLUTE_UNIX = /^\//
1111
ABSOLUTE_WINDOWS = /^[a-z]:/i
1212
CURRENT_DRIVE_RELATIVE_WINDOWS = /^\\/

lib/puppet/forge.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
1616

1717
include Puppet::Forge::Errors
1818

19-
USER_AGENT = "PMT/1.1.1 (v3; Net::HTTP)".freeze
19+
USER_AGENT = "PMT/1.1.1 (v3; Net::HTTP)"
2020

2121
# From https://forgeapi.puppet.com/#!/release/getReleases
2222
MODULE_RELEASE_EXCLUSIONS=%w[readme changelog license uri module tags supported file_size downloads created_at updated_at deleted_at].join(',').freeze

lib/puppet/functions.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -685,11 +685,11 @@ class Function3x < InternalFunction
685685
# Table of optimized parameter names - 0 to 5 parameters
686686
PARAM_NAMES = [
687687
[],
688-
['p0'.freeze].freeze,
689-
['p0'.freeze, 'p1'.freeze].freeze,
690-
['p0'.freeze, 'p1'.freeze, 'p2'.freeze].freeze,
691-
['p0'.freeze, 'p1'.freeze, 'p2'.freeze, 'p3'.freeze].freeze,
692-
['p0'.freeze, 'p1'.freeze, 'p2'.freeze, 'p3'.freeze, 'p4'.freeze].freeze,
688+
['p0'].freeze,
689+
['p0', 'p1'].freeze,
690+
['p0', 'p1', 'p2'].freeze,
691+
['p0', 'p1', 'p2', 'p3'].freeze,
692+
['p0', 'p1', 'p2', 'p3', 'p4'].freeze,
693693
]
694694

695695
# Creates an anonymous Function3x class that wraps a 3x function

lib/puppet/http.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module Puppet
88
# @see Puppet::HTTP::Response
99
# @api public
1010
module HTTP
11-
ACCEPT_ENCODING = "gzip;q=1.0,deflate;q=0.6,identity;q=0.3".freeze
12-
HEADER_PUPPET_VERSION = "X-Puppet-Version".freeze
11+
ACCEPT_ENCODING = "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
12+
HEADER_PUPPET_VERSION = "X-Puppet-Version"
1313

1414
require_relative 'http/errors'
1515
require_relative 'http/site'

lib/puppet/http/service/ca.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Puppet::HTTP::Service::Ca < Puppet::HTTP::Service
77
HEADERS = { 'Accept' => 'text/plain' }.freeze
88

99
# @return [String] default API for the ca service
10-
API = '/puppet-ca/v1'.freeze
10+
API = '/puppet-ca/v1'
1111

1212
# Use `Puppet::HTTP::Session.route_to(:ca)` to create or get an instance of this class.
1313
#

lib/puppet/http/service/compiler.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# @api public
66
class Puppet::HTTP::Service::Compiler < Puppet::HTTP::Service
77
# @return [String] Default API for the Compiler service
8-
API = '/puppet/v3'.freeze
8+
API = '/puppet/v3'
99

1010
# Use `Puppet::HTTP::Session.route_to(:puppet)` to create or get an instance of this class.
1111
#

lib/puppet/http/service/file_server.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
class Puppet::HTTP::Service::FileServer < Puppet::HTTP::Service
99
# @return [String] Default API for the FileServer service
10-
API = '/puppet/v3'.freeze
10+
API = '/puppet/v3'
1111

1212
# @return [RegEx] RegEx used to determine if a path contains a leading slash
1313
PATH_REGEX = /^\//

lib/puppet/http/service/report.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class Puppet::HTTP::Service::Report < Puppet::HTTP::Service
77

88
# @return [String] Default API for the report service
9-
API = '/puppet/v3'.freeze
9+
API = '/puppet/v3'
1010

1111
# Use `Puppet::HTTP::Session.route_to(:report)` to create or get an instance of this class.
1212
#

lib/puppet/http/session.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# @api public
55
class Puppet::HTTP::Session
66
# capabilities for a site
7-
CAP_LOCALES = 'locales'.freeze
8-
CAP_JSON = 'json'.freeze
7+
CAP_LOCALES = 'locales'
8+
CAP_JSON = 'json'
99

1010
# puppet version where locales mount was added
1111
SUPPORTED_LOCALES_MOUNT_AGENT_VERSION = Gem::Version.new("5.3.4")

lib/puppet/network/format_handler.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
module Puppet::Network::FormatHandler
77
class FormatError < Puppet::Error; end
88

9-
ALL_MEDIA_TYPES = '*/*'.freeze
9+
ALL_MEDIA_TYPES = '*/*'
1010

1111
@formats = {}
1212

lib/puppet/node.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Puppet::Node
2222

2323
attr_reader :server_facts
2424

25-
ENVIRONMENT = 'environment'.freeze
25+
ENVIRONMENT = 'environment'
2626

2727
def initialize_from_hash(data)
2828
@name = data['name'] || (raise ArgumentError, _("No name provided in serialized data"))

lib/puppet/parser/compiler.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def set_node_parameters
580580
@topscope.set_facts(facts_hash)
581581
end
582582

583-
SETTINGS = 'settings'.freeze
583+
SETTINGS = 'settings'
584584

585585
def create_settings_scope
586586
settings_type = create_settings_type

lib/puppet/pops.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ module Puppet
1313
module Pops
1414
EMPTY_HASH = {}.freeze
1515
EMPTY_ARRAY = [].freeze
16-
EMPTY_STRING = ''.freeze
16+
EMPTY_STRING = ''
1717

1818
MAX_INTEGER = 0x7fffffffffffffff
1919
MIN_INTEGER = -0x8000000000000000
2020

21-
DOUBLE_COLON = '::'.freeze
22-
USCORE = '_'.freeze
21+
DOUBLE_COLON = '::'
22+
USCORE = '_'
2323

2424
require 'semantic_puppet'
2525

lib/puppet/pops/evaluator/access_operator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def access_PResourceType(o, scope, keys)
658658
return result_type_array ? result : result.pop
659659
end
660660

661-
NS = '::'.freeze
661+
NS = '::'
662662

663663
def access_PClassType(o, scope, keys)
664664
blamed = keys.size == 0 ? @semantic : @semantic.keys[0]

lib/puppet/pops/evaluator/closure.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def block_name
164164
'unsupported_block'
165165
end
166166

167-
CLOSURE_NAME = 'lambda'.freeze
167+
CLOSURE_NAME = 'lambda'
168168

169169
# @api public
170170
def closure_name()

lib/puppet/pops/evaluator/deferred_resolver.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def resolve
1717
# Utility class to help resolve instances of Puppet::Pops::Types::PDeferredType::Deferred
1818
#
1919
class DeferredResolver
20-
DOLLAR = '$'.freeze
21-
DIG = 'dig'.freeze
20+
DOLLAR = '$'
21+
DIG = 'dig'
2222

2323
# Resolves and replaces all Deferred values in a catalog's resource attributes
2424
# found as direct values or nested inside Array, Hash or Sensitive values.

lib/puppet/pops/evaluator/evaluator_impl.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class EvaluatorImpl
3434
include Runtime3Support
3535
include ExternalSyntaxSupport
3636

37-
COMMA_SEPARATOR = ', '.freeze
37+
COMMA_SEPARATOR = ', '
3838

3939
# Reference to Issues name space makes it easier to refer to issues
4040
# (Issues are shared with the validator).

lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class Puppet::Pops::Evaluator::JsonStrictLiteralEvaluator
2121
#include Puppet::Pops::Utils
2222

23-
COMMA_SEPARATOR = ', '.freeze
23+
COMMA_SEPARATOR = ', '
2424

2525
def initialize
2626
@@literal_visitor ||= Puppet::Pops::Visitor.new(self, "literal", 0, 0)

lib/puppet/pops/evaluator/literal_evaluator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Evaluator
1717
#
1818
class LiteralEvaluator
1919

20-
COMMA_SEPARATOR = ', '.freeze
20+
COMMA_SEPARATOR = ', '
2121

2222
def initialize
2323
@@literal_visitor ||= Visitor.new(self, "literal", 0, 0)

lib/puppet/pops/evaluator/runtime3_resource_support.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Evaluator
44

55
# @api private
66
module Runtime3ResourceSupport
7-
CLASS_STRING = 'class'.freeze
7+
CLASS_STRING = 'class'
88

99
def self.create_resources(file, line, scope, virtual, exported, type_name, resource_titles, evaluated_parameters)
1010

lib/puppet/pops/evaluator/runtime3_support.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Evaluator
88
# @api private
99
module Runtime3Support
1010

11-
NAME_SPACE_SEPARATOR = '::'.freeze
11+
NAME_SPACE_SEPARATOR = '::'
1212

1313
# Fails the evaluation of _semantic_ with a given issue.
1414
#

lib/puppet/pops/loader/loader.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
module Puppet::Pops
2424
module Loader
2525

26-
ENVIRONMENT = 'environment'.freeze
27-
ENVIRONMENT_PRIVATE = 'environment private'.freeze
26+
ENVIRONMENT = 'environment'
27+
ENVIRONMENT_PRIVATE = 'environment private'
2828

2929
class Loader
3030
attr_reader :environment, :loader_name

lib/puppet/pops/loader/loader_paths.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def instantiator
118118
end
119119

120120
class RubySmartPath < SmartPath
121-
EXTENSION = '.rb'.freeze
121+
EXTENSION = '.rb'
122122

123123
def extension
124124
EXTENSION
@@ -134,7 +134,7 @@ def effective_path(typed_name, start_index_in_name)
134134
# path (which is a reference to its 'lib' directory.
135135
#
136136
class PuppetSmartPath < SmartPath
137-
EXTENSION = '.pp'.freeze
137+
EXTENSION = '.pp'
138138

139139
def extension
140140
EXTENSION
@@ -194,7 +194,7 @@ def instantiator
194194
end
195195

196196
class FunctionPathPP < PuppetSmartPath
197-
FUNCTION_PATH_PP = 'functions'.freeze
197+
FUNCTION_PATH_PP = 'functions'
198198

199199
def relative_path
200200
FUNCTION_PATH_PP
@@ -219,7 +219,7 @@ def instantiator
219219
end
220220

221221
class TypePathPP < PuppetSmartPath
222-
TYPE_PATH_PP = 'types'.freeze
222+
TYPE_PATH_PP = 'types'
223223

224224
def relative_path
225225
TYPE_PATH_PP
@@ -233,7 +233,7 @@ def instantiator
233233
# TaskPath is like PuppetSmartPath but it does not use an extension and may
234234
# match more than one path with one name
235235
class TaskPath < PuppetSmartPath
236-
TASKS_PATH = 'tasks'.freeze
236+
TASKS_PATH = 'tasks'
237237
FORBIDDEN_EXTENSIONS = %w{.conf .md}.freeze
238238

239239
def extension
@@ -286,7 +286,7 @@ def is_task_name?(name)
286286
end
287287

288288
class ResourceTypeImplPP < PuppetSmartPath
289-
RESOURCE_TYPES_PATH_PP = '.resource_types'.freeze
289+
RESOURCE_TYPES_PATH_PP = '.resource_types'
290290

291291
def relative_path
292292
RESOURCE_TYPES_PATH_PP
@@ -313,8 +313,8 @@ def effective_path(typed_name, start_index_in_name)
313313

314314
class PlanPath < PuppetSmartPath
315315
PLAN_PATH = File.join('plans')
316-
PP_EXT = '.pp'.freeze
317-
YAML_EXT = '.yaml'.freeze
316+
PP_EXT = '.pp'
317+
YAML_EXT = '.yaml'
318318

319319
def initialize(loader)
320320
super

lib/puppet/pops/loader/module_loaders.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module Loader
2222
module ModuleLoaders
2323

2424
# Wildcard module name for module loaders, makes loading possible from any namespace.
25-
NAMESPACE_WILDCARD = '*'.freeze
25+
NAMESPACE_WILDCARD = '*'
2626

2727
# This is exactly the same as the #system_loader_from method, but the argument for path is changed to
2828
# location where pluginsync stores functions. It also accepts definitions in any namespace since pluginsync

lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
require 'ripper'
66
class Puppet::Pops::Loader::RubyLegacyFunctionInstantiator
7-
UNKNOWN = '<unknown>'.freeze
7+
UNKNOWN = '<unknown>'
88

99
# Produces an instance of the Function class with the given typed_name, or fails with an error if the
1010
# given ruby source does not produce this instance when evaluated.

lib/puppet/pops/loader/typed_name.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def initialize(type, name, name_authority = Pcore::RUNTIME_NAME_AUTHORITY)
2727
@name_parts = parts.freeze
2828

2929
# Use a frozen compound key for the hash and comparison. Most varying part first
30-
@compound_name = "#{@name}/#{@type}/#{@name_authority}".freeze
30+
@compound_name = "#{@name}/#{@type}/#{@name_authority}"
3131
@hash = @compound_name.hash
3232
freeze
3333
end

lib/puppet/pops/lookup.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#
55
module Puppet::Pops
66
module Lookup
7-
LOOKUP_OPTIONS = 'lookup_options'.freeze
8-
GLOBAL = '__global__'.freeze
7+
LOOKUP_OPTIONS = 'lookup_options'
8+
GLOBAL = '__global__'
99

1010
# Performs a lookup in the configured scopes and optionally merges the default.
1111
#

0 commit comments

Comments
 (0)