mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
fix warnings
This commit is contained in:
parent
039275e68c
commit
ae10fefd15
13 changed files with 16 additions and 21 deletions
|
@ -29,7 +29,7 @@ class AuditDaemonConf < Vulcano.resource(1)
|
|||
private
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
|
||||
# read the file
|
||||
file = vulcano.file(@conf_path)
|
||||
|
|
|
@ -12,7 +12,7 @@ class GemPackage < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def info
|
||||
return @info unless @info.nil?
|
||||
return @info if defined?(@info)
|
||||
|
||||
cmd = vulcano.run_command("gem list --local -a -q \^#{@package_name}\$")
|
||||
@info = {
|
||||
|
|
|
@ -28,7 +28,7 @@ class InetdConf < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
|
||||
# read the file
|
||||
file = vulcano.file(@conf_path)
|
||||
|
|
|
@ -26,7 +26,7 @@ class LimitsConf < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
|
||||
# read the file
|
||||
file = vulcano.file(@conf_path)
|
||||
|
|
|
@ -32,7 +32,7 @@ class LoginDef < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
|
||||
# read the file
|
||||
file = vulcano.file(@conf_path)
|
||||
|
|
|
@ -13,7 +13,7 @@ class NpmPackage < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def info
|
||||
return @info unless @info.nil?
|
||||
return @info if defined?(@info)
|
||||
|
||||
cmd = vulcano.run_command("npm ls -g --json #{@package_name}")
|
||||
@info = {
|
||||
|
|
|
@ -32,7 +32,7 @@ class NtpConf < Vulcano.resource(1)
|
|||
private
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
|
||||
if !vulcano.file(@conf_path).file?
|
||||
skip_resource "Can't find file \"#{@conf_path}\""
|
||||
|
|
|
@ -15,7 +15,7 @@ class OneGetPackage < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def info
|
||||
return @info unless @info.nil?
|
||||
return @info if defined?(@info)
|
||||
|
||||
@info = {}
|
||||
@info[:type] = 'oneget'
|
||||
|
|
|
@ -12,7 +12,7 @@ class PipPackage < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def info
|
||||
return @info unless @info.nil?
|
||||
return @info if defined?(@info)
|
||||
|
||||
@info = {}
|
||||
@info[:type] = 'pip'
|
||||
|
|
|
@ -176,7 +176,7 @@ class LinuxPorts < PortsInfo
|
|||
ip6addr = ip6[1]
|
||||
ip6addr = '::' if /^:::$/.match(ip6addr)
|
||||
# build uri
|
||||
ip_addr = URI('addr://[' + ip6addr +']:' + ip6[2])
|
||||
ip_addr = URI("addr://[#{ip6addr}]:#{ip6[2]}")
|
||||
# replace []
|
||||
host = ip_addr.host[1..ip_addr.host.size-2]
|
||||
port = ip_addr.port
|
||||
|
@ -248,7 +248,7 @@ class FreeBsdPorts < PortsInfo
|
|||
# extract port
|
||||
ip6 = /^(\S+):(\d+)$/.match(net_addr)
|
||||
ip6addr = ip6[1]
|
||||
ip_addr = URI('addr://[' + ip6addr +']:' + ip6[2])
|
||||
ip_addr = URI("addr://[#{ip6addr}]:#{ip6[2]}")
|
||||
# replace []
|
||||
host = ip_addr.host[1..ip_addr.host.size-2]
|
||||
port = ip_addr.port
|
||||
|
|
|
@ -38,7 +38,7 @@ class SshConf < Vulcano.resource(1)
|
|||
private
|
||||
|
||||
def read_content
|
||||
return @content if @content_read
|
||||
return @content if defined?(@content)
|
||||
file = vulcano.file(@conf_path)
|
||||
if !file.file?
|
||||
return skip_resource "Can't find file \"#{@conf_path}\""
|
||||
|
@ -49,12 +49,11 @@ class SshConf < Vulcano.resource(1)
|
|||
return skip_resource "Can't read file \"#{@conf_path}\""
|
||||
end
|
||||
|
||||
@content_read = true
|
||||
@content
|
||||
end
|
||||
|
||||
def read_params
|
||||
return @params unless @params.nil?
|
||||
return @params if defined?(@params)
|
||||
return @params = {} if read_content.nil?
|
||||
conf = SimpleConfig.new(
|
||||
read_content,
|
||||
|
|
|
@ -32,10 +32,6 @@ module Vulcano::Resources
|
|||
class Yum < Vulcano.resource(1)
|
||||
name 'yum'
|
||||
|
||||
def initialize
|
||||
@cache = nil
|
||||
end
|
||||
|
||||
# returns all repositories
|
||||
# works as following:
|
||||
# search for Repo-id
|
||||
|
@ -43,7 +39,7 @@ module Vulcano::Resources
|
|||
# store data in object
|
||||
# until \n
|
||||
def repositories
|
||||
return @cache if !@cache.nil?
|
||||
return @cache if defined?(@cache)
|
||||
# parse the repository data from yum
|
||||
# we cannot use -C, because this is not reliable and may lead to errors
|
||||
@command_result = vulcano.run_command('yum -v repolist all')
|
||||
|
@ -111,7 +107,7 @@ class YumRepo
|
|||
end
|
||||
|
||||
def info
|
||||
return @cache if !@cache.nil?
|
||||
return @cache if defined?(@cache)
|
||||
selection = @yum.repositories.select { |e| e['id'] == @reponame || shortname(e['id']) == @reponame }
|
||||
@cache = selection[0] if !selection.nil? && selection.length == 1
|
||||
@cache
|
||||
|
|
|
@ -26,7 +26,7 @@ class Vulcano::Plugins::Backend
|
|||
end
|
||||
|
||||
def lsb
|
||||
return @lsb unless @lsb.nil?
|
||||
return @lsb if defined?(@lsb)
|
||||
@lsb = {}
|
||||
if !(raw = get_config('/etc/lsb-release')).nil?
|
||||
@lsb = lsb_config(raw)
|
||||
|
|
Loading…
Add table
Reference in a new issue