Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom type misdetection #9

Merged
merged 2 commits into from
Sep 14, 2018
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
7 changes: 6 additions & 1 deletion lib/puppet-lint/plugins/check_trailing_comma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ def defaults_indexes
defaults = []
tokens.each_with_index do |token, token_idx|
if token.type == :CLASSREF && token.next_code_token && \
token.next_code_token.type == :LBRACE
token.next_code_token.type == :LBRACE && \
token.prev_code_token && \
# 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
real_idx = 0

tokens[token_idx+1..-1].each_with_index do |cur_token, cur_token_idx|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ class { '::apache':
'/etc/baz.conf', '/etc/baz.conf.d'
],
}

function myfunc (
Mymod::Mytype $arg1,
String[1] $arg2,
) >> Mymod::Mytype {
seanmil marked this conversation as resolved.
Show resolved Hide resolved
notice('foo')
}

if $var =~ Sensitive {
$foo = $var.unwrap
}
EOS
}

Expand Down