diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-05 12:58:00 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-05 12:58:00 -0700 |
commit | 2a4916b7f01940d1199c35645c1b2172f5bd74b2 (patch) | |
tree | df7370ed682895857181f14bb66cad8db18b298e /lib/chef/knife | |
parent | 8215091264d67d81f0da9a13f968b864ff736cb2 (diff) | |
download | chef-2a4916b7f01940d1199c35645c1b2172f5bd74b2.tar.gz |
Style/StringLiteralsInInterpolation
since we use double quotes, be consistent everywhere.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/knife')
-rw-r--r-- | lib/chef/knife/cookbook_download.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/cookbook_upload.rb | 6 | ||||
-rw-r--r-- | lib/chef/knife/core/gem_glob_loader.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/core/generic_presenter.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/core/node_presenter.rb | 30 | ||||
-rw-r--r-- | lib/chef/knife/core/object_loader.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/core/status_presenter.rb | 8 | ||||
-rw-r--r-- | lib/chef/knife/core/ui.rb | 8 | ||||
-rw-r--r-- | lib/chef/knife/deps.rb | 4 | ||||
-rw-r--r-- | lib/chef/knife/key_list.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/node_edit.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/ssh.rb | 8 | ||||
-rw-r--r-- | lib/chef/knife/supermarket_download.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/supermarket_show.rb | 2 |
14 files changed, 40 insertions, 40 deletions
diff --git a/lib/chef/knife/cookbook_download.rb b/lib/chef/knife/cookbook_download.rb index 2da5e138a3..aa6458a5d0 100644 --- a/lib/chef/knife/cookbook_download.rb +++ b/lib/chef/knife/cookbook_download.rb @@ -87,7 +87,7 @@ class Chef ui.info("Downloading #{segment}") files.each do |segment_file| dest = File.join(basedir, segment_file["path"].gsub("/", File::SEPARATOR)) - Chef::Log.trace("Downloading #{segment_file['path']} to #{dest}") + Chef::Log.trace("Downloading #{segment_file["path"]} to #{dest}") FileUtils.mkdir_p(File.dirname(dest)) tempfile = rest.streaming_request(segment_file["url"]) FileUtils.mv(tempfile.path, dest) diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index 1aeb097991..ef66cc16c7 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -224,7 +224,7 @@ class Chef broken_filenames = Array(broken_files).map { |path, info| path } ui.error "The cookbook #{cookbook.name} has one or more broken files" ui.error "This is probably caused by broken symlinks in the cookbook directory" - ui.error "The broken file(s) are: #{broken_filenames.join(' ')}" + ui.error "The broken file(s) are: #{broken_filenames.join(" ")}" exit 1 end end @@ -240,7 +240,7 @@ class Chef missing_cookbook_names = missing_dependencies.map { |cookbook_name, version| "'#{cookbook_name}' version '#{version}'" } ui.error "Cookbook #{cookbook.name} depends on cookbooks which are not currently" ui.error "being uploaded and cannot be found on the server." - ui.error "The missing cookbook(s) are: #{missing_cookbook_names.join(', ')}" + ui.error "The missing cookbook(s) are: #{missing_cookbook_names.join(", ")}" exit 1 end end @@ -253,7 +253,7 @@ class Chef Log.debug "Versions of cookbook '#{cookbook_name}' returned by the server: #{versions.join(", ")}" @server_side_cookbooks[cookbook_name]["versions"].each do |versions_hash| if Chef::VersionConstraint.new(version).include?(versions_hash["version"]) - Log.debug "Matched cookbook '#{cookbook_name}' with constraint '#{version}' to cookbook version '#{versions_hash['version']}' on the server" + Log.debug "Matched cookbook '#{cookbook_name}' with constraint '#{version}' to cookbook version '#{versions_hash["version"]}' on the server" return true end end diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb index 15707dee2e..6b969c695f 100644 --- a/lib/chef/knife/core/gem_glob_loader.rb +++ b/lib/chef/knife/core/gem_glob_loader.rb @@ -111,7 +111,7 @@ class Chef def check_spec_for_glob(spec, glob) dirs = if spec.require_paths.size > 1 - "{#{spec.require_paths.join(',')}}" + "{#{spec.require_paths.join(",")}}" else spec.require_paths.first end diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb index e219e29707..fe8a84b753 100644 --- a/lib/chef/knife/core/generic_presenter.rb +++ b/lib/chef/knife/core/generic_presenter.rb @@ -220,7 +220,7 @@ class Chef end key_length = versions_by_cookbook.empty? ? 0 : versions_by_cookbook.keys.map { |name| name.size }.max + 2 versions_by_cookbook.sort.map do |cookbook, versions| - "#{cookbook.ljust(key_length)} #{versions.join(' ')}" + "#{cookbook.ljust(key_length)} #{versions.join(" ")}" end end end diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb index 3f1feb9d16..258a4822fd 100644 --- a/lib/chef/knife/core/node_presenter.rb +++ b/lib/chef/knife/core/node_presenter.rb @@ -98,47 +98,47 @@ class Chef ip = (node[:ec2] && node[:ec2][:public_ipv4]) || node[:ipaddress] summarized = <<~SUMMARY - #{ui.color('Node Name:', :bold)} #{ui.color(node.name, :bold)} + #{ui.color("Node Name:", :bold)} #{ui.color(node.name, :bold)} SUMMARY show_policy = !(node.policy_name.nil? && node.policy_group.nil?) if show_policy summarized << <<~POLICY - #{key('Policy Name:')} #{node.policy_name} - #{key('Policy Group:')} #{node.policy_group} + #{key("Policy Name:")} #{node.policy_name} + #{key("Policy Group:")} #{node.policy_group} POLICY else summarized << <<~ENV - #{key('Environment:')} #{node.chef_environment} + #{key("Environment:")} #{node.chef_environment} ENV end summarized << <<~SUMMARY - #{key('FQDN:')} #{node[:fqdn]} - #{key('IP:')} #{ip} - #{key('Run List:')} #{node.run_list} + #{key("FQDN:")} #{node[:fqdn]} + #{key("IP:")} #{ip} + #{key("Run List:")} #{node.run_list} SUMMARY unless show_policy summarized << <<~ROLES - #{key('Roles:')} #{Array(node[:roles]).join(', ')} + #{key("Roles:")} #{Array(node[:roles]).join(", ")} ROLES end summarized << <<~SUMMARY - #{key('Recipes:')} #{Array(node[:recipes]).join(', ')} - #{key('Platform:')} #{node[:platform]} #{node[:platform_version]} - #{key('Tags:')} #{node.tags.join(', ')} + #{key("Recipes:")} #{Array(node[:recipes]).join(", ")} + #{key("Platform:")} #{node[:platform]} #{node[:platform_version]} + #{key("Tags:")} #{node.tags.join(", ")} SUMMARY if config[:medium_output] || config[:long_output] summarized += <<~MORE - #{key('Attributes:')} + #{key("Attributes:")} #{text_format(node.normal_attrs)} MORE end if config[:long_output] summarized += <<~MOST - #{key('Default Attributes:')} + #{key("Default Attributes:")} #{text_format(node.default_attrs)} - #{key('Override Attributes:')} + #{key("Override Attributes:")} #{text_format(node.override_attrs)} - #{key('Automatic Attributes (Ohai Data):')} + #{key("Automatic Attributes (Ohai Data):")} #{text_format(node.automatic_attrs)} MOST end diff --git a/lib/chef/knife/core/object_loader.rb b/lib/chef/knife/core/object_loader.rb index 94b956be04..087213fadf 100644 --- a/lib/chef/knife/core/object_loader.rb +++ b/lib/chef/knife/core/object_loader.rb @@ -40,7 +40,7 @@ class Chef def load_from(repo_location, *components) unless object_file = find_file(repo_location, *components) - ui.error "Could not find or open file '#{components.last}' in current directory or in '#{repo_location}/#{components.join('/')}'" + ui.error "Could not find or open file '#{components.last}' in current directory or in '#{repo_location}/#{components.join("/")}'" exit 1 end object_from_file(object_file) diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb index 8bf419e49a..562bd7b0e9 100644 --- a/lib/chef/knife/core/status_presenter.rb +++ b/lib/chef/knife/core/status_presenter.rb @@ -112,9 +112,9 @@ class Chef if node["ohai_time"] hours, minutes, seconds = time_difference_in_hms(node["ohai_time"]) - hours_text = "#{hours} hour#{hours == 1 ? ' ' : 's'}" - minutes_text = "#{minutes} minute#{minutes == 1 ? ' ' : 's'}" - seconds_text = "#{seconds} second#{seconds == 1 ? ' ' : 's'}" + hours_text = "#{hours} hour#{hours == 1 ? " " : "s"}" + minutes_text = "#{minutes} minute#{minutes == 1 ? " " : "s"}" + seconds_text = "#{seconds} second#{seconds == 1 ? " " : "s"}" if hours > 24 color = :red text = hours_text @@ -140,7 +140,7 @@ class Chef if node["platform"] platform = node["platform"].dup if node["platform_version"] - platform << " #{node['platform_version']}" + platform << " #{node["platform_version"]}" end line_parts << platform end diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb index 88fb5dfac8..41fb37c220 100644 --- a/lib/chef/knife/core/ui.rb +++ b/lib/chef/knife/core/ui.rb @@ -108,28 +108,28 @@ class Chef # # @param message [String] the text string def debug(message) - log("#{color('DEBUG:', :blue, :bold)} #{message}") + log("#{color("DEBUG:", :blue, :bold)} #{message}") end # Print a warning message # # @param message [String] the text string def warn(message) - log("#{color('WARNING:', :yellow, :bold)} #{message}") + log("#{color("WARNING:", :yellow, :bold)} #{message}") end # Print an error message # # @param message [String] the text string def error(message) - log("#{color('ERROR:', :red, :bold)} #{message}") + log("#{color("ERROR:", :red, :bold)} #{message}") end # Print a message describing a fatal error. # # @param message [String] the text string def fatal(message) - log("#{color('FATAL:', :red, :bold)} #{message}") + log("#{color("FATAL:", :red, :bold)} #{message}") end def color(string, *colors) diff --git a/lib/chef/knife/deps.rb b/lib/chef/knife/deps.rb index 021cf902d5..f620b53bfa 100644 --- a/lib/chef/knife/deps.rb +++ b/lib/chef/knife/deps.rb @@ -79,7 +79,7 @@ class Chef def print_dependencies_tree(entry, dependencies, printed = {}, depth = 0) dependencies[entry.path] = get_dependencies(entry) unless dependencies[entry.path] - output "#{' ' * depth}#{format_path(entry)}" + output "#{" " * depth}#{format_path(entry)}" if !printed[entry.path] && (config[:recurse] || depth == 0) printed[entry.path] = true dependencies[entry.path].each do |child| @@ -97,7 +97,7 @@ class Chef node = Chef::JSONCompat.parse(entry.read) result = [] if node["chef_environment"] && node["chef_environment"] != "_default" - result << "/environments/#{node['chef_environment']}.json" + result << "/environments/#{node["chef_environment"]}.json" end if node["run_list"] result += dependencies_from_runlist(node["run_list"]) diff --git a/lib/chef/knife/key_list.rb b/lib/chef/knife/key_list.rb index aefb1928df..2ffafc63ed 100644 --- a/lib/chef/knife/key_list.rb +++ b/lib/chef/knife/key_list.rb @@ -71,7 +71,7 @@ class Chef next if !key["expired"] && @config[:only_expired] next if key["expired"] && @config[:only_non_expired] - display = "#{colorize(key['name'].ljust(max_length))} #{key['uri']}" + display = "#{colorize(key["name"].ljust(max_length))} #{key["uri"]}" display = "#{display} (expired)" if key["expired"] display_info(display) end diff --git a/lib/chef/knife/node_edit.rb b/lib/chef/knife/node_edit.rb index d0b9239e28..ca3b54c2a5 100644 --- a/lib/chef/knife/node_edit.rb +++ b/lib/chef/knife/node_edit.rb @@ -46,7 +46,7 @@ class Chef updated_node = node_editor.edit_node if updated_values = node_editor.updated? - ui.info "Saving updated #{updated_values.join(', ')} on node #{node.name}" + ui.info "Saving updated #{updated_values.join(", ")} on node #{node.name}" updated_node.save else ui.info "Node not updated, skipping node save" diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index 26d1bb6458..2a4334570e 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -185,8 +185,8 @@ class Chef if fqdns.count != fqdns.uniq.count duplicated_fqdns = fqdns.uniq ui.send(config[:duplicated_fqdns], - "SSH #{duplicated_fqdns.count > 1 ? 'nodes are' : 'node is'} " + - "duplicated: #{duplicated_fqdns.join(',')}") + "SSH #{duplicated_fqdns.count > 1 ? "nodes are" : "node is"} " + + "duplicated: #{duplicated_fqdns.join(",")}") exit 10 if config[:duplicated_fqdns] == :fatal end end @@ -397,7 +397,7 @@ class Chef # line is input. def read_line loop do - command = reader.readline("#{ui.color('knife-ssh>', :bold)} ", true) + command = reader.readline("#{ui.color("knife-ssh>", :bold)} ", true) if command.nil? command = "exit" @@ -486,7 +486,7 @@ class Chef end.join(" \\; ") end - tmux_name = "'knife ssh #{@name_args[0].tr(':.', '=-')}'" + tmux_name = "'knife ssh #{@name_args[0].tr(":.", "=-")}'" begin server = session.servers_for.first cmd = ["tmux new-session -d -s #{tmux_name}", diff --git a/lib/chef/knife/supermarket_download.rb b/lib/chef/knife/supermarket_download.rb index b48126151f..8bd7b90add 100644 --- a/lib/chef/knife/supermarket_download.rb +++ b/lib/chef/knife/supermarket_download.rb @@ -115,7 +115,7 @@ class Chef end def specific_cookbook_version_url - "#{cookbooks_api_url}/#{@name_args[0]}/versions/#{@name_args[1].tr('.', '_')}" + "#{cookbooks_api_url}/#{@name_args[0]}/versions/#{@name_args[1].tr(".", "_")}" end end end diff --git a/lib/chef/knife/supermarket_show.rb b/lib/chef/knife/supermarket_show.rb index c3f0628029..8ef00fca2b 100644 --- a/lib/chef/knife/supermarket_show.rb +++ b/lib/chef/knife/supermarket_show.rb @@ -45,7 +45,7 @@ class Chef when 1 noauth_rest.get("#{supermarket_uri}/cookbooks/#{@name_args[0]}") when 2 - noauth_rest.get("#{supermarket_uri}/cookbooks/#{@name_args[0]}/versions/#{name_args[1].tr('.', '_')}") + noauth_rest.get("#{supermarket_uri}/cookbooks/#{@name_args[0]}/versions/#{name_args[1].tr(".", "_")}") end end |