Philip Durbin
2011-Oct-06 14:19 UTC
[Puppet Users] perltidy workalike to tidy up Puppet manifests
There''s a wonderful tool called "perltidy" that can clean up Perl scripts, enforcing certain style guidelines by default but allowing lots of customization. Does Puppet have a tool like perltidy to enforce a certain style in Puppet manifests? I don''t see any mention of such a tool at http://docs.puppetlabs.com/guides/style_guide Thanks, Phil p.s. Below is an example of perltidy in action, but there are more at http://perltidy.sourceforge.net . Various configuration options such as "Cuddled Else", "Define Horizontal Tightness", etc. are explained at http://perltidy.sourceforge.net/stylekey.html [pdurbin@beamish bin]$ cat print_binary_numbers.pl #!/usr/bin/perl use strict; use warnings; use Time::HiRes qw( sleep ) ; for (my $i = 0; $i < 10; $i++ ) { sleep .1 ; printf ("%10b %3d\n", $i, $i); } [pdurbin@beamish bin]$ perltidy print_binary_numbers.pl [pdurbin@beamish bin]$ cat print_binary_numbers.pl.tdy #!/usr/bin/perl use strict; use warnings; use Time::HiRes qw( sleep ); for ( my $i = 0 ; $i < 10 ; $i++ ) { sleep .1; printf( "%10b %3d\n", $i, $i ); } [pdurbin@beamish bin]$ -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Craig White
2011-Oct-06 15:00 UTC
Re: [Puppet Users] perltidy workalike to tidy up Puppet manifests
On Oct 6, 2011, at 7:19 AM, Philip Durbin wrote:> There''s a wonderful tool called "perltidy" that can clean up Perl > scripts, enforcing certain style guidelines by default but allowing > lots of customization. > > Does Puppet have a tool like perltidy to enforce a certain style in > Puppet manifests? I don''t see any mention of such a tool at > http://docs.puppetlabs.com/guides/style_guide---- not the same but certainly in the neighborhood... https://github.com/rodjek/puppet-lint/ Craig -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Philip Durbin
2011-Oct-06 17:03 UTC
Re: [Puppet Users] perltidy workalike to tidy up Puppet manifests
On Thu, Oct 6, 2011 at 11:00 AM, Craig White <craig.white@ttiltd.com> wrote:> On Oct 6, 2011, at 7:19 AM, Philip Durbin wrote: >> There''s a wonderful tool called "perltidy" that can clean up Perl >> scripts, enforcing certain style guidelines by default but allowing >> lots of customization. >> >> Does Puppet have a tool like perltidy to enforce a certain style in >> Puppet manifests? I don''t see any mention of such a tool at >> http://docs.puppetlabs.com/guides/style_guide > ---- > not the same but certainly in the neighborhood... > > https://github.com/rodjek/puppet-lint/Ah, unlike perltidy, puppet-lint doesn''t re-write your code. It''s a reporting tool, so you are left to go and make the recommended changes yourself. That said, puppet-lint is *very* useful and I could see it being a great help in detecting ugly Puppet code. It''s a huge step up from simply using `puppet --parseonly` to check the syntax. Also, within minutes of me opening an issue, the developer (Tim Sharpe) replied, which is a great sign. Thanks! Phil -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.