summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-09-08 10:51:08 -0700
committerTim Smith <tsmith84@gmail.com>2020-09-08 10:51:08 -0700
commit9a12ed3baa2c2bfa8c32066027c0374cfe50fdee (patch)
tree3357fab41f1e763a4f24c1a828b1954ccf84cbdb
parent9a111dee0b612fd95d7a0c8fef01dfdf0412123b (diff)
downloadchef-9a12ed3baa2c2bfa8c32066027c0374cfe50fdee.tar.gz
Resolve RuboCop Style/RedundantInterpolation warnings
Resolve the issues that pete pointed out plus a few others Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--chef-config/spec/unit/config_spec.rb2
-rw-r--r--lib/chef/application.rb2
-rw-r--r--lib/chef/deprecated.rb2
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb2
-rw-r--r--lib/chef/log/syslog.rb2
-rw-r--r--lib/chef/resource/chef_client_launchd.rb6
-rw-r--r--lib/chef/resource/chef_client_systemd_timer.rb2
-rw-r--r--lib/chef/resource/homebrew_update.rb6
-rw-r--r--spec/unit/node/immutable_collections_spec.rb4
-rw-r--r--spec/unit/provider/package/chocolatey_spec.rb2
10 files changed, 15 insertions, 15 deletions
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb
index 8daee3fa19..1cb83bb8d0 100644
--- a/chef-config/spec/unit/config_spec.rb
+++ b/chef-config/spec/unit/config_spec.rb
@@ -170,7 +170,7 @@ RSpec.describe ChefConfig::Config do
apply_config
expect(described_class[:data_bag_path]).to eq("#{current_directory}/data_bags")
expect(described_class[:cookbook_path]).to eq("#{current_directory}/cookbooks")
- expect(described_class[:chef_repo_path]).to eq("#{current_directory}")
+ expect(described_class[:chef_repo_path]).to eq(current_directory)
end
end
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index 257f993bbe..42bcf9445e 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -317,7 +317,7 @@ class Chef
" finishing converge to exit normally (send SIGINT to terminate immediately)")
end
- client_solo = chef_config[:solo] ? "#{Chef::Dist::SOLOEXEC}" : "#{Chef::Dist::CLIENT}"
+ client_solo = chef_config[:solo] ? Chef::Dist::SOLOEXEC : Chef::Dist::CLIENT
$0 = "#{client_solo} worker: ppid=#{Process.ppid};start=#{Time.new.strftime("%R:%S")};"
begin
logger.trace "Forked instance now converging"
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index 1d167d7aca..992876c17d 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -113,7 +113,7 @@ class Chef
# @return [void]
def target(id, page = nil)
@deprecation_id = id
- @doc_page = page || "#{deprecation_key}"
+ @doc_page = page || deprecation_key.to_s
end
end
end
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index a70e463089..12923f149a 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -184,7 +184,7 @@ class Chef
def start_chef
# If the user doesn't have a client path configure, let bash use the PATH for what it was designed for
- client_path = chef_config[:chef_client_path] || "#{Chef::Dist::CLIENT}"
+ client_path = chef_config[:chef_client_path] || Chef::Dist::CLIENT
s = "#{client_path} -j /etc/chef/first-boot.json"
if config[:verbosity] && config[:verbosity] >= 3
s << " -l trace"
diff --git a/lib/chef/log/syslog.rb b/lib/chef/log/syslog.rb
index 5cf4de4602..28c5bf8799 100644
--- a/lib/chef/log/syslog.rb
+++ b/lib/chef/log/syslog.rb
@@ -33,7 +33,7 @@ class Chef
attr_accessor :sync, :formatter
- def initialize(program_name = "#{Chef::Dist::CLIENT}", facility = ::Syslog::LOG_DAEMON, logopts = nil)
+ def initialize(program_name = Chef::Dist::CLIENT, facility = ::Syslog::LOG_DAEMON, logopts = nil)
super
return if defined? ::Logger::Syslog::SYSLOG
diff --git a/lib/chef/resource/chef_client_launchd.rb b/lib/chef/resource/chef_client_launchd.rb
index 03aa012832..c33fa05876 100644
--- a/lib/chef/resource/chef_client_launchd.rb
+++ b/lib/chef/resource/chef_client_launchd.rb
@@ -130,8 +130,8 @@ class Chef
launchd "com.#{Chef::Dist::SHORT}.restarter" do
username "root"
watch_paths ["/Library/LaunchDaemons/com.#{Chef::Dist::SHORT}.#{Chef::Dist::CLIENT}.plist"]
- standard_out_path "#{::File.join(new_resource.log_directory, new_resource.log_file_name)}"
- standard_error_path "#{::File.join(new_resource.log_directory, new_resource.log_file_name)}"
+ standard_out_path ::File.join(new_resource.log_directory, new_resource.log_file_name)
+ standard_error_path ::File.join(new_resource.log_directory, new_resource.log_file_name)
program_arguments ["/bin/bash",
"-c",
"echo; echo #{Chef::Dist::PRODUCT} launchd daemon config has been updated. Manually unloading and reloading the daemon; echo Now unloading the daemon; launchctl unload /Library/LaunchDaemons/com.#{Chef::Dist::SHORT}.#{Chef::Dist::CLIENT}.plist; sleep 2; echo Now loading the daemon; launchctl load /Library/LaunchDaemons/com.#{Chef::Dist::SHORT}.#{Chef::Dist::CLIENT}.plist"]
@@ -149,7 +149,7 @@ class Chef
end
action :disable do
- service "#{Chef::Dist::PRODUCT}" do
+ service Chef::Dist::PRODUCT do
service_name "com.#{Chef::Dist::SHORT}.#{Chef::Dist::CLIENT}"
action :disable
end
diff --git a/lib/chef/resource/chef_client_systemd_timer.rb b/lib/chef/resource/chef_client_systemd_timer.rb
index e050714a4f..119f920c18 100644
--- a/lib/chef/resource/chef_client_systemd_timer.rb
+++ b/lib/chef/resource/chef_client_systemd_timer.rb
@@ -133,7 +133,7 @@ class Chef
# @return [String]
#
def chef_client_cmd
- cmd = "#{new_resource.chef_binary_path}"
+ cmd = new_resource.chef_binary_path.dup
cmd << " #{new_resource.daemon_options.join(" ")}" unless new_resource.daemon_options.empty?
cmd << " --chef-license accept" if new_resource.accept_chef_license
cmd << " -c #{::File.join(new_resource.config_directory, "client.rb")}"
diff --git a/lib/chef/resource/homebrew_update.rb b/lib/chef/resource/homebrew_update.rb
index 2bf1f8023f..17d756b039 100644
--- a/lib/chef/resource/homebrew_update.rb
+++ b/lib/chef/resource/homebrew_update.rb
@@ -62,8 +62,8 @@ class Chef
#
# @return [Boolean]
def brew_up_to_date?
- ::File.exist?("#{BREW_STAMP}") &&
- ::File.mtime("#{BREW_STAMP}") > Time.now - new_resource.frequency
+ ::File.exist?(BREW_STAMP) &&
+ ::File.mtime(BREW_STAMP) > Time.now - new_resource.frequency
end
def do_update
@@ -71,7 +71,7 @@ class Chef
recursive true
end
- file "#{BREW_STAMP}" do
+ file BREW_STAMP do
content "BREW::Update::Post-Invoke-Success\n"
action :create_if_missing
end
diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb
index 5ced8053a0..836e9862e9 100644
--- a/spec/unit/node/immutable_collections_spec.rb
+++ b/spec/unit/node/immutable_collections_spec.rb
@@ -130,7 +130,7 @@ describe Chef::Node::ImmutableMash do
end
%w{to_h to_hash dup}.each do |immutable_meth|
- describe "#{immutable_meth}" do
+ describe immutable_meth do
include_examples "ImmutableMash module", description
end
end
@@ -238,7 +238,7 @@ describe Chef::Node::ImmutableArray do
end
%w{to_a to_array dup}.each do |immutable_meth|
- describe "#{immutable_meth}" do
+ describe immutable_meth do
include_examples "ImmutableArray module", description
end
end
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb
index 4c1ccc7834..96b17d90f2 100644
--- a/spec/unit/provider/package/chocolatey_spec.rb
+++ b/spec/unit/provider/package/chocolatey_spec.rb
@@ -150,7 +150,7 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
new_resource.package_name("package-does-not-exist")
new_resource.returns([0])
allow(provider).to receive(:shell_out_compacted!)
- .with(choco_exe, "list", "-r", "#{new_resource.package_name.first}", { returns: new_resource.returns, timeout: timeout })
+ .with(choco_exe, "list", "-r", new_resource.package_name.first, { returns: new_resource.returns, timeout: timeout })
.and_raise(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
expect { provider.send(:available_packages) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
end