From d7b0b6846068885503dea0f6931a1e9dd358dbc3 Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Thu, 18 Aug 2016 22:10:45 -0500 Subject: [PATCH] Revert "Bugfix: properly handling $gronk-$grouik with --fix (fix #442)" --- README.md | 5 ----- lib/puppet-lint/lexer.rb | 4 ++-- lib/puppet-lint/plugins/check_variables.rb | 2 +- .../plugins/check_strings/variables_not_enclosed_spec.rb | 6 +++--- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 610a0c2c..8d8b2aeb 100644 --- a/README.md +++ b/README.md @@ -174,11 +174,6 @@ If you find a bug in puppet-lint or its results, please create an issue in the [repo issues tracker](https://github.com/rodjek/puppet-lint/issues/). Bonus points will be awarded if you also include a patch that fixes the issue. -## Executing puppet-lint tests suite - - bundle exec rspec [spec/puppet-lint/a_single_test.rb] - - ## Thank You Many thanks to the following people for contributing to puppet-lint diff --git a/lib/puppet-lint/lexer.rb b/lib/puppet-lint/lexer.rb index 771cc604..dc24cd3d 100644 --- a/lib/puppet-lint/lexer.rb +++ b/lib/puppet-lint/lexer.rb @@ -170,7 +170,7 @@ def tokenise(code) end unless found - if var_name = chunk[/\A\$((::)?([\w]+::)*[\w]+(\[.+?\])*)/, 1] + if var_name = chunk[/\A\$((::)?([\w-]+::)*[\w-]+(\[.+?\])*)/, 1] length = var_name.size + 1 tokens << new_token(:VARIABLE, var_name, length) @@ -346,7 +346,7 @@ def interpolate_string(string, line, column) tokens << new_token(:DQMID, value, value.size, :line => line, :column => token_column) end if ss.scan(/\{/).nil? - var_name = ss.scan(/(::)?([\w]+::)*[\w]+/) + var_name = ss.scan(/(::)?([\w-]+::)*[\w-]+/) if var_name.nil? token_column = column + ss.pos - 1 tokens << new_token(:DQMID, "$", 1, :line => line, :column => token_column) diff --git a/lib/puppet-lint/plugins/check_variables.rb b/lib/puppet-lint/plugins/check_variables.rb index 6a2f5724..08480d9d 100644 --- a/lib/puppet-lint/plugins/check_variables.rb +++ b/lib/puppet-lint/plugins/check_variables.rb @@ -7,7 +7,7 @@ def check tokens.select { |r| VARIABLE_DASH_TYPES.include? r.type }.each do |token| - if not token.next_token.nil? and Set[:DQMID, :DQPOST, :MINUS].include? token.next_token.type and token.next_token.value.start_with? '-' + if token.value.gsub(/\[.+?\]/, '').match(/-/) notify :warning, { :message => 'variable contains a dash', :line => token.line, diff --git a/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb b/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb index ac50d875..a27e9526 100644 --- a/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb +++ b/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb @@ -39,10 +39,10 @@ end context 'variable not enclosed in {}' do - let(:code) { '" $gronk-$grouik"' } + let(:code) { '" $gronk"' } it 'should only detect a single problem' do - expect(problems).to have(2).problem + expect(problems).to have(1).problem end it 'should fix the manifest' do @@ -50,7 +50,7 @@ end it 'should enclose the variable in braces' do - expect(manifest).to eq('" ${gronk}-${grouik}"') + expect(manifest).to eq('" ${gronk}"') end end