From b079eae6645b1795c9fbf750e83f557f5072640b Mon Sep 17 00:00:00 2001 From: Sean Millichamp Date: Mon, 19 Nov 2018 19:59:56 -0500 Subject: [PATCH] Fix for type matching misdetection with !~ The fix in 0753217f88866c4c8927b0d29d49099a54abc756 was incomplete as it only handled the case where a positive match was used (=~). --- lib/puppet-lint/plugins/check_trailing_comma.rb | 2 +- .../plugins/check_trailing_comma/check_trailing_comma_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/puppet-lint/plugins/check_trailing_comma.rb b/lib/puppet-lint/plugins/check_trailing_comma.rb index d1d8936..1ceb341 100644 --- a/lib/puppet-lint/plugins/check_trailing_comma.rb +++ b/lib/puppet-lint/plugins/check_trailing_comma.rb @@ -62,7 +62,7 @@ def defaults_indexes # Ensure that we aren't matching a function return type: token.prev_code_token.type != :RSHIFT && \ # Or a conditional matching a type: - token.prev_code_token.type != :MATCH + ! [:MATCH, :NOMATCH].include?(token.prev_code_token.type) real_idx = 0 tokens[token_idx+1..-1].each_with_index do |cur_token, cur_token_idx| diff --git a/spec/puppet-lint/plugins/check_trailing_comma/check_trailing_comma_spec.rb b/spec/puppet-lint/plugins/check_trailing_comma/check_trailing_comma_spec.rb index e0b4492..7dd02b8 100644 --- a/spec/puppet-lint/plugins/check_trailing_comma/check_trailing_comma_spec.rb +++ b/spec/puppet-lint/plugins/check_trailing_comma/check_trailing_comma_spec.rb @@ -66,6 +66,10 @@ class { '::apache': if $var =~ Sensitive { $foo = $var.unwrap } + + if $var !~ Mymodule::MyType { + fail("encountered error ${err}") + } EOS }