Skip to content

Commit

Permalink
Do not fix variables called $present
Browse files Browse the repository at this point in the history
  • Loading branch information
raphink committed Feb 10, 2015
1 parent 3cea067 commit 7fe7841
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/puppet-lint/plugins/check_file_ensure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ def check
attr = resource[:tokens].select { |t| t.type == :NAME && \
t.value == 'ensure' && \
t.next_code_token.type == :FARROW }
unless attr.empty?
val_token = attr[0].next_code_token.next_code_token
if val_token.value == 'present'
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
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
ensure => 'target',
target => '/etc/mtab',
}
file { '/tmp/foo':
ensure => $present,
}
EOS
}

Expand All @@ -34,6 +38,10 @@
ensure => 'present',
target => '/etc/mtab',
}
file { '/tmp/foo':
ensure => $present,
}
EOS
}

Expand Down Expand Up @@ -68,6 +76,10 @@
ensure => 'target',
target => '/etc/mtab',
}
file { '/tmp/foo':
ensure => $present,
}
EOS
}

Expand All @@ -91,6 +103,10 @@
ensure => 'present',
target => '/etc/mtab',
}
file { '/tmp/foo':
ensure => $present,
}
EOS
}

Expand All @@ -114,6 +130,10 @@
ensure => 'link',
target => '/etc/mtab',
}
file { '/tmp/foo':
ensure => $present,
}
EOS
)
end
Expand Down

0 comments on commit 7fe7841

Please sign in to comment.