Skip to content

voxpupuli/puppet-lint-topscope-variable-check

Repository files navigation

puppet-lint-topscope-variable-check

License Test Release RubyGem Version RubyGem Downloads

A puppet-lint plugin to check that topscope variables in a class do not begin with $::

Installation

From the command line

$ gem install puppet-lint-topscope-variable-check

In a Gemfile

gem 'puppet-lint-topscope-variable-check', require: false

Checks

What you have done

class foo::blub {
  notify { 'foo':
    message => $::foo::bar,
  }
}

or

class foo::blub(
  String $foo = $::foo::params::foo
) {
  # ...
}

What you should have done

class foo::blub {
  notify { 'foo'
    message => $foo::bar,
  }
}

and

class foo::blub(
  String $foo = $foo::params::foo
) {
  # ...
}

Disabling the check

To disable this check, you can add --no-topscope_variable-check to your puppet-lint command line:

$ puppet-lint --no-topscope_variable-checks

Alternatively, if you are calling puppet-lint via the Rake task, you should insert the following line into your Rakefile:

PuppetLint.configuration.send('disable_topscope_variable')

Limitations

The fix function of this plugin does not work when the variable is used in a string and hasn't been enclosed with {}. For example:

$foo = "/etc/$::foobar::path/test"

Note: The Variables Not Enclosed check can fix the missing braces and then the fix from this plugin should work.

Transfer Notice

This plugin and github repository was originally developed and maintained by Sixt. On 2021/11/24 the github project was transferred to Voxpupuli for ongoing improvement and maintenance.

Previously: https://github.com/Sixt/puppet-lint-topscope-variable-check

License

MIT License

Copyright (c) 2018 Sixt GmbH & Co. Autovermietung KG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.