Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix checks for 0.25.x

  • Loading branch information...
commit aaaa98191c3e54fa97b56d10389311c9430bdfff 1 parent 6bcb2b6
@rodjek authored
View
8 lib/puppet-lint/plugins/check_classes.rb
@@ -1,7 +1,9 @@
class PuppetLint::Plugins::CheckClasses < PuppetLint::CheckPlugin
- check 'right_to_left_relationship' do
- tokens.select { |r| r.first == :OUT_EDGE }.each do |token|
- notify :warning, :message => "right-to-left (<-) relationship", :linenumber => token.last[:line]
+ if Puppet::PUPPETVERSION !~ /^0\.2/
+ check 'right_to_left_relationship' do
+ tokens.select { |r| r.first == :OUT_EDGE }.each do |token|
+ notify :warning, :message => "right-to-left (<-) relationship", :linenumber => token.last[:line]
+ end
end
end
View
9 lib/puppet-lint/plugins/check_strings.rb
@@ -29,6 +29,10 @@ def del_token(token)
unless token.last[:value].include? "\t" or token.last[:value].include? "\n"
notify :warning, :message => "double quoted string containing no variables", :linenumber => token.last[:line]
end
+ elsif token.first == :DQTEXT
+ unless token.last[:value].include? "\\t" or token.last[:value].include? "\\n" or token.last[:value] =~ /[^\\]?\$\{?/
+ notify :warning, :message => "double quoted string containing no variables", :linenumber => token.last[:line]
+ end
end
end
end
@@ -44,6 +48,9 @@ def del_token(token)
end
end
end
+ if token.first == :DQTEXT and token.last[:value] =~ /\A\$\{.+\}\Z/
+ notify :warning, :message => "string containing only a variable", :linenumber => token.last[:line]
+ end
end
end
@@ -61,6 +68,8 @@ def del_token(token)
end
end
end
+ elsif token.first == :DQTEXT and token.last[:value] =~ /\$\w+/
+ notify :warning, :message => "variable not enclosed in {}", :linenumber => token.last[:line]
end
end
end
View
22 spec/puppet-lint/check_classes_spec.rb
@@ -7,19 +7,21 @@
klass
end
- describe 'chain 2 resources left to right' do
- let(:code) { "Class[foo] -> Class[bar]" }
+ if Puppet::PUPPETVERSION !~ /^0\.2/
+ describe 'chain 2 resources left to right' do
+ let(:code) { "Class[foo] -> Class[bar]" }
- its(:problems) { should be_empty }
- end
+ its(:problems) { should be_empty }
+ end
- describe 'chain 2 resources right to left' do
- let(:code) { "Class[foo] <- Class[bar]" }
+ describe 'chain 2 resources right to left' do
+ let(:code) { "Class[foo] <- Class[bar]" }
- its(:problems) {
- should have_problem :kind => :warning, :message => "right-to-left (<-) relationship", :linenumber => 1
- should_not have_problem :kind => :error
- }
+ its(:problems) {
+ should have_problem :kind => :warning, :message => "right-to-left (<-) relationship", :linenumber => 1
+ should_not have_problem :kind => :error
+ }
+ end
end
describe 'class on its own' do
View
2  spec/spec_helper.rb
@@ -86,7 +86,7 @@ def filter_array_of_hashes(array_of_hashes, filter_hash)
end
failure_message_for_should do |problems|
- left = problems - filter_problems(actual, filter)
+ left = problems - filter_array_of_hashes(actual, filter)
message = "There were problems not matching filter."
message << "
* filter = #{filter.inspect}
Please sign in to comment.
Something went wrong with that request. Please try again.