Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -100,7 +100,7 @@ RSpec/FilePath:

# Offense count: 29
RSpec/MultipleExpectations:
Max: 10
Max: 11

# Offense count: 30
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-syntax/hiera.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/hiera/hiera_badkey.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')}"
3 changes: 2 additions & 1 deletion spec/puppet-syntax/hiera_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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
Expand Down