diff options
author | Tim Smith <tsmith@chef.io> | 2021-05-10 11:33:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-10 11:33:29 -0700 |
commit | 3e359c8b71a4caca7353ceb6dbefebfe22439d4b (patch) | |
tree | decdb2a14237c0a0e0a9cc6a1d0e0c4684d0e7ab | |
parent | ed6947da991ecaf9751fa9bc5bde55e8645423da (diff) | |
parent | cb0b972a45ebd3727627ed991dba6b51d85c1ef9 (diff) | |
download | chef-3e359c8b71a4caca7353ceb6dbefebfe22439d4b.tar.gz |
Merge pull request #11527 from chef/expeditor/chef/chefstyle_9e9864d3839e1a78703e6662b0dbe7a04af05fd1
Signed-off-by: Tim Smith <tsmith@chef.io>
29 files changed, 45 insertions, 45 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index edffb1dab0..1e0dc1fd78 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,10 @@ GIT remote: https://github.com/chef/chefstyle.git - revision: 6b08692b230b9766b9e730c57aca8a94b0749782 + revision: aabbd0cd0b6ad646e55370277ee5af4eefed148a branch: master specs: - chefstyle (2.0.1) - rubocop (= 1.13.0) + chefstyle (2.0.3) + rubocop (= 1.14.0) GIT remote: https://github.com/chef/ohai.git @@ -290,13 +290,13 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) - rubocop (1.13.0) + rubocop (1.14.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.5.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.5.0) @@ -108,8 +108,8 @@ task :update_chef_exec_dll do sh("hab pkg install chef/chef-powershell-shim") sh("hab pkg install chef/chef-powershell-shim-x86") - x64 = `hab pkg path chef/chef-powershell-shim`.chomp.tr('\\', "/") - x86 = `hab pkg path chef/chef-powershell-shim-x86`.chomp.tr('\\', "/") + x64 = `hab pkg path chef/chef-powershell-shim`.chomp.tr("\\", "/") + x86 = `hab pkg path chef/chef-powershell-shim-x86`.chomp.tr("\\", "/") FileUtils.rm_rf(Dir["distro/ruby_bin_folder/AMD64/*"]) FileUtils.rm_rf(Dir["distro/ruby_bin_folder/x86/*"]) puts "Copying #{x64}/bin/* to distro/ruby_bin_folder/AMD64" diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 2f261b45a7..2496a07eae 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -71,8 +71,8 @@ module ChefConfig # Some installations will be on different drives so use the drive that # the expanded path to __FILE__ is found. drive = windows_installation_drive - if drive && path[0] == '\\' && path.split('\\')[2] == "chef" - path = PathHelper.join(drive, path.split('\\', 3)[2]) + if drive && path[0] == "\\" && path.split("\\")[2] == "chef" + path = PathHelper.join(drive, path.split("\\", 3)[2]) end end path diff --git a/chef-config/lib/chef-config/path_helper.rb b/chef-config/lib/chef-config/path_helper.rb index 8fe45febfc..adacade391 100644 --- a/chef-config/lib/chef-config/path_helper.rb +++ b/chef-config/lib/chef-config/path_helper.rb @@ -45,7 +45,7 @@ module ChefConfig end end - BACKSLASH = '\\'.freeze + BACKSLASH = "\\".freeze def self.path_separator(windows: ChefUtils.windows?) if windows diff --git a/chef-config/spec/unit/path_helper_spec.rb b/chef-config/spec/unit/path_helper_spec.rb index 5721e105ec..de45de2a62 100644 --- a/chef-config/spec/unit/path_helper_spec.rb +++ b/chef-config/spec/unit/path_helper_spec.rb @@ -56,7 +56,7 @@ RSpec.describe ChefConfig::PathHelper do context "forcing windows/non-windows" do context "forcing windows" do it "path_separator is \\" do - expect(path_helper.path_separator(windows: true)).to eq('\\') + expect(path_helper.path_separator(windows: true)).to eq("\\") end context "platform-specific #join behavior" do @@ -133,7 +133,7 @@ RSpec.describe ChefConfig::PathHelper do end it "path_separator is \\" do - expect(path_helper.path_separator).to eq('\\') + expect(path_helper.path_separator).to eq("\\") end context "platform-specific #join behavior" do diff --git a/knife/spec/support/chef_helpers.rb b/knife/spec/support/chef_helpers.rb index 3738c4a41e..f11dee47b6 100644 --- a/knife/spec/support/chef_helpers.rb +++ b/knife/spec/support/chef_helpers.rb @@ -43,7 +43,7 @@ end # This is a helper to canonicalize paths that we're using in the file # tests. def canonicalize_path(path) - windows? ? path.tr("/", '\\') : path + windows? ? path.tr("/", "\\") : path end # Makes a temp directory with a canonical path on any platform. diff --git a/knife/spec/unit/application/knife_spec.rb b/knife/spec/unit/application/knife_spec.rb index ad705ab1e5..300f2b2f83 100644 --- a/knife/spec/unit/application/knife_spec.rb +++ b/knife/spec/unit/application/knife_spec.rb @@ -163,7 +163,7 @@ describe Chef::Application::Knife do expect(@knife).to receive(:exit).with(0) @knife.run end - expect(Chef::Config[:client_key]).to eq(File.join(ENV["HOME"], ".chef/client.pem").gsub((File::ALT_SEPARATOR || '\\'), File::SEPARATOR)) + expect(Chef::Config[:client_key]).to eq(File.join(ENV["HOME"], ".chef/client.pem").gsub((File::ALT_SEPARATOR || "\\"), File::SEPARATOR)) end it "does not expand a full path" do diff --git a/lib/chef/chef_fs/file_pattern.rb b/lib/chef/chef_fs/file_pattern.rb index 37e72f379b..7e7a58e312 100644 --- a/lib/chef/chef_fs/file_pattern.rb +++ b/lib/chef/chef_fs/file_pattern.rb @@ -255,7 +255,7 @@ class Chef end def self.regexp_escape_characters - [ "[", '\\', "^", "$", ".", "|", "?", "*", "+", "(", ")", "{", "}" ] + [ "[", "\\", "^", "$", ".", "|", "?", "*", "+", "(", ")", "{", "}" ] end def self.pattern_to_regexp(pattern) @@ -281,7 +281,7 @@ class Chef exact = nil regexp << "." else - if part[0, 1] == '\\' && part.length == 2 + if part[0, 1] == "\\" && part.length == 2 # backslash escapes are only supported on Unix, and are handled here by leaving the escape on (it means the same thing in a regex) exact << part[1, 1] unless exact.nil? if regexp_escape_characters.include?(part[1, 1]) diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb index 3c81ea1414..113807e49a 100644 --- a/lib/chef/provider/link.rb +++ b/lib/chef/provider/link.rb @@ -73,7 +73,7 @@ class Chef end def canonicalize(path) - ChefUtils.windows? ? path.tr("/", '\\') : path + ChefUtils.windows? ? path.tr("/", "\\") : path end action :create do diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb index 316a2a1081..5d723feb29 100644 --- a/lib/chef/provider/registry_key.rb +++ b/lib/chef/provider/registry_key.rb @@ -78,7 +78,7 @@ class Chef def define_resource_requirements requirements.assert(:create, :create_if_missing, :delete, :delete_key) do |a| a.assertion { registry.hive_exists?(new_resource.key) } - a.failure_message(Chef::Exceptions::Win32RegHiveMissing, "Hive #{new_resource.key.split('\\').shift} does not exist") + a.failure_message(Chef::Exceptions::Win32RegHiveMissing, "Hive #{new_resource.key.split("\\").shift} does not exist") end requirements.assert(:create) do |a| diff --git a/lib/chef/provider/windows_script.rb b/lib/chef/provider/windows_script.rb index a93319a35a..ee986c6d59 100644 --- a/lib/chef/provider/windows_script.rb +++ b/lib/chef/provider/windows_script.rb @@ -83,7 +83,7 @@ class Chef username = new_resource.user if new_resource.domain - username = new_resource.domain + '\\' + new_resource.user + username = new_resource.domain + "\\" + new_resource.user end # Create an ACE that allows the alternate user read access to the script diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index 88f52bbde1..b830f119be 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -633,13 +633,13 @@ class Chef end # if domain is provided in both username and domain - if specified_user.is_a?(String) && ((specified_user.include? '\\') || (specified_user.include? "@")) && specified_domain + if specified_user.is_a?(String) && ((specified_user.include? "\\") || (specified_user.include? "@")) && specified_domain raise ArgumentError, "The domain is provided twice. Username: `#{specified_user}`, Domain: `#{specified_domain}`. Please specify domain only once." end if specified_user.is_a?(String) && specified_domain.nil? # Splitting username of format: Domain\Username - domain_and_user = user.split('\\') + domain_and_user = user.split("\\") if domain_and_user.length == 2 domain = domain_and_user[0] diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb index f47a8ba2c9..8eca1c3337 100644 --- a/lib/chef/resource/remote_file.rb +++ b/lib/chef/resource/remote_file.rb @@ -142,13 +142,13 @@ class Chef end # if domain is provided in both username and domain - if specified_user && ((specified_user.include? '\\') || (specified_user.include? "@")) && specified_domain + if specified_user && ((specified_user.include? "\\") || (specified_user.include? "@")) && specified_domain raise ArgumentError, "The domain is provided twice. Username: `#{specified_user}`, Domain: `#{specified_domain}`. Please specify domain only once." end if ! specified_user.nil? && specified_domain.nil? # Splitting username of format: Domain\Username - domain_and_user = user.split('\\') + domain_and_user = user.split("\\") if domain_and_user.length == 2 domain = domain_and_user[0] diff --git a/lib/chef/resource/windows_env.rb b/lib/chef/resource/windows_env.rb index dde3412ef5..c8385ecc1b 100644 --- a/lib/chef/resource/windows_env.rb +++ b/lib/chef/resource/windows_env.rb @@ -186,7 +186,7 @@ class Chef if environment_variables && environment_variables.length > 0 environment_variables.each do |env| @env_obj = env.wmi_ole_object - return @env_obj if @env_obj.username.split('\\').last.casecmp(new_resource.user) == 0 + return @env_obj if @env_obj.username.split("\\").last.casecmp(new_resource.user) == 0 end end @env_obj = nil diff --git a/lib/chef/resource/windows_font.rb b/lib/chef/resource/windows_font.rb index 6a7d065678..9043ba94f3 100644 --- a/lib/chef/resource/windows_font.rb +++ b/lib/chef/resource/windows_font.rb @@ -43,7 +43,7 @@ class Chef property :source, String, description: "A local filesystem path or URI that is used to source the font file.", - coerce: proc { |x| /^.:.*/.match?(x) ? x.tr('\\', "/").gsub("//", "/") : x } + coerce: proc { |x| /^.:.*/.match?(x) ? x.tr("\\", "/").gsub("//", "/") : x } action :install, description: "Install a font to the system fonts directory" do if font_exists? diff --git a/lib/chef/resource/windows_pagefile.rb b/lib/chef/resource/windows_pagefile.rb index 6b39bfc35b..871f36b3c7 100644 --- a/lib/chef/resource/windows_pagefile.rb +++ b/lib/chef/resource/windows_pagefile.rb @@ -56,7 +56,7 @@ class Chef DOC property :path, String, - coerce: proc { |x| x.tr("/", '\\') }, + coerce: proc { |x| x.tr("/", "\\") }, description: "An optional property to set the pagefile name if it differs from the resource block's name.", name_property: true @@ -220,7 +220,7 @@ class Chef end def get_setting_id(pagefile) - split_path = pagefile.split('\\') + split_path = pagefile.split("\\") "#{split_path[1]} @ #{split_path[0]}" end diff --git a/lib/chef/resource/windows_path.rb b/lib/chef/resource/windows_path.rb index f0cc316e66..45077f74af 100644 --- a/lib/chef/resource/windows_path.rb +++ b/lib/chef/resource/windows_path.rb @@ -72,7 +72,7 @@ class Chef env "path" do action :modify delim ::File::PATH_SEPARATOR - value path.tr("/", '\\') + value path.tr("/", "\\") end end @@ -84,7 +84,7 @@ class Chef env "path" do action :delete delim ::File::PATH_SEPARATOR - value path.tr("/", '\\') + value path.tr("/", "\\") end end end diff --git a/lib/chef/resource/windows_security_policy.rb b/lib/chef/resource/windows_security_policy.rb index 6d124f7fcf..ad6c0b249e 100644 --- a/lib/chef/resource/windows_security_policy.rb +++ b/lib/chef/resource/windows_security_policy.rb @@ -118,13 +118,13 @@ class Chef policy_line = "#{security_option} = \"#{security_value}\"" file.write("[Unicode]\r\nUnicode=yes\r\n[System Access]\r\n#{policy_line}\r\n[Version]\r\nsignature=\"$CHICAGO$\"\r\nRevision=1\r\n") file.close - file_path = file.path.tr("/", '\\') + file_path = file.path.tr("/", "\\") cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg #{file_path} /areas SECURITYPOLICY" else policy_line = "#{security_option} = #{security_value}" file.write("[Unicode]\r\nUnicode=yes\r\n[System Access]\r\n#{policy_line}\r\n[Version]\r\nsignature=\"$CHICAGO$\"\r\nRevision=1\r\n") file.close - file_path = file.path.tr("/", '\\') + file_path = file.path.tr("/", "\\") cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg #{file_path} /areas SECURITYPOLICY" end shell_out!(cmd) diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb index c3eb627a4e..7864ff6c22 100644 --- a/lib/chef/resource/windows_task.rb +++ b/lib/chef/resource/windows_task.rb @@ -549,7 +549,7 @@ class Chef if @current_resource.exists task.get_task(new_resource.task_name) @current_resource.task = task - pathed_task_name = new_resource.task_name.start_with?('\\') ? new_resource.task_name : "\\#{new_resource.task_name}" + pathed_task_name = new_resource.task_name.start_with?("\\") ? new_resource.task_name : "\\#{new_resource.task_name}" @current_resource.task_name(pathed_task_name) end @current_resource diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb index 1f83b7ea5a..8382983ca0 100644 --- a/lib/chef/run_lock.rb +++ b/lib/chef/run_lock.rb @@ -173,7 +173,7 @@ class Chef # Mutex name is case-sensitive contrary to other things in # windows. "\" is the only invalid character. def acquire_win32_mutex - @mutex = Chef::ReservedNames::Win32::Mutex.new("Global\\#{runlock_file.tr('\\', "/").downcase}") + @mutex = Chef::ReservedNames::Win32::Mutex.new("Global\\#{runlock_file.tr("\\", "/").downcase}") mutex.test end diff --git a/omnibus/config/software/more-ruby-cleanup.rb b/omnibus/config/software/more-ruby-cleanup.rb index 663fc71e42..b875c8a166 100644 --- a/omnibus/config/software/more-ruby-cleanup.rb +++ b/omnibus/config/software/more-ruby-cleanup.rb @@ -43,7 +43,7 @@ build do block "Removing additional non-code files from installed gems" do # find the embedded ruby gems dir and clean it up for globbing - target_dir = "#{install_dir}/embedded/lib/ruby/gems/*/gems".tr('\\', "/") + target_dir = "#{install_dir}/embedded/lib/ruby/gems/*/gems".tr("\\", "/") files = %w{ .rspec-tm .sitearchdir.time @@ -82,7 +82,7 @@ build do block "Removing Gemspec / Rakefile / Gemfile unless there's a bin dir / not a chef gem" do # find the embedded ruby gems dir and clean it up for globbing - target_dir = "#{install_dir}/embedded/lib/ruby/gems/*/gems".tr('\\', "/") + target_dir = "#{install_dir}/embedded/lib/ruby/gems/*/gems".tr("\\", "/") files = %w{ Gemfile Rakefile @@ -102,7 +102,7 @@ build do end block "Removing spec dirs from non-Chef gems" do - Dir.glob("#{install_dir}/embedded/lib/ruby/gems/*/gems/*/spec".tr('\\', "/")).each do |f| + Dir.glob("#{install_dir}/embedded/lib/ruby/gems/*/gems/*/spec".tr("\\", "/")).each do |f| # if we're in a chef- gem then don't remove the specs next if File.basename(File.expand_path("..", f)).start_with?("chef-") diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb index a682e9c0c7..279f8ac8d4 100644 --- a/spec/functional/resource/group_spec.rb +++ b/spec/functional/resource/group_spec.rb @@ -72,7 +72,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do end def windows_domain_user?(user_name) - domain, user = user_name.split('\\') + domain, user = user_name.split("\\") if user && domain != "." computer_name = ENV["computername"] diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb index c1de3bf99d..734897aaa4 100644 --- a/spec/functional/resource/link_spec.rb +++ b/spec/functional/resource/link_spec.rb @@ -84,7 +84,7 @@ describe Chef::Resource::Link do end def canonicalize(path) - windows? ? path.tr("/", '\\') : path + windows? ? path.tr("/", "\\") : path end def symlink(a, b) diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb index 09e4fdccb4..3e929d22f7 100644 --- a/spec/functional/resource/remote_file_spec.rb +++ b/spec/functional/resource/remote_file_spec.rb @@ -155,7 +155,7 @@ describe Chef::Resource::RemoteFile do before do shell_out("net.exe share #{smb_share_name} /delete") File.write(smb_file_local_path, smb_file_content ) - shell_out!("net.exe share #{smb_share_name}=\"#{smb_share_root_directory.tr("/", '\\')}\" /grant:\"authenticated users\",read") + shell_out!("net.exe share #{smb_share_name}=\"#{smb_share_root_directory.tr("/", "\\")}\" /grant:\"authenticated users\",read") end after do diff --git a/spec/functional/resource/windows_env_spec.rb b/spec/functional/resource/windows_env_spec.rb index bbcbf393e2..4d77ee34bd 100644 --- a/spec/functional/resource/windows_env_spec.rb +++ b/spec/functional/resource/windows_env_spec.rb @@ -38,7 +38,7 @@ describe Chef::Resource::WindowsEnv, :windows_only do if environment_variables && environment_variables.length > 0 environment_variables.each do |env| env_obj = env.wmi_ole_object - return env_obj if env_obj.username.split('\\').last.casecmp(test_resource.user) == 0 + return env_obj if env_obj.username.split("\\").last.casecmp(test_resource.user) == 0 end end nil @@ -93,7 +93,7 @@ describe Chef::Resource::WindowsEnv, :windows_only do test_resource.value(env_value1) test_resource.user(env_user) test_resource.run_action(:create) - expect(env_obj.username.split('\\').last.upcase).to eq(env_user) + expect(env_obj.username.split("\\").last.upcase).to eq(env_user) end context "when env variable exist with same name" do diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb index 3738c4a41e..f11dee47b6 100644 --- a/spec/support/chef_helpers.rb +++ b/spec/support/chef_helpers.rb @@ -43,7 +43,7 @@ end # This is a helper to canonicalize paths that we're using in the file # tests. def canonicalize_path(path) - windows? ? path.tr("/", '\\') : path + windows? ? path.tr("/", "\\") : path end # Makes a temp directory with a canonical path on any platform. diff --git a/spec/support/shared/functional/execute_resource.rb b/spec/support/shared/functional/execute_resource.rb index 9d1c29dfac..62f3f19a2b 100644 --- a/spec/support/shared/functional/execute_resource.rb +++ b/spec/support/shared/functional/execute_resource.rb @@ -58,7 +58,7 @@ shared_context "a command that can be executed as an alternate user" do include Chef::Mixin::ShellOut before do - shell_out!("icacls \"#{script_output_dir.tr("/", '\\')}\" /grant \"authenticated users:(F)\"") + shell_out!("icacls \"#{script_output_dir.tr("/", "\\")}\" /grant \"authenticated users:(F)\"") end after do diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index 654765e82d..dccfd5d027 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -36,7 +36,7 @@ end # forwards-vs-reverse slashes on windows sucks def windows_path - windows? ? normalized_path.tr('\\', "/") : normalized_path + windows? ? normalized_path.tr("\\", "/") : normalized_path end # this is all getting a bit stupid, CHEF-4802 cut to remove all this diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb index eebf0a9d07..4ab4c57094 100644 --- a/spec/unit/provider/link_spec.rb +++ b/spec/unit/provider/link_spec.rb @@ -41,7 +41,7 @@ describe Chef::Resource::Link do end def canonicalize(path) - ChefUtils.windows? ? path.tr("/", '\\') : path + ChefUtils.windows? ? path.tr("/", "\\") : path end describe "when the target is a symlink" do |