A puppet-lint plugin to check for uncuddled else blocks.
$ gem install puppet-lint-uncuddled_else-check
There are two different styles regarding the placement of else
and elsif
keywords. It can be placed on the same line as the closing curly of the preceding if block (cuddled
) or on a separate line below that closing curly (uncuddled
). There are pros and cons for both styles -- cmp. http://wiki.c2.com/?CuddledElseBlocks.
This check helps to enforce a consistent style by warning about uncuddled
else/elsif keywords.
The else
(or elsif
) keyword is on a new line below the closing curly brace of the preceding if block.
if $foo == 'bar' {
## some stuff
}
else {
## other stuff
}
The else
(or elsif
) keyword is on the same line as the closing curly brace of the preceding if block.
if $foo == 'bar' {
## some stuff
} else {
## other stuff
}
To disable this check, you can add `--no-uncuddled_else-check' to your puppet-lint command line.
$ puppet-lint --no-uncuddled_else-check /path/to/file.pp
There is a corresponding plugin puppet-lint-cuddled_else-check
that warns for cuddled else blocks. Most probably you only want one of both checks. ;)
This plugin for puppet-lint
has been written owing to the very nice tutorial for writing puppet-lint checks.