summaryrefslogtreecommitdiff
path: root/chef-config
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
commit686113531d23f30e9973d659c456ae33eb9cff1f (patch)
treef225de7251a8b49b8d183dd168bab0a0addbe23f /chef-config
parentd1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff)
downloadchef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces 1860 Style/SpaceAroundOperators 1336 Style/SpaceInsideBlockBraces 1292 Style/AlignHash 997 Style/SpaceAfterComma 860 Style/SpaceAroundEqualsInParameterDefault 310 Style/EmptyLines 294 Style/IndentationConsistency 267 Style/TrailingWhitespace 238 Style/ExtraSpacing 212 Style/SpaceBeforeBlockBraces 166 Style/MultilineOperationIndentation 144 Style/TrailingBlankLines 120 Style/EmptyLineBetweenDefs 101 Style/IndentationWidth 82 Style/SpaceAroundBlockParameters 40 Style/EmptyLinesAroundMethodBody 29 Style/EmptyLinesAroundAccessModifier 1 Style/RescueEnsureAlignment
Diffstat (limited to 'chef-config')
-rw-r--r--chef-config/Rakefile1
-rw-r--r--chef-config/chef-config.gemspec2
-rw-r--r--chef-config/lib/chef-config/config.rb9
-rw-r--r--chef-config/lib/chef-config/logger.rb3
-rw-r--r--chef-config/lib/chef-config/package_task.rb4
-rw-r--r--chef-config/lib/chef-config/path_helper.rb24
-rw-r--r--chef-config/lib/chef-config/windows.rb1
-rw-r--r--chef-config/lib/chef-config/workstation_config_loader.rb9
-rw-r--r--chef-config/spec/unit/config_spec.rb3
-rw-r--r--chef-config/spec/unit/path_helper_spec.rb3
-rw-r--r--chef-config/spec/unit/workstation_config_loader_spec.rb2
11 files changed, 25 insertions, 36 deletions
diff --git a/chef-config/Rakefile b/chef-config/Rakefile
index ac088852cf..151c2754c3 100644
--- a/chef-config/Rakefile
+++ b/chef-config/Rakefile
@@ -11,4 +11,3 @@ desc "Run standard specs"
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = FileList["spec/**/*_spec.rb"]
end
-
diff --git a/chef-config/chef-config.gemspec b/chef-config/chef-config.gemspec
index 12373ac8fb..f59741629f 100644
--- a/chef-config/chef-config.gemspec
+++ b/chef-config/chef-config.gemspec
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
end
spec.files = %w{Rakefile LICENSE README.md} + Dir.glob("*.gemspec") +
- Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
+ Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
spec.bindir = "bin"
spec.executables = []
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 2a9f5e87aa..ac55853bc7 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -57,7 +57,7 @@ module ChefConfig
path
end
- def self.add_formatter(name, file_path=nil)
+ def self.add_formatter(name, file_path = nil)
formatters << [name, file_path]
end
@@ -115,7 +115,7 @@ module ChefConfig
end
end
elsif configuration[:cookbook_artifact_path]
- File.expand_path("..", self.configuration[:cookbook_artifact_path])
+ File.expand_path("..", self.configuration[:cookbook_artifact_path])
else
cache_path
end
@@ -141,7 +141,7 @@ module ChefConfig
if chef_repo_path.kind_of?(String)
PathHelper.join(chef_repo_path, child_path)
else
- chef_repo_path.uniq.map { |path| PathHelper.join(path, child_path)}
+ chef_repo_path.uniq.map { |path| PathHelper.join(path, child_path) }
end
end
@@ -367,7 +367,7 @@ module ChefConfig
# if the chef_server_url is a path to an organization, aka
# 'some_url.../organizations/*' then remove the '/organization/*' by default
if self.configuration[:chef_server_url] =~ /\/organizations\/\S*$/
- self.configuration[:chef_server_url].split("/")[0..-3].join("/")
+ self.configuration[:chef_server_url].split("/")[0..-3].join("/")
elsif self.configuration[:chef_server_url] # default to whatever chef_server_url is
self.configuration[:chef_server_url]
else
@@ -449,7 +449,6 @@ module ChefConfig
# effect if `policy_document_native_api` is set to `false`.
default :deployment_group, nil
-
# Set these to enable SSL authentication / mutual-authentication
# with the server
diff --git a/chef-config/lib/chef-config/logger.rb b/chef-config/lib/chef-config/logger.rb
index d298852c6e..d239e85f43 100644
--- a/chef-config/lib/chef-config/logger.rb
+++ b/chef-config/lib/chef-config/logger.rb
@@ -15,7 +15,6 @@
# limitations under the License.
#
-
module ChefConfig
# Implements enough of Logger's API that we can use it in place of a real
@@ -58,5 +57,3 @@ module ChefConfig
@logger
end
end
-
-
diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb
index 1eb702965f..6c7a4d6f55 100644
--- a/chef-config/lib/chef-config/package_task.rb
+++ b/chef-config/lib/chef-config/package_task.rb
@@ -55,7 +55,7 @@ module ChefConfig
# Name of git remote used to push tags during a release. Default is origin.
attr_accessor :git_remote
- def initialize(root_path=nil, module_name=nil)
+ def initialize(root_path = nil, module_name = nil)
init(root_path, module_name)
yield self if block_given?
define unless root_path.nil? || module_name.nil?
@@ -72,7 +72,7 @@ module ChefConfig
end
def component_full_paths
- component_paths.map { |path| File.expand_path(path, root_path)}
+ component_paths.map { |path| File.expand_path(path, root_path) }
end
def version_rb_path
diff --git a/chef-config/lib/chef-config/path_helper.rb b/chef-config/lib/chef-config/path_helper.rb
index 28c16cd608..7fc79ba4a9 100644
--- a/chef-config/lib/chef-config/path_helper.rb
+++ b/chef-config/lib/chef-config/path_helper.rb
@@ -36,7 +36,7 @@ module ChefConfig
elsif slash == end_slash - 1
end_slash = slash
else
- return path[0..slash-1]
+ return path[0..slash - 1]
end
end
else
@@ -110,7 +110,7 @@ module ChefConfig
end
# Produces a comparable path.
- def self.canonical_path(path, add_prefix=true)
+ def self.canonical_path(path, add_prefix = true)
# First remove extra separators and resolve any relative paths
abs_path = File.absolute_path(path)
@@ -146,7 +146,7 @@ module ChefConfig
# http://stackoverflow.com/questions/14127343
def self.escape_glob(*parts)
path = cleanpath(join(*parts))
- path.gsub(/[\\\{\}\[\]\*\?]/) { |x| "\\"+x }
+ path.gsub(/[\\\{\}\[\]\*\?]/) { |x| "\\" + x }
end
def self.relative_path_from(from, to)
@@ -233,18 +233,19 @@ module ChefConfig
def self.is_sip_path?(path, node)
if node["platform"] == "mac_os_x" and Gem::Version.new(node["platform_version"]) >= Gem::Version.new("10.11")
# todo: parse rootless.conf for this?
- sip_paths= [
- "/System", "/bin", "/sbin", "/usr"
- ]
- sip_paths.each do |sip_path|
- ChefConfig.logger.info("This is a SIP path, checking if it in exceptions list.")
- return true if path.start_with?(sip_path)
- end
- false
+ sip_paths = [
+ "/System", "/bin", "/sbin", "/usr"
+ ]
+ sip_paths.each do |sip_path|
+ ChefConfig.logger.info("This is a SIP path, checking if it in exceptions list.")
+ return true if path.start_with?(sip_path)
+ end
+ false
else
false
end
end
+
# Determine if the given path is on the exception list for OS X System Integrity Protection.
def self.writable_sip_path?(path)
# todo: parse rootless.conf for this?
@@ -261,4 +262,3 @@ module ChefConfig
end
end
end
-
diff --git a/chef-config/lib/chef-config/windows.rb b/chef-config/lib/chef-config/windows.rb
index a3d8ffe73a..9c606110a4 100644
--- a/chef-config/lib/chef-config/windows.rb
+++ b/chef-config/lib/chef-config/windows.rb
@@ -26,4 +26,3 @@ module ChefConfig
end
end
-
diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb
index 70028ff798..34ba6d6537 100644
--- a/chef-config/lib/chef-config/workstation_config_loader.rb
+++ b/chef-config/lib/chef-config/workstation_config_loader.rb
@@ -29,7 +29,7 @@ module ChefConfig
attr_accessor :explicit_config_file
# TODO: initialize this with a logger for Chef and Knife
- def initialize(explicit_config_file, logger=nil)
+ def initialize(explicit_config_file, logger = nil)
@explicit_config_file = explicit_config_file
@chef_config_dir = nil
@config_location = nil
@@ -119,7 +119,7 @@ module ChefConfig
candidate_configs << File.join(dot_chef_dir, "knife.rb")
end
- candidate_configs.find do | candidate_config |
+ candidate_configs.find do |candidate_config|
have_config?(candidate_config)
end
end
@@ -151,7 +151,7 @@ module ChefConfig
message = "You have an error in your config file #{config_file_path}\n\n"
message << "#{e.class.name}: #{e.message}\n"
filtered_trace = e.backtrace.grep(/#{Regexp.escape(config_file_path)}/)
- filtered_trace.each {|bt_line| message << " " << bt_line << "\n" }
+ filtered_trace.each { |bt_line| message << " " << bt_line << "\n" }
if !filtered_trace.empty?
line_nr = filtered_trace.first[/#{Regexp.escape(config_file_path)}:([\d]+)/, 1]
message << highlight_config_error(config_file_path, line_nr.to_i)
@@ -159,10 +159,9 @@ module ChefConfig
raise ChefConfig::ConfigurationError, message
end
-
def highlight_config_error(file, line)
config_file_lines = []
- IO.readlines(file).each_with_index {|l, i| config_file_lines << "#{(i + 1).to_s.rjust(3)}: #{l.chomp}"}
+ IO.readlines(file).each_with_index { |l, i| config_file_lines << "#{(i + 1).to_s.rjust(3)}: #{l.chomp}" }
if line == 1
lines = config_file_lines[0..3]
else
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb
index 2408d3c822..dbde3d3160 100644
--- a/chef-config/spec/unit/config_spec.rb
+++ b/chef-config/spec/unit/config_spec.rb
@@ -537,7 +537,7 @@ RSpec.describe ChefConfig::Config do
end
describe "ChefConfig::Config[:encrypted_data_bag_secret]" do
- let(:db_secret_default_path){ to_platform("/etc/chef/encrypted_data_bag_secret") }
+ let(:db_secret_default_path) { to_platform("/etc/chef/encrypted_data_bag_secret") }
before do
allow(File).to receive(:exist?).with(db_secret_default_path).and_return(secret_exists)
@@ -838,7 +838,6 @@ RSpec.describe ChefConfig::Config do
end
end
-
end
end
diff --git a/chef-config/spec/unit/path_helper_spec.rb b/chef-config/spec/unit/path_helper_spec.rb
index 0192bbf621..b67a074f9e 100644
--- a/chef-config/spec/unit/path_helper_spec.rb
+++ b/chef-config/spec/unit/path_helper_spec.rb
@@ -93,7 +93,6 @@ RSpec.describe ChefConfig::PathHelper do
end
-
it "cleanpath changes slashes into backslashes and leaves backslashes alone" do
expect(path_helper.cleanpath('/a/b\\c/d/')).to eq('\\a\\b\\c\\d')
end
@@ -224,7 +223,7 @@ RSpec.describe ChefConfig::PathHelper do
end
end
- context "not on windows", :unix_only do
+ context "not on windows", :unix_only do
it "returns a canonical path" do
expect(path_helper.canonical_path("/etc//apache.d/sites-enabled/../sites-available/default")).to eq("/etc/apache.d/sites-available/default")
end
diff --git a/chef-config/spec/unit/workstation_config_loader_spec.rb b/chef-config/spec/unit/workstation_config_loader_spec.rb
index ecfb27f8eb..df53f87de9 100644
--- a/chef-config/spec/unit/workstation_config_loader_spec.rb
+++ b/chef-config/spec/unit/workstation_config_loader_spec.rb
@@ -138,7 +138,6 @@ RSpec.describe ChefConfig::WorkstationConfigLoader do
expect(config_loader.config_location).to eq("#{cwd}/config.rb")
end
-
context "and/or KNIFE_HOME is set" do
let(:knife_home) { "/path/to/knife/home" }
@@ -206,7 +205,6 @@ RSpec.describe ChefConfig::WorkstationConfigLoader do
end
end
-
describe "loading the config file" do
context "when no explicit config is specifed and no implicit config is found" do