Chris Mague 7 years ago
parent
commit
858c26c878
1 changed files with 10 additions and 13 deletions
  1. 10 13
      lib/neoinfra/audit.rb

+ 10 - 13
lib/neoinfra/audit.rb

@@ -10,7 +10,7 @@ module NeoInfra
   # Provide informations about the accounts available
   class Audit
     def audit_nodes
-      results = Hash.new{ |h, k| h[k] = {} }
+      results = Hash.new { |h, k| h[k] = {} }
       aws = NeoInfra::Aws.new
       @cfg = NeoInfra::Config.new
 
@@ -24,22 +24,19 @@ module NeoInfra
           region_conf = { region: region }
           new_conn = Fog::Compute.new(region_conf.merge(base_conf))
           new_conn.servers.all.each do |ec2|
-            [:required, :recommended]. each do |a|
-              unless (ec2.tags.keys.sort & @cfg.tag_policy[a].sort) == @cfg.tag_policy[a].sort
-                results[ec2.id].merge!({
-                                  "#{a.to_s}_missing_tags" => @cfg.tag_policy[a].sort - ec2.tags.keys.sort,
-                                  'tags' => ec2.tags.keys.sort,
-                                  'account' => account[:name],
-                                  'launched' => ec2.created_at,
-                                  'region' => region,
-                                  'ssh_key' => ec2.key_name
-                })
-              end
+            %i[required recommended]. each do |a|
+              next if (ec2.tags.keys.sort & @cfg.tag_policy[a].sort) == @cfg.tag_policy[a].sort
+              results[ec2.id].merge!("#{a}_missing_tags" => @cfg.tag_policy[a].sort - ec2.tags.keys.sort,
+                                     'tags' => ec2.tags.keys.sort,
+                                     'account' => account[:name],
+                                     'launched' => ec2.created_at,
+                                     'region' => region,
+                                     'ssh_key' => ec2.key_name)
             end
           end
         end
       end
-      return results
+      results
     end
   end
 end