improvement: separate specfile sanitize vs check

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
Dominik Richter 2015-06-10 17:21:03 +02:00
parent 1833ff9aa0
commit beee62fabd
2 changed files with 13 additions and 5 deletions

View file

@ -5,9 +5,9 @@
class VulcanoBaseRule
def initialize(id, &block)
@id = id
@impact = 1.0
@title = id
@desc = ""
@impact = nil
@title = nil
@desc = nil
self.instance_eval(&block)
end

View file

@ -72,7 +72,7 @@ module Vulcano
invalid.("Missing impact for rule #{k}") if v['impact'].nil?
invalid.("Impact cannot be larger than 1.0 for rule #{k}") if v['impact'] > 1.0
invalid.("Impact cannot be less than 0.0 for rule #{k}") if v['impact'] < 0.0
invalid.("Missing title for rule #{k}") if v['title'].nil? || v['title'] == k
invalid.("Missing title for rule #{k}") if v['title'].nil?
invalid.("Missing description for rule #{k}") if v['desc'].nil?
end
@ -87,7 +87,7 @@ module Vulcano
Dir["#{path}/spec/*_spec.rb"].each do |specfile|
rel_path = specfile.sub(File.join(path,''), '')
specs = SpecFile.from_file(specfile)
allchecks[rel_path] = specs.vulcano_meta
allchecks[rel_path] = sanitize_specfile_json(specs.vulcano_meta)
end
res = Metadata.for_path(path, @log).dict
@ -95,5 +95,13 @@ module Vulcano
@profiles = res
end
def sanitize_specfile_json j
j['checks'].each do |k,v|
v['title'] = k if v['title'].nil?
v['desc'] = "" if v['desc'].nil?
v['impact'] = 1.0 if v['impact'].nil?
end
end
end
end