diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-07-02 18:20:06 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-07-02 18:20:06 -0700 |
commit | 2da413fe65595e95b16e9e01afa240d5c668a03a (patch) | |
tree | aaa60ecf50befabe0c6a5444c593275e411873d5 | |
parent | 5f45c98f1e2ae9ec7b95760a41d617a7a698cc19 (diff) | |
download | chef-2da413fe65595e95b16e9e01afa240d5c668a03a.tar.gz |
fix Style/MutableConstant
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
62 files changed, 109 insertions, 109 deletions
@@ -61,7 +61,7 @@ end begin require "yard" - DOC_FILES = [ "README.rdoc", "LICENSE", "spec/tiny_server.rb", "lib/**/*.rb" ] + DOC_FILES = [ "README.rdoc", "LICENSE", "spec/tiny_server.rb", "lib/**/*.rb" ].freeze namespace :yard do desc "Create YARD documentation" diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 28d5207ad1..4dc6da6a49 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -21,7 +21,7 @@ module ChefConfig CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__) - VERSION = "14.3.27" + VERSION = "14.3.27".freeze end # diff --git a/ext/win32-eventlog/Rakefile b/ext/win32-eventlog/Rakefile index 3bdf7f91d8..1b974670e5 100644 --- a/ext/win32-eventlog/Rakefile +++ b/ext/win32-eventlog/Rakefile @@ -12,13 +12,13 @@ def ensure_present(commands) end end -EVT_MC_FILE = "chef-log.man" -EVT_RC_FILE = "chef-log.rc" -EVT_RESOURCE_OBJECT = "resource.o" -EVT_SHARED_OBJECT = "chef-log.dll" -MC = "windmc" -RC = "windres" -CC = "gcc" +EVT_MC_FILE = "chef-log.man".freeze +EVT_RC_FILE = "chef-log.rc".freeze +EVT_RESOURCE_OBJECT = "resource.o".freeze +EVT_SHARED_OBJECT = "chef-log.dll".freeze +MC = "windmc".freeze +RC = "windres".freeze +CC = "gcc".freeze ensure_present [MC, RC, CC] diff --git a/lib/chef/api_client_v1.rb b/lib/chef/api_client_v1.rb index 645016c5b9..fcd4d91c13 100644 --- a/lib/chef/api_client_v1.rb +++ b/lib/chef/api_client_v1.rb @@ -44,7 +44,7 @@ class Chef include Chef::Mixin::ParamsValidate include Chef::Mixin::ApiVersionRequestHandling - SUPPORTED_API_VERSIONS = [0, 1] + SUPPORTED_API_VERSIONS = [0, 1].freeze # Create a new Chef::ApiClientV1 object. def initialize diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb index 21a926eca1..7bea2bd845 100644 --- a/lib/chef/application/client.rb +++ b/lib/chef/application/client.rb @@ -35,7 +35,7 @@ class Chef::Application::Client < Chef::Application include ChefConfig::Mixin::DotD # Mimic self_pipe sleep from Unicorn to capture signals safely - SELF_PIPE = [] + SELF_PIPE = [] # rubocop:disable Style/MutableConstant option :config_file, short: "-c CONFIG", diff --git a/lib/chef/application/exit_code.rb b/lib/chef/application/exit_code.rb index 917aa16e62..c87592f06b 100644 --- a/lib/chef/application/exit_code.rb +++ b/lib/chef/application/exit_code.rb @@ -36,11 +36,11 @@ class Chef REBOOT_FAILED: 41, AUDIT_MODE_FAILURE: 42, CLIENT_UPGRADED: 213, - } + }.freeze DEPRECATED_RFC_062_EXIT_CODES = { DEPRECATED_FAILURE: -1, - } + }.freeze class << self diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb index 2c8d886b27..d8818cd5aa 100644 --- a/lib/chef/application/knife.rb +++ b/lib/chef/application/knife.rb @@ -23,7 +23,7 @@ require "chef/monkey_patches/net_http.rb" class Chef::Application::Knife < Chef::Application - NO_COMMAND_GIVEN = "You need to pass a sub-command (e.g., knife SUB-COMMAND)\n" + NO_COMMAND_GIVEN = "You need to pass a sub-command (e.g., knife SUB-COMMAND)\n".freeze banner "Usage: knife sub-command (options)" diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb index b49c12c312..3c73a4925d 100644 --- a/lib/chef/application/windows_service.rb +++ b/lib/chef/application/windows_service.rb @@ -59,7 +59,7 @@ class Chef description: "Set the number of seconds to wait between chef-client runs", proc: lambda { |s| s.to_i } - DEFAULT_LOG_LOCATION ||= "#{ENV['SYSTEMDRIVE']}/chef/client.log" + DEFAULT_LOG_LOCATION ||= "#{ENV['SYSTEMDRIVE']}/chef/client.log".freeze def service_init @service_action_mutex = Mutex.new diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb index 0572169ca3..2ba1861a5b 100644 --- a/lib/chef/application/windows_service_manager.rb +++ b/lib/chef/application/windows_service_manager.rb @@ -163,9 +163,9 @@ class Chef private # Just some state constants - STOPPED = "stopped" - RUNNING = "running" - PAUSED = "paused" + STOPPED = "stopped".freeze + RUNNING = "running".freeze + PAUSED = "paused".freeze def service_exists? ::Win32::Service.exists?(@service_name) diff --git a/lib/chef/audit/audit_reporter.rb b/lib/chef/audit/audit_reporter.rb index 1dfb11f53b..7e3abf2608 100644 --- a/lib/chef/audit/audit_reporter.rb +++ b/lib/chef/audit/audit_reporter.rb @@ -28,7 +28,7 @@ class Chef attr_reader :rest_client, :audit_data, :ordered_control_groups, :run_status private :rest_client, :audit_data, :ordered_control_groups, :run_status - PROTOCOL_VERSION = "0.1.1" + PROTOCOL_VERSION = "0.1.1".freeze def initialize(rest_client) @rest_client = rest_client diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb index 2a41fb5870..83efdad063 100644 --- a/lib/chef/chef_fs/config.rb +++ b/lib/chef/chef_fs/config.rb @@ -44,7 +44,7 @@ class Chef "users" => "user", "policies" => "policy", "policy_groups" => "policy_group", - } + }.freeze INFLECTIONS.each { |k, v| k.freeze; v.freeze } INFLECTIONS.freeze diff --git a/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb b/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb index f4655412fa..3951f1a7e6 100644 --- a/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +++ b/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb @@ -24,7 +24,7 @@ class Chef module FileSystem module ChefServer class AclEntry < RestListEntry - PERMISSIONS = %w{create read update delete grant} + PERMISSIONS = %w{create read update delete grant}.freeze def api_path "#{super}/_acl" diff --git a/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb b/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb index b9af486203..dbc895f85e 100644 --- a/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb @@ -28,7 +28,7 @@ class Chef module FileSystem module ChefServer class AclsDir < BaseFSDir - ENTITY_TYPES = %w{clients containers cookbook_artifacts cookbooks data_bags environments groups nodes policies policy_groups roles} # we don't read sandboxes, so we don't read their acls + ENTITY_TYPES = %w{clients containers cookbook_artifacts cookbooks data_bags environments groups nodes policies policy_groups roles}.freeze # we don't read sandboxes, so we don't read their acls def data_handler @data_handler ||= Chef::ChefFS::DataHandler::AclDataHandler.new diff --git a/lib/chef/chef_fs/file_system/repository/acls_dir.rb b/lib/chef/chef_fs/file_system/repository/acls_dir.rb index 110befdf22..ef30bef725 100644 --- a/lib/chef/chef_fs/file_system/repository/acls_dir.rb +++ b/lib/chef/chef_fs/file_system/repository/acls_dir.rb @@ -28,7 +28,7 @@ class Chef module Repository class AclsDir < Repository::Directory - BARE_FILES = %w{ organization.json root } + BARE_FILES = %w{ organization.json root }.freeze def can_have_child?(name, is_dir) is_dir ? Chef::ChefFS::FileSystem::ChefServer::AclsDir::ENTITY_TYPES.include?(name) : BARE_FILES.include?(name) diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb index 7f14b4d5e8..e07a73a118 100644 --- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb @@ -84,7 +84,7 @@ class Chef attr_reader :child_paths attr_reader :versioned_cookbooks - CHILDREN = %w{org.json invitations.json members.json} + CHILDREN = %w{org.json invitations.json members.json}.freeze def children @children ||= begin diff --git a/lib/chef/cookbook/manifest_v0.rb b/lib/chef/cookbook/manifest_v0.rb index bb6d8fc6aa..5a6d7401fa 100644 --- a/lib/chef/cookbook/manifest_v0.rb +++ b/lib/chef/cookbook/manifest_v0.rb @@ -24,7 +24,7 @@ class Chef minimum_api_version 0 - COOKBOOK_SEGMENTS = %w{ resources providers recipes definitions libraries attributes files templates root_files } + COOKBOOK_SEGMENTS = %w{ resources providers recipes definitions libraries attributes files templates root_files }.freeze def self.from_hash(hash) response = Mash.new(hash) diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb index a07844e0a4..8716e502af 100644 --- a/lib/chef/cookbook/metadata.rb +++ b/lib/chef/cookbook/metadata.rb @@ -59,12 +59,12 @@ class Chef :maintainer_email, :license, :platforms, :dependencies, :providing, :attributes, :recipes, :version, :source_url, :issues_url, :privacy, :chef_versions, :ohai_versions, - :gems ] + :gems ].freeze VERSION_CONSTRAINTS = { depends: DEPENDENCIES, provides: PROVIDING, chef_version: CHEF_VERSIONS, - ohai_version: OHAI_VERSIONS } + ohai_version: OHAI_VERSIONS }.freeze include Chef::Mixin::ParamsValidate include Chef::Mixin::FromFile diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb index 8611357e1a..fdd8f690ae 100644 --- a/lib/chef/cookbook_site_streaming_uploader.rb +++ b/lib/chef/cookbook_site_streaming_uploader.rb @@ -31,7 +31,7 @@ class Chef # inspired by http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html class CookbookSiteStreamingUploader - DefaultHeaders = { "accept" => "application/json", "x-chef-version" => ::Chef::VERSION } # rubocop:disable Naming/ConstantName + DefaultHeaders = { "accept" => "application/json", "x-chef-version" => ::Chef::VERSION }.freeze # rubocop:disable Naming/ConstantName class << self diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index 6ac4bb24be..343b037c8b 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -42,7 +42,7 @@ class Chef def_delegator :@cookbook_manifest, :files_for def_delegator :@cookbook_manifest, :each_file - COOKBOOK_SEGMENTS = [ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates, :root_files ] + COOKBOOK_SEGMENTS = [ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates, :root_files ].freeze attr_reader :all_files diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb index 74c600bef9..c0291e057e 100644 --- a/lib/chef/deprecated.rb +++ b/lib/chef/deprecated.rb @@ -30,7 +30,7 @@ class Chef end class Base - BASE_URL = "https://docs.chef.io/deprecations_" + BASE_URL = "https://docs.chef.io/deprecations_".freeze attr_reader :message, :location diff --git a/lib/chef/encrypted_data_bag_item.rb b/lib/chef/encrypted_data_bag_item.rb index c7c6145f61..56135872ac 100644 --- a/lib/chef/encrypted_data_bag_item.rb +++ b/lib/chef/encrypted_data_bag_item.rb @@ -47,8 +47,8 @@ require "open-uri" # such nodes in the infrastructure. # class Chef::EncryptedDataBagItem - ALGORITHM = "aes-256-cbc" - AEAD_ALGORITHM = "aes-256-gcm" + ALGORITHM = "aes-256-cbc".freeze + AEAD_ALGORITHM = "aes-256-gcm".freeze # # === Synopsis diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb index 61777fb7b4..fa845cea6f 100644 --- a/lib/chef/environment.rb +++ b/lib/chef/environment.rb @@ -29,7 +29,7 @@ require "chef/server_api" class Chef class Environment - DEFAULT = "default" + DEFAULT = "default".freeze include Chef::Mixin::ParamsValidate include Chef::Mixin::FromFile diff --git a/lib/chef/event_loggers/windows_eventlog.rb b/lib/chef/event_loggers/windows_eventlog.rb index 860d049314..950477556a 100644 --- a/lib/chef/event_loggers/windows_eventlog.rb +++ b/lib/chef/event_loggers/windows_eventlog.rb @@ -35,7 +35,7 @@ class Chef LOG_CATEGORY_ID = 11001 # Since we must install the event logger, this is not really configurable - SOURCE = "Chef" + SOURCE = "Chef".freeze def self.available? Chef::Platform.windows? diff --git a/lib/chef/formatters/error_inspectors/api_error_formatting.rb b/lib/chef/formatters/error_inspectors/api_error_formatting.rb index 954eebafdb..a4a97ebb95 100644 --- a/lib/chef/formatters/error_inspectors/api_error_formatting.rb +++ b/lib/chef/formatters/error_inspectors/api_error_formatting.rb @@ -23,7 +23,7 @@ class Chef module APIErrorFormatting - NETWORK_ERROR_CLASSES = [Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError] + NETWORK_ERROR_CLASSES = [Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError].freeze def describe_network_errors(error_description) error_description.section("Networking Error:", <<~E) diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb index bfb85785c8..daa582f890 100644 --- a/lib/chef/http/authenticator.rb +++ b/lib/chef/http/authenticator.rb @@ -24,7 +24,7 @@ class Chef class HTTP class Authenticator - DEFAULT_SERVER_API_VERSION = "1" + DEFAULT_SERVER_API_VERSION = "1".freeze attr_reader :signing_key_filename attr_reader :raw_key diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb index 774419a58c..8fec34f8b3 100644 --- a/lib/chef/http/http_request.rb +++ b/lib/chef/http/http_request.rb @@ -40,7 +40,7 @@ class Chef engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby" - UA_COMMON = "/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +https://chef.io)" + UA_COMMON = "/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +https://chef.io)".freeze DEFAULT_UA = "Chef Client" << UA_COMMON USER_AGENT = "User-Agent".freeze diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb index 34a5dbb083..6484a6d540 100644 --- a/lib/chef/http/socketless_chef_zero_client.rb +++ b/lib/chef/http/socketless_chef_zero_client.rb @@ -131,7 +131,7 @@ class Chef 505 => "HTTP Version Not Supported", 507 => "Insufficient Storage", 511 => "Network Authentication Required", - } + }.freeze STATUS_MESSAGE.each_value { |v| v.freeze } STATUS_MESSAGE.freeze diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index ebb6841055..e28ca81f71 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -234,7 +234,7 @@ class Chef end end - OFFICIAL_PLUGINS = %w{ec2 rackspace windows openstack azure google linode push vcenter lpar} + OFFICIAL_PLUGINS = %w{ec2 rackspace windows openstack azure google linode push vcenter lpar}.freeze class << self def list_commands(preferred_category = nil) diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index 67a5580860..2b3c6ba948 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -25,7 +25,7 @@ class Chef class Knife class CookbookUpload < Knife - CHECKSUM = "checksum" + CHECKSUM = "checksum".freeze MATCH_CHECKSUM = /[0-9a-f]{32,}/ deps do diff --git a/lib/chef/knife/core/hashed_command_loader.rb b/lib/chef/knife/core/hashed_command_loader.rb index 8423c01812..cbe4d558c1 100644 --- a/lib/chef/knife/core/hashed_command_loader.rb +++ b/lib/chef/knife/core/hashed_command_loader.rb @@ -24,7 +24,7 @@ class Chef # for the given command. # class HashedCommandLoader < Chef::Knife::SubcommandLoader - KEY = "_autogenerated_command_paths" + KEY = "_autogenerated_command_paths".freeze attr_accessor :manifest def initialize(chef_config_dir, plugin_manifest) diff --git a/lib/chef/log/winevt.rb b/lib/chef/log/winevt.rb index a35f99c52c..7b756e1aab 100644 --- a/lib/chef/log/winevt.rb +++ b/lib/chef/log/winevt.rb @@ -36,7 +36,7 @@ class Chef FATAL_EVENT_ID = 10104 # Since we must install the event logger, this is not really configurable - SOURCE = "Chef" + SOURCE = "Chef".freeze include Chef::Mixin::Unformatter diff --git a/lib/chef/mixin/deprecation.rb b/lib/chef/mixin/deprecation.rb index 06726b5252..d0e36d5f93 100644 --- a/lib/chef/mixin/deprecation.rb +++ b/lib/chef/mixin/deprecation.rb @@ -54,7 +54,7 @@ class Chef module Deprecation class DeprecatedObjectProxyBase - KEEPERS = %w{__id__ __send__ instance_eval == equal? initialize object_id} + KEEPERS = %w{__id__ __send__ instance_eval == equal? initialize object_id}.freeze instance_methods.each { |method_name| undef_method(method_name) unless KEEPERS.include?(method_name.to_s) } end diff --git a/lib/chef/mixin/xml_escape.rb b/lib/chef/mixin/xml_escape.rb index 243bb7f044..7011ff4f56 100644 --- a/lib/chef/mixin/xml_escape.rb +++ b/lib/chef/mixin/xml_escape.rb @@ -89,18 +89,18 @@ class Chef 156 => 339, # latin small ligature oe 158 => 382, # latin small letter z with caron 159 => 376 # latin capital letter y with diaeresis - } + }.freeze # http://www.w3.org/TR/REC-xml/#dt-chardata PREDEFINED = { 38 => "&", # ampersand 60 => "<", # left angle bracket 62 => ">" # right angle bracket - } + }.freeze # http://www.w3.org/TR/REC-xml/#charsets VALID = [[0x9, 0xA, 0xD], (0x20..0xD7FF), - (0xE000..0xFFFD), (0x10000..0x10FFFF)] + (0xE000..0xFFFD), (0x10000..0x10FFFF)].freeze def xml_escape(unescaped_str) unescaped_str.unpack("U*").map { |char| xml_escape_char!(char) }.join diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index 8cb45d2584..46683d9405 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -69,14 +69,14 @@ class Chef :@env_default, :@role_default, :@force_default, - ] + ].freeze OVERRIDE_COMPONENTS = [ :@override, :@role_override, :@env_override, :@force_override, - ] + ].freeze [:all?, :any?, diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb index 2836473b1d..f62eceb646 100644 --- a/lib/chef/node/attribute_collections.rb +++ b/lib/chef/node/attribute_collections.rb @@ -55,7 +55,7 @@ class Chef :sort_by!, :uniq!, :unshift, - ] + ].freeze # For all of the methods that may mutate an Array, we override them to # also invalidate the cached merged_attributes on the root @@ -140,7 +140,7 @@ class Chef :replace, :select!, :shift, - ] + ].freeze # For all of the mutating methods on Mash, override them so that they # also invalidate the cached `merged_attributes` on the root Attribute diff --git a/lib/chef/node/mixin/immutablize_array.rb b/lib/chef/node/mixin/immutablize_array.rb index ba59385d68..000a088410 100644 --- a/lib/chef/node/mixin/immutablize_array.rb +++ b/lib/chef/node/mixin/immutablize_array.rb @@ -121,7 +121,7 @@ class Chef :values_at, :zip, :|, - ] + ].freeze # A list of methods that mutate Array. Each of these is overridden to # raise an error, making this instances of this class more or less # immutable. @@ -160,7 +160,7 @@ class Chef :uniq!, :unshift, :update, - ] + ].freeze # Redefine all of the methods that mutate a Hash to raise an error when called. # This is the magic that makes this object "Immutable" diff --git a/lib/chef/node/mixin/immutablize_hash.rb b/lib/chef/node/mixin/immutablize_hash.rb index 71d2f754a4..04ac5418ef 100644 --- a/lib/chef/node/mixin/immutablize_hash.rb +++ b/lib/chef/node/mixin/immutablize_hash.rb @@ -121,7 +121,7 @@ class Chef :values, :values_at, :zip, - ] + ].freeze DISALLOWED_MUTATOR_METHODS = [ :[]=, :clear, @@ -147,7 +147,7 @@ class Chef :update, :write!, :write, - ] + ].freeze # Redefine all of the methods that mutate a Hash to raise an error when called. # This is the magic that makes this object "Immutable" diff --git a/lib/chef/provider/apt_update.rb b/lib/chef/provider/apt_update.rb index 9d794abcf0..28fc122055 100644 --- a/lib/chef/provider/apt_update.rb +++ b/lib/chef/provider/apt_update.rb @@ -25,8 +25,8 @@ class Chef class AptUpdate < Chef::Provider provides :apt_update, platform_family: "debian" - APT_CONF_DIR = "/etc/apt/apt.conf.d" - STAMP_DIR = "/var/lib/apt/periodic" + APT_CONF_DIR = "/etc/apt/apt.conf.d".freeze + STAMP_DIR = "/var/lib/apt/periodic".freeze def load_current_resource end diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb index 70edd89636..f25a58a789 100644 --- a/lib/chef/provider/cron.rb +++ b/lib/chef/provider/cron.rb @@ -25,9 +25,9 @@ class Chef provides :cron, os: ["!aix", "!solaris2"] - SPECIAL_TIME_VALUES = [:reboot, :yearly, :annually, :monthly, :weekly, :daily, :midnight, :hourly] - CRON_ATTRIBUTES = [:minute, :hour, :day, :month, :weekday, :time, :command, :mailto, :path, :shell, :home, :environment] - WEEKDAY_SYMBOLS = [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday] + SPECIAL_TIME_VALUES = [:reboot, :yearly, :annually, :monthly, :weekly, :daily, :midnight, :hourly].freeze + CRON_ATTRIBUTES = [:minute, :hour, :day, :month, :weekday, :time, :command, :mailto, :path, :shell, :home, :environment].freeze + WEEKDAY_SYMBOLS = [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday].freeze CRON_PATTERN = /\A([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+|[a-zA-Z]{3})\s([-0-9*,\/]+|[a-zA-Z]{3})\s(.*)/ SPECIAL_PATTERN = /\A(@(#{SPECIAL_TIME_VALUES.join('|')}))\s(.*)/ diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb index 126a431742..34e05df504 100644 --- a/lib/chef/provider/service/openbsd.rb +++ b/lib/chef/provider/service/openbsd.rb @@ -31,8 +31,8 @@ class Chef attr_reader :init_command, :rc_conf, :rc_conf_local, :enabled_state_found - RC_CONF_PATH = "/etc/rc.conf" - RC_CONF_LOCAL_PATH = "/etc/rc.conf.local" + RC_CONF_PATH = "/etc/rc.conf".freeze + RC_CONF_LOCAL_PATH = "/etc/rc.conf.local".freeze def initialize(new_resource, run_context) super diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb index 325367322d..59d3fc5a29 100644 --- a/lib/chef/provider/service/windows.rb +++ b/lib/chef/provider/service/windows.rb @@ -34,22 +34,22 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service include Chef::Win32ServiceConstants # Win32::Service.get_start_type - AUTO_START = "auto start" - MANUAL = "demand start" - DISABLED = "disabled" + AUTO_START = "auto start".freeze + MANUAL = "demand start".freeze + DISABLED = "disabled".freeze # Win32::Service.get_current_state - RUNNING = "running" - STOPPED = "stopped" - CONTINUE_PENDING = "continue pending" - PAUSE_PENDING = "pause pending" - PAUSED = "paused" - START_PENDING = "start pending" - STOP_PENDING = "stop pending" + RUNNING = "running".freeze + STOPPED = "stopped".freeze + CONTINUE_PENDING = "continue pending".freeze + PAUSE_PENDING = "pause pending".freeze + PAUSED = "paused".freeze + START_PENDING = "start pending".freeze + STOP_PENDING = "stop pending".freeze TIMEOUT = 60 - SERVICE_RIGHT = "SeServiceLogonRight" + SERVICE_RIGHT = "SeServiceLogonRight".freeze def load_current_resource @current_resource = Chef::Resource::WindowsService.new(new_resource.name) diff --git a/lib/chef/provider/user/solaris.rb b/lib/chef/provider/user/solaris.rb index 38e7f8cb31..2c3222534d 100644 --- a/lib/chef/provider/user/solaris.rb +++ b/lib/chef/provider/user/solaris.rb @@ -27,7 +27,7 @@ class Chef provides :solaris_user provides :user, os: %w{openindiana opensolaris illumos omnios solaris2 smartos} - PASSWORD_FILE = "/etc/shadow" + PASSWORD_FILE = "/etc/shadow".freeze def create_user shell_out!("useradd", universal_options, useradd_options, new_resource.username) diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb index f8df5dc9a8..f10e4adb70 100644 --- a/lib/chef/provider/windows_task.rb +++ b/lib/chef/provider/windows_task.rb @@ -47,7 +47,7 @@ class Chef OCT: TaskScheduler::OCTOBER, NOV: TaskScheduler::NOVEMBER, DEC: TaskScheduler::DECEMBER, - } + }.freeze DAYS_OF_WEEK = { MON: TaskScheduler::MONDAY, TUE: TaskScheduler::TUESDAY, @@ -55,14 +55,14 @@ class Chef THU: TaskScheduler::THURSDAY, FRI: TaskScheduler::FRIDAY, SAT: TaskScheduler::SATURDAY, - SUN: TaskScheduler::SUNDAY } + SUN: TaskScheduler::SUNDAY }.freeze WEEKS_OF_MONTH = { FIRST: TaskScheduler::FIRST_WEEK, SECOND: TaskScheduler::SECOND_WEEK, THIRD: TaskScheduler::THIRD_WEEK, FOURTH: TaskScheduler::FOURTH_WEEK, - } + }.freeze DAYS_OF_MONTH = { 1 => TaskScheduler::TASK_FIRST, @@ -96,7 +96,7 @@ class Chef 29 => TaskScheduler::TASK_TWENTY_NINTH, 30 => TaskScheduler::TASK_THIRTYETH, 31 => TaskScheduler::TASK_THIRTY_FIRST, - } + }.freeze def load_current_resource @current_resource = Chef::Resource::WindowsTask.new(new_resource.name) diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index a90a018d2f..d341e401de 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -1181,8 +1181,8 @@ class Chef # Internal Resource Interface (for Chef) # - FORBIDDEN_IVARS = [:@run_context, :@logger, :@not_if, :@only_if, :@enclosing_provider, :@description, :@introduced, :@examples, :@validation_message, :@deprecated] - HIDDEN_IVARS = [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@logger, :@name, :@not_if, :@only_if, :@elapsed_time, :@enclosing_provider, :@description, :@introduced, :@examples, :@validation_message, :@deprecated] + FORBIDDEN_IVARS = [:@run_context, :@logger, :@not_if, :@only_if, :@enclosing_provider, :@description, :@introduced, :@examples, :@validation_message, :@deprecated].freeze + HIDDEN_IVARS = [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@logger, :@name, :@not_if, :@only_if, :@elapsed_time, :@enclosing_provider, :@description, :@introduced, :@examples, :@validation_message, :@deprecated].freeze include Chef::Mixin::ConvertToClassName extend Chef::Mixin::ConvertToClassName diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb index 7b550ea11a..a9ce1f454f 100644 --- a/lib/chef/resource/windows_service.rb +++ b/lib/chef/resource/windows_service.rb @@ -28,7 +28,7 @@ class Chef automatic: SERVICE_AUTO_START, manual: SERVICE_DEMAND_START, disabled: SERVICE_DISABLED, - } + }.freeze # Until #1773 is resolved, you need to manually specify the windows_service resource # to use action :configure_startup and attribute startup_type diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb index 42665ef82c..fd4c93907d 100644 --- a/lib/chef/resource/windows_task.rb +++ b/lib/chef/resource/windows_task.rb @@ -63,10 +63,10 @@ class Chef attr_accessor :exists, :task, :command_arguments SYSTEM_USERS = ['NT AUTHORITY\SYSTEM', "SYSTEM", 'NT AUTHORITY\LOCALSERVICE', 'NT AUTHORITY\NETWORKSERVICE', 'BUILTIN\USERS', "USERS"].freeze - VALID_WEEK_DAYS = %w{ mon tue wed thu fri sat sun * } + VALID_WEEK_DAYS = %w{ mon tue wed thu fri sat sun * }.freeze VALID_DAYS_OF_MONTH = ("1".."31").to_a << "last" << "lastday" - VALID_MONTHS = %w{JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC *} - VALID_WEEKS = %w{FIRST SECOND THIRD FOURTH LAST LASTDAY} + VALID_MONTHS = %w{JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC *}.freeze + VALID_WEEKS = %w{FIRST SECOND THIRD FOURTH LAST LASTDAY}.freeze def after_created if random_delay diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb index 1ec25fc79a..3198f84d12 100644 --- a/lib/chef/resource_reporter.rb +++ b/lib/chef/resource_reporter.rb @@ -96,7 +96,7 @@ class Chef attr_reader :exception attr_reader :error_descriptions - PROTOCOL_VERSION = "0.1.0" + PROTOCOL_VERSION = "0.1.0".freeze def initialize(rest_client) if Chef::Config[:enable_reporting] && !Chef::Config[:why_run] diff --git a/lib/chef/user_v1.rb b/lib/chef/user_v1.rb index 8bd92dfab8..293bec54a7 100644 --- a/lib/chef/user_v1.rb +++ b/lib/chef/user_v1.rb @@ -39,7 +39,7 @@ class Chef include Chef::Mixin::ParamsValidate include Chef::Mixin::ApiVersionRequestHandling - SUPPORTED_API_VERSIONS = [0, 1] + SUPPORTED_API_VERSIONS = [0, 1].freeze def initialize @username = nil diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb index d282ba9046..9231afe46f 100644 --- a/lib/chef/util/windows/net_user.rb +++ b/lib/chef/util/windows/net_user.rb @@ -60,7 +60,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows profile: :usri3_profile, home_dir_drive: :usri3_home_dir_drive, password_expired: :usri3_password_expired, - } + }.freeze def transform_usri3(args) args.inject({}) do |memo, (k, v)| diff --git a/lib/chef/version_constraint.rb b/lib/chef/version_constraint.rb index f10325f946..6b57cfefe1 100644 --- a/lib/chef/version_constraint.rb +++ b/lib/chef/version_constraint.rb @@ -18,9 +18,9 @@ require "chef/version_class" class Chef class VersionConstraint - DEFAULT_CONSTRAINT = ">= 0.0.0" - STANDARD_OPS = %w{< > <= >=} - OPS = %w{< > = <= >= ~>} + DEFAULT_CONSTRAINT = ">= 0.0.0".freeze + STANDARD_OPS = %w{< > <= >=}.freeze + OPS = %w{< > = <= >= ~>}.freeze PATTERN = /^(#{OPS.join('|')}) *([0-9].*)$/ VERSION_CLASS = Chef::Version diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb index f96fd18316..9a506aa740 100644 --- a/lib/chef/win32/version.rb +++ b/lib/chef/win32/version.rb @@ -65,7 +65,7 @@ class Chef "Windows Server 2003" => { major: 5, minor: 2, callable: lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) == 0 } }, "Windows XP" => { major: 5, minor: 1 }, "Windows 2000" => { major: 5, minor: 0 }, - } + }.freeze def initialize @major_version, @minor_version, @build_number = get_version diff --git a/spec/scripts/ssl-serve.rb b/spec/scripts/ssl-serve.rb index 5677e94d0a..66e400b6d0 100644 --- a/spec/scripts/ssl-serve.rb +++ b/spec/scripts/ssl-serve.rb @@ -36,7 +36,7 @@ DEFAULT_OPTIONS = { Logger: LOGGER, DocumentRoot: File.expand_path("#{Dir.tmpdir}/chef-118-sampledata") #:AccessLog => [] # Remove this option to enable the access log when debugging. -} +}.freeze webrick_opts = DEFAULT_OPTIONS.merge(server_opts) pp webrick_opts: webrick_opts diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb index cd2b83fda1..abeb1ba4bb 100644 --- a/spec/support/shared/functional/securable_resource_with_reporting.rb +++ b/spec/support/shared/functional/securable_resource_with_reporting.rb @@ -19,7 +19,7 @@ ALL_EXPANDED_PERMISSIONS = ["generic read", "execute / traverse", "delete child", "read attributes", - "write attributes"] + "write attributes"].freeze shared_examples_for "a securable resource with reporting" do diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb index c3eab76d8e..4a6bdfb599 100644 --- a/spec/tiny_server.rb +++ b/spec/tiny_server.rb @@ -38,7 +38,7 @@ module TinyServer # SSLEnable: options[:ssl], # SSLCertName: [ [ 'CN', WEBrick::Utils::getservername ] ], AccessLog: [], # Remove this option to enable the access log when debugging. - } + }.freeze def initialize(**options) @options = DEFAULT_OPTIONS.merge(options) @@ -101,10 +101,10 @@ module TinyServer class API include Singleton - GET = "GET" - PUT = "PUT" - POST = "POST" - DELETE = "DELETE" + GET = "GET".freeze + PUT = "PUT".freeze + POST = "POST".freeze + DELETE = "DELETE".freeze attr_reader :routes @@ -170,7 +170,7 @@ module TinyServer end class Response - HEADERS = { "Content-Type" => "application/json" } + HEADERS = { "Content-Type" => "application/json" }.freeze def initialize(response_code = 200, data = nil, headers = nil, &block) @response_code, @data = response_code, data diff --git a/spec/unit/chef_fs/file_system/repository/directory_spec.rb b/spec/unit/chef_fs/file_system/repository/directory_spec.rb index efd17204e0..5b2a0a47b8 100644 --- a/spec/unit/chef_fs/file_system/repository/directory_spec.rb +++ b/spec/unit/chef_fs/file_system/repository/directory_spec.rb @@ -22,7 +22,7 @@ require "chef/chef_fs/file_system/base_fs_object" require "chef/chef_fs/file_system/exceptions" require "chef/chef_fs/file_system/nonexistent_fs_object" -CHILD_FILES = %w{ test1.json test2.json skip test3.json skip2 test4 } +CHILD_FILES = %w{ test1.json test2.json skip test3.json skip2 test4 }.freeze class TestDirectory < Chef::ChefFS::FileSystem::Repository::Directory def make_child_entry(name) diff --git a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb index a09b192b6d..209d987e78 100644 --- a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb @@ -18,7 +18,7 @@ require "spec_helper" -BAD_RECIPE = <<~E +BAD_RECIPE = <<~E.freeze # # Cookbook Name:: syntax-err # Recipe:: default diff --git a/spec/unit/provider/apt_repository_spec.rb b/spec/unit/provider/apt_repository_spec.rb index 8ea2b9b823..79b871eb6c 100644 --- a/spec/unit/provider/apt_repository_spec.rb +++ b/spec/unit/provider/apt_repository_spec.rb @@ -23,7 +23,7 @@ require "spec_helper" # # Output of the command: # => apt-key adv --list-public-keys --with-fingerprint --with-colons -APT_KEY_FINGER = <<~EOF +APT_KEY_FINGER = <<~EOF.freeze tru:t:1:1488924856:0:3:1:5 pub:-:1024:17:40976EAF437D05B5:2004-09-12:::-:Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>::scESC: fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5: @@ -38,7 +38,7 @@ EOF # Output of the command: # => gpg --with-fingerprint --with-colons [FILE] -GPG_FINGER = <<~EOF +GPG_FINGER = <<~EOF.freeze pub:-:1024:17:327574EE02A818DD:2009-04-22:::-:Cloudera Apt Repository: fpr:::::::::F36A89E33CC1BD0F71079007327574EE02A818DD: sub:-:2048:16:84080586D1CA74A1:2009-04-22:::: diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb index 6d55fb958c..aeff294347 100644 --- a/spec/unit/provider/mount/windows_spec.rb +++ b/spec/unit/provider/mount/windows_spec.rb @@ -29,8 +29,8 @@ class Chef end end -GUID = "\\\\?\\Volume{578e72b5-6e70-11df-b5c5-000c29d4a7d9}\\" -REMOTE = "\\\\server-name\\path" +GUID = "\\\\?\\Volume{578e72b5-6e70-11df-b5c5-000c29d4a7d9}\\".freeze +REMOTE = "\\\\server-name\\path".freeze describe Chef::Provider::Mount::Windows do before(:each) do diff --git a/spec/unit/provider/zypper_repository_spec.rb b/spec/unit/provider/zypper_repository_spec.rb index fc8ff14afb..df45c742d4 100644 --- a/spec/unit/provider/zypper_repository_spec.rb +++ b/spec/unit/provider/zypper_repository_spec.rb @@ -20,14 +20,14 @@ require "spec_helper" # Output of the command: # => rpm -qa gpg-pubkey* -RPM_KEYS = <<~EOF +RPM_KEYS = <<~EOF.freeze gpg-pubkey-307e3d54-4be01a65 gpg-pubkey-3dbdc284-53674dd4 EOF # Output of the command: # => gpg --with-fingerprint [FILE] -GPG_FINGER = <<~EOF +GPG_FINGER = <<~EOF.freeze pub 2048R/3DBDC284 2011-08-19 [expires: 2024-06-14] Key fingerprint = 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 uid nginx signing key <signing-key@nginx.com> diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb index cb03141c76..a3f2801adf 100644 --- a/spec/unit/provider_resolver_spec.rb +++ b/spec/unit/provider_resolver_spec.rb @@ -887,7 +887,7 @@ describe Chef::ProviderResolver do }, }, }, - } + }.freeze def self.create_provider_tests(providers, test, expected, filter) expected = expected.merge(providers.select { |key, value| key.is_a?(Symbol) }) diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb index 8e73ad347d..57f1d5c6ba 100644 --- a/spec/unit/role_spec.rb +++ b/spec/unit/role_spec.rb @@ -245,7 +245,7 @@ describe Chef::Role do end end - ROLE_DSL = <<~EOR + ROLE_DSL = <<~EOR.freeze name "ceiling_cat" description "like Aliens, but furry" EOR diff --git a/tasks/maintainers.rb b/tasks/maintainers.rb index 117ac2ce4c..7465f7ba9e 100644 --- a/tasks/maintainers.rb +++ b/tasks/maintainers.rb @@ -25,7 +25,7 @@ REPOSITORIES = ["chef/chef", "chef/chef-dk", "chef/chef-census", "chef/chef-repo "chef/client-docs", "chef/ffi-yajl", "chef/libyajl2-gem", "chef/mixlib-authentication", "chef/mixlib-cli", "chef/mixlib-config", "chef/mixlib-install", "chef/mixlib-log", - "chef/mixlib-shellout", "chef/ohai", "chef/omnibus-chef"] + "chef/mixlib-shellout", "chef/ohai", "chef/omnibus-chef"].freeze begin require "tomlrb" |