diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bdbbf18..5d8fd70 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -86,7 +86,7 @@ RSpec/DescribedClass: # Offense count: 7 # Configuration parameters: CountAsOne. RSpec/ExampleLength: - Max: 16 + Max: 17 # Offense count: 4 # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. @@ -100,7 +100,7 @@ RSpec/FilePath: # Offense count: 29 RSpec/MultipleExpectations: - Max: 10 + Max: 11 # Offense count: 30 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. diff --git a/lib/puppet-syntax/hiera.rb b/lib/puppet-syntax/hiera.rb index 2a8fdfe..d96f43d 100644 --- a/lib/puppet-syntax/hiera.rb +++ b/lib/puppet-syntax/hiera.rb @@ -122,7 +122,7 @@ def check(filelist) # You can do string concatenation outside of {}: # "%{lookup('this_is_ok')}:3306" def check_broken_function_call(element) - 'string after a function call but before `}` in the value' if element.is_a?(String) && /%{.+\('.*'\).+}/.match?(element) + 'string after a function call but before `}` in the value' if element.is_a?(String) && /%{[^}]+\('[^}]*'\)[^}\s]+}/.match?(element) end # gets a hash or array, returns all keys + values as array diff --git a/spec/fixtures/hiera/hiera_badkey.yaml b/spec/fixtures/hiera/hiera_badkey.yaml index 9e81278..38449a3 100644 --- a/spec/fixtures/hiera/hiera_badkey.yaml +++ b/spec/fixtures/hiera/hiera_badkey.yaml @@ -3,6 +3,7 @@ this_is_ok: 0 this_is_ok::too: 0 th1s_is_ok::two3: 0 :eventhis: 0 +this_is_ok::concat_func: "%{lookup('foo')}%{lookup('bar')}" typical:typo::warning1: true ::notsotypical::warning2: true @@ -15,3 +16,4 @@ this_is::warning7: - "%{lookup('foobar'):3306}" this_is::warning8: foo: "%{lookup('foobar'):3306}" +this_is::warning9: "%{lookup('foo'):3306}%{lookup('bar')}" diff --git a/spec/puppet-syntax/hiera_spec.rb b/spec/puppet-syntax/hiera_spec.rb index 1436fbc..91fc4ad 100644 --- a/spec/puppet-syntax/hiera_spec.rb +++ b/spec/puppet-syntax/hiera_spec.rb @@ -29,7 +29,7 @@ it 'returns warnings for invalid keys' do hiera_yaml = 'hiera_badkey.yaml' - examples = 8 + examples = 9 files = fixture_hiera(hiera_yaml) res = subject.check(files) (1..examples).each do |n| @@ -44,6 +44,7 @@ expect(res[5]).to match('Key :this_is::warning6: string after a function call but before `}` in the value') expect(res[6]).to match('Key :this_is::warning7: string after a function call but before `}` in the value') expect(res[7]).to match('Key :this_is::warning8: string after a function call but before `}` in the value') + expect(res[8]).to match('Key :this_is::warning9: string after a function call but before `}` in the value') end it 'returns warnings for bad eyaml values' do