puppet-lint icon indicating copy to clipboard operation
puppet-lint copied to clipboard

vars without defaults are not recognized as declaration in defines

Open arlt opened this issue 9 years ago • 1 comments

class a {
  define b($var) {
    ...
  }
}

creates the error '[variable_scope] top-scope variable being used without an explicit namespace' for line 2.

If it has a default value, all is fine:

class a {
  define b($var=5) {
    ...
  }
}

Adding the optional data type (https://docs.puppetlabs.com/puppet/latest/reference/lang_defined_types.html#defining-a-type) brings even more problems:

class a {
  define b(Integer $var) {
    ...
  }
}

-> Syntax error at 'Integer'; expected ')'

At the time of writing this, i recognized that define in class is not best practice (https://docs.puppetlabs.com/puppet/latest/reference/lang_defined_types.html#location) but that's another problem...

arlt avatar Jan 11 '16 15:01 arlt

@arlt It would be nice for this to parse properly, which is something we can look at later. But I don't think it has high value, given the other style guide issues that are impacted, so it might be a while before anyone gets to it. PRs are welcome, of course.

rnelson0 avatar Dec 19 '16 17:12 rnelson0