Uploaded image for project: 'Puppet Development Kit'
  1. Puppet Development Kit
  2. PDK-678

"puppet lint" warns about block-scoped variables used with subscript

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Template:

      Description

      Block-scoped variables (those defined in block expressions for .map, .each, .filter) cause lint warnings when subscripted.

      Given this class file:

      #
      class test {
        $used = $::partitions.filter |$k, $v| { $v['filesystem'] != undef }
        $usednames = $used.map |$k, $v| { $k }
        notify { $usednames: }
      }
      

      The file validates just fine:

      $ puppet parser validate init.pp
      $
      

      However, lint gives warnings about the subscripted block-scoped variable:

      $ puppet parser lint init.pp
      WARNING: top-scope variable being used without an explicit namespace on line 3
      $
      

      This can be worked around by putting the block-scoped variable in parentheses before the subscript:

      #
      class test {
        $used = $::partitions.filter |$k, $v| { ($v)['filesystem'] != undef }
        $usednames = $used.map |$k, $v| { $k }
        notify { $usednames: }
      }
      

      $ puppet lint init.pp
      $
      

      The style guide gives no indication that parentheses are required in this usage, and the file validates (and functions) just fine, so this makes me think this is a bug in the linter.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              JohnsonEarls Johnson Earls
              QA Contact:
              Eric Thompson
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Zendesk Support