geppetto
geppetto copied to clipboard
Variable declared inside an each loop is marked as Unqualified/Unknown.
If a variable is declared inside an each loop , it is marked as "Unqualified and Unknown variable".
Ex:
$client_list.each {|$cl| $db_name = "DBName" if ($server_id == 1) and !defined(Mysql_database[$db_name]) { mysql_database { $db_name: ensure => 'present', charset => 'utf8', } }
- $db_name will be marked as Unqualified
The sample uses syntax that is no longer supported in Puppet (from 3.4) - the correct (and final) way of writing your example is:
$client_list.each | $cl | { $db_name = "DBName" if ($server_id == 1) and !defined(Mysql_database[$db_name]) { mysql_database { $db_name: ensure => 'present', charset => 'utf8', } }
i.e. the parameters to the lambda should be placed before the lambda body, not inside. (Strange that Geppetto does not flag this as bad in other ways though).
However, there seems to be a problem with finding the local variables while editing. If you do a "Build clean", does the problem go away? (That worked for me). The lookup seems to miss looking in the "dirty" index.