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

Array operations on parameters confuse puppet-lint #930

Closed
simondeziel opened this issue Oct 1, 2020 · 0 comments · Fixed by #934
Closed

Array operations on parameters confuse puppet-lint #930

simondeziel opened this issue Oct 1, 2020 · 0 comments · Fixed by #934
Labels

Comments

@simondeziel
Copy link

Running puppet-lint (version 2.4.2) on the following:

#
class ntp (
  # XXX: remove "self" from the list
  Array[String] $ntp_servers = [
    'foo',
    'bar',
    'baz',
  ] - $::fqdn,
  Array[String] $pools       = [],
) {
  ...
}

Gives WARNING: optional parameter listed before required parameter on line 8.

However, puppet itself (6.18) has no problem removing the $::fqdn element from the $ntp_servers array. A workaround is to use the delete() function from puppetlabs-stdlib like this:

#
class ntp (
  # XXX: remove "self" from the list
  Array[String] $ntp_servers = delete([
    'foo',
    'bar',
    'baz',
  ], $::fqdn),
  Array[String] $pools       = [],
) {
  ...
}

P.S.: thanks a lot for working on this fantastic tool!

@rodjek rodjek added the bug label Nov 9, 2020
rodjek added a commit that referenced this issue Nov 10, 2020
Class/defined type parameter name tokens can be more accurately selected
based on the type of non-whitespace token that preceeds it.

`:VARIABLE` preceeded by:
  * `:LPAREN` - First parameter, no data type
  * `:COMMA` - Subsequent parameters, no data type
  * `:TYPE` - Parameter with a simple data type (e.g. `String`)
  * `:RBRACK - Parameter with a complex data type (e.g. `Array[String]`)

As before, tokens within balanced pairs of parens will be automatically
skipped over, preventing a function call that takes a variable parameter
from generating a false positive in the first 2 cases.

Fixes #930
rodjek added a commit that referenced this issue Nov 10, 2020
Class/defined type parameter name tokens can be more accurately selected
based on the type of non-whitespace token that preceeds it.

`:VARIABLE` preceeded by:
  * `:LPAREN` - First parameter, no data type
  * `:COMMA` - Subsequent parameters, no data type
  * `:TYPE` - Parameter with a simple data type (e.g. `String`)
  * `:RBRACK - Parameter with a complex data type (e.g. `Array[String]`)

As before, tokens within balanced pairs of parens will be automatically
skipped over, preventing a function call that takes a variable parameter
from generating a false positive in the first 2 cases.

Fixes #930
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants