Project

General

Profile

« Previous | Next » 

Revision 7b0a46e5

Added by Michael Moll over 4 years ago

Fixes #29172 - Fix Layout/SpaceBeforeBlockBraces cop

View differences:

.rubocop_todo.yml
Layout/SpaceAroundOperators:
Enabled: false
# Offense count: 22
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceBeforeBlockBraces:
Enabled: false
# Offense count: 20
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
lib/launcher.rb
def write_pid
FileUtils.mkdir_p(File.dirname(pid_path)) unless File.exist?(pid_path)
File.open(pid_path, ::File::CREAT | ::File::EXCL | ::File::WRONLY){|f| f.write(Process.pid.to_s) }
File.open(pid_path, ::File::CREAT | ::File::EXCL | ::File::WRONLY) {|f| f.write(Process.pid.to_s) }
at_exit { File.delete(pid_path) if File.exist?(pid_path) }
rescue Errno::EEXIST
check_pid
lib/proxy/log_buffer/buffer.rb
LogRecord = Struct.new(:timestamp, :level, :message, :backtrace, :request_id) do
def to_h
h = {}
self.class.members.each{|m| h[m.to_sym] = self[m]}
self.class.members.each {|m| h[m.to_sym] = self[m]}
h[:level] = case h[:level]
when ::Logger::Severity::INFO
:INFO
lib/proxy/plugins.rb
#
def enabled_plugins
loaded.select {|p| p[:state] == :running && p[:class].ancestors.include?(::Proxy::Plugin)}.map{|p| p[:class]}
loaded.select {|p| p[:state] == :running && p[:class].ancestors.include?(::Proxy::Plugin)}.map {|p| p[:class]}
end
def plugin_enabled?(plugin_name)
lib/proxy/request.rb
end
def query_string(input={})
input.compact.map{|k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v)}"}.join("&")
input.compact.map {|k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v)}"}.join("&")
end
def create_get(path, query={}, headers={})
modules/dhcp/dhcp_api.rb
get "/?" do
content_type :json
server.subnets.map{|s| {:network => s.network, :netmask => s.netmask, :options => s.options}}.to_json
server.subnets.map {|s| {:network => s.network, :netmask => s.netmask, :options => s.options}}.to_json
rescue => e
log_halt 400, e
end
modules/dhcp_common/isc/omapi_provider.rb
end
def format_omshell_output(output)
output.map{|x| "omshell= #{x.chomp}"}.join("\n")
output.map {|x| "omshell= #{x.chomp}"}.join("\n")
end
def report(msg, response="")
......
end
def ip2hex(ip)
ip.to_s.split(".").map{|i| "%02x" % i }.join(":")
ip.to_s.split(".").map {|i| "%02x" % i }.join(":")
end
end
end
modules/dhcp_common/isc/subnet_service_initialization.rb
when 'SUNW.JumpStart-server'
[:jumpstart_server_path, strip_quotes(values.flatten.first)]
else
[name.tr('.', '_').tr('-', '_').to_sym, values.map {|vv| vv.map{|v| strip_quotes(v)}}]
[name.tr('.', '_').tr('-', '_').to_sym, values.map {|vv| vv.map {|v| strip_quotes(v)}}]
# TODO: check if adding a new reservation with omshell for a free lease still
# generates a conflict
end
......
end
def hex2ip(hex)
hex.split(":").map{|h| h.to_i(16).to_s}.join(".")
hex.split(":").map {|h| h.to_i(16).to_s}.join(".")
end
end
end
modules/dhcp_common/record/lease.rb
end
def to_json(*opts)
Hash[[:name, :ip, :mac, :subnet, :starts, :ends, :state, :type].map{|s| [s, send(s)]}].merge(options).to_json(*opts)
Hash[[:name, :ip, :mac, :subnet, :starts, :ends, :state, :type].map {|s| [s, send(s)]}].merge(options).to_json(*opts)
end
end
end
modules/dhcp_common/record/reservation.rb
end
def to_json(*opts)
Hash[[:name, :ip, :mac, :subnet, :type].map{|s| [s, send(s)]}].merge(options).to_json(*opts)
Hash[[:name, :ip, :mac, :subnet, :type].map {|s| [s, send(s)]}].merge(options).to_json(*opts)
end
end
end
modules/dhcp_common/server.rb
subnet = options.delete("network")
# convert string keys to symbols
options = options.inject({}){|all, current| all[current[0].to_sym] = current[1]; all}
options = options.inject({}) {|all, current| all[current[0].to_sym] = current[1]; all}
[name || hostname, ip, mac, subnet, options.merge!(:hostname => hostname || name)]
end
modules/dhcp_common/subnet.rb
@ipaddr = IPAddr.new(to_s)
@options = {}
@options[:routers] = options[:routers].each{|ip| validate_ip ip } if options[:routers]
@options[:routers] = options[:routers].each {|ip| validate_ip ip } if options[:routers]
@options[:domain_name] = options[:domain_name] if options[:domain_name]
@options[:domain_name_servers] = options[:domain_name_servers] if options[:domain_name_servers]
@options[:ntp_servers] = options[:ntp_servers] if options[:ntp_servers]
modules/puppet_proxy/puppet_api.rb
get "/environments/:environment/classes" do
content_type :json
begin
class_retriever.classes_in_environment(params[:environment]).map{|k| {k.to_s => { :name => k.name, :module => k.module, :params => k.params} } }.to_json
class_retriever.classes_in_environment(params[:environment]).map {|k| {k.to_s => { :name => k.name, :module => k.module, :params => k.params} } }.to_json
rescue Proxy::Puppet::EnvironmentNotFound
log_halt 404, "Could not find environment '#{params[:environment]}'"
rescue Proxy::Puppet::TimeoutError => e
modules/root/root_v2_api.rb
end
def process_capabilities(state, capabilities)
capabilities = capabilities.select{|cap| !cap.is_a?(Proc) || state == :running }
capabilities = capabilities.select {|cap| !cap.is_a?(Proc) || state == :running }
capabilities = capabilities.map do |capability|
capability.is_a?(Proc) ? capability.call : capability
end
modules/templates/proxy_request.rb
end
def extract_request_headers(env)
Hash[env.select{|k, v| k =~ /^HTTP_/ && k !~ /^HTTP_(VERSION|HOST)$/}.map{|k, v| [k[5..-1], v]}]
Hash[env.select {|k, v| k =~ /^HTTP_/ && k !~ /^HTTP_(VERSION|HOST)$/}.map {|k, v| [k[5..-1], v]}]
rescue Exception => e
logger.warn "Unable to extract request headers: #{e}"
{}
test/bmc/bmc_api_test.rb
Proxy::BMC::IPMI.logger = Proxy::LogBuffer::Decorator.instance
Proxy::BMC::IPMI.logger.error "TEST ERROR"
found = false
Proxy::LogBuffer::Buffer.instance.iterate_descending{|x| found = true if x.message == "TEST ERROR" }
Proxy::LogBuffer::Buffer.instance.iterate_descending {|x| found = true if x.message == "TEST ERROR" }
assert found
end
test/plugins/plugin_initializer_test.rb
class TestPlugin4 < Proxy::Provider; plugin :plugin_4, "1.0"; default_settings :enabled => true; end
class TestPlugin5 < Proxy::Plugin; plugin :plugin_5, "1.0"; default_settings :enabled => false; end
CAP_PROC = proc{}
CAP_PROC = proc {}
CAP_LAMBDA = -> { }
class TestPlugin6 < Proxy::Plugin
plugin :plugin_6, "1.0"
test/test_helper.rb
include DhcpProviderInterfaceValidation
def hash_symbols_to_strings(hash)
Hash[hash.collect{|k, v| [k.to_s, v]}]
Hash[hash.collect {|k, v| [k.to_s, v]}]
end
# Starts up a real smart proxy instance under WEBrick
test/tftp/tftp_server_test.rb
end
def pxe_config_files
@pxe_config_files.collect{|f| File.join(@rootdir, f)}
@pxe_config_files.collect {|f| File.join(@rootdir, f)}
end
def pxe_default_files
@pxe_default_files.collect{|f| File.join(@rootdir, f)}
@pxe_default_files.collect {|f| File.join(@rootdir, f)}
end
def test_set

Also available in: Unified diff