Sha256: 6595c45fe88fc6aab7aa9c82751be542ad8ec1118bb818b0e922f95d53d55e91
Contents?: true
Size: 1.21 KB
Versions: 5
Compression:
Stored size: 1.21 KB
Contents
PuppetLint.new_check(:file_ensure) do def check resource_indexes.each do |resource| if resource[:type].value == 'file' attr = resource[:tokens].select { |t| t.type == :NAME && \ t.value == 'ensure' && \ t.next_code_token.type == :FARROW } next if attr.empty? val_token = attr[0].next_code_token.next_code_token next unless val_token.value == 'present' next unless [:NAME, :STRING, :SSTRING].include? val_token.type notify :warning, { :message => 'ensure set to present on file resource', :line => val_token.line, :column => val_token.column, :token => val_token, :resource => resource, } end end end def fix(problem) target_attr = problem[:resource][:tokens].select { |t| t.type == :NAME && \ t.value == 'target' && \ t.next_code_token.type == :FARROW } if target_attr.empty? problem[:token].value = 'file' else problem[:token].value = 'link' end end end
Version data entries
5 entries across 5 versions & 1 rubygems