Skip to content

Commit

Permalink
fix: convert nil values to empty string "" (#1645)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryankaraffa authored Nov 27, 2023
1 parent c50046e commit f0ac211
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,20 @@

# Construct the policy hash with just the info we need for the output
p = {file: file, name: pp.parsed_name, category: pp.parsed_category, provider: pp.parsed_info[:provider], service: pp.parsed_info[:service], policy_set: pp.parsed_info[:policy_set], recommendation_type: pp.parsed_info[:recommendation_type]}

## Check that all keys/values are not nil
p.each do |key, value|
if value.nil? then p[key] = "" end
end

# Check if the pt_stats counters have been initialized yet
# If not, initialize them with count starting at 0
if pt_stats[:categories][p[:category]].nil? then pt_stats[:categories][p[:category]] = 0 end
if pt_stats[:providers][p[:provider]].nil? then pt_stats[:providers][p[:provider]] = 0 end
if pt_stats[:services][p[:service]].nil? then pt_stats[:services][p[:service]] = 0 end
if pt_stats[:policy_sets][p[:policy_set]].nil? then pt_stats[:policy_sets][p[:policy_set]] = 0 end

# Increment the stats for the policy
pt_stats[:categories][p[:category]] += 1
pt_stats[:providers][p[:provider]] += 1
pt_stats[:services][p[:service]] += 1
Expand Down

0 comments on commit f0ac211

Please sign in to comment.