Test::Tabs(3pm)

πŸ“¦
version 0.005 Β· 5 versions
, in ubuntu resolute, ubuntu stonking

✨ Test::Tabs ✨

okay bestie, so this is Test::Tabs (a Test:: module, iykyk) and its whole entire job is checking for tabs in your project. not even joking. it's giving "whitespace hall monitor" and honestly? she ate πŸ’…


🌸 SYNOPSIS 🌸

like, you can do the one-file vibe:

use Test::Tabs tests => 1;
tabs_ok('lib/Module.pm', 'Module is indented sanely');

orrrr:

use Test::Tabs;
all_perl_files_ok();

orrrr if you're feeling extra and wanna point at your own dirs:

use Test::Tabs;
all_perl_files_ok( @mydirs );

✨ DESCRIPTION ✨

so what this module does is it goes through your whole project/distribution and scans every perl file it can find (scripts, modules, etc, all of them) looking for tabs. she's thorough, no cap.

specifically, here's the vibe check it runs πŸ‘‡

  • all indentation has to be done with tabs, never spaces
  • alignment has to be done with spaces, never tabs
  • indentation levels can never jump up β€” like, going from 1 tab indent straight to 3 tab indent without an intervening 2 tab indent? absolutely not, that's a red flag 🚩
  • no trailing whitespace on any line (though a line is allowed to be entirely whitespace, that's fine, we're not monsters)

Comment lines and pod? ignored. completely. not our problem. (tho the docs do say a future version may also ignore heredocs β€” so maybe one day, bestie, maybe one day πŸ™ˆ)

now, the escape hatches, and there's three of them so listen up:

  • a trailing comment ##WS lets you ignore all the whitespace rules for that one line πŸ’–
  • ## no Test::Tabs starts ignoring the whitespace rules for all the following lines, and keeps doing that until it sees ## use Test::Tabs
  • ## skip Test::Tabs tells Test::Tabs to skip the current file entirely β€” but there's a catch, it has to be used before the first whitespace rule violation, otherwise it's too late and she's already clocked you πŸ’€

πŸŽ€ Functions πŸŽ€

  • all_perl_files_ok( @directories ) β€” runs tabs_ok() on literally every perl file it finds in @directories, recursively, down the whole tree. if you don't pass any @directories at all, the starting point defaults to one level above the current running script, which should cover all the files of a typical CPAN distribution. and what counts as a perl file, you ask? a *.pl, a *.pm, a *.psgi, a *.t, or any file whose first line starts with "#!...perl". that's the whole list, periodt.
  • tabs_ok( $file, $text ) β€” runs a tab check on $file. here's the cute part: for a module you can pass in either the path (lib/My/Module.pm) or the package name (My::Module), your choice, both work 🫢. $text is the optional test name, if you wanna be descriptive about it.

πŸ¦‹ BUGS πŸ¦‹

found a bug? please report it, bestie, don't just sit on it:

<http://rt.cpan.org/Dist/Display.html?Queue=Test-Tabs>


⭐ SEE ALSO ⭐

Test::EOL, Test::More.

go read those too, they're in the same friend group πŸ‘‘


πŸ’œ AUTHOR πŸ’œ

Toby Inkster <tobyink@cpan.org>.

and huge shoutout: large portions stolen from Test::NoTabs by Nick Gerakines. iconic behavior, we respect it πŸ™Œ


This software is copyright (c) 2012-2013 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


πŸ’… DISCLAIMER OF WARRANTIES πŸ’…

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

and that's the whole page, bestie!! this one's from perl v5.40.1, dated 2025-08-14 β€” go forth and check those tabs, ily, mwah πŸ’–βœ¨

πŸ“¦ where this page comes from