summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-06-21 17:38:00 -0700
committerelijah <elijah@riseup.net>2016-06-21 17:38:00 -0700
commit7818abd6a89a882cabb3d2a14a572308d9e959ff (patch)
tree89927201e4406af2334c4ef97cbe58750426ef3f
parent3df7a57d866cf1e6eda9bb9e3fe19c7387ec6c1d (diff)
minor ruby linting
-rwxr-xr-xbin/puppet_command6
-rwxr-xr-xbin/run_tests2
-rw-r--r--lib/leap_cli/commands/ca.rb3
-rw-r--r--lib/leap_cli/commands/compile.rb1
-rw-r--r--lib/leap_cli/commands/inspect.rb2
-rw-r--r--lib/leap_cli/commands/node.rb2
-rw-r--r--lib/leap_cli/commands/node_init.rb10
-rw-r--r--lib/leap_cli/commands/test.rb4
-rw-r--r--lib/leap_cli/macros/haproxy.rb2
-rw-r--r--lib/leap_cli/macros/keys.rb2
-rw-r--r--tests/white-box/network.rb4
11 files changed, 18 insertions, 20 deletions
diff --git a/bin/puppet_command b/bin/puppet_command
index eb3cd0b9..a06b4940 100755
--- a/bin/puppet_command
+++ b/bin/puppet_command
@@ -173,9 +173,9 @@ def platform_version_check!
return unless @info["platform"]
new_version = @info["platform"].split(' ').first
return unless new_version
- if File.exists?(SUMMARY_LOG) && File.size(SUMMARY_LOG) != 0
+ if File.exist?(SUMMARY_LOG) && File.size(SUMMARY_LOG) != 0
file = SUMMARY_LOG
- elsif File.exists?(SUMMARY_LOG_1) && File.size(SUMMARY_LOG_1) != 0
+ elsif File.exist?(SUMMARY_LOG_1) && File.size(SUMMARY_LOG_1) != 0
file = SUMMARY_LOG_1
else
return
@@ -195,7 +195,7 @@ end
# Return a ruby object representing the contents of the hiera yaml file.
#
def hiera_file
- unless File.exists?(HIERA_FILE)
+ unless File.exist?(HIERA_FILE)
log("ERROR: hiera file '#{HIERA_FILE}' does not exist.")
exit(1)
end
diff --git a/bin/run_tests b/bin/run_tests
index b6784ed5..b25a419c 100755
--- a/bin/run_tests
+++ b/bin/run_tests
@@ -459,7 +459,7 @@ end
def main
# load node data from hiera file
- if File.exists?(HIERA_FILE)
+ if File.exist?(HIERA_FILE)
$node = YAML.load_file(HIERA_FILE)
else
$node = {"services" => [], "dummy" => true}
diff --git a/lib/leap_cli/commands/ca.rb b/lib/leap_cli/commands/ca.rb
index 1b311eee..6abffe7b 100644
--- a/lib/leap_cli/commands/ca.rb
+++ b/lib/leap_cli/commands/ca.rb
@@ -39,7 +39,7 @@ module LeapCli; module Commands
if cmd_exists?('certtool')
log 0, 'Generating DH parameters (takes a long time)...'
output = assert_run!('certtool --generate-dh-params --sec-param high')
- output.sub! /.*(-----BEGIN DH PARAMETERS-----.*-----END DH PARAMETERS-----).*/m, '\1'
+ output.sub!(/.*(-----BEGIN DH PARAMETERS-----.*-----END DH PARAMETERS-----).*/m, '\1')
output << "\n"
write_file!(:dh_params, output)
else
@@ -116,7 +116,6 @@ module LeapCli; module Commands
digest = options[:digest] || server_certificates.digest
log :generating, "CSR with #{digest} digest and #{print_dn(dn)}" do
csr = create_csr(dn, keypair, digest)
- request = csr.to_x509_csr
write_file! [:commercial_csr, domain], csr.to_pem
end
diff --git a/lib/leap_cli/commands/compile.rb b/lib/leap_cli/commands/compile.rb
index f9079279..92c879d7 100644
--- a/lib/leap_cli/commands/compile.rb
+++ b/lib/leap_cli/commands/compile.rb
@@ -284,7 +284,6 @@ remove this directory if you don't use it.
# note: we use the default provider for all nodes, because we use it
# to generate hostnames that are relative to the default domain.
provider = manager.env('default').provider
- hosts_seen = {}
lines = []
#
diff --git a/lib/leap_cli/commands/inspect.rb b/lib/leap_cli/commands/inspect.rb
index 20654fa7..6f58a65f 100644
--- a/lib/leap_cli/commands/inspect.rb
+++ b/lib/leap_cli/commands/inspect.rb
@@ -26,7 +26,7 @@ module LeapCli; module Commands
}
def inspection_method(object)
- if File.exists?(object)
+ if File.exist?(object)
ftype = `file #{object}`.split(':').last.strip
log 2, "file is of type '#{ftype}'"
if FTYPE_MAP[ftype]
diff --git a/lib/leap_cli/commands/node.rb b/lib/leap_cli/commands/node.rb
index a23661b3..1dce437e 100644
--- a/lib/leap_cli/commands/node.rb
+++ b/lib/leap_cli/commands/node.rb
@@ -43,7 +43,7 @@ module LeapCli; module Commands
if file_exists? :ca_cert, :ca_key
generate_cert_for_node(manager.reload_node!(node))
end
- rescue LeapCli::ConfigError => exc
+ rescue LeapCli::ConfigError
remove_node_files(name)
end
end
diff --git a/lib/leap_cli/commands/node_init.rb b/lib/leap_cli/commands/node_init.rb
index 33f6288d..9698a789 100644
--- a/lib/leap_cli/commands/node_init.rb
+++ b/lib/leap_cli/commands/node_init.rb
@@ -6,14 +6,14 @@
module LeapCli; module Commands
desc 'Node management'
- command :node do |node|
- node.desc 'Bootstraps a node or nodes, setting up SSH keys and installing prerequisite packages'
- node.long_desc "This command prepares a server to be used with the LEAP Platform by saving the server's SSH host key, " +
+ command :node do |cmd|
+ cmd.desc 'Bootstraps a node or nodes, setting up SSH keys and installing prerequisite packages'
+ cmd.long_desc "This command prepares a server to be used with the LEAP Platform by saving the server's SSH host key, " +
"copying the authorized_keys file, installing packages that are required for deploying, and registering important facts. " +
"Node init must be run before deploying to a server, and the server must be running and available via the network. " +
"This command only needs to be run once, but there is no harm in running it multiple times."
- node.arg_name 'FILTER'
- node.command :init do |init|
+ cmd.arg_name 'FILTER'
+ cmd.command :init do |init|
init.switch 'echo', :desc => 'If set, passwords are visible as you type them (default is hidden)', :negatable => false
init.flag :port, :desc => 'Override the default SSH port.', :arg_name => 'PORT'
init.flag :ip, :desc => 'Override the default SSH IP address.', :arg_name => 'IPADDRESS'
diff --git a/lib/leap_cli/commands/test.rb b/lib/leap_cli/commands/test.rb
index 73207b31..f506d849 100644
--- a/lib/leap_cli/commands/test.rb
+++ b/lib/leap_cli/commands/test.rb
@@ -8,7 +8,7 @@ module LeapCli; module Commands
run.switch 'continue', :desc => 'Continue over errors and failures (default is --no-continue).', :negatable => true
run.action do |global_options,options,args|
test_order = File.join(Path.platform, 'tests/order.rb')
- if File.exists?(test_order)
+ if File.exist?(test_order)
require test_order
end
manager.filter!(args).names_in_test_dependency_order.each do |node_name|
@@ -17,7 +17,7 @@ module LeapCli; module Commands
ssh_connect(node) do |ssh|
ssh.run(test_cmd(options))
end
- rescue Capistrano::CommandError => exc
+ rescue Capistrano::CommandError
if options[:continue]
exit_status(1)
else
diff --git a/lib/leap_cli/macros/haproxy.rb b/lib/leap_cli/macros/haproxy.rb
index 602ae726..3fef24c4 100644
--- a/lib/leap_cli/macros/haproxy.rb
+++ b/lib/leap_cli/macros/haproxy.rb
@@ -26,7 +26,7 @@ module LeapCli
# create a simple map for node name -> local stunnel accept port
accept_ports = stunnel_clients.inject({}) do |hsh, stunnel_entry|
- name = stunnel_entry.first.sub /_[0-9]+$/, ''
+ name = stunnel_entry.first.sub(/_[0-9]+$/, '')
hsh[name] = stunnel_entry.last['accept_port']
hsh
end
diff --git a/lib/leap_cli/macros/keys.rb b/lib/leap_cli/macros/keys.rb
index e7a75cfb..9dd9b34f 100644
--- a/lib/leap_cli/macros/keys.rb
+++ b/lib/leap_cli/macros/keys.rb
@@ -56,7 +56,7 @@ module LeapCli
require 'base64'
require 'openssl'
path = Path.find_file([path_name, self.name])
- if path && File.exists?(path)
+ if path && File.exist?(path)
public_key_str = File.readlines(path).grep(/^[^-]/).join
public_key = Base64.decode64(public_key_str)
public_key = public_key.slice(22..-1) # Tor ignores the 22 byte SPKI header
diff --git a/tests/white-box/network.rb b/tests/white-box/network.rb
index 436fc8a8..a08cdfbe 100644
--- a/tests/white-box/network.rb
+++ b/tests/white-box/network.rb
@@ -65,7 +65,7 @@ class Network < LeapTest
end
def test_03_Is_shorewall_running?
- ignore unless File.exists?('/sbin/shorewall')
+ ignore unless File.exist?('/sbin/shorewall')
assert_run('/sbin/shorewall status')
pass
end
@@ -75,7 +75,7 @@ class Network < LeapTest
def test_04_Are_server_certificates_valid?
cert_paths = ["/etc/x509/certs/leap_commercial.crt", "/etc/x509/certs/leap.crt"]
cert_paths.each do |cert_path|
- if File.exists?(cert_path)
+ if File.exist?(cert_path)
cert = OpenSSL::X509::Certificate.new(File.read(cert_path))
if Time.now > cert.not_after
fail "The certificate #{cert_path} expired on #{cert.not_after}"